diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2024-02-17 11:42:06 -0300 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2024-02-17 12:00:02 -0300 |
commit | e52cf114039af8f3df25a707235d382c96847104 (patch) | |
tree | e52f50b06d8672b59331713aa224c9d70c48f7d7 | |
parent | d05d4f528d08da064ede7ba3fa19276efe1adcf7 (diff) | |
download | pahole-e52cf114039af8f3df25a707235d382c96847104.tar.gz |
fprintf: When expanding types do it for union typedefs as well
For instance:
$ pahole xfrm_address_t
typedef union xfrm_address_t;
$
Is completely broken, xfrm_address_t is an "inline" union, this patch
fixes it:
$ pahole xfrm_address_t
typedef union {
__be32 a4; /* 0 4 */
__be32 a6[4]; /* 0 16 */
struct in6_addr in6; /* 0 16 */
} xfrm_address_t;
$
Expansion also now works:
$ pahole -E xfrm_address_t
typedef union {
/* typedef __be32 -> __u32 */ unsigned int a4; /* 0 4 */
/* typedef __be32 -> __u32 */ unsigned int a6[4]; /* 0 16 */
struct in6_addr {
union {
/* typedef __u8 */ unsigned char u6_addr8[16]; /* 0 16 */
/* typedef __be16 -> __u16 */ short unsigned int u6_addr16[8]; /* 0 16 */
/* typedef __be32 -> __u32 */ unsigned int u6_addr32[4]; /* 0 16 */
} in6_u; /* 0 16 */
} in6; /* 0 16 */
} xfrm_address_t;
$
And with a named union typedef:
$ pahole sigval_t
typedef union sigval sigval_t;
$ pahole -E sigval_t
typedef union sigval {
int sival_int; /* 0 4 */
void * sival_ptr; /* 0 8 */
} sigval_t;
$
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | dwarves_fprintf.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/dwarves_fprintf.c b/dwarves_fprintf.c index a2471fa3..80d8a73a 100644 --- a/dwarves_fprintf.c +++ b/dwarves_fprintf.c @@ -393,6 +393,8 @@ next_type: tconf.suffix = type__name(type); return printed + __class__fprintf(cclass, cu, &tconf, fp); } + case DW_TAG_union_type: + return printed + union_decl__fprintf(tag_type, cu, type__name(type), pconf, fp); case DW_TAG_enumeration_type: { struct type *ctype = tag__type(tag_type); |