dwarves_fprintf: Find holes when expanding types

When --expand_types/-E is used we go on expanding internal types, and
when doing that for structs we were not looking for holes in them, only
on the main struct, fix it.

With that we can see these extra holes in a expanded Linux kernel's
'struct task_struct':

@@ -46,6 +46,9 @@
 			struct list_head * prev;                                         /*   176     8 */
 		} group_node; /*   168    16 */
 		unsigned int       on_rq;                                                /*   184     4 */
+
+		/* XXX 4 bytes hole, try to pack */
+
 		/* --- cacheline 3 boundary (192 bytes) --- */
 		/* typedef u64 */ long long unsigned int exec_start;                     /*   192     8 */
 		/* typedef u64 */ long long unsigned int sum_exec_runtime;               /*   200     8 */
@@ -86,9 +89,15 @@
 		} statistics; /*   232   216 */
 		/* --- cacheline 7 boundary (448 bytes) --- */
 		int                depth;                                                /*   448     4 */
+
+		/* XXX 4 bytes hole, try to pack */
+
 		struct sched_entity * parent;                                            /*   456     8 */
 		struct cfs_rq *    cfs_rq;                                               /*   464     8 */
 		struct cfs_rq *    my_q;                                                 /*   472     8 */
+
+		/* XXX 32 bytes hole, try to pack */
+
 		/* --- cacheline 8 boundary (512 bytes) --- */
 		struct sched_avg {
 			/* typedef u64 */ long long unsigned int last_update_time;       /*   512     8 */
@@ -153,6 +162,9 @@
 			struct hrtimer_clock_base * base;                                /*   768     8 */
 			/* typedef u8 */ unsigned char state;                            /*   776     1 */
 			/* typedef u8 */ unsigned char is_rel;                           /*   777     1 */
+
+			/* XXX 2 bytes hole, try to pack */
+
 			int        start_pid;                                            /*   780     4 */
 			void *     start_site;                                           /*   784     8 */
 			char       start_comm[16];                                       /*   792    16 */
@@ -197,6 +209,9 @@
 	} tasks; /*   912    16 */
 	struct plist_node {
 		int                prio;                                                 /*   928     4 */
+
+		/* XXX 4 bytes hole, try to pack */
+
 		struct list_head {
 			struct list_head * next;                                         /*   936     8 */
 			struct list_head * prev;                                         /*   944     8 */
@@ -258,12 +273,18 @@
 				/* typedef u32 */ unsigned int val;                      /*  1136     4 */
 				/* typedef u32 */ unsigned int flags;                    /*  1140     4 */
 				/* typedef u32 */ unsigned int bitset;                   /*  1144     4 */
+
+				/* XXX 4 bytes hole, try to pack */
+
 				/* --- cacheline 18 boundary (1152 bytes) --- */
 				/* typedef u64 */ long long unsigned int time;           /*  1152     8 */
 				u32 * uaddr2;                                            /*  1160     8 */
 			} futex;                                                         /*          40 */
 			struct {
 				/* typedef clockid_t -> __kernel_clockid_t */ int clockid; /*  1128     4 */
+
+				/* XXX 4 bytes hole, try to pack */
+
 				struct timespec * rmtp;                                  /*  1136     8 */
 				struct compat_timespec * compat_rmtp;                    /*  1144     8 */
 				/* typedef u64 */ long long unsigned int expires;        /*  1152     8 */
@@ -426,6 +447,9 @@
 	unsigned int               sessionid;                                            /*  1804     4 */
 	struct seccomp {
 		int                mode;                                                 /*  1808     4 */
+
+		/* XXX 4 bytes hole, try to pack */
+
 		struct seccomp_filter * filter;                                          /*  1816     8 */
 	} seccomp; /*  1808    16 */
 	/* typedef u32 */ unsigned int               parent_exec_id;                     /*  1824     4 */
@@ -602,6 +626,9 @@
 		long unsigned int  backtrace[12];                                        /*  2472    96 */
 		/* --- cacheline 40 boundary (2560 bytes) was 8 bytes ago --- */
 		unsigned int       count;                                                /*  2568     4 */
+
+		/* XXX 4 bytes hole, try to pack */
+
 		long unsigned int  time;                                                 /*  2576     8 */
 		long unsigned int  max;                                                  /*  2584     8 */
 	} latency_record[32]; /*  2472  3840 */
@@ -686,12 +713,18 @@
 		long unsigned int * io_bitmap_ptr;                                       /*  6600     8 */
 		long unsigned int  iopl;                                                 /*  6608     8 */
 		unsigned int       io_bitmap_max;                                        /*  6616     4 */
+
+		/* XXX 36 bytes hole, try to pack */
+
 		/* --- cacheline 104 boundary (6656 bytes) --- */
 		struct fpu {
 			unsigned int last_cpu;                                           /*  6656     4 */
 			unsigned char fpstate_active;                                    /*  6660     1 */
 			unsigned char fpregs_active;                                     /*  6661     1 */
 			unsigned char counter;                                           /*  6662     1 */
+
+			/* XXX 57 bytes hole, try to pack */
+
 			/* --- cacheline 105 boundary (6720 bytes) --- */
 			union fpregs_state {
 				struct fregs_state {
@@ -751,6 +784,9 @@
 					/* typedef u8 */ unsigned char no_update;        /*  6831     1 */
 					/* typedef u8 */ unsigned char rm;               /*  6832     1 */
 					/* typedef u8 */ unsigned char alimit;           /*  6833     1 */
+
+					/* XXX 6 bytes hole, try to pack */
+
 					struct math_emu_info * info;                     /*  6840     8 */
 					/* typedef u32 */ unsigned int entry_eip;        /*  6848     4 */
 				} soft; /*         136 */

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Arnaldo Carvalho de Melo 2016-06-30 16:30:28 -03:00
parent 103e89bb25
commit b52386d041
1 changed files with 9 additions and 4 deletions

View File

@ -671,15 +671,20 @@ static size_t type__fprintf(struct tag *type, const struct cu *cu,
case DW_TAG_structure_type:
ctype = tag__type(type);
if (type__name(ctype, cu) != NULL && !expand_types)
if (type__name(ctype, cu) != NULL && !expand_types) {
printed += fprintf(fp, "%s %-*s %s",
(type->tag == DW_TAG_class_type &&
!conf->classes_as_structs) ? "class" : "struct",
conf->type_spacing - 7,
type__name(ctype, cu), name);
else
printed += __class__fprintf(tag__class(type),
cu, &tconf, fp);
} else {
struct class *cclass = tag__class(type);
if (!conf->suppress_comments)
class__find_holes(cclass);
printed += __class__fprintf(cclass, cu, &tconf, fp);
}
break;
case DW_TAG_union_type:
ctype = tag__type(type);