Blame SOURCES/0008-gdb-print-details-of-unnamed-struct-and-union.patch

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