aboutsummaryrefslogtreecommitdiff
path: root/gdb
AgeCommit message (Collapse)AuthorFilesLines
2025-03-06Use "::" as separator for Fortran in cooked indexTom Tromey1-0/+1
This teaches cooked_index_entry::full_name that "::" is the separator for Fortran. I don't know enough Fortran to write a test case for this. However, a different series I am working on has a regression if this patch is not applied. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2025-03-06Avoid double-decoding in ada_add_global_exceptionsTom Tromey1-11/+9
I noticed that ada_add_global_exceptions calls ada_decode on 'search_name' -- and then passes this to name_matches_regex, which also calls ada_decode. name_matches_regex is also used later, where the result of 'natural_name ()' is passed to it -- but natural_name also calls ada_decode. So, I think the call to ada_decode in name_matches_regex is redundant. This patch removes it, and turns name_matches_regex into an inner function to avoid propagating its use. Note that, right now, the DWARF implementation of expand_symtabs_matching does not in fact pass an encoded name to this callback. So, this code remains slightly (but currently harmlessly) wrong. expand_symtabs_matching is fixed by another pending series of mine.
2025-03-06[gdb] Fix typos in some selftestsTom de Vries3-5/+5
Fix typos: ... figured on out -> figured one out fpr -> for hopefuly -> hopefully ...
2025-03-05gdb/testsuite: add test for memory requirements of gcoreGuinevere Larsen2-0/+149
For a long time, Fedora has been carrying an out-of-tree patch with a similar test to the one proposed in this patch, that ensures that the memory requirements don't grow with the inferior's memory. It's been so long that the context for why this test exists has been lost, but it looked like it could be interesting for upstream. The test runs twice, once with the inferior allocating 4Mb of memory, and the other allocating 64Mb. My plan was to find the rate at which things increase based on inferior size, and have that tested to ensure we're not growing that requirement accidentally, but my testing actually showed memory requirements going down as the inferior increases, so instead I just hardcoded that we need less than 2Mb for the command, and it can be tweaked later if necessary. Approved-By: Tom Tromey <tom@tromey.com>
2025-03-05gdb: do not handle a NULL linebuffer in pager_file::putsSimon Marchi1-2/+1
This patch [1] has shown that different implementations of ui_file::puts handle a NULL line differently. pager_file::puts handles a NULL argument gracefully, as a no-op, while other implementations don't and likely crash. This causes subtle bugs: things will be working until the current ui_file is suddenly not a pager_file anymore. I think it would be better to be consistent here, so change pager_file::puts to not accept a NULL line. A regular test run on Linux shows no regression. [1] https://inbox.sourceware.org/gdb-patches/edfe6e17-1c20-4a4c-944f-247ff71b6c10@simark.ca/T/#m864aea10de8ca6fa84757971fcbaf3180e2eaefa Change-Id: Ieb465c86cd2c42a248cf481cd174c8622ef6724b Approved-By: Tom Tromey <tom@tromey.com>
2025-03-05Inconsistent treatment of template parameters in DWARF readerTom Tromey2-14/+7
I noticed that if you hack some clean_restart calls into paramless.exp, the test will fail. That is, the test currently relies on the desired CUs already being expanded when trying to set a breakpoint -- which is clearly a bug, the CU expansion state should not affect "break". I tracked this down to incorrect construction of a lookup_name_info in cooked_index_functions::expand_symtabs_matching. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32510 Approved-By: Simon Marchi <simon.marchi@efficios.com>
2025-03-05gdb/dwarf: store dwo_file_up in dwo_file_setSimon Marchi2-92/+97
Heap-allocated dwo_file objects, stored in dwarf2_per_bfd::dwo_files, are never freed. They are created in one of the create_dwo_unit_in_dwp_* or lookup_dwo_cutu functions. I confirmed this by running: $ make check TESTS="gdb.cp/anon-ns.exp" RUNTESTFLAGS="--target_board=fission-dwp" $ ./gdb -q -nx --data-directory=data-directory testsuite/outputs/gdb.cp/anon-ns/anon-ns -ex "p main" -ex "file" -batch ... and checking the ASan leak report. I also debugged this invocation of GDB, placed a breakpoint on ~dwo_file, and didn't see any hit. Change the dwo_file set to hold dwo_file_up objects. When the dwarf2_per_bfd object gets destroyed, dwo_file objects will automatically get destroyed. With this change, I see the related leaks disappear in the ASan leak report, and my ~dwo_file breakpoint gets hit when debugging GDB. Change-Id: Icb38539c3f9e553f3625c625a00fc63dd6e9f3c5 Approved-By: Tom Tromey <tom@tromey.com>
2025-03-05gdb/dwarf: make dwarf2_per_bfd::dwo_files a gdb::unordered_setSimon Marchi2-166/+147
Change the dwarf2_per_bfd::dwo_files htab to a gdb::unordered_set. No behavior change expected, except maybe the failure case in lookup_dwo_cutu. If open_and_init_dwo_file returns nullptr, the previous code would leave the slot value empty (nullptr). Is this legit? With the new hash table, the only thing we can do really is not attempt to insert the nullptr value. Change-Id: I63992f388b1197e696ded4ea483634e8ae67fce4 Approved-By: Tom Tromey <tom@tromey.com>
2025-03-05gdb/dwarf: change htabs holding dwo_unit objects to gdb::unordered_setSimon Marchi1-181/+99
Change a few occurences of htabs holding `dwo_unit *` values, using their signature as identity, to gdb::unordered_set. allocate_dwo_unit_table and allocate_dwp_loaded_cutus_table appeared to create hash tables with identical behavior, so they both use the same set type now. The only expected change in behavior is that when there are multiple units with the same signature, we will now keep the unit previously in the set, rather than overwriting it. But this seems ok, as it's a case of bad DWARF. Also, in the complaint in create_debug_type_hash_table, I think we previously erroneously printed the same sect_off twice. Change-Id: I57739977735ee1fd5c7b754107f5624f0621baa5 Approved-By: Tom Tromey <tom@tromey.com>
2025-03-05gdb/dwarf: remove unused local variable in create_debug_type_hash_tableSimon Marchi1-1/+0
Change-Id: I40679fbe32a8a1a9cced085532c83f06affc294c Approved-By: Tom Tromey <tom@tromey.com>
2025-03-05gdb/dwarf: remove unnecessary parameters to create_{cus,debug_type}_hash_tableSimon Marchi1-30/+21
In create_cus_hash_table, we can get the section and hash table from the dwo_file directly. In create_debug_type_hash_table, we can get the hash table from the dwo_file directly - the section varies. Change-Id: I1d5ef49df98fe2620e12b83484b28cd7398f24ae Approved-By: Tom Tromey <tom@tromey.com>
2025-03-05gdb/dwarf: remove die_reader_specsSimon Marchi1-109/+78
die_reader_specs is a relic of some past design, today it only serves as (useless) a base class for cutu_reader. Remove it and move all its fields to cutu_reader. Change-Id: I5d55018eb8c6e0b828ef5d2f6d09b2047d1a5912 Approved-By: Tom Tromey <tom@tromey.com>
2025-03-05gdb/dwarf: remove unnecessary parameter of create_cus_hash_tableSimon Marchi1-4/+3
We can use `cu->per_objfile` instead of passing down a dwarf2_per_objfile explicitly. Change-Id: Ie1fd93d9e7a74d09b857f1f0909d7441b79ed893 Approved-By: Tom Tromey <tom@tromey.com>
2025-03-05gdb/dwarf: remove unnecessary local variable in dw2_get_file_names_readerSimon Marchi1-3/+2
It seems like the lh_cu variable is not necessary, we can just use this_cu. Change-Id: Ic2ed6ee82faf1fb5d340cd92dc8ef15434b20cb8 Approved-By: Tom Tromey <tom@tromey.com>
2025-03-05gdb: fix null pointer dereference on missing PATH variableDaniel Starke1-3/+4
When running "show" with missing PATH variable a null pointer is being dereferenced in path_info(). path_command() correctly checks whether PATH has been set before using it. It then calls path_info() which retrieves the variable again but fails to perform the null pointer test on it. As a result, the application crashes with SIGSEGV on Windows for example. Fix this by handling the null pointer case in path_info() accordingly. Signed-off-by: Daniel Starke <daniel-email@gmx.net> Co-Authored-By: Simon Marchi <simon.marchi@efficios.com> Approved-By: Tom Tromey <tom@tromey.com> Change-Id: I41ef10f00802d3163793491454190008e78f5dc1
2025-03-05Create dwarf2/parent-map.cTom Tromey3-66/+89
This creates a new file, dwarf2/parent-map.c, to hold some code related to parent maps. This helps shrink read.c a bit. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2025-03-05Dump debug names indexTom Tromey1-1/+1
This changes the .debug_names reader to dump the contents of the index. This follows what the cooked index does, and also fixes a couple of test failures when run with the debug-names board: forward-spec-inter-cu.exp and backward-spec-inter-cu.exp. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2025-03-04gdb/dwarf: pass is_dwz to dwarf2_per_cu constructorSimon Marchi3-28/+33
It is always known at construction time whether a dwarf2_per_cu is built to represent a unit from a dwz file or not, so pass that information through the constructor. Change-Id: I278c1894ed606451aad02e830085190bb724c473 Approved-By: Tom Tromey <tom@tromey.com>
2025-03-04gdb/dwarf: make dwarf2_get_dwz_file a method of dwarf2_per_bfdSimon Marchi9-44/+32
dwarf2_get_dwz_file looks more or less like a simple getter of dwarf2_per_bfd::dwz_file, so make it into a method. I typically avoid the `get_` prefix for getters, but that would conflict with the field name here. Change-Id: Idd0d5b1bd3813babf438b20aac514b19c77cfc18 Approved-By: Tom Tromey <tom@tromey.com>
2025-03-04gdb/dwarf: remove create_cu_from_index_listSimon Marchi3-24/+3
I noticed that create_cu_from_index_list is only used in read-gdb-index.c, so I started by moving it there. But given that this function is use at only one spot and doesn't do much, I opted to inline its code in the caller instead. Change-Id: Iebe0dc20d345fa70a2f11aa9ff1a04fe26a31407 Approved-By: Tom Tromey <tom@tromey.com>
2025-03-04Check whether gnatmake can link with -sharedTom Tromey2-0/+10
Currently, gnat-llvm does not ship a shared libgnat. This patch changes the relevant test to check whether linking with -shared actually works.
2025-03-04Check whether gnatmake supports -OgTom Tromey2-0/+9
gnat-llvm does not support the -Og flag. This arranges to check for this flag before using it.
2025-03-04Look for -fgnat-encodings optionTom Tromey2-4/+24
gnat-llvm does not support the -fgnat-encodings option, and does not emit GNAT encodings at all -- it only supports the equivalent of GCC's "minimal" encodings; which is to say, ordinary DWARF. This patch changes gdb to test whether gnatmake supports this flag and adapt accordingly. foreach_gnat_encoding is changed to pretend that the "minimal" mode is in effect, as some test examine the mode.
2025-03-04Check -fvar-tracking via ada_simple_compileTom Tromey3-2/+7
A couple of Ada tests check whether the C compiler supports -fvar-tracking. However, this doesn't really work when using gnat-llvm, because that will invoke clang under the hood. This patch arranges to check gnatmake instead, which is more robust even when toolchains are mix-and-matched.
2025-03-04Introduce ada_simple_compileTom Tromey2-11/+56
This introduces ada_simple_compile, an Ada-specific analog of gdb_simple_compile. gdb_compile_test is split into two procs to make this possible. ada_simple_compile isn't used in this patch but will be by later patches in this series.
2025-03-04Check for compiler support in scalar_storage.expTom Tromey1-2/+14
gnat-llvm does not currently handle Scalar_Storage_Order. This patch changes the scalar_storage.exp test to check the compiler error messages and report "unsupported" in this case. This way, the test ought to start working automatically if this feature is added to gnat-llvm.
2025-03-03Obvious comment fix in cooked-index.hTom Tromey1-1/+1
I noticed that cooked-index.h still refers to a vector of parent maps, but the code itself actually uses a parent_map here.
2025-03-03Add language to type unit in debug-names-tu.exp.tclTom Tromey6-45/+67
I think debug-names-tu.exp.tcl only passes by accident -- the type unit does not have a language, which gdb essentially requires. This isn't noticeable right now because the type unit in question is expanded in one phase and then the symbol found in another. However, I'm working on a series that would regress this. This patch partially fixes the problem by correcting the test case, adding the language to the TU. Hoewver, it then goes a bit further and arranges for this information not to be written to .debug_names. Whether or not a type should be considered "static" seems like something that is purely internal to gdb, so this patch has the entry-creation function apply the appropriate transform. It also may make sense to change the "debug_names" proc in the test suite to process attributes more like the ordinary "cu" proc does.
2025-03-03gdb/dwarf: remove unnecessary abfd parameter in dwarf2_per_bfd::locate_sectionsSimon Marchi2-6/+5
The parameter `abfd` is always the same as `this->obfd`, there is no need to pass it as a parameter. Change-Id: If7ad58ad4efdf6b070cbf2b8a73436bd8b452fa6 Approved-By: Tom Tromey <tom@tromey.com>
2025-03-03gdb/dwarf: rename dwarf2_per_cu_data -> dwarf2_per_cuSimon Marchi21-298/+260
This scratches an itch I had for a while. I don't know why this struct type has "data" in its name. Others like "dwarf2_per_objfile" and "dwarf2_per_bfd" don't. The primary job of a structure is to hold data, there's no need to specify it. It also makes the name a bit shorter, which is always nice. Rename related types too. Change-Id: Ifb63195ff105809fc15b502f639c0bb4d18a675e Approved-By: Tom Tromey <tom@tromey.com> Reviewed-By: Guinevere Larsen <guinevere@redhat.com>
2025-03-03Bploc should try to return full pathSimon Farre1-3/+22
Compilers often emit relative paths in the line number program, relative to the build directory for that compilation unit (if it's DWARF>=4 I think). Therefore use symtab->fullname() when not null as this seemingly has attempted path normalization for the symtab and only fall back on symtab->filename which will never be null if that fails. This has a much better UX. Applications may choose to expose this name as a clickable link to some file, at which point a non-normalized and non-absolute path would lead nowhere. When I wrote this feature the first time, I don't think this relative-to-cu-scheme was as prevalent in the output of gcc/clang for DWARF. Approved-By: Tom Tromey <tom@tromey.com>
2025-03-03[gdb/doc] Indicate in which languages 'filename'::funcaddr worksTom de Vries1-4/+8
In the docs I read [1]: ... In this section, we discuss operators that you can use in GDB expressions regardless of your programming language. ... GDB supports these operators, in addition to those common to programming languages: ‘::’ allows you to specify a variable in terms of the file or function where it is defined. See Program Variables. ... In fact, this is not supported in Ada: ... (gdb) b *'foo.adb'::foo No file or function "foo.adb'". (gdb) ... and likewise in a few other working languages. Fix this by making this restriction explicit. Approved-By: Eli Zaretskii <eliz@gnu.org> PR gdb/32753 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32753 [1] https://sourceware.org/gdb/current/onlinedocs/gdb.html/Expressions.html
2025-03-03[gdb/doc] Fix address location with file prefixTom de Vries1-2/+4
In the docs I read [1]: ... Address locations indicate a specific program address. They have the generalized form *address. funcaddr An address of a function or procedure derived from its name. ... 'filename':funcaddr Like funcaddr above, but also specifies the name of the source file explicitly. This is useful if the name of the function does not specify the function unambiguously, e.g., if there are several functions with identical names in different source files. ... This is incorrect, the notation is in fact 'filename'::funcaddr. Fix this by correcting the typo, and add a reference to "variable name conflict", where the concept is explained in more detail. Approved-By: Eli Zaretskii <eliz@gnu.org> PR gdb/32748 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32748 [1] https://sourceware.org/gdb/current/onlinedocs/gdb.html/Address-Locations.html
2025-03-03[gdb/doc] Don't advertise *&function for pascal and modula-2Tom de Vries1-4/+3
In the docs I read [1]: ... Address locations indicate a specific program address. They have the generalized form *address. ... funcaddr An address of a function or procedure derived from its name. ... In Pascal and Modula-2, this is &function. ... I tried "break *&function" for Pascal and Modula-2, and this doesn't work, while "break *function" works fine. Fix this by updating the documentation to reflect actual behaviour. Approved-By: Eli Zaretskii <eliz@gnu.org> PR gdb/32754 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32754 [1] https://sourceware.org/gdb/current/onlinedocs/gdb.html/Address-Locations.html
2025-03-03gdb: remove some unused includes from printcmd.cSimon Marchi1-2/+0
clangd reports them as unused. Change-Id: I50a3c13db128ffe1630364f707d66a24ce11d352
2025-03-03gdb: remove unused include from frame.cSimon Marchi1-1/+0
clangd reports it as unused. Change-Id: I636e57747d3c42ce6615a14d4cf5dc115628a73d
2025-02-28gdb/dwarf: add dwarf2_per_bfd::filename and use it where possibleSimon Marchi4-18/+17
I noticed we quite often use: bfd_get_filename (per_bfd->obfd) Add a shortcut for that. Change-Id: I4e33925a481fd44088386510b01936d38e1d7d38 Approved-By: Andrew Burgess <aburgess@redhat.com>
2025-02-28[gdb/testsuite] Fix gdb.base/nostdlib.exp on aarch64Tom de Vries1-2/+22
On aarch64-linux, in test-case gdb.base/nostdlib.exp I run into: ... (gdb) continue^M Continuing.^M warning: Temporarily disabling breakpoints for unloaded shared library \ "/lib/ld-linux-aarch64.so.1"^M ^M Breakpoint 2, _start () at nostdlib.c:20^M 20 {^M (gdb) FAIL: $exp: pie=pie: continue to marker ... This happens as follows: - the test-case sets a breakpoint on *_start, - the breakpoint resolves to *_start in the executable, - the executable is started, and the breakpoint resolves to *_start in the dynamic linker, - execution stops at *_start in the dynamic linker, - the test-case issues a continue, expecting to continue to the breakpoint on marker, - while continuing, the dynamic linker is reported as unloaded, - the breakpoint again resolves to *_start in the executable, - execution stops at *_start in the executable, and - the test-case concludes that it failed to "continue to marker". This doesn't happen on x86_64-linux. There, after the executable is started, the breakpoint again resolves to *_start in the exec. This is similar to what happens when printing _start. On aarch64-linux, we print the _start in the dynamic linker: ... $ gdb -q -batch outputs/gdb.base/nostdlib/nostdlib-pie \ -ex "b _start" \ -ex run \ -ex "print _start" \ -ex "info break" Breakpoint 1 at 0x2bc: file nostdlib.c, line 23. Breakpoint 1.2, _start () at ../sysdeps/aarch64/dl-start.S:22 22 ENTRY (_start) $1 = {void (void)} 0xfffff7fd6ac0 <_start> Num Type Disp Enb Address What 1 breakpoint keep y <MULTIPLE> breakpoint already hit 1 time 1.1 y 0x0000aaaaaaaa02bc in _start at nostdlib.c:23 1.2 y 0x0000fffff7fd6ac0 in _start at dl-start.S:22 ... On x86_64-linux, we print the _start in the exec: ... Breakpoint 1 at 0x2c5: file nostdlib.c, line 23. Breakpoint 1.2, 0x00007ffff7fe4f00 in _start () from \ /lib64/ld-linux-x86-64.so.2 $1 = {void (void)} 0x5555555542c1 <_start> Num Type Disp Enb Address What 1 breakpoint keep y <MULTIPLE> breakpoint already hit 1 time 1.1 y 0x00005555555542c5 in _start at nostdlib.c:23 1.2 y 0x00007ffff7fe4f00 <_start> ... The difference may be down to the availability of debug info for the _start in the dynamic linker. Finally, the described scenario on aarch64-linux is not deterministic. The behavior depends on the dynamic linker being reported as unloaded, which has been classified as a GLIBC bug, so that might get fixed. Ideally this test-case would stop at both *_start in the executable and the dynamic linker, but in absense of a way to specify this reliably (see PR32748), fix this by making this a temporary breakpoint, ensuring that the breakpoint will only trigger once. Approved-by: Kevin Buettner <kevinb@redhat.com> PR testsuite/32743 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32743
2025-02-27gdb, gdbserver, gdbsupport: fix some namespace comment formattingSimon Marchi21-23/+23
I noticed a // namespace selftests comment, which doesn't follow our comment formatting convention. I did a find & replace to fix all the offenders. Change-Id: Idf8fe9833caf1c3d99e15330db000e4bab4ec66c
2025-02-27gdb/dwarf: fix failed assertion in dwarf2_find_containing_comp_unit selftestSimon Marchi1-2/+9
Commit 2f0521c0d6f6 ("gdb/dwarf: fix signature_type created with nullptr section") added some asserts in the dwarf2_per_cu_data constructor to verify that the passed dwarf2_per_bfd and dwarf2_section_info are not nullptr. However, the dummy dwarf2_per_cu_data objects created in the dwarf2_find_containing_comp_unit selftests are passed nullptr for those parameters. I prefer to keep the asserts in place, as protection for the non-test code and as self documentation, so fix this by passing some dummy pointers in the test. Change-Id: Ic7cdc1b976f7506041b651222234eefc998e473a Reviewed-By: Tom de Vries <tdevries@suse.de>
2025-02-27gdb/dwarf: pass unit length to dwarf2_per_cu_data constructorSimon Marchi3-38/+46
Most of the time, the length of a unit is known when constructing a dwarf2_per_cu_data or signatured_type. Add a construtor parameter for it. In the few cases where it isn't, pass 0, which leaves it unset. Change-Id: I0c8b9683164d3e3f3823ed995f71689a4d17fd96 Reviewed-By: Tom de Vries <tdevries@suse.de>
2025-02-26[gdb/build] Fix unused var in dwarf2/read.cTom de Vries1-1/+1
On x86_64-linux, with gcc 7.5.0 I ran into a build breaker: ... gdb/dwarf2/read.c: In function ‘void read_comp_units_from_section()’: gdb/dwarf2/read.c:4297:31: error: unused variable ‘sig_type_it’ \ [-Werror=unused-variable] auto [sig_type_it, inserted] = sig_types.emplace (sig_ptr); ^ ... Fix this by dropping the unused variable. Tested on x86_64-linux, by completing a build.
2025-02-25gdb/dwarf: fix signature_type created with nullptr sectionSimon Marchi2-1/+4
Commit c44ab627b02 ("gdb/dwarf: pass section to dwarf2_per_cu_data constructor") introduced a regression when using dwp. It can be reproduced with: $ make check TESTS="gdb.base/ptype-offsets.exp" RUNTESTFLAGS="--target_board=fission-dwp" Then, to investigate: $ ./gdb -nx -q --data-directory=data-directory testsuite/outputs/gdb.base/ptype-offsets/ptype-offsets -ex 'ptype int' Reading symbols from testsuite/outputs/gdb.base/ptype-offsets/ptype-offsets... /home/smarchi/src/binutils-gdb/gdb/dwarf2/read.c:3195:38: runtime error: member call on null pointer of type 'struct dwarf2_section_info' Commit c44ab627b02 removed the assignment of signatured_type::section (dwarf2_per_cu_data::section, really) in fill_in_sig_entry_from_dwo_entry with the justification that the section was already set when constructing the signatured_type. Well, that was true except for one spot in lookup_dwp_signatured_type which passes a nullptr section to add_type_unit. Fix that by passing the section to add_type_unit in that one spot. This is the same section that would have been set by fill_in_sig_entry_from_dwo_entry before. Add some asserts in the dwarf2_per_cu_data constructor to verity that the passed dwarf2_per_bfd and dwarf2_section_info are non-nullptr. Change-Id: If27dae6b4727957c96defc058c7e4be31472005b Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32739 Co-Authored-By: Tom de Vries <tdevries@suse.de> Approved-By: Tom Tromey <tom@tromey.com>
2025-02-25gdb/dwarf: convert dwarf2_per_bfd::signatured_types to a gdb::unordered_setSimon Marchi3-136/+102
I'd like to add these asserts in dwarf2_per_cu_data's constructor: gdb_assert (per_bfd != nullptr); gdb_assert (section != nullptr); However, these dummy instances of signatured_type, used as hash table lookup keys, are in the way: signatured_type find_sig_entry (nullptr, nullptr, sect_offset {}, sig); This motivated me to convert the dwarf2_per_bfd::signatured_types hash table to a gdb::unordered_set. This allows finding an entry by simply passing the signature (an integer) and removes the need to create dummy signatured_type objects. There is one small unfortunate pessimization: lookup_dwo_signatured_type, for instance, does a lookup by signature to find an existing signatured_type. If not found, it adds a new one by calling add_type_unit. The current code passes down the slot where to put the new element, avoiding an extra hash when inserting the new signatured_type. With the new code, I don't see a way to do that. This is probably negligible, but it bugs me. If we used a map of signature -> signatured_type, I would see a way, but then it would waste space. I see one change in behavior, that is not really important IMO. In read_comp_units_from_section, if duplicate signature type entries are detected, the code prior to this patch overwrites the existing signatured_type in the hash table with the new one. With this patch, the existing signatured_type is kept: the call to emplace does not insert the value if an existing equal value exists. Other than that, no behavior change expected. Change-Id: I0bef1b49cc63dbdf4e32fa9d4ea37f83025efc3e Approved-By: Tom Tromey <tom@tromey.com>
2025-02-25gdb/dwarf: change some per-objfile functions to be per-bfdSimon Marchi1-31/+31
I identified the following functions that currently take a dwarf2_per_objfile, but could take a less specific dwarf2_per_bfd. - try_open_dwop_file - open_dwo_file - open_dwp_file The uses of the per-objfile object in try_open_dwop_file can be replaced with equivalent per-bfd ones. Change-Id: Ia31fa0b988375e86a715ee863d4ec3c572ce89c0 Approved-By: Tom Tromey <tom@tromey.com>
2025-02-25gdb/dwarf: use dwz_file::filename in a few spotsSimon Marchi2-4/+4
I found a few spots where the existing dwz_file::filename method could be used. Change-Id: I0522b1e3abbfac2f392f9ec777c37b242ee236d8 Approved-By: Tom Tromey <tom@tromey.com>
2025-02-25gdb: move "gdb:function_view" into quick-symbol.h typedefsSimon Marchi12-144/+122
All users of these typedefs use them inside a gdb::function_view. Move the gdb::function_view in the typedefs themselves. This shortens the types in function signatures and helps with readability, IMO. Rename them to remove the `_ftype` suffix: this suffix is not as relevant in C++ as it was in C. With function_view, the caller can pass more than just a simple "function". Anyway, I think it's clearer to name them after the role the callback has (listener, matcher, etc). Adjust some related comments. Change-Id: Iaf9f8ede68b51ea9e4d954792e8eb90def8659a6 Approved-By: Tom Tromey <tom@tromey.com>
2025-02-25gdb/dwarf: initialize tu_stats fieldsSimon Marchi1-7/+7
Initialize fields of tu_stats to 0, remove the explicit default initialization of dwarf2_per_bfd::tu_stats. Change-Id: I98b2d5c4171291a3df2569466559174fb7cf32b6 Approved-By: Tom Tromey <tom@tromey.com>
2025-02-25Remove struct print_one_inferior_dataTom Tromey1-6/+0
struct print_one_inferior_data is not used, so remove it.
2025-02-25gdb/dwarf: remove unused include in read.cSimon Marchi1-1/+0
This include is reported as unused by clangd. Change-Id: I95b73f85607537551ef54e46551197d1371d621b