diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2025-04-24 11:13:37 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2025-04-24 12:50:20 -0400 |
commit | a163e2015a4e2f9b6701832d3c40f848524e4793 (patch) | |
tree | 34048802165176437c80e34939afbfb9f1380f9c | |
parent | 93e6a942e9707e0f229d61772651ae6cf38200c5 (diff) | |
download | binutils-a163e2015a4e2f9b6701832d3c40f848524e4793.zip binutils-a163e2015a4e2f9b6701832d3c40f848524e4793.tar.gz binutils-a163e2015a4e2f9b6701832d3c40f848524e4793.tar.bz2 |
gdb: fix completion of anonymous struct members
Completing fields inside an anonymous struct does not work. With:
struct commit_counters_hot {
union {
struct {
long owner;
};
char padding[16];
};
};
I get:
(gdb) complete print cc_hot.
print cc_hot.padding
After this patch, I get:
(gdb) complete print cc_hot.
print cc_hot.owner
print cc_hot.padding
Update break1.c to include an anonymous struct. The tests that complete
"z_field" inside gdb.base/completion.exp would start to fail without the
fix.
Change-Id: I46b65a95ad16b0825de58dfa241777fe57acc361
Reviewed-By: Keith Seitz <keiths@redhat.com>
-rw-r--r-- | gdb/eval.c | 5 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/break1.c | 8 |
2 files changed, 10 insertions, 3 deletions
@@ -994,9 +994,10 @@ add_struct_fields (struct type *type, completion_list &output, output.emplace_back (concat (prefix, type->field (i).name (), nullptr)); } - else if (type->field (i).type ()->code () == TYPE_CODE_UNION) + else if (type->field (i).type ()->code () == TYPE_CODE_UNION + || type->field (i).type ()->code () == TYPE_CODE_STRUCT) { - /* Recurse into anonymous unions. */ + /* Recurse into anonymous unions and structures. */ add_struct_fields (type->field (i).type (), output, fieldname, namelen, prefix); } diff --git a/gdb/testsuite/gdb.base/break1.c b/gdb/testsuite/gdb.base/break1.c index 110341c..26c4663 100644 --- a/gdb/testsuite/gdb.base/break1.c +++ b/gdb/testsuite/gdb.base/break1.c @@ -23,7 +23,13 @@ struct some_struct { int a_field; int b_field; - union { int z_field; }; + union + { + struct + { + int z_field; + }; + }; }; struct some_struct values[50]; |