]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
libctf: dump: dump struct-based bitfields
authorNick Alcock <nick.alcock@oracle.com>
Fri, 25 Apr 2025 20:22:20 +0000 (21:22 +0100)
committerNick Alcock <nick.alcock@oracle.com>
Fri, 25 Apr 2025 20:23:08 +0000 (21:23 +0100)
libctf/ctf-dump.c

index d318b576a3de1a3b83f2cd3072431a419d004d7d..f76dec97fb673694ac7a3f4b6e0046b29f0ba77f 100644 (file)
@@ -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;