binutils-gdb/gdb/compile
Tom Tromey bcfe6157ca Use the linkage name if it exists
The DWARF reader has had some odd code since the "physname" patches landed.

In particular, these patches caused PR symtab/12707; namely, they made
it so "set print demangle off" no longer works.

This patch attempts to fix the problem.  It arranges to store the
linkage name on the symbol if it exists, and it changes the DWARF
reader so that the demangled name is no longer (usually) stored in the
symbol's "linkage name" field.

c-linkage-name.exp needed a tweak, because it started working
correctly.  This conforms to what I think ought to happen, so this
seems like an improvement here.

compile-object-load.c needed a small change to use
symbol_matches_search_name rather than directly examining the linkage
name.  Looking directly at the name does the wrong thing for C++.

There is still some name-related confusion in the DWARF reader:

* "physname" often refers to the logical name and not what I would
  consider to be the "physical" name;

* dwarf2_full_name, dwarf2_name, and dwarf2_physname all exist and
  return different strings -- but this seems like at least one name
  too many.  For example, Fortran requires dwarf2_full_name, but other
  languages do not.

* To my surprise, dwarf2_physname prefers the form emitted by the
  demangler over the one that it computes.  This seems backward to me,
  given that the partial symbol reader prefers the opposite, and it
  seems to me that this choice may perform better as well.

I didn't attempt to clean up these things.  It would be good to do,
but whenever I contemplate it I get caught up in dreams of truly
rewriting the DWARF reader instead.

gdb/ChangeLog
2020-04-24  Tom Tromey  <tom@tromey.com>

	PR symtab/12707:
	* dwarf2/read.c (add_partial_symbol): Use the linkage name if it
	exists.
	(new_symbol): Likewise.
	* compile/compile-object-load.c (get_out_value_type): Use
	symbol_matches_search_name.

gdb/testsuite/ChangeLog
2020-04-24  Tom Tromey  <tom@tromey.com>

	PR symtab/12707:
	* gdb.python/py-symbol.exp: Update expected results for
	linkage_name test.
	* gdb.cp/print-demangle.exp: New file.
	* gdb.base/c-linkage-name.exp: Fix test.
	* gdb.guile/scm-symbol.exp: Update expected results for
	linkage_name test.
2020-04-24 15:35:03 -06:00
..
compile-c-support.c Update copyright year range in all GDB files. 2020-01-01 10:20:53 +04:00
compile-c-symbols.c Move DWARF code to dwarf2/ subdirectory 2020-02-08 13:40:59 -07:00
compile-c-types.c Update copyright year range in all GDB files. 2020-01-01 10:20:53 +04:00
compile-c.h Update copyright year range in all GDB files. 2020-01-01 10:20:53 +04:00
compile-cplus-symbols.c Move DWARF code to dwarf2/ subdirectory 2020-02-08 13:40:59 -07:00
compile-cplus-types.c gdb: add back declarations for _initialize functions 2020-01-13 14:01:38 -05:00
compile-cplus.h Update copyright year range in all GDB files. 2020-01-01 10:20:53 +04:00
compile-internal.h Update copyright year range in all GDB files. 2020-01-01 10:20:53 +04:00
compile-loc2c.c Add some methods to dwarf2_per_cu_data 2020-02-08 13:43:24 -07:00
compile-object-load.c Use the linkage name if it exists 2020-04-24 15:35:03 -06:00
compile-object-load.h Update copyright year range in all GDB files. 2020-01-01 10:20:53 +04:00
compile-object-run.c Update copyright year range in all GDB files. 2020-01-01 10:20:53 +04:00
compile-object-run.h Update copyright year range in all GDB files. 2020-01-01 10:20:53 +04:00
compile.c gdb: add back declarations for _initialize functions 2020-01-13 14:01:38 -05:00
compile.h Update copyright year range in all GDB files. 2020-01-01 10:20:53 +04:00
gcc-c-plugin.h Update copyright year range in all GDB files. 2020-01-01 10:20:53 +04:00
gcc-cp-plugin.h Update copyright year range in all GDB files. 2020-01-01 10:20:53 +04:00