Commit Graph

408 Commits

Author SHA1 Message Date
Tom Tromey
8e8d48f91c Remove ALL_DICT_SYMBOLS
This replaces ALL_DICT_SYMBOLS with an iterator so that for-each can
be used.
2023-05-07 12:44:17 -06:00
Tom Tromey
5250cbc85c Remove ALL_OBJFILE_OSECTIONS
This replaces ALL_OBJFILE_OSECTIONS with an iterator so that for-each
can be used.
2023-05-07 12:44:17 -06:00
Tom Tromey
9ed8433a04 Rename objfile::sections
I think objfile::sections makes sense as the name of the method to
iterate over an objfile's sections, so this patch renames the existing
field to objfile::sections_start in preparation for that.
2023-05-07 12:44:17 -06:00
Tom Tromey
a8ed3dde83 Rename objfile_type to builtin_type
This renames objfile_type to be an overload of builtin_type, in
preparation for their unification.

Reviewed-By: Simon Marchi <simon.marchi@efficios.com>
2023-03-18 11:12:38 -06:00
Tom Tromey
82c5090c61 Remove extra scopes from objfile_relocate1
objfile_relocate1 introduces new scopes that aren't necessary.  I
noticed this while working on an earlier patch in this series.  This
patch removes these.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-03-11 08:48:10 -07:00
Tom Tromey
1acc9dca42 Change linetables to be objfile-independent
This changes linetables to not add the text offset to the addresses
they contain.  I did this in a few steps, necessarily combined
together in one patch: I renamed the 'pc' member to 'm_pc', added the
appropriate accessors, and then recompiled.  Then I fixed all the
errors.  Where possible I generally chose to use the raw_pc accessor,
as it is less expensive.

