Index | Thread | Search

From:
Claudio Jeker <claudio@openbsd.org>
Subject:
ctfdump, show size of object for more types
To:
Martin Pieuchot <mpi@openbsd.org>
Cc:
tech@openbsd.org
Date:
Wed, 21 Feb 2024 17:08:58 +0100

Download raw body.

Thread
  • Claudio Jeker:

    ctfdump, show size of object for more types

This diff shows the ctt_size for more types (int, float, enum) the same
way as done for structs.

I want to use the ctt_size in ddb so showing them in ctfdump helps to
validate the ctf produced by ctfconv.
-- 
:wq Claudio

Index: ctfdump.c
===================================================================
RCS file: /cvs/src/usr.bin/ctfdump/ctfdump.c,v
diff -u -p -r1.27 ctfdump.c
--- ctfdump.c	14 Aug 2022 15:01:18 -0000	1.27
+++ ctfdump.c	21 Feb 2024 15:33:37 -0000
@@ -490,16 +490,16 @@ ctf_dump_type(struct ctf_header *cth, co
 	case CTF_K_INTEGER:
 		eob = *((uint32_t *)(p + toff));
 		toff += sizeof(uint32_t);
-		printf(" encoding=%s offset=%u bits=%u",
+		printf(" encoding=%s offset=%u bits=%u (%llu bytes)",
 		    ctf_enc2name(CTF_INT_ENCODING(eob)), CTF_INT_OFFSET(eob),
-		    CTF_INT_BITS(eob));
+		    CTF_INT_BITS(eob), size);
 		break;
 	case CTF_K_FLOAT:
 		eob = *((uint32_t *)(p + toff));
 		toff += sizeof(uint32_t);
-		printf(" encoding=%s offset=%u bits=%u",
+		printf(" encoding=%s offset=%u bits=%u (%llu bytes)",
 		    ctf_fpenc2name(CTF_FP_ENCODING(eob)), CTF_FP_OFFSET(eob),
-		    CTF_FP_BITS(eob));
+		    CTF_FP_BITS(eob), size);
 		break;
 	case CTF_K_ARRAY:
 		cta = (struct ctf_array *)(p + toff);
@@ -563,7 +563,8 @@ ctf_dump_type(struct ctf_header *cth, co
 		}
 		break;
 	case CTF_K_ENUM:
-		printf("\n");
+		printf(" (%llu bytes)\n", size);
+
 		for (i = 0; i < vlen; i++) {
 			struct ctf_enum	*cte;