From: Aditya Dutt <duttaditya18@gmail.com>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Aditya Dutt <duttaditya18@gmail.com>,
dwarves@vger.kernel.org, Alan Maguire <alan.maguire@oracle.com>
Subject: [PATCH dwarves v2 2/3] pahole: Don't match unions with --with_flexible_array
Date: Wed, 2 Sep 2026 17:05:57 +0000 [thread overview]
Message-ID: <a98ad2b33aecb5b2f4f85201b0ca9553e302dd26.1788368236.git.duttaditya18@gmail.com> (raw)
In-Reply-To: <cover.1788368236.git.duttaditya18@gmail.com>
C doesn't allow a flexible array member in a union, but
--with_flexible_array prints unions anyway.
$ cat flex.c
union wrap_u { int a; long b; };
union wrap_u u;
$ pahole --with_flexible_array flex.o
union wrap_u {
int a; /* 0 4 */
long int b; /* 0 8 */
};
--with_embedded_flexible_array doesn't have this problem because its
option handler also sets just_structs.
Add both to the list so neither relies on that side effect.
After:
$ pahole --with_flexible_array flex.o
$
Structs with a flexible array are unaffected:
$ cat has_flex.c
struct has_flex { int n; char data[]; };
struct has_flex *p;
$ pahole --with_flexible_array has_flex.o
struct has_flex {
int n; /* 0 4 */
char data[]; /* 4 0 */
/* size: 4, cachelines: 1, members: 2 */
/* last cacheline: 4 bytes */
};
Signed-off-by: Aditya Dutt <duttaditya18@gmail.com>
---
pahole.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/pahole.c b/pahole.c
index 7ec4a74..d2dcd90 100644
--- a/pahole.c
+++ b/pahole.c
@@ -734,7 +734,8 @@ static struct class *class__filter(struct class *class, struct cu *cu,
*/
if (!tag__is_struct(tag))
return (just_structs || show_packable || nr_holes || nr_bit_holes || hole_size_ge ||
- end_padding_ge || end_padding) ? NULL : class;
+ end_padding_ge || end_padding || show_with_flexible_array ||
+ show_with_embedded_flexible_array) ? NULL : class;
if (tag->top_level)
class__find_holes(class);
--
2.50.1
next prev parent reply other threads:[~2026-09-02 17:06 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-02 17:05 [PATCH dwarves v2 0/3] pahole: Fix --unions bypassing the struct-only options Aditya Dutt
2026-09-02 17:05 ` [PATCH dwarves v2 1/3] pahole: Fix --unions --packable segfault Aditya Dutt
2026-09-02 17:05 ` Aditya Dutt [this message]
2026-09-02 17:05 ` [PATCH dwarves v2 3/3] pahole: Apply the struct-only filters to unions Aditya Dutt
2026-09-03 13:37 ` [PATCH dwarves v2 0/3] pahole: Fix --unions bypassing the struct-only options Arnaldo Carvalho de Melo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a98ad2b33aecb5b2f4f85201b0ca9553e302dd26.1788368236.git.duttaditya18@gmail.com \
--to=duttaditya18@gmail.com \
--cc=acme@kernel.org \
--cc=alan.maguire@oracle.com \
--cc=dwarves@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.