From 8586d4d1fd6b405831bc4b95c658f596a17b00cf Mon Sep 17 00:00:00 2001 From: Nick Alcock Date: Fri, 25 Apr 2025 21:22:20 +0100 Subject: libctf: dump: dump struct-based bitfields --- libctf/ctf-dump.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'libctf') diff --git a/libctf/ctf-dump.c b/libctf/ctf-dump.c index d318b57..f76dec9 100644 --- a/libctf/ctf-dump.c +++ b/libctf/ctf-dump.c @@ -723,12 +723,26 @@ ctf_dump_member (ctf_dict_t *fp, const char *name, ctf_id_t id, | CTF_FT_ID)) == NULL) return -1; /* errno is set for us. */ - if (asprintf (&bit, "[0x%lx] %s: %s\n", offset, name, typestr) < 0) + if (asprintf (&bit, "[0x%lx] %s:", offset, name) < 0) goto oom; + *state->cdm_str = str_append (*state->cdm_str, bit); + free (bit); + + if (bit_width > 0) + { + if (asprintf (&bit, "%i:", bit_width) < 0) + goto oom; + *state->cdm_str = str_append (*state->cdm_str, bit); + free (bit); + } + if (asprintf (&bit, " %s\n", typestr) < 0) + goto oom; *state->cdm_str = str_append (*state->cdm_str, bit); + free (typestr); free (bit); + typestr = NULL; bit = NULL; -- cgit v1.1