From 56547f133a5b4e8db27c1a6b8e1ba0c0738f0b70 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Tue, 19 Nov 2019 11:48:36 -0300 Subject: [PATCH] fprintf: Fix alignment of class members that are structs/enums/unions E.g. look at that 'completion' member in this struct: struct cpu_stop_done { atomic_t nr_todo; /* 0 4 */ int ret; /* 4 4 */ - struct completion completion; /* 8 32 */ + struct completion completion; /* 8 32 */ /* size: 40, cachelines: 1, members: 3 */ /* last cacheline: 40 bytes */ Signed-off-by: Arnaldo Carvalho de Melo --- dwarves_fprintf.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/dwarves_fprintf.c b/dwarves_fprintf.c index 62ac292..d4ad79e 100644 --- a/dwarves_fprintf.c +++ b/dwarves_fprintf.c @@ -678,7 +678,6 @@ static size_t type__fprintf(struct tag *type, const struct cu *cu, if (tag__is_struct(type) || tag__is_union(type) || tag__is_enumeration(type)) { inner_struct: - tconf.type_spacing -= 8; tconf.prefix = NULL; tconf.suffix = name; tconf.emit_stats = 0; @@ -711,6 +710,7 @@ next_type: tconf.rel_offset = 1; name = namebfptr; type = ptype; + tconf.type_spacing -= 8; goto inner_struct; } } @@ -757,18 +757,21 @@ print_default: if (!tconf.suppress_comments) class__find_holes(cclass); + tconf.type_spacing -= 8; printed += __class__fprintf(cclass, cu, &tconf, fp); } break; case DW_TAG_union_type: ctype = tag__type(type); - if (type__name(ctype, cu) != NULL && !expand_types) + if (type__name(ctype, cu) != NULL && !expand_types) { printed += fprintf(fp, "union %-*s %s", tconf.type_spacing - 6, type__name(ctype, cu), name); - else + } else { + tconf.type_spacing -= 8; printed += union__fprintf(ctype, cu, &tconf, fp); + } break; case DW_TAG_enumeration_type: ctype = tag__type(type);