Currently gdb's "ptype" command does not print the details of unnamed
structure and union deeper than second level in a structure, it prints
only "{...}" instead. And crash's "struct" and similar commands
also
inherit this behavior, so we cannot get the full information of them.
To print the details of them, change the show variable when it is an
unnamed one like crash-7.x.
Without the patch:
crash> struct -o page
struct page {
[0] unsigned long flags;
union {
struct {...};
struct {...};
...
With the patch:
crash> struct -o page
struct page {
[0] unsigned long flags;
union {
struct {
[8] struct list_head lru;
[24] struct address_space *mapping;
[32] unsigned long index;
[40] unsigned long private;
};
struct {
[8] dma_addr_t dma_addr;
};
...
Signed-off-by: Kazuhito Hagio <k-hagio-ab(a)nec.com>
---
gdb-10.2.patch | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/gdb-10.2.patch b/gdb-10.2.patch
index b67db4e1ded9..603679657eee 100644
--- a/gdb-10.2.patch
+++ b/gdb-10.2.patch
@@ -1638,3 +1638,15 @@ exit 0
$(ECHO_CXXLD) $(CC_LD) $(INTERNAL_LDFLAGS) $(WIN32LDAPP) \
-o $(shell /bin/cat mergeobj) $(LIBGDB_OBS) \
$(TDEPLIBS) $(TUI_LIBRARY) $(CLIBS) $(LOADLIBES) $(shell /bin/cat
mergelibs)
+--- gdb-10.2/gdb/c-typeprint.c.orig
++++ gdb-10.2/gdb/c-typeprint.c
+@@ -1202,6 +1202,9 @@ c_type_print_base_struct_union (struct t
+ = podata->end_bitpos
+ - TYPE_LENGTH (type->field (i).type ()) * TARGET_CHAR_BIT;
+ }
++ else if (strlen(TYPE_FIELD_NAME (type, i)) == 0)
++ /* crash: Print details for unnamed struct and union. */
++ newshow = show;
+
+ c_print_type_1 (type->field (i).type (),
+ TYPE_FIELD_NAME (type, i),
--
2.27.0