Print this page
12259 CTF shouldn't assume enum size
*** 8,18 ****
* source. A copy of the CDDL is also available via the Internet at
* http://www.illumos.org/license/CDDL.
*/
/*
! * Copyright 2019, Joyent, Inc.
*/
/*
* Dump information about CTF containers.
*/
--- 8,18 ----
* source. A copy of the CDDL is also available via the Internet at
* http://www.illumos.org/license/CDDL.
*/
/*
! * Copyright 2020 Joyent, Inc.
*/
/*
* Dump information about CTF containers.
*/
*** 611,621 ****
--- 611,630 ----
g_stats.cs_unionsz += size;
g_stats.cs_uszmax = MAX(count, g_stats.cs_uszmax);
}
break;
case CTF_K_ENUM:
+ size = ctf_type_size(g_fp, id);
+
+ /* Only the oddest enums are worth reporting on size. */
+ if (size != CTF_ERR && size != sizeof (int)) {
+ ctfdump_printf(CTFDUMP_TYPES, "%s (%zd bytes)\n",
+ name, size);
+ } else {
ctfdump_printf(CTFDUMP_TYPES, "%s\n", name);
+ }
+
count = 0;
if (ctf_enum_iter(g_fp, id, ctfdump_enum_cb, &count) != 0)
ctfdump_fatal("failed to iterate enumerators of %s: "
"%s\n", name, ctf_errmsg(ctf_errno(g_fp)));
g_stats.cs_nemembs += count;
*** 803,813 ****
--- 812,829 ----
if (ctf_enum_iter(g_fp, id, ctfsrc_enum_cb, NULL) != 0) {
ctfdump_fatal("failed to iterate enumerators of %s: "
"%s\n", name, ctf_errmsg(ctf_errno(g_fp)));
}
+ size = ctf_type_size(g_fp, id);
+
+ /* Only the oddest enums are worth reporting on size. */
+ if (size != CTF_ERR && size != sizeof (int)) {
+ printf("} /* 0x%x bytes */;\n\n", size);
+ } else {
printf("};\n\n");
+ }
break;
case CTF_K_TYPEDEF:
/*
* If this fails, it's probably because the referent type is in
* a parent container that was not supplied via -p.