diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2024-02-09 11:39:20 -0300 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2024-02-09 11:39:20 -0300 |
commit | bd8d0536b4352b5d72c5bc67637fd68238cf2cca (patch) | |
tree | b01df71e9f7eff21c561d4acadbf0d5ebc5083b1 | |
parent | fdd815151054d840fe3bdc54f7ca79ff89fd4980 (diff) | |
download | pahole-bd8d0536b4352b5d72c5bc67637fd68238cf2cca.tar.gz |
fprintf: Introduce struct to account holes in class member types
This will allow introducing a function to print info about holes in
member types, something that is only done today for the padding at the
end of such types.
This is how it is now:
$ pahole task_struct | grep "XXX last" -B2
struct sched_statistics stats __attribute__((__aligned__(64))); /* 768 256 */
/* XXX last struct has 24 bytes of padding */
--
struct prev_cputime prev_cputime; /* 2720 24 */
/* XXX last struct has 4 bytes of padding */
--
struct posix_cputimers_work posix_cputimers_work; /* 2928 56 */
/* XXX last struct has 4 bytes of padding */
--
struct syscall_user_dispatch syscall_dispatch; /* 3224 32 */
/* XXX last struct has 7 bytes of padding */
--
struct tlbflush_unmap_batch tlb_ubc; /* 3976 1032 */
/* XXX last struct has 6 bytes of padding */
--
struct timer_list oom_reaper_timer; /* 9056 40 */
/* XXX last struct has 4 bytes of padding */
$
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | dwarves_fprintf.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/dwarves_fprintf.c b/dwarves_fprintf.c index ef8b82bd..cfee786a 100644 --- a/dwarves_fprintf.c +++ b/dwarves_fprintf.c @@ -1462,19 +1462,23 @@ out: return printed; } +struct member_types_holes { + uint16_t nr_paddings; + uint32_t sum_paddings; +}; + static size_t __class__fprintf(struct class *class, const struct cu *cu, const struct conf_fprintf *conf, FILE *fp) { struct type *type = &class->type; size_t last_size = 0, size; uint8_t newline = 0; - uint16_t nr_paddings = 0; uint16_t nr_forced_alignments = 0, nr_forced_alignment_holes = 0; uint32_t sum_forced_alignment_holes = 0; uint32_t sum_bytes = 0, sum_bits = 0; uint32_t sum_holes = 0; - uint32_t sum_paddings = 0; uint32_t sum_bit_holes = 0; + struct member_types_holes member_types_holes = { 0, }; uint32_t cacheline = 0; int size_diff = 0; int first = 1; @@ -1693,8 +1697,8 @@ static size_t __class__fprintf(struct class *class, const struct cu *cu, padding = tclass->padding; if (padding > 0) { - ++nr_paddings; - sum_paddings += padding; + ++member_types_holes.nr_paddings; + member_types_holes.sum_paddings += padding; if (!newline++) { fputc('\n', fp); ++printed; @@ -1841,11 +1845,11 @@ static size_t __class__fprintf(struct class *class, const struct cu *cu, printed += fprintf(fp, "%.*s/* padding: %u */\n", cconf.indent, tabs, class->padding); - if (nr_paddings > 0) + if (member_types_holes.nr_paddings > 0) printed += fprintf(fp, "%.*s/* paddings: %u, sum paddings: " "%u */\n", cconf.indent, tabs, - nr_paddings, sum_paddings); + member_types_holes.nr_paddings, member_types_holes.sum_paddings); if (class->bit_padding > 0) printed += fprintf(fp, "%.*s/* bit_padding: %u bits */\n", cconf.indent, tabs, |