Note that this patch discounts the possibility that the text section
offset might cause wraparound in the addresses in the line table.
However, this was already discounted -- in particular,
objfile_relocate1 did not re-sort the table in this scenario.  (There
was a bug open about this, but as far as I can tell this has never
happened, it's not even clear what inspired that bug.)

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-03-11 08:47:40 -07:00
Tom Tromey
21f6be77b9 Merge forget_cached_source_info_for_objfile into objfile method
forget_cached_source_info_for_objfile does some objfile-specific work
and then calls objfile::forget_cached_source_info.  It seems better to
me to just have the method do all the work.
2023-03-07 14:46:58 -07:00
Tom Tromey
dae58e0444 Remove most calls to fixup_symbol_section
Nearly every call to fixup_symbol_section in gdb is incorrect, and if
any such call has an effect, it's purely by happenstance.

fixup_section has a long comment explaining that the call should only
be made before runtime section offsets are applied.  And, the loop in
this code (the fallback loop -- the minsym lookup code is "ok") is
careful to remove these offsets before comparing addresses.

However, aside from a single call in dwarf2/read.c, every call in gdb
is actually done after section offsets have been applied.  So, these
calls are incorrect.

Now, these calls could be made when the symbol is created.  I
considered this approach, but I reasoned that the code has been this
way for many years, seemingly without ill effect.  So, instead I chose
to simply remove the offending calls.
2023-02-08 08:20:12 -07:00
Tom Tromey
d401e7bf04 Remove compunit_symtab::m_block_line_section
The previous patch hard-coded SECT_OFF_TEXT into the buildsym code.
After this, it's clear that there is only one caller of
compunit_symtab::set_block_line_section, and it always passes
SECT_OFF_TEXT.  So, remove compunit_symtab::m_block_line_section and
use SECT_OFF_TEXT instead.
2023-02-08 08:20:12 -07:00
Tom Tromey
6ec27270ff Use bool in pc_in_* functions
I noticed that pc_in_unmapped_range had a weird return type -- it was
returning a CORE_ADDR but intending to return a bool.  This patch
changes all the pc_in_* functions to return bool instead.
2023-01-20 11:02:23 -07:00
Tom Tromey
5ea14aa4e5 Remove some unused includes
I noticed a few spots that include gnu-stabs.h but that do not need
to.  This patch removes these unnecessary includes.  Tested by
rebuilding.
2023-01-19 11:09:10 -07:00
Joel Brobecker
213516ef31 Update copyright year range in header of all files managed by GDB
This commit is the result of running the gdb/copyright.py script,
which automated the update of the copyright year range for all
source files managed by the GDB project to be updated to include
year 2023.
2023-01-01 17:01:16 +04:00
Tom Tromey
6829683679 Remove quick_symbol_functions::relocated
quick_symbol_functions::relocated is only needed for psymtabs, and
there it is only needed for Rust.  However, because we've switched the
DWARF reader away from psymtabs, this means there's no longer a need
for this method at all.
2022-12-19 08:05:14 -07:00
Simon Marchi
df86565b31 gdb: remove TYPE_LENGTH
Remove the macro, replace all uses with calls to type::length.

Change-Id: Ib9bdc954576860b21190886534c99103d6a47afb
2022-09-21 11:05:21 -04:00
Tom Tromey
88c4cce8d2 Use unique_ptr to destroy per-bfd object
In some cases, the objfile owns the per-bfd object.  This is yet
another object that can sometimes be destroyed before the registry is
destroyed, possibly reslting in a use-after-free.  Also, I noticed
that the condition for deleting the object is not the same as the
condition used to create it -- so it could possibly result in a memory
leak in some situations.  This patch fixes the problem by introducing
a new unique_ptr that holds this object when necessary.
2022-08-03 13:26:58 -06:00
Tom Tromey
075e4d6d95 Use auto_obstack in objfile
This changes objfile to use an auto_obstack.  This helps prevent
use-after-free bugs, because it ensures that anything allocated on the
objfile obstack will live past the point at which the registry object
is destroyed.
2022-08-03 13:26:58 -06:00
Tom Tromey
98badbfdc2 Use gdb_bfd_ref_ptr in objfile
This changes struct objfile to use a gdb_bfd_ref_ptr.  In addition to
removing some manual memory management, this fixes a use-after-free
that was introduced by the registry rewrite series.  The issue there
was that, in some cases, registry shutdown could refer to memory that
had already been freed.  This help fix the bug by delaying the
destruction of the BFD reference (and thus the per-bfd object) until
after the registry has been shut down.
2022-08-03 13:26:58 -06:00
Tom Tromey
08b8a139c9 Rewrite registry.h
This rewrites registry.h, removing all the macros and replacing it
with relatively ordinary template classes.  The result is less code
than the previous setup.  It replaces large macros with a relatively
straightforward C++ class, and now manages its own cleanup.

The existing type-safe "key" class is replaced with the equivalent
template class.  This approach ended up requiring relatively few
changes to the users of the registry code in gdb -- code using the key
system just required a small change to the key's declaration.

All existing users of the old C-like API are now converted to use the
type-safe API.  This mostly involved changing explicit deletion
functions to be an operator() in a deleter class.

The old "save/free" two-phase process is removed, and replaced with a
single "free" phase.  No existing code used both phases.

The old "free" callbacks took a parameter for the enclosing container
object.  However, this wasn't truly needed and is removed here as
well.
2022-07-28 14:16:50 -06:00
Tom Tromey
769520b7e5 Remove addrmap wrapper functions
This removes the various addrmap wrapper functions in favor of simple
method calls on the objects themselves.
2022-06-12 10:49:48 -06:00
Ilya Leoshkevich
625b6eae09 gdb: Do not add empty sections to the section map
From: Ulrich Weigand <ulrich.weigand@de.ibm.com>

build_objfile_section_table () creates four synthetic sections per
objfile, which are collected by update_section_map () and passed to
std::sort ().  When there are a lot of objfiles, for example, when
debugging JITs, the presence of these sections slows down the sorting
significantly.

The output of update_section_map () is used by find_pc_section (),
which can never return any of these sections: their size is 0, so they
cannot be accepted by bsearch_cmp ().

Filter them (and all the other empty sections) out in
insert_section_p (), which is used only by update_section_map ().
2022-06-02 14:20:05 +02:00
Tom Tromey
e2904e1ff0 Use unique_ptr for objfiles
A while back, I changed objfiles to be held via a shared_ptr.  The
idea at the time was that this was a step toward writing to the index
cache in the background, and this would let gdb keep a reference alive
to do so.  However, since then we've rewritten the DWARF reader, and
the new index can do this without requiring a shared pointer -- in
fact there are patches pending to implement this.

This patch switches objfile management to unique_ptr, which makes more
sense now.

Regression tested on x86-64 Fedora 34.
2022-05-31 14:46:11 -06:00
Simon Marchi
6e9cd73eb5 gdb: use gdb::function_view for gdbarch_iterate_over_objfiles_in_search_order callback
A rather straightforward patch to change an instance of callback +
void pointer to gdb::function_view, allowing pasing lambdas that
capture, and eliminating the need for the untyped pointer.

Change-Id: I73ed644e7849945265a2c763f79f5456695b0037
2022-05-05 15:27:26 -04:00
Simon Marchi
414705d1c2 gdb: remove BLOCKVECTOR_MAP macro
Replace with equivalent methods.

Change-Id: I4e56c76dfc363c1447686fb29c4212ea18b4dba0
2022-04-27 22:05:03 -04:00
Simon Marchi
63d609debb gdb: remove BLOCKVECTOR_BLOCK and BLOCKVECTOR_NBLOCKS macros
Replace with calls to blockvector::blocks, and the appropriate method
call on the returned array_view.

Change-Id: I04d1f39603e4d4c21c96822421431d9a029d8ddd
2022-04-27 22:05:03 -04:00
Simon Marchi
f5cb8afdd2 gdb: remove BLOCK_RANGES macro
Replace with an equivalent method on struct block.

Change-Id: I6dcf13e9464ba8a08ade85c89e7329c300fd6c2a
2022-04-27 22:05:03 -04:00
Simon Marchi
6dd5a4bd44 gdb: remove BLOCK_RANGE_{START,END} macros
Replace with equivalent methods on blockrange.

Change-Id: I20fd8f624e0129782c36768291891e7582d77c74
2022-04-27 22:05:03 -04:00
Simon Marchi
24d74bb5df gdb: remove BLOCK_MULTIDICT macro
Replace with equivalent methods.

Change-Id: If9a239c511a664f2a59fecb6d1cd579881b23dc2
2022-04-27 22:05:03 -04:00
Simon Marchi
4b8791e10e gdb: remove BLOCK_{START,END} macros
Replace with equivalent methods.

Change-Id: I10a6c8a2a86462d9d4a6a6409a3f07a6bea66310
2022-04-27 22:05:02 -04:00
Simon Marchi
7ab2607f97 gdbsupport: make gdb_abspath return an std::string
I'm trying to switch these functions to use std::string instead of char
arrays, as much as possible.  Some callers benefit from it (can avoid
doing a copy of the result), while others suffer (have to make one more
copy).

Change-Id: Iced49b8ee2f189744c5072a3b217aab5af17a993
2022-04-18 15:48:03 -04:00
Simon Marchi
4aeddc50d7 gdb: remove symbol value macros
Remove all macros related to getting and setting some symbol value:

    #define SYMBOL_VALUE(symbol)           (symbol)->value.ivalue
    #define SYMBOL_VALUE_ADDRESS(symbol)                         \
    #define SET_SYMBOL_VALUE_ADDRESS(symbol, new_value)    \
    #define SYMBOL_VALUE_BYTES(symbol)     (symbol)->value.bytes
    #define SYMBOL_VALUE_COMMON_BLOCK(symbol) (symbol)->value.common_block
    #define SYMBOL_BLOCK_VALUE(symbol)     (symbol)->value.block
    #define SYMBOL_VALUE_CHAIN(symbol)     (symbol)->value.chain
    #define MSYMBOL_VALUE(symbol)          (symbol)->value.ivalue
    #define MSYMBOL_VALUE_RAW_ADDRESS(symbol) ((symbol)->value.address + 0)
    #define MSYMBOL_VALUE_ADDRESS(objfile, symbol)                         \
    #define BMSYMBOL_VALUE_ADDRESS(symbol) \
    #define SET_MSYMBOL_VALUE_ADDRESS(symbol, new_value)   \
    #define MSYMBOL_VALUE_BYTES(symbol)    (symbol)->value.bytes
    #define MSYMBOL_BLOCK_VALUE(symbol)    (symbol)->value.block

Replace them with equivalent methods on the appropriate objects.

Change-Id: Iafdab3b8eefc6dc2fd895aa955bf64fafc59ed50
2022-04-11 10:45:36 -04:00
Simon Marchi
3c86fae3d9 gdb: remove symtab::objfile
Same idea as previous patch, but for symtab::objfile.  I find
it clearer without this wrapper, as it shows that the objfile is
common to all symtabs of a given compunit.  Otherwise, you could think
that each symtab (of a given compunit) can have a specific objfile.

Change-Id: Ifc0dbc7ec31a06eefa2787c921196949d5a6fcc6
2022-04-07 13:05:22 -04:00
Simon Marchi
66d7f48f80 gdb: remove SYMBOL_CLASS macro, add getter
Change-Id: I83211d5a47efc0564386e5b5ea4a29c00b1fd46a
2022-02-06 16:03:46 -05:00
Simon Marchi
652099717d gdb: remove SYMTAB_OBJFILE macro
Remove the macro, replace with an equivalent method.

Change-Id: I8f9ecd290ad28502e53c1ceca5006ba78bf042eb
2022-02-06 16:03:46 -05:00
Simon Marchi
5b6074611e gdb: remove SYMTAB_LINETABLE macro, add getter/setter
Add a getter and a setter for a symtab's linetable.  Remove the
corresponding macro and adjust all callers.

Change-Id: I159183fc0ccd8e18ab937b3c2f09ef2244ec6e9c
2022-02-06 15:48:19 -05:00
Simon Marchi
c1e35bc9c6 gdb: remove COMPUNIT_BLOCK_LINE_SECTION macro, add getter/setter
Add a getter and a setter for a compunit_symtab's block line section.  Remove
the corresponding macro and adjust all callers.

Change-Id: I3eb1a323388ad55eae8bfa45f5bc4a08dc3df455
2022-02-06 15:48:19 -05:00
Simon Marchi
af39c5c874 gdb: remove COMPUNIT_BLOCKVECTOR macro, add getter/setter
Add a getter and a setter for a compunit_symtab's blockvector.  Remove
the corresponding macro and adjust all callers.

Change-Id: I99484c6619dcbbea7c5d89c72aa660316ca62f64
2022-02-06 15:48:18 -05:00
Simon Marchi
102cc23543 gdb: move compunit_filetabs to compunit_symtab::filetabs
Make compunit_filetabs, used to iterate a compunit_symtab's filetabs, a
method of compunit_symtab.  The name filetabs conflicts with the current
name of the field.  Rename the field to m_filetabs, since at this point
nothing outside of compunit_symtab uses it, so we should treat it as
private (even though it's not actually private).  Rename the
last_filetab field to m_last_filetab as well (it's only used on
compunit_symtab::add_filetab).

Adjust the COMPUNIT_FILETABS macro to keep its current behavior of
returning the first filetab.

Change-Id: I537b553a44451c52d24b18ee1bfa47e23747cfc3
2022-02-06 15:48:18 -05:00
Tom Tromey
bf31fd38f0 Move gdb obstack code to gdbsupport
This moves the gdb-specific obstack code -- both extensions like
obconcat and obstack_strdup, and things like auto_obstack -- to
gdbsupport.
2022-01-18 10:14:42 -07:00
Joel Brobecker
4a94e36819 Automatic Copyright Year update after running gdb/copyright.py
This commit brings all the changes made by running gdb/copyright.py
as per GDB's Start of New Year Procedure.

For the avoidance of doubt, all changes in this commits were
performed by the script.
2022-01-01 19:13:23 +04:00
Weimin Pan
b3a01ce215 CTF: incorrect underlying type setting for enumeration types
A bug was filed against the incorrect underlying type setting for
an enumeration type, which was caused by a copy and paste error.
This patch fixes the problem by setting it by calling objfile_int_type,
which was originally dwarf2_per_objfile::int_type, with ctf_type_size bits.
Also add error checking on ctf_func_type_info call.
2021-10-18 14:15:21 -04:00
Simon Marchi
0c1bcd2327 gdb: convert obj_section macros to methods
Convert these three macros to methods of obj_section.  The problem fixed
by the following patch is caused by an out of bound access of the
objfile::section_offsets vector.  Since this is deep in macros, we don't
get a clear backtrace and it's difficult to debug.  Changing that to
methods means we can step in them and break on them.

Because their implementation requires knowing about struct objfile, move
struct obj_section below struct objfile in objfiles.h.

The obj_section_offset was used in one place as an lvalue to set
offsets, in machoread.c.  Replace that with a set_offset method.

Add the objfile::section_offset and objfile::set_section_offset methods
to improve encapsulation (reduce other objects poking into struct
objfile's internals).

gdb/ChangeLog:

	* objfiles.h (struct obj_section): Move down.
	<offset, set_offset, addr, endaddr>: New.
	(obj_section_offset, obj_section_addr, obj_section_endaddr),
	replace all users to use obj_section methods.
	(struct objfile) <section_offset, set_section_offset>: New.

Change-Id: I97e8fcae93ab2353fbdadcb4a5ec10d7949a7334
2021-06-28 15:28:26 -04:00
Simon Marchi
9161c89ad8 gdb: remove objfile parameter from get_objfile_bfd_data
I noticed it was unused.  I think that makes sense, as it shows that
objfile_per_bfd_storage is not specific to one objfile (it can be shared
by multiple objfiles that have the same bfd).

There is one thing I wonder though, maybe I'm missing something.  If
the BFD doesn't require relocation, get_objfile_bfd_data stores the
newly allocated object in objfiles_bfd_data, so we can assume that
objfiles_bfd_data is the owner of the object.  When the bfd's refcount
drops to 0, the corresponding objfile_per_bfd_storage object in
objfiles_bfd_data is deleted.

But if the BFD requires relocation, get_objfile_bfd_data returns a newly
allocated object that isn't kept anywhere else (and isn't shared).  So
the objfile becomes the owner of the objfile_per_bfd_storage object.  In
objfile::~objfile, we have this:

    if (obfd)
      gdb_bfd_unref (obfd);
    else
      delete per_bfd;

I'm thinking that obfd could be non-nullptr, and it could require
relocation.  In that case, it would never be freed.  Anyway, that's not
really connected to this patch.

gdb/ChangeLog:

	* objfiles.c (get_objfile_bfd_data): Remove objfile parameter,
	adjust callers.

Change-Id: Ifa3158074ea6b42686780ba09d0c964b0cf14cf1
2021-04-02 11:51:45 -04:00
Simon Marchi
0072c87379 gdb: pass objfile_per_bfd_storage instead of objfile to partial_symtab
Since partial_symtab is supposed to be objfile-independent (since series
[1]), I think it would make sense for partial_symtab to not take an
objfile as a parameter in its constructor.

This patch replaces that parameter with an objfile_per_bfd_storage
parameter.

The objfile is used for two things:

 - to get the objfile_name, for debug messages.  We can get that name
   from the bfd instead.
 - to intern the partial symtab filename.  Even though it goes through
   an objfile method, the request is actually forwarded to the
   underlying objfile_per_bfd_storage.  So we can ask the new
   objfile_per_bfd_storage instead.

In order to get a reference to the BFD from the objfile_per_bfd_storage,
the BFD is saved in the objfile_per_bfd_storage object.

[1] https://sourceware.org/pipermail/gdb-patches/2021-February/176625.html

gdb/ChangeLog:

	* psympriv.h (struct partial_symtab) <partial_symtab>: Change
	objfile parameter for objfile_per_bfd_storage, adjust callers.
	(struct standard_psymtab) <standard_psymtab>: Likewise.
	(struct legacy_psymtab) <legacy_psymtab>: Likewise.
	* psymtab.c (partial_symtab::partial_symtab): Likewise.
	* ctfread.c (struct ctf_psymtab): Likewise.
	* dwarf2/read.h (struct dwarf2_psymtab): Likewise.
	* dwarf2/read.c (struct dwarf2_include_psymtab): Likewise.
	(dwarf2_create_include_psymtab): Likewise.
	* objfiles.h (struct objfile_per_bfd_storage)
	<objfile_per_bfd_storage>: Add bfd parameter, adjust callers.
	<get_bfd>: New method.
	<m_bfd>: New field.
	* objfiles.c (get_objfile_bfd_data): Adjust.

Change-Id: I2ed3ab5d2e6f27d034bd4dc26ae2fae7b0b8a2b9
2021-04-02 11:45:37 -04:00
Tom Tromey
e11145903f Switch objfile to hold a list of psymbol readers
This changes objfile::qf to be a forward_list, and then updates all
the uses to iterate over the list.  Note that there is still only ever
a single element in the list; this is handled by clearing the list
whenever an object is added.

gdb/ChangeLog
2021-03-20  Tom Tromey  <tom@tromey.com>

	* dwarf2/read.c (dwarf2_build_psymtabs): Update.
	* symfile.c (syms_from_objfile_1, reread_symbols): Update.
	* symfile-debug.c (objfile::has_partial_symbols)
	(objfile::find_last_source_symtab)
	(objfile::forget_cached_source_info)
	(objfile::map_symtabs_matching_filename, objfile::lookup_symbol)
	(objfile::print_stats, objfile::dump)
	(objfile::expand_symtabs_for_function)
	(objfile::expand_all_symtabs)
	(objfile::expand_symtabs_with_fullname)
	(objfile::map_matching_symbols)
	(objfile::expand_symtabs_matching)
	(objfile::find_pc_sect_compunit_symtab)
	(objfile::map_symbol_filenames)
	(objfile::find_compunit_symtab_by_address)
	(objfile::lookup_global_symbol_language)
	(objfile::require_partial_symbols): Update.
	* psymtab.c (maintenance_print_psymbols)
	(maintenance_info_psymtabs, maintenance_check_psymtabs): Update.
	* objfiles.h (struct objfile) <qf>: Now a forward_list.
	* objfiles.c (objfile_relocate1): Update.
	* elfread.c (elf_symfile_read): Update.
2021-03-20 17:23:45 -06:00
Tom Tromey
b29b98cf84 Rearrange psymtab_storage construction
This changes objfile so that it doesn't construct a psymtab_storage
object until the psymtab functions are installed.  It also applies a
similar treatment to reread_symbols.

gdb/ChangeLog
2021-03-20  Tom Tromey  <tom@tromey.com>

	* symfile.c (syms_from_objfile_1): Call reset_psymtabs.
	(reread_symbols): Move reset_psymtabs call later.
	* objfiles.c (objfile::objfile): Don't initialize
	partial_symtabs.
2021-03-20 17:23:44 -06:00
Tom Tromey
75336a5a2a Move psymbol_map out of objfile
objfile::psymbol_map is used to implement a Rust feature.  It is
currently specific to partial symbols -- it isn't used by the DWARF
indices.

This patch moves it out of objfile and into psymbol_functions, adding
a new method to quick_symbol_functions to handle the clearing case.
This is needed because the map holds unrelocated addresses.

gdb/ChangeLog
2021-03-20  Tom Tromey  <tom@tromey.com>

	* quick-symbol.h (struct quick_symbol_functions)
	<relocated>: New method.
	* psymtab.h (struct psymbol_functions) <relocated>: New
	method.
	<fill_psymbol_map>: Declare method.
	<m_psymbol_map>: New member.
	* psymtab.c (psymbol_functions::fill_psymbol_map): Rename.
	(psymbol_functions::find_compunit_symtab_by_address): Update.
	* objfiles.h (reset_psymtabs): Don't clear psymbol_map.
	(struct objfile) <psymbol_map>: Remove.
	* objfiles.c (objfile_relocate1): Update.
2021-03-20 17:23:42 -06:00
Tom Tromey
4d080b4687 Introduce method wrappers for quick_symbol_functions
This introduces wrappers for each function in quick_symbol_functions.
The wrappers are methods on objfile, and are defined in
symfile-debug.c, so that they can use the symfile_debug variable.
Places that call the quick functions are all updated to call these new
wrapper methods.

gdb/ChangeLog
2021-03-20  Tom Tromey  <tom@tromey.com>

	* symtab.c (iterate_over_symtabs, expand_symtab_containing_pc)
	(lookup_symbol_via_quick_fns, find_quick_global_symbol_language)
	(basic_lookup_transparent_type_quick)
	(find_pc_sect_compunit_symtab, find_symbol_at_address)
	(find_line_symtab, global_symbol_searcher::expand_symtabs):
	Update.
	* symmisc.c (print_objfile_statistics, dump_objfile)
	(maintenance_expand_symtabs): Update.
	* symfile.c (symbol_file_add_with_addrs)
	(expand_symtabs_matching, map_symbol_filenames): Update.
	* symfile-debug.c (objfile::has_partial_symbols)
	(objfile::find_last_source_symtab)
	(objfile::forget_cached_source_info)
	(objfile::map_symtabs_matching_filename, objfile::lookup_symbol)
	(objfile::print_stats, objfile::dump)
	(objfile::expand_symtabs_for_function)
	(objfile::expand_all_symtabs)
	(objfile::expand_symtabs_with_fullname)
	(objfile::map_matching_symbols)
	(objfile::expand_symtabs_matching)
	(objfile::find_pc_sect_compunit_symtab)
	(objfile::map_symbol_filenames)
	(objfile::find_compunit_symtab_by_address)
	(objfile::lookup_global_symbol_language): New methods.
	(debug_sym_quick_functions): Remove.
	(debug_sym_fns, install_symfile_debug_logging): Update.
	* source.c (forget_cached_source_info_for_objfile)
	(select_source_symtab): Update.
	* objfiles.h (struct objfile): Add methods corresponding to
	quick_symbol_functions.
	* objfiles.c (objfile::has_partial_symbols): Move to
	symfile-debug.c.
	* linespec.c (iterate_over_all_matching_symtabs): Update.
	* cp-support.c (add_symbol_overload_list_qualified): Update.
	* ada-lang.c (add_nonlocal_symbols): Update.
2021-03-20 17:23:41 -06:00
Tom Tromey
fae2120ba0 Change objfile::has_partial_symbols to return bool
This changes objfile::has_partial_symbols and
quick_symbol_functions::has_symbols to return bool.

gdb/ChangeLog
2021-03-20  Tom Tromey  <tom@tromey.com>

	* objfiles.h (struct objfile) <has_partial_symbols>: Return bool.
	* symfile.h (struct quick_symbol_functions) <has_symbols>: Return
	bool.
	* symfile-debug.c (debug_qf_has_symbols): Return bool.
	* psymtab.c (psym_has_symbols): Return bool.
	* objfiles.c (objfile::has_partial_symbols): Return bool.
	* dwarf2/read.c (dw2_has_symbols): Return bool.
2021-03-20 17:23:41 -06:00
Tom Tromey
a8ad4f3c17 Change objfile_has_partial_symbols to a method
This changes objfile_has_partial_symbols to be a method on objfile.

There are some other functions that could benefit from this sort of
change, but this was the only one that was relevant to this series.

gdb/ChangeLog
2021-03-20  Tom Tromey  <tom@tromey.com>

	* symfile.c (read_symbols): Update.
	* objfiles.h (struct objfile) <has_partial_symbols>: New method.
	(objfile_has_partial_symbols): Don't declare.
	* objfiles.c (objfile::has_partial_symbols): Rename from
	objfile_has_partial_symbols.
	(objfile_has_symbols, have_partial_symbols): Update.
	* elfread.c (elf_symfile_read): Update.
	* dwarf2/read.c (dwarf2_has_info): Update.
	* coffread.c (coff_symfile_read): Update.
2021-03-20 17:23:41 -06:00
Andrew Burgess
a52d653e91 gdb: delete SYMBOL_SECTION and MSYMBOL_SECTION macros
Delete two more symbol/section related macros.  This time it's
SYMBOL_SECTION and MSYMBOL_SECTION.

As with general_symbol_info::m_name it is not currently possible to
make general_symbol_info::m_section private as general_symbol_info
must remain a POD type.

But other than failing to make the new m_section private, this change
does what you'd expect, adds a get and set member function and updates
all users to use the new functions instead of the previous wrapper
macros.

There should be no user visible change after this commit.

gdb/ChangeLog:

	* coff-pe-read.c (add_pe_forwarded_sym): Make use of section_index
	and set_section_index member functions where appropriate.
	* coffread.c (coff_symtab_read): Likewise.
	(process_coff_symbol): Likewise.
	* ctfread.c (set_symbol_address): Likewise.
	* dwarf2/read.c (add_partial_symbol): Likewise.
	(var_decode_location): Likewise.
	* language.c: Likewise.
	* minsyms.c (minimal_symbol_reader::record_full): Likewise.
	(compact_minimal_symbols): Likewise.
	(minimal_symbol_upper_bound): Likewise.
	* objfiles.c (relocate_one_symbol): Likewise.
	* psympriv.h (partial_symbol::obj_section): Likewise.
	(partial_symbol::address): Likewise.
	* psymtab.c (partial_symtab::add_psymbol): Likewise.
	* stabsread.c (scan_file_globals): Likewise.
	* symmisc.c (dump_msymbols): Likewise.
	* symtab.c (general_symbol_info::obj_section): Likewise.
	(fixup_section): Likewise.
	(get_msymbol_address): Likewise.
	* symtab.h (general_symbol_info::section): Rename to...
	(general_symbol_info::m_section): ...this.
	(general_symbol_info::set_section_index): New member function.
	(general_symbol_info::section_index): Likewise.
	(SYMBOL_SECTION): Delete.
	(MSYMBOL_VALUE_ADDRESS): Make use of section_index and
	set_section_index member functions where appropriate.
	(MSYMBOL_SECTION): Delete.
	(symbol::symbol): Update to initialize 'm_section'.
	* xcoffread.c (read_xcoff_symtab): Make use of set_section_index.
	(process_xcoff_symbol): Likewise.
2021-02-10 14:38:08 +00:00