diff options
author | Joel Brobecker <brobecker@adacore.com> | 2018-03-27 08:57:16 -0500 |
---|---|---|
committer | Joel Brobecker <brobecker@adacore.com> | 2018-03-27 09:57:16 -0400 |
commit | 59cc4834e53565da1de4a7b615ed8890ed55c7da (patch) | |
tree | 8a530a567d3dc3f55a723e427f77c42eff56944d /gdb/language.h | |
parent | 675015399bf80896706865e3d77d3af7fc925932 (diff) | |
download | gdb-59cc4834e53565da1de4a7b615ed8890ed55c7da.zip gdb-59cc4834e53565da1de4a7b615ed8890ed55c7da.tar.gz gdb-59cc4834e53565da1de4a7b615ed8890ed55c7da.tar.bz2 |
problem looking up some symbols when they have a linkage name
This patch fixes a known failure in gdb.ada/maint_with_ada.exp
(maintenance check-psymtabs). Another way to witness the same
issue is by considering the following Ada declarations...
type Wrapper is record
A : Integer;
end record;
u00045 : constant Wrapper := (A => 16#060287af#);
pragma Export (C, u00045, "symada__cS");
... which declares a variable name "u00045" but with a linkage
name which is "symada__cS". This variable is a record with one
component, the Ada equivalent of a struct with one field in C.
Trying to print that variable's value currently yields:
(gdb) p /x <symada__cS>
'symada(char, signed)' has unknown type; cast it to its declared type
This indicates that GDB was only able to find the minimal symbol,
but not the full symbol. The expected output is:
(gdb) print /x <symada__cS>
$1 = (a => 0x60287af)
The error message gives a hint about what's happening: We processed
the symbol through gdb_demangle, which in the case of this particular
symbol name, ends up matching the C++ naming scheme. As a result,
the demangler transforms our symbol name into 'symada(char, signed)',
thus breaking Ada lookups.
This patch fixes the issue by first introducing a new language_defn
attribute called la_store_sym_names_in_linkage_form_p, which is a boolean
to be set to true for the few languages that do not want their symbols
to have their names stored in demangled form, and false otherwise.
We then use this language attribute to skip the call to gdb_demangle
for all languages whose la_store_sym_names_in_linkage_form_p is true.
In terms of the selection of languages for which the new attribute
is set to true, the selection errs on the side of preserving the
existing behavior, and only changes the behavior for the languages
where we are certain storing symbol names in demangling form is not
needed. It is conceivable that other languages might be in the same
situation, but I not knowing in detail the symbol name enconding
strategy, I decided to play it safe and let other language maintainers
potentially adjust their language if it makes sense to do so.
gdb/ChangeLog:
PR gdb/22670
* dwarf2read.c (dwarf2_physname): Do not return the demangled
symbol name if the CU's language stores symbol names in linkage
format.
* language.h (struct language_defn)
<la_store_sym_names_in_linkage_form_p>: New field. Adjust
all instances of this struct.
gdb/testsuite/ChangeLog:
* gdb.ada/maint_with_ada.exp: Remove PR gdb/22670 setup_kfail.
* gdb.ada/notcplusplus: New testcase.
* gdb.base/c-linkage-name.c: New file.
* gdb.base/c-linkage-name.exp: New testcase.
Tested on x86_64-linux.
This also passes AdaCore's internal GDB testsuite.
Diffstat (limited to 'gdb/language.h')
-rw-r--r-- | gdb/language.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/gdb/language.h b/gdb/language.h index 06b42ae..029de4a 100644 --- a/gdb/language.h +++ b/gdb/language.h @@ -264,6 +264,26 @@ struct language_defn const char *la_name_of_this; + /* True if the symbols names should be stored in GDB's data structures + for minimal/partial/full symbols using their linkage (aka mangled) + form; false if the symbol names should be demangled first. + + Most languages implement symbol lookup by comparing the demangled + names, in which case it is advantageous to store that information + already demangled, and so would set this field to false. + + On the other hand, some languages have opted for doing symbol + lookups by comparing mangled names instead, for reasons usually + specific to the language. Those languages should set this field + to true. + + And finally, other languages such as C or Asm do not have + the concept of mangled vs demangled name, so those languages + should set this field to true as well, to prevent any accidental + demangling through an unrelated language's demangler. */ + + const bool la_store_sym_names_in_linkage_form_p; + /* This is a function that lookup_symbol will call when it gets to the part of symbol lookup where C looks up static and global variables. */ |