]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
Don't trust templates from DW_AT_name users/simark/template-suffix
authorSimon Marchi <simon.marchi@polymtl.ca>
Sun, 4 Feb 2018 18:10:28 +0000 (13:10 -0500)
committerSimon Marchi <simon.marchi@polymtl.ca>
Mon, 5 Feb 2018 03:21:08 +0000 (22:21 -0500)
commite61b4af73de761ca2b877b09c1ad710f44ba0f54
treeb82ac5f4a15dca00cd1231e162d73176af548b8a
parent9f7393d8fc8b79a92b027cd8ac6fda9441d3fff9
Don't trust templates from DW_AT_name

With gcc 8 (and clang?) the non-type template arguments (constants)
don't include the integer suffixes anymore.  For example, with

  template <unsigned int X>
  class foo
  {
    ...
  };

  foo<10u>

used to generate foo<10u> as the DW_AT_name, now it generates foo<10>.
This is a problem when things look up "foo<10u>" and don't find it.  For
example, when trying to print an instance of that class through a base
class pointer, GDB would first demangle the symbol for that class'
vtable, which would give "vtable for foo<10u>".  GDB would then take the
"foo<10u>" from that string and try to look up the type.  With the new
DW_AT_name, it would fail to look it up, and fail to print the value.

This patch makes it so GDB doesn't trust the templates contained in
DW_AT_name.  Instead, it re-builds the name from the DW_AT_template_*
DIES in the format that it expects (with the integer suffixes).
gdb/c-valprint.c
gdb/dwarf2read.c
gdb/valprint.c
gdb/valprint.h