path: root/cddl/contrib/opensolaris/tools/ctf/common
diff options
authorMark Johnston <markj@FreeBSD.org>2022-08-03 00:32:17 +0000
committerMark Johnston <markj@FreeBSD.org>2022-08-03 00:32:17 +0000
commit1165fc9a526630487a1feb63daef65c5aee1a583 (patch)
tree94a26dd090a34f33fd9dfe209ad7f0f443d9f2fb /cddl/contrib/opensolaris/tools/ctf/common
parent6a05f1438145c2d8c3d0e29e1d5e24a05d394453 (diff)
ctfconvert: Give bitfield types names distinct from the base type
CTF integers have an explicit width and so can be used to represent bitfields. Bitfield types emitted by ctfconvert(1) share the name of the base integer type, so a struct field with type "unsigned int : 15" will have a type named "unsigned int". To avoid ambiguity when looking up types by name, add a suffix to names of bitfield types to distinguish them from the base type. Then, if ctfmerge happens to order bitfield types before the corresponding base type in a CTF file, a name lookup will return the base type, which is always going to be the desired behaviour. PR: 265403 Reported by: cy MFC after: 1 week Sponsored by: The FreeBSD Foundation
Diffstat (limited to 'cddl/contrib/opensolaris/tools/ctf/common')
2 files changed, 15 insertions, 0 deletions
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)
+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" {
+int xasprintf(char **, const char *, ...);
void *xmalloc(size_t);
void *xcalloc(size_t);
char *xstrdup(const char *);