aboutsummaryrefslogtreecommitdiff
path: root/gdb/c-valprint.c
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2018-02-04 13:10:28 -0500
committerSimon Marchi <simon.marchi@polymtl.ca>2018-02-04 22:21:08 -0500
commite61b4af73de761ca2b877b09c1ad710f44ba0f54 (patch)
treeb82ac5f4a15dca00cd1231e162d73176af548b8a /gdb/c-valprint.c
parent9f7393d8fc8b79a92b027cd8ac6fda9441d3fff9 (diff)
downloadbinutils-users/simark/template-suffix.zip
binutils-users/simark/template-suffix.tar.gz
binutils-users/simark/template-suffix.tar.bz2
Don't trust templates from DW_AT_nameusers/simark/template-suffix
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).
Diffstat (limited to 'gdb/c-valprint.c')
-rw-r--r--gdb/c-valprint.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c
index c4c0918..12b9086 100644
--- a/gdb/c-valprint.c
+++ b/gdb/c-valprint.c
@@ -454,6 +454,21 @@ c_val_print_int (struct type *type, struct type *unresolved_type,
: options->output_format);
val_print_scalar_formatted (type, embedded_offset,
original_value, &opts, 0, stream);
+
+ if (opts.print_suffix)
+ {
+ struct type *t = check_typedef (type);
+
+ if (TYPE_UNSIGNED (t))
+ fputc_filtered ('u', stream);
+
+ /* Is there a better way to do this? Just looking at the size doesn't
+ work. */
+ if (strstr (TYPE_NAME (t), "long long") != NULL)
+ fputs_filtered ("ll", stream);
+ else if (strstr (TYPE_NAME (t), "long") != NULL)
+ fputc_filtered ('l', stream);
+ }
}
else
{