diff options
author | Tom Tromey <tom@tromey.com> | 2023-03-02 07:44:11 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2024-01-28 10:58:16 -0700 |
commit | 974b36c2ae2b351d022cc62579656f722da6e17a (patch) | |
tree | 1d7d813ffba23ac283f502e655460d52156a7d18 /gdb/xcoffread.c | |
parent | 10d6e9413e7ab9b30fbdb69e03262dc327831f84 (diff) | |
download | gdb-974b36c2ae2b351d022cc62579656f722da6e17a.zip gdb-974b36c2ae2b351d022cc62579656f722da6e17a.tar.gz gdb-974b36c2ae2b351d022cc62579656f722da6e17a.tar.bz2 |
Use the new symbol domains
This patch changes the DWARF reader to use the new symbol domains. It
also adjusts many bits of associated code to adapt to this change.
The non-DWARF readers are updated on a best-effort basis. This is
somewhat simpler since most of them only support C and C++. I have no
way to test a few of these.
I went back and forth a few times on how to handle the "tag"
situation. The basic problem is that C has a special namespace for
tags, which is separate from the type namespace. Other languages
don't do this. So, the question is, should a DW_TAG_structure_type
end up in the tag domain, or the type domain, or should it be
language-dependent?
I settled on making it language-dependent using a thought experiment.
Suppose there was a Rust compiler that only emitted nameless
DW_TAG_structure_type objects, and specified all structure type names
using DW_TAG_typedef. This DWARF would be correct, in that it
faithfully represents the source language -- but would not work with a
purely struct-domain implementation in gdb. Therefore gdb would be
wrong.
Now, this approach is a little tricky for C++, which uses tags but
also enters a typedef for them. I notice that some other readers --
like stabsread -- actually emit a typedef symbol as well. And, I
think this is a reasonable approach. It uses more memory, but it
makes the internals simpler. However, DWARF never did this for
whatever reason, and so in the interest of keeping the series slightly
shorter, I've left some C++-specific hacks in place here.
Note that this patch includes language_minimal as a language that uses
tags. I did this to avoid regressing gdb.dwarf2/debug-names-tu.exp,
which doesn't specify the language for a type unit. Arguably this
test case is wrong.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30164
Diffstat (limited to 'gdb/xcoffread.c')
-rw-r--r-- | gdb/xcoffread.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c index d161ad3..589208c 100644 --- a/gdb/xcoffread.c +++ b/gdb/xcoffread.c @@ -1491,6 +1491,7 @@ process_xcoff_symbol (struct xcoff_symbol *cs, struct objfile *objfile) sym->set_linkage_name (SYMNAME_ALLOC (name, symname_alloced)); sym->set_type (builtin_type (objfile)->nodebug_text_symbol); + sym->set_domain (FUNCTION_DOMAIN); sym->set_aclass_index (LOC_BLOCK); sym2 = new (&objfile->objfile_obstack) symbol (*sym); @@ -2546,7 +2547,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader, /* Also a typedef with the same name. */ pst->add_psymbol (std::string_view (namestring, p - namestring), - true, VAR_DOMAIN, LOC_TYPEDEF, -1, + true, TYPE_DOMAIN, LOC_TYPEDEF, -1, psymbol_placement::STATIC, unrelocated_addr (0), psymtab_language, @@ -2561,7 +2562,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader, { pst->add_psymbol (std::string_view (namestring, p - namestring), - true, VAR_DOMAIN, LOC_TYPEDEF, -1, + true, TYPE_DOMAIN, LOC_TYPEDEF, -1, psymbol_placement::STATIC, unrelocated_addr (0), psymtab_language, @@ -2661,7 +2662,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader, } pst->add_psymbol (std::string_view (namestring, p - namestring), - true, VAR_DOMAIN, LOC_BLOCK, + true, FUNCTION_DOMAIN, LOC_BLOCK, SECT_OFF_TEXT (objfile), psymbol_placement::STATIC, unrelocated_addr (symbol.n_value), @@ -2688,7 +2689,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader, pst->add_psymbol (std::string_view (namestring, p - namestring), - true, VAR_DOMAIN, LOC_BLOCK, + true, FUNCTION_DOMAIN, LOC_BLOCK, SECT_OFF_TEXT (objfile), psymbol_placement::GLOBAL, unrelocated_addr (symbol.n_value), |