diff options
author | Christina Schimpe <christina.schimpe@intel.com> | 2021-10-25 17:08:32 +0200 |
---|---|---|
committer | Christina Schimpe <christina.schimpe@intel.com> | 2022-03-04 16:42:30 +0100 |
commit | e8db803129822d3df8e773f28dd99105a84d881d (patch) | |
tree | a4ea0a41756612b8cb00142b92e306c44af2ded3 /gdb/typeprint.c | |
parent | 7919e5667cf6607a3d7e28b1fa7f15f3c49a4e55 (diff) | |
download | binutils-gdb-e8db803129822d3df8e773f28dd99105a84d881d.tar.gz |
gdb: Use a typedef's scoped type name to identify local typedefs
GDB prints the wrong type for typedefs in case there is another typedef
available for the same raw type (gdb/16040). The reason is that the
current hashmap based substitution mechanism always compares the target
type of a typedef and not its scoped name.
The original output of GDB for a program like
~~~~
namespace ns
{
typedef double scoped_double;
}
typedef double global_double;
class TypedefHolder
{
public:
double a;
ns::scoped_double b;
global_double c;
private:
typedef double class_double;
class_double d;
double method1(ns::scoped_double) { return 24.0; }
double method2(global_double) { return 24.0; }
};
int main()
{
TypedefHolder th;
return 0;
}
~~~~
is
~~~~
(gdb) b 27
Breakpoint 1 at 0x1131: file TypedefHolder.cc, line 27.
(gdb) r
Starting program: /tmp/typedefholder
Breakpoint 1, main () at TypedefHolder.cc:27
27 return 0;
(gdb) ptype th
type = class TypedefHolder {
public:
class_double a;
class_double b;
class_double c;
private:
class_double d;
class_double method1(class_double);
class_double method2(class_double);
typedef double class_double;
}
~~~~
Basically all attributes of a class which have the raw type "double" are
substituted by "class_double".
With the patch the output is the following
~~~~
type = class TypedefHolder {
public:
double a;
ns::scoped_double b;
global_double c;
private:
class_double d;
double method1(ns::scoped_double);
double method2(global_double);
typedef double class_double;
}
~~~~
Diffstat (limited to 'gdb/typeprint.c')
-rw-r--r-- | gdb/typeprint.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/gdb/typeprint.c b/gdb/typeprint.c index 8cb34ad1921..0282ff632f1 100644 --- a/gdb/typeprint.c +++ b/gdb/typeprint.c @@ -201,9 +201,8 @@ static hashval_t hash_typedef_field (const void *p) { const struct decl_field *tf = (const struct decl_field *) p; - struct type *t = check_typedef (tf->type); - return htab_hash_string (TYPE_SAFE_NAME (t)); + return htab_hash_string (TYPE_SAFE_NAME (tf->type)); } /* An equality function for a typedef field. */ |