aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2025-02-14x86: correct ISA-used version recordingJan Beulich2-15/+21
Updating should be based solely on the current instruction. For example, recording of VEX-encoded insns as v3 should be independent of there being earlier AMX insns. Further for BASELINE only a very limited set of the GNU_PROPERTY_X86_FEATURE_2_* bits should actually be taken into account: Most of the bits represent advanced (later) features (XSAVE, XSAVEOPT, and XSAVEC for example being part of v3).
2025-02-14gas: fix rs_fill_nop listingJan Beulich4-2/+14
In commit a0094f1a70e1 ("gas: make .nops output visible in listing") I was wrongly assuming fr_fix would be zero for rs_fill_nop, when that's only a side effect of listing_newline() inserting dummy frags, but only when file/line did actually change from the previous invocation. This is in particular not going to be true when the .nops directive isn't the first statement on a line.
2025-02-14x86/APX: make .insn extended-EVEX capableJan Beulich6-25/+197
So far tricks had to be played to use .insn to encode extended-EVEX insns; the X4 bit couldn't be controlled at all. Extend the syntax just enough to cover all features, taking care to reject invalid feature combinations (albeit aiming at being as lax there as possible, to offer users as much flexibility as we can - we don't, after all, know what future will bring). In a pre-existing testcase replace all but one .byte; the one that needs to remain wants to have EVEX.U clear in a way that's neither controllable via AVX10/256 embedded rounding (would otherwise also set EVEX.ND), nor via the index register (EVEX.X4), as there's no memory operand. For one of the converted instances ModR/M.mod needs correcting: An 8-bit displacement requires that to be 1, not 2. Also adjust source comments to better represent what the bad insns mimic.
2025-02-14RISC-V: Add missing doc for OP_VKito Cheng1-0/+3
2025-02-14RISC-V: Add OP_VE for .insnKito Cheng6-4/+12
OP_VE is the opcode space for crypto vector instructions. Ref: https://github.com/riscv/riscv-isa-manual/blob/main/src/vector-crypto.adoc#crypto-vector-cryptographic-instructions
2025-02-14RISC-V: Make SSAMOSWAP.W available for rv64Hau Hsu3-4/+20
Previously we limited SSAMOSWAP.W only available on RV32, but it should be available on RV64 as well. See https://github.com/riscv/riscv-cfi/blob/main/src/cfi_backward.adoc https://github.com/riscv/riscv-isa-manual/blob/702a3e6e843235a2a13b918ae6938b04f8974ffc/src/unpriv-cfi.adoc#L789
2025-02-14Automatic date update in version.inGDB Administrator1-1/+1
2025-02-14dlltool memory leaksAlan Modra3-134/+118
dlltool copies strings with strdup all over the place, seeming to take the attitude that anything might be modified. That leads to lots of memory leaks. Fixing the leaks by removing the strdup calls of course means you need to take good care that strings *aren't* modified. This isn't as easy as it sounds due to functions like xlate that have const char* params but then manage to modify the strings. I've fixed xlate, but if I've missed something somewhere then this patch likely will break dlltool. Testsuite coverage of dlltool isn't good. The leaks in defparse.y are small. It also is a little work to verify that all the strings I'm freeing in defparse.y are in fact malloc'd, which is no doubt why the leaks are there. Using bfd_xalloc in make_one_lib_file and functions called from there results in memory being freed automatically at the bfd_close in make_one_lib_file, without any fuss. The patch also makes use of xasprintf to replace xmalloc followed by sprintf. * defparse.y (opt_name2): Free incoming ID strings after adding prefix/suffix. * dlltool.c (struct ifunct): Constify char* fields. (struct iheadt, struct dlist): Likewise. (set_dll_name_from_def, def_heapsize, def_stacksize), (def_section, assemble_file): Use xasprintf. (def_name, def_library): Free dll_name and name. (def_description, new_directove): Don't strdup incoming args. (append_import): Likewise. (def_import): Free module after appending dllext. (run): Free temp_base. (scan_filtered_symbols): Don't segfault on NULL strchr return. Remove unnecessary strdup. (scan_drectve_symbols): Likewise. Constify pointers. Use bfd_malloc_and_get_section. Use xmemdup. (add_excludes): Use xasprintf and xstrdup. (gen_exp_file): Free xlate return. Constify pointer to suit struct changes. Free copy. (xlate): Always copy arg. Use xasprintf and xstrdup. (make_imp_label): Add bfd arg. Use bfd_xalloc. (gen_lib_file): Adjust to suit. (make_one_lib_file): Likewise. Use bfd_xalloc for section data and relocs. Simplify code calling xlate, and free xlate return. (dll_name_list_free_contents): Flatten recursion. (mangle_defs): Free d_export_vec. (main): Formatting. Use xasprintf. * resres.c (write_res_id): Free section data.
2025-02-14gas: replace bfd_alloc with notes_allocAlan Modra2-9/+3
bfd_alloc can return NULL on out-of-memory so code needs to check the return value and print an error. That check was missing in write.c. notes_alloc won't return NULL, instead the underlying obstack_alloc prints an OOM message and the process exits. This is more convenient, and when the bfd_alloc memory is attached to the gas output bfd it is released only slightly before the notes obstack. * config/obj-macho.c (obj_mach_o_set_indirect_symbols): Use notes_calloc rather than bfd_zalloc. * write.c (set_symtab): Use notes_alloc.
2025-02-14gas obj-coff memory leaksAlan Modra4-25/+40
This patch addresses memory leaks in gas that show up when running the testsuite on x86_64-w64-mingw32. The seh_ctx_cur, and weak sym naming leaks can occur many times during assembly. The symbol hook and section leaks are not so important since this memory needs to persist until closing the output bfd. * config/obj-coff-seh.c (do_seh_endproc): Free seh_ctx_cur and its fields. * config/obj-coff-seh.h (struct seh_context): Remove unused "next" field. * config/obj-coff.c (coff_obj_symbol_new_hook): Use notes_alloc for aux entries. (coff_obj_symbol_clone_hook): Likewise. (obj_coff_def): Don't strdup name unless we need to do so for tc_canonicalize_symbol_name. Free after making symbol. (weak_name2altname, weak_altname2name): Return a char*. (weak_uniquify): Use notes_concat. (pecoff_obj_set_weak_hook, pecoff_obj_clear_weak_hook): Free name returned by weak_name2altname. (coff_frob_symbol): Similarly for weak_altname2name. (obj_coff_section): Use notes_memdup0. * symbols.h: Add include guard. (notes_memdup0): New inline function.
2025-02-13Remove assumption from py-symbol.expTom Tromey1-8/+12
The current py-symbol.exp test makes an assumption about which symbol will be returned first. I don't think gdb should really make promises about the order in which the symbols are listed, though, and a series I am working on changes this behavior. This patch changes the test to merely ensure that both symbols are returned. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2025-02-13Update my maintenance areas in MAINTAINERS fileKevin Buettner1-5/+0
I've dropped maintenance of the mep target. Additionally, I'm removed myself as an authorized committer for PowerPC, ia64, AIX, and GNU/Linux PPC native.
2025-02-13gdb, testsuite: Rename set_sanitizer procedures to append_environment.Christina Schimpe6-16/+16
The procedures set_sanitizer_1, set_sanitizer and set_sanitizer_default are used for the configuration of ASAN specific environment variables. However, they are actually generic. Rename them to append_environment* so that their purpose is more clear. Approved-By: Tom Tromey <tom@tromey.com>
2025-02-13aarch64: fix a crash during maintenance print cooked-registersKlaus Gerlicher1-0/+3
On aarch64 with pauth enabled a crash when can be seen when using "maintenance print cooked-registers". This happens because the register dump code tries to read a pseudo reg that is not handled here because it is supposedly only used in unwinding. Fix this by returning a zero value typed as a built-in uint64. Approved-By: Luis Machado <luis.machado@arm.com>
2025-02-13Automatic date update in version.inGDB Administrator1-1/+1
2025-02-12Reorder gnatmake arguments in inline-section-gc.exp, againTom Tromey1-3/+9
Tom de Vries pointed out that commit 8cfa1fc4 ("Reorder gnatmake arguments in inline-section-gc.exp") caused a regression with an older version of dejagnu. This patch works around that problem by further reordering the arguments to gnatmake and also arranging to leave gnatmake in "-margs" mode.
2025-02-12Add copyright header to gnat_debug_info_test.adbTom Tromey1-0/+15
I noticed that gdb/testsuite/lib/gnat_debug_info_test.adb is missing a copyright header. This adds one, using the date range from the original commit.
2025-02-11gdb: cleanup includes in mi/Simon Marchi10-20/+1
Remove a few includes reported as unused by clangd. Change-Id: I7365b7cce04c9ef1a4164764191303914da42ef9
2025-02-12Automatic date update in version.inGDB Administrator1-1/+1
2025-02-11gdb: remove check for minimal symbols in 'start_command'Rohr, Stephan1-6/+0
GDB aborts the 'start' command if the minimal symbols cannot be resolved. On Windows, GDB reads the minimal symbols from the COFF header of the PE file. The symbol table is deprecated and the number of symbols in the COFF header may be zero: https://learn.microsoft.com/en-us/windows/win32/debug/pe-format This is reproducible with clang version 18.1.8 on Windows: clang++ -g -O0 -gdwarf -fuse-ld=lld test.cpp -o test_clang The COFF file header shows: FILE HEADER VALUES 8664 machine (x64) E number of sections 66E889EC time date stamp Mon Sep 16 21:41:32 2024 FB400 file pointer to symbol table 0 number of symbols F0 size of optional header 22 characteristics GDB is not able to read the minimal symbols; the `start' command fails with an error: (gdb) start No symbol table loaded. Use the "file" command. Manually inserting a breakpoint in main works fine: (gdb) tbreak main Temporary breakpoint 1 at 0x14000100c: file test.cpp, line 6. (gdb) run Starting program: C:\test-clang Temporary breakpoint 1, main () at test.cpp:6 6 std::cout << "Hello World.\n"; Remove the check entirely; a 'NOT_FOUND_ERROR' is thrown if 'main' cannot be resolved. The error is consumed in 'create_breakpoint ()' and an error message is displayed to the user. Approved-by: Kevin Buettner <kevinb@redhat.com> Reviewed-By: Guinevere Larsen <guinevere@redhat.com>
2025-02-11gdb/dwarf: rename cooked_index::m_vector to m_shardsSimon Marchi2-19/+19
I think that is clearer and helps readability. Rename a few iteration variables from "index" or "idx" to "shard". In my mental model, the "index" is the whole thing, so it's confusing to use that word when referring to shards. Change-Id: I208cb839e873c514d1f8eae250d4a16f31016148 Approved-By: Tom Tromey <tom@tromey.com>
2025-02-11gdb/dwarf: remove cooked_index::vec_typeSimon Marchi2-8/+5
I find this typedef to be confusing. The name is a bit too generic, so it's not clear what it represents. When using the typedef for a cooked_index_shard unique pointer, I think that spelling out the vector type is not overly long. Change-Id: I99fdab5cd925c37c3835b466ce40ec9c1ec7209d Approved-By: Tom Tromey <tom@tromey.com>
2025-02-11RISC-V: Add .bfloat16 directiveKito Cheng5-1/+53
RISC-V already support bfloat16 instruciton like Zfbfmin, Zvfbfmin and Zvfbfwma, so I think it's reasonable to add .bfloat16 directive to support bfloat16 data type. And the code logic mostly support by common code already.
2025-02-11RISC-V: Move all global static target stuff into private data for disassembler.Nelson Chu3-161/+178
I got a request said that the JDK multi-thread compiler may be broken if two or more threads are trying to print/disassemble stuff, and filling the disassemble_info, setting callbacks, and grabbing the function pointer to disasm at the same time. Since such as the target global static stuff, including subset of extensions and mapping symbol stuff, seems to only be one globally. Ideally, for dis-assembler, all global static target stuff should/can be better to be defined into the target private data, since they are target-dependency. opcodes/ * riscv-dis.c: Moved all global static target-dependency stuff into riscv_private_data, including architecture and mapping symbol stuff. (set_default_riscv_dis_options): Updated since global static target- dependency stuff are moved into riscv_private_data. (parse_riscv_dis_option_without_args): Likewise. (parse_riscv_dis_option): Likewise. (parse_riscv_dis_options): Likewise. (maybe_print_address): Likewise. (print_reg_list): Likewise. (riscv_get_spimm): Likewise. (print_insn_args): Likewise. (riscv_disassemble_insn): Likewise. (riscv_update_map_state): Likewise. (riscv_search_mapping_symbol): Likewise. (riscv_data_length): Likewise. (print_insn_riscv): Likewise. Call the riscv_init_disasm_info before parsing any disassembler options, since the related stuff are moved into riscv_private_data. (riscv_init_disasm_info): Likewise. Parse and set the architecture string and privileged spec version since riscv_get_disassembler is no longer needed. (riscv_get_disassembler): Removed. (disassemble_free_riscv): Only free the subset_list if riscv_private_data exsits. * disassemble.c (disassembler): Since riscv_get_disassembler is removed, call to print_insn_riscv. * disassemble.h: Removed extern riscv_get_disassembler.
2025-02-11Automatic date update in version.inGDB Administrator1-1/+1
2025-02-10Port GDB to Hurd x86_64.Flavio Cruz9-57/+403
This port extends the existing i686 port to support x86_64 by reusing existing code whenever it makes sense. * gdb/amd64-gnu-tdep.c: Adds logic for handling signal frames and position of amd64 registers in the different Hurd structs. The signal code is very similar to i686, except the trampoline code is adapted. * gdb/config/i386/nm-i386gnu.h: renamed to gdb/config/i386/nm-x86-gnu.h and adapt it for x86_64. * gdb/config/i386/i386gnu.mn: renamed to gdb/config/i386/nm-x86-gnu.mn and reuse it for x86_64. * gdb/configure.host: recognize gnu64 as a host. * gdb/configure.nat: recognize gnu64 host and update existing i386gnu to reuse the new shared files. * gdb/configure.tgt: recognize x86_64-*-gnu* triplet and use amd64-gnu-tdep.c. * gdb/i386-gnu-tdep.c: added i386_gnu_thread_state_reg_offset that is copied from i386-gnu-nat.c. This makes it similar to amd64. * gdb/i386-gnu-nat.c: rename it to x86-gnu-nat.c since we reuse this for i386 and amd64. Updated REG_ADDR to use one of the structures. Added VALID_REGISTER to make sure it's a register we can provide at this time (not all of them are available in amd64). FLAGS_REGISTER is either rfl or efl depending on the arch. Renamed functions and class from i386 to x86 whenever they can be reused. Tested on Hurd x86_64 and i686.
2025-02-10MIPS16/GAS: Streamline forced size suffix handling codeMaciej W. Rozycki1-17/+6
Clean up after commit 112cf77b1855 ("MIPS: use is_whitespace()") and untangle the code flow in the handling of forced size suffixes, noting that owing to the loop right above the only data `c' can hold at this point is '\0', '.', or a white-space character. No functional change.
2025-02-10MIPS16/GAS: Reject instructions that end with a dotMaciej W. Rozycki5-4/+39
Fix a regression from commit 3fb49709438e ("MIPS16/GAS: Fix forced size suffixes with argumentless instructions") and reject MIPS16 instructions that end with a dot and no forced size suffix following, e.g.: $ cat test.s .set mips16 foo: break. entry. addiu. $2, 0x7fff addiu. $3, $2, 0 .align 8, 0 $ as -32 -o test.o test.s $ objdump -d test.o test.o: file format elf32-tradbigmips Disassembly of section .text: 00000000 <foo>: 0: e805 break 2: e809 entry 4: f7ef 4a1f addiu v0,32767 8: 4260 addiu v1,v0,0 ... $ Add a test accordingly, also verifying invalid forced size suffixes.
2025-02-10MIPS/BFD: Remove redundant "want64=true" settingsMaciej W. Rozycki1-2/+0
Clean up after commit 29c108c96106 ("MIPS: Support `-gnuabi64' target triplet suffix for 64-bit Linux targets") and discard individual MIPS "want64=true" settings, the use of which has been superseded by commit 42429eacb42f ("Require a 64-bit bfd_vma for MIPS ELF") back in 2013[1]. References: [1] <https://inbox.sourceware.org/binutils/87mwqg4mfn.fsf@talisman.default/>
2025-02-10gdb/tui: use tui_batch_rendering moreAndrew Burgess4-2/+14
While working on the commit: commit 4f28b020a3416ac87ac12cf7ae3625a4bc178975 Date: Wed Feb 5 20:12:03 2025 +0000 gdb/tui: use wrefresh if output is not surpressed I spotted some places where tui_win_info::refresh_window() was being called when suppress_output was false. This means that there is no tui_batch_rendering in place on the call stack, and so, after that commit, we might be performing more wrefresh() calls than necessary. Before the above commit we would have been calling wnoutrefresh() and, due to the missing tui_batch_rendering, there might have been a delay before doupdate() was called. To (hopefully) make screen updates smoother, this commit adds tui_batch_rendering in a few places where it is possible that there might be multiple window updates performed, this will mean the final write to screen is deferred until the tui_batch_rendering goes out of scope. Other than possibly smother screen updates, there should be no user visible changes after this commit. Approved-By: Tom Tromey <tom@tromey.com>
2025-02-10gdb/tui: remove unnecessary wmove call from tui_status_windowAndrew Burgess1-1/+1
I've been looking recently at when the TUI calls wnoutrefresh vs wrefresh, and the ordering of other screen update actions relative to these calls. I noticed in tui_status_window::rerender() a call to wmove() that is placed after the refresh_window() call. This surely means that the cursor is moved, but, this update is not sent to the screen. But we call wmove() at the start of tui_status_window::rerender() before anything is sent to the screen, so the final wmove() call is pointless as far as I can tell. I propose removing it. This is trivial, but removing pointless work like this slowly makes the TUI code easier to understand. There should be no user visible changes after this commit. Approved-By: Tom Tromey <tom@tromey.com>
2025-02-10gdb: Deprecate stabs debug infoGuinevere Larsen1-0/+3
GCC has deprecated stabs generation in GCC 12 and entirely removed it in GCC 13, which was released in April 2023. At the time it was proposed that GDB deprecate stabs as well, but the decision was to support it a bit longer. With this patch, it'll be deprecated on GDB 17, and removed on GDB 18, which following the current cadence, will be released early 2026, meaning we will have supported stabs for nearly 3 years longer than GCC, which I think is reasonable. As pointed out in the previous discussion on this topic[1], there are several existing issues on the code, and none of the current maintainers knows how to fix it. Unless someone steps up to fix this before the removal on GDB 18, I don't see why we should keep this old code that breaks all conventions of modern debuginfo readers and doesn't even work, instead of being able to further advance adjacent code. Finally, deprecating and removing stabs will make a.out/dbx inferiors be essentially unsupported, as the only debuginfo GDB supports for those formats is stabs, meaning users would only have assembly-level debugging for that format. With that in mind, this commit deprecates the a.out/dbx format as well. [1] https://inbox.sourceware.org/gdb-patches/20230119174156.654402-1-tom@tromey.com/ Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31210 Approved-By: Tom Tromey <tom@tromey.com>
2025-02-10gdb/dwarf: create multiple cooked index shards when reading .debug_namesSimon Marchi3-12/+49
New in v2: - install address map in a single shard - update test gdb.mi/mi-sym-info.exp to cope with the fact that different symbols could be returned when using --max-results When playing with the .debug_names reader, I noticed it was significantly slower than the DWARF scanner. Using a "performance" build of GDB (with optimization, no runtime sanitizer enabled, etc), I measure with the following command on a rather large debug info file (~4 GB): $ time ./gdb -q -nx --data-directory=data-directory <binary> -iex 'maint set dwarf sync on' -batch This measures the time it takes for GDB to build the cooked index (plus some startup and exit overhead). I have a version of the binary without .debug_names and a version with .debug_names added using gdb-add-index. The results are: - without .debug_names: 7.5 seconds - with .debug_names: 24 seconds This is a bit embarrassing, given that the purpose of .debug_names is to accelerate things :). The reason is that the .debug_names processing is not parallelized at all, while the DWARF scanner is heavily parallelized. The process of creating the cooked index from .debug_names is roughly in two steps: 1. scanning of .debug_names and creation of cooked index entries (see mapped_debug_names_reader::scan_all_names) 2. finalization of the index, name canonicalization and sorting of the entries (see cooked_index::set_contents). This patch grabs a low hanging fruit by creating multiple cooked index shards instead of a single one during step one. Just doing this allows the second step of the processing to be automatically parallelized, as each shard is sent to a separate thread to be finalized. With this patch, I get: - without .debug_names: 7.5 seconds - with .debug_names: 9.7 seconds Not as fast as we'd like, but it's an improvement. The process of scanning .debug_names could also be parallelized to shave off a few seconds. My profiling shows that out of those ~10 seconds of excecution, about 6 are inside scan_all_names. Assuming perfect parallelization with 8 threads, it means that at best we could shave about 5 seconds from that time, which sounds interesting. I gave it a shot, but it's a much more intrusive change, I'm not sure if I will finish it. This patch caused some regressions in gdb.mi/mi-sym-info.exp with the cc-with-debug-names board, in the test about the `--max-results` switch. It appears at this test is relying on the specific symbols returned when using `--max-results`. As far as I know, we don't guarantee which specific symbols are returned, so any of the matching symbols could be returned. The round robin method used in this patch to assign index entries to shards ends up somewhat randomizing which CU gets expanded first during the symbol search, and therefore which order they appear in the objfile's CU list, and therefore which one gets searched first. I meditated on whether keeping compunits sorted within objfiles would help make things more stable and predictable. It would somewhat, but it wouldn't remove all sources of randomness. It would still possible for a call to `expand_symtabs_matching` to stop on the first hit. Which compunit gets expanded then would still be dependent on the specific `quick_symbol_functions` internal details / implementation. Commit 5b99c5718f1c ("[gdb/testsuite] Fix various issues in gdb.mi/mi-sym-info.exp") had already started to make the test a bit more flexible in terms of which symbols it accepts, but with this patch, I think it's possible to get wildly varying results. I therefore modified the test to count the number of returned symbols, but not expect any specific symbol. Change-Id: Ifd39deb437781f72d224ec66daf6118830042941 Approved-By: Tom Tromey <tom@tromey.com>
2025-02-10gdb/dwarf: allow for cooked_index_shard::m_addrmap to be nullptrSimon Marchi3-5/+14
The following patch makes the .debug_names reader create multiple cooked index shards, only one of them having an address map. The others will have a nullptr address map. Change the code using cooked_index_shard::m_addrmap to account for the fact that it can be nullptr. Change-Id: Id05b974e661d901dd43bb5ecb3a8fcfc15abc7ed Approved-By: Tom Tromey <tom@tromey.com>
2025-02-10gdb/dwarf: write offset to parent entry for DW_IDX_parentSimon Marchi4-72/+205
New in v2: - add doc - fix computation of offset in entry pool Due to a mistake in the DWARF 5 spec, the way that GDB interprets DW_IDX_parent when generating and reading .debug_names is not correct. In Section 6.1.1.2, the parent index entry attribute is described as: Parent debugging information entry, a reference to the index entry for the parent. This is represented as the offset of the entry relative to the start of the entry pool. But in Table 6.1, DW_IDX_parent is described as: Index of name table entry for parent These two contradict each other. The former is the correct one and the latter is an unfortunate leftover from an earlier version of the proposal, according to [1]. It does make sense, because pointing to a name table entry is ambiguous, while poiting to an index entry directly is not. Unfortunately, GDB implemented pointing to a name table entry. Changes on the writer side: - For each written pool entry, remember the offset within the pool. - Change the DW_IDX_parent form to DW_FORM_data4. Using DW_FORM_udata isn't an option, because we don't know the actual value when doing the first pass of writing the pool (see next point), so we wouldn't know how many bytes to reserve, if we used a variable-size encoding. Using a fixed 4 bytes encoding would be an issue if the entry pool was larger than 4 GiB, but that seems unlikely. Note that clang uses DW_FORM_ref4 for this, but I'm not sure it is appropriate, since forms of the reference class are specified as referring "to one of the debugging information entries that describe the program". Since we're not referring to a DIE, I decided to stay with a form of the "constant" class. I think that readers will be able to understand either way. - Write a dummy 4 byte number when writing the pool, then patch those values later. This is needed because parents can appear before their children in the pool (there's no way to ensure that parents always appear before their children), so we might now know at first what value to put in. - Add a `write_uint` method to `class data_buf` to support that use case of patching a value in the middle of the data buffer. - Simplify the type of `m_name_to_value_set`, we no longer need to track the index at which a name will be written at. - Produce a new augmentation string, "GDB3", to be able to distinguish "old" and "new" indexes. It would be possible for a reader to distinguish the two semantics of DW_IDX_parent using the form. However, current versions of GDB don't do that, so they would be confused trying to read a new index. I think it is preferable to use a new augmentation string so that they will reject a new index instead. Changes on the reader side: - Track the GDB augmentation version, in addition to whether the augmentation string indicates the index was produced by GDB. - When reading index entries, maintain a "pool offset" -> "cooked index entry" mapping, to be able to find parents by pool offset. - When resolving parents, keep the existing behavior of finding parents by name table index if the augmentation string is "GDB2. Otherwise, look up parents by pool offset. This assumes that .debug_names from other producers (if/when we add support for reading them) use pool offsets for DW_IDX_parent. This at least what clang does. - Simplify augmentation string comparison a bit by using array views. Update the "Extensions to ‘.debug_names’" section of the documentation to reflect the new augmentation string version. Tested by: - manually producing executables with "GDB2" and "GDB3" .debug_names sections and reading them. - running the testsuite with the cc-with-debug-names board [1] https://lists.dwarfstd.org/pipermail/dwarf-discuss/2025-January/002618.html Change-Id: I265fa38070b86ef320e0a972c300d1d755735d8d Reviewed-By: Eli Zaretskii <eliz@gnu.org> Approved-By: Tom Tromey <tom@tromey.com>
2025-02-10gdbsupport: add gdb::make_array_view overload to create from an arraySimon Marchi2-0/+22
I think this overload will be useful for the following reasons. Consider a templated function like this: template <typename T> void func(gdb::array_view<T> view) {} Trying to pass an array to this function doesn't work, as template argument deduction fails: test.c:698:8: error: no matching function for call to ‘func(int [12])’ 698 | func (array); | ~~~~~^~~~~~~ test.c:686:6: note: candidate: ‘template<class T> void func(gdb::array_view<U>)’ 686 | void func(gdb::array_view<T> view) {} | ^~~~ test.c:686:6: note: template argument deduction/substitution failed: test.c:698:8: note: mismatched types ‘gdb::array_view<U>’ and ‘int*’ 698 | func (array); | ~~~~~^~~~~~~ Similarly, trying to compare a view with an array doesn't work. This: int array[12]; gdb::array_view<int> view; if (view == array) {} ... fails with: test.c:698:8: error: no matching function for call to ‘func(int [12])’ 698 | func (array); | ~~~~~^~~~~~~ test.c:686:6: note: candidate: ‘template<class T> void func(gdb::array_view<U>)’ 686 | void func(gdb::array_view<T> view) {} | ^~~~ test.c:686:6: note: template argument deduction/substitution failed: test.c:698:8: note: mismatched types ‘gdb::array_view<U>’ and ‘int*’ 698 | func (array); | ~~~~~^~~~~~~ With this new overload, we can do: func (gdb::make_array_view (array)); and if (view == gdb::make_array_view (array)) {} This is not ideal, I wish that omitting `gdb::make_array_view` would just work, but at least it allows creating an array view and have the element type automatically deduced from the array type. If someone knows how to make these cases "just work", I would be happy to know how. Change-Id: I6a71919d2d5a385e6826801d53f5071b470fef5f Approved-By: Tom Tromey <tom@tromey.com>
2025-02-10gdb: LoongArch: Improve the handling of atomic sequenceHui Li1-2/+4
In the current code, when using software single-step to debug atomic instruction sequence, the execution of the atomic instruction sequence may not be completed normally. Here is a test with setting a software watchpoint to execute in software single-step mode: $ cat test.c int a = 0; int main() { a = 1; return 0; } $ gcc -g test.c -o test $ gdb test .. (gdb) start .. Temporary breakpoint 1, main () at test.c:4 4 a = 1; (gdb) set can-use-hw-watchpoints 0 (gdb) n 5 return 0; (gdb) watch a Watchpoint 2: a (gdb) c Continuing. At this point, the program continues to execute and can not exit normally because it incorrectly handled the following ll/sc atomic sequence in __run_exit_handlers () from /lib64/libc.so.6 during software single-step execution. 0x00007ffff7df7a48 <+408>: ld.d $t1, $s2, 1776 0x00007ffff7df7a4c <+412>: ll.w $t0, $t1, 0 => 0x00007ffff7df7a50 <+416>: bne $t0, $zero, 20 # 0x7ffff7df7a64 <__run_exit_handlers+436> 0x00007ffff7df7a54 <+420>: or $t3, $zero, $s4 0x00007ffff7df7a58 <+424>: sc.w $t3, $t1, 0 0x00007ffff7df7a5c <+428>: beq $zero, $t3, -16 # 0x7ffff7df7a4c <__run_exit_handlers+412> 0x00007ffff7df7a60 <+432>: b 8 # 0x7ffff7df7a68 <__run_exit_handlers+440> 0x00007ffff7df7a64 <+436>: dbar 0x700 0x00007ffff7df7a68 <+440>: slli.w $t0, $t0, 0x0 The root cause of this problem is that a breakpoint was inserted in the middle of ll/sc atomic sequence during software single-step execution. The execution result of the atomic instruction sequence is disrupted, causing the program unable to complete the execution of the atomic instruction sequence normally. Further explanation, if the current pc is 0x00007ffff7df7a50, it is a conditional branch instruction, breakpoint should only be set at the jump destination address (0x00007ffff7df7a64, which is outside of the ll/sc atomic instruction sequence) and should not set at the address of pc + 4 (0x00007ffff7df7a54, which is in the middle of ll/sc atomic sequence). Modify a judgment condition in loongarch_deal_with_atomic_sequence() to ensure that breakpoints can not be inserted in the middle of ll/sc atomic sequence to address such issues. Signed-off-by: Hui Li <lihui@loongson.cn> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
2025-02-10gdb: fix selecting tail-call frames by nameAndrew Burgess3-2/+62
I noticed that attempting to select a tail-call frame using 'frame function NAME' wouldn't work: (gdb) bt #0 func_that_never_returns () at /tmp/build/gdb/testsuite/../../../src/gdb/testsuite/gdb.base/frame-selection.c:49 #1 0x0000000000401183 in func_that_tail_calls () at /tmp/build/gdb/testsuite/../../../src/gdb/testsuite/gdb.base/frame-selection.c:59 #2 0x00000000004011a5 in main () at /tmp/build/gdb/testsuite/../../../src/gdb/testsuite/gdb.base/frame-selection.c:70 (gdb) frame function func_that_tail_calls No frame for function "func_that_tail_calls". (gdb) up #1 0x0000000000401183 in func_that_tail_calls () at /tmp/build/gdb/testsuite/../../../src/gdb/testsuite/gdb.base/frame-selection.c:59 59 func_that_never_returns (); (gdb) disassemble Dump of assembler code for function func_that_tail_calls: 0x000000000040117a <+0>: push %rbp 0x000000000040117b <+1>: mov %rsp,%rbp 0x000000000040117e <+4>: call 0x40116c <func_that_never_returns> End of assembler dump. (gdb) The problem is that the 'function' mechanism uses get_frame_pc() and then compares the address returned with the bounds of the function we're looking for. So in this case, the bounds of func_that_tail_calls are 0x40117a to 0x401183, with 0x401183 being the first address _after_ the function. However, because func_that_tail_calls ends in a tail call, then the get_frame_pc() is 0x401183, the first address after the function. As a result, GDB fails to realise that frame #1 is inside the function we're looking for, and the lookup fails. The fix is to use get_frame_address_in_block, which will return an adjusted address, in this case, 0x401182, which is within the function bounds. Now the lookup works: (gdb) frame function func_that_tail_calls #1 0x0000000000401183 in func_that_tail_calls () at /tmp/build/gdb/testsuite/../../../src/gdb/testsuite/gdb.base/frame-selection.c:59 59 func_that_never_returns (); (gdb) I've extended the gdb.base/frame-selection.exp test to cover this case.
2025-02-10tc-i386.c fix for oss-fuzz gas fuzzingAlan Modra1-0/+1
oss-fuzz fuzz_as is seriously broken with respect to gas static variables, so much so that most fuzz_as reports should simply be ignored. This patch is a fix for https://oss-fuzz.com/testcase-detail/6268463220654080 * config/tc-i386.c (i386_md_end): Clear GOT_symbol.
2025-02-10x86-64: Use x86_64_elf_howto_table for standard relocationsH.J. Lu1-4/+4
For standard relocations, use x86_64_elf_howto_table, instead of calling elf_x86_64_rtype_to_howto. * elf64-x86-64.c (elf_x86_64_tls_transition): Use x86_64_elf_howto_table, instead of elf_x86_64_rtype_to_howto. (elf_x86_64_convert_load_reloc): Use x86_64_elf_howto_table, instead of elf_x86_64_rtype_to_howto, for R_X86_64_PC32. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-02-10Automatic date update in version.inGDB Administrator1-1/+1
2025-02-09Add dwarf2_per_bfd::start_readingTom Tromey5-14/+28
The cooked index "start_reading" method can only be called after the dwarf2_per_bfd "index_table" member is set. This patch refactors this code a little to centralize this constraint, adding a new dwarf2_per_bfd::start_reading method and another (virtual) method to dwarf_scanner_base. This removes some casts, but also is also useful to support another series I'm working on where the .gdb_index is rewritten. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2025-02-09gdb/testsuite: avoid incorrect symbols in gdb.base/condbreak-multi-context.ccAndrew Burgess2-72/+165
In a different series I tweak how disabled_by_cond is handled in update_breakpoint_locations for code_breakpoint objects, see: https://inbox.sourceware.org/gdb-patches/cover.1734366277.git.aburgess@redhat.com But when I did this I ran into a regression in the test script gdb.base/condbreak-multi-context.cc which I think is actually an issue with this test. The test relies on creating a multi-location breakpoint with a condition and having GDB disable some of the locations as the condition is only valid in some of the locations. Here's an example of the test creating one such breakpoint: Reading symbols from /tmp/build/gdb/testsuite/outputs/gdb.base/condbreak-multi-context/condbreak-multi-context... (gdb) break func if a == 10 warning: failed to validate condition at location 1, disabling: No symbol "a" in current context. warning: failed to validate condition at location 3, disabling: No symbol "a" in current context. Breakpoint 1 at 0x401142: func. (3 locations) (gdb) info breakpoints Num Type Disp Enb Address What 1 breakpoint keep y <MULTIPLE> stop only if a == 10 1.1 N* 0x0000000000401142 in Base::func() at /tmp/build/gdb/testsuite/../../../src/gdb/testsuite/gdb.base/condbreak-multi-context.cc:23 1.2 y 0x000000000040114e in A::func() at /tmp/build/gdb/testsuite/../../../src/gdb/testsuite/gdb.base/condbreak-multi-context.cc:31 1.3 N* 0x000000000040115a in C::func() at /tmp/build/gdb/testsuite/../../../src/gdb/testsuite/gdb.base/condbreak-multi-context.cc:39 (*): Breakpoint condition is invalid at this location. (gdb) Notice that only location 1.2 is actually enabled, 1.1 and 1.3 are disabled due to the condition 'a == 10' not being valid. However, notice that this b/p is created before GDB has started the inferior. What I noticed is that if I first start the inferior then I get a different behaviour: Reading symbols from /tmp/build/gdb/testsuite/outputs/gdb.base/condbreak-multi-context/condbreak-multi-context... (gdb) start Temporary breakpoint 1 at 0x40110e: file /tmp/build/gdb/testsuite/../../../src/gdb/testsuite/gdb.base/condbreak-multi-context.cc, line 49. Starting program: /tmp/build/gdb/testsuite/outputs/gdb.base/condbreak-multi-context/condbreak-multi-context Temporary breakpoint 1, main () at /tmp/build/gdb/testsuite/../../../src/gdb/testsuite/gdb.base/condbreak-multi-context.cc:49 49 aobj.func (); (gdb) break func if a == 10 Breakpoint 2 at 0x401142: func. (3 locations) (gdb) info breakpoints Num Type Disp Enb Address What 2 breakpoint keep y <MULTIPLE> stop only if a == 10 2.1 y 0x0000000000401142 in Base::func() at /tmp/build/gdb/testsuite/../../../src/gdb/testsuite/gdb.base/condbreak-multi-context.cc:23 2.2 y 0x000000000040114e in A::func() at /tmp/build/gdb/testsuite/../../../src/gdb/testsuite/gdb.base/condbreak-multi-context.cc:31 2.3 y 0x000000000040115a in C::func() at /tmp/build/gdb/testsuite/../../../src/gdb/testsuite/gdb.base/condbreak-multi-context.cc:39 (gdb) Notice that now all three locations are valid. What's actually happening is that, on my machine libm.so contains a global symbol 'a' which for 2.1 and 2.3 is being used to satisfy the condition. I don't believe this is actually the intention of the test, this is just an unfortunate consequence of name collision. The test actually relies on the local variables 'a' and 'c', and my libm.so contains a global version of both. So I propose that we just update the test, I've gone for the super inventive 'aaa' and 'ccc'. With this change, after starting the inferior I now see the expected behaviour where only one of the three locations is enabled. However, while I'm fixing this I figure that it would be nice if the test checked both cases, creating the breakpoints before starting the inferior, and after starting the inferior. So I've updated the test to check both cases. This has meant converting the mostly linear test script into a set of parameterised functions which I then call with a flag to indicate if the inferior should be started before of after creating the breakpoints. Approved-By: Tom Tromey <tom@tromey.com> Tested-By: Hannes Domani <ssbssa@yahoo.de>
2025-02-10x86: Return error for invalid relocation offsetH.J. Lu5-0/+32
Return error if relocation offset + relocation size > section size. bfd/ PR ld/32665 * elf32-i386.c (elf_i386_scan_relocs): Return error for invalid relocation offset. * elf64-x86-64.c (elf_x86_64_scan_relocs): Likewise. ld/ PR ld/32665 * testsuite/ld-x86-64/pr32665.err: New file. * testsuite/ld-x86-64/pr32665.o.bz2: Likewise. * testsuite/ld-x86-64/x86-64.exp: Run PR ld/32665 test. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-02-10Fix typo in objdump info/man pageAlan Modra1-1/+1
2025-02-10gprof: fix odd inst len hist scale calculationRichard Allen1-1/+1
With even instruction sizes, this rounding never truncated. Xtensa CPUs mostly use 2-3 byte instructions, and this can lead to a histogram being captured with an odd length address range. This small truncation prevented gprof from parsing gmon.out files containing multiple histograms when at least one of them has an odd address range length and another has any other address range. Signed-off-by: Richard Allen <rsaxvc@gmail.com>
2025-02-10gprof: print values of mismatched histogram scalesRichard Allen1-2/+2
Signed-off-by: Richard Allen <rsaxvc@gmail.com>
2025-02-10gprof: fix comment typosRichard Allen1-3/+3
Signed-off-by: Richard Allen <rsaxvc@gmail.com>
2025-02-10gprof: add missing newline to error textRichard Allen1-1/+1
Signed-off-by: Richard Allen <rsaxvc@gmail.com>
2025-02-10PR32664, compressed debug section naming confusionAlan Modra1-0/+1
The pr326664 fuzzer testcase has two .debug_info sections, one SHF_ALLOC, one not. SEC_DEBUGGING is never set for SHF_ALLOC sections that happen to be named .debug_info, nor are they compressed. However in this case we get an output section that is both SEC_ALLOC and SEC_DEBUGGING which confuses code setting up the output section names (.zdebug_* for compressed debug sections), resulting in a -1u index into a string table. PR 32664 * elf.c (elf_fake_sections): Do not delay naming of SEC_ALLOC sections.