diff --git a/cddl/contrib/opensolaris/tools/ctf/common/memory.c b/cddl/contrib/opensolaris/tools/ctf/common/memory.c index e16044a8b672..66296c5b114d 100644 --- a/cddl/contrib/opensolaris/tools/ctf/common/memory.c +++ b/cddl/contrib/opensolaris/tools/ctf/common/memory.c @@ -44,6 +44,20 @@ memory_bailout(void) exit(1); } +int +xasprintf(char **s, const char *fmt, ...) +{ + va_list ap; + int ret; + + va_start(ap, fmt); + ret = vasprintf(s, fmt, ap); + va_end(ap); + if (ret == -1) + memory_bailout(); + return (ret); +} + void * xmalloc(size_t size) { diff --git a/cddl/contrib/opensolaris/tools/ctf/common/memory.h b/cddl/contrib/opensolaris/tools/ctf/common/memory.h index 88ca31bec65a..72706b5f7fdb 100644 --- a/cddl/contrib/opensolaris/tools/ctf/common/memory.h +++ b/cddl/contrib/opensolaris/tools/ctf/common/memory.h @@ -39,6 +39,7 @@ extern "C" { #endif +int xasprintf(char **, const char *, ...); void *xmalloc(size_t); void *xcalloc(size_t); char *xstrdup(const char *); diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/dwarf.c b/cddl/contrib/opensolaris/tools/ctf/cvt/dwarf.c index 2d686e53fed1..9c422fb58fa1 100644 --- a/cddl/contrib/opensolaris/tools/ctf/cvt/dwarf.c +++ b/cddl/contrib/opensolaris/tools/ctf/cvt/dwarf.c @@ -618,7 +618,7 @@ tdesc_intr_long(dwarf_t *dw) * caller can then use the copy as the type for a bitfield structure member. */ static tdesc_t * -tdesc_intr_clone(dwarf_t *dw, tdesc_t *old, size_t bitsz) +tdesc_intr_clone(dwarf_t *dw, tdesc_t *old, size_t bitsz, const char *suffix) { tdesc_t *new = xcalloc(sizeof (tdesc_t)); @@ -627,7 +627,7 @@ tdesc_intr_clone(dwarf_t *dw, tdesc_t *old, size_t bitsz) "unresolved type\n", old->t_id); } - new->t_name = xstrdup(old->t_name); + asprintf(&new->t_name, "%s %s", old->t_name, suffix); new->t_size = old->t_size; new->t_id = mfgtid_next(dw); new->t_type = INTRINSIC; @@ -1158,7 +1158,8 @@ die_sou_resolve(tdesc_t *tdp, tdesc_t **tdpp __unused, void *private) debug(3, "tdp %u: creating bitfield for %d bits\n", tdp->t_id, ml->ml_size); - ml->ml_type = tdesc_intr_clone(dw, mt, ml->ml_size); + ml->ml_type = tdesc_intr_clone(dw, mt, ml->ml_size, + "bitfield"); } }