From nobody Wed Aug  3 00:39:12 2022
X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1])
	by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4LyCfT08klz4Y494;
	Wed,  3 Aug 2022 00:39:13 +0000 (UTC)
	(envelope-from git@FreeBSD.org)
Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256
	 client-signature RSA-PSS (4096 bits) client-digest SHA256)
	(Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK))
	by mx1.freebsd.org (Postfix) with ESMTPS id 4LyCfS6mYdz3W1k;
	Wed,  3 Aug 2022 00:39:12 +0000 (UTC)
	(envelope-from git@FreeBSD.org)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim;
	t=1659487152;
	h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
	 to:to:cc:mime-version:mime-version:content-type:content-type:
	 content-transfer-encoding:content-transfer-encoding;
	bh=Uiqs43wvV1kLk3C7XIDhJB8dpcG+f6T0aifffZjK4eA=;
	b=T88gz9xRkJLKdMELHQdZs1FGCudvRwRNrUA665kdRBBoQ5JZWIxMefNpe67i4rBFLnsJa/
	9ltNEl3BljjaKaQ2zQwV60viU2oCWoWjvbdD3Fqw+gCL+BNIenwlygd29RJ1GBgoEupdpn
	I4H+PLc7lgWoyhugFzhUjgpiyqjovMeaLwbmiqJuxMYdoC4GZZexvne5DzoA3/Cke97v8o
	Ce87LyWOLbavCcLnVxYoxhOuoD1NYePnxqwdJan1mW09mup7Sb2HfGpqVoytW7nOTgD0hh
	b+//FNaOfi6U2KW/D0P3xm7ZwxwTK9mw1OZm2rWwfAXbgWbjv7r6CiSQC5myBQ==
Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256)
	(Client did not present a certificate)
	by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4LyCfS5nX3zXkV;
	Wed,  3 Aug 2022 00:39:12 +0000 (UTC)
	(envelope-from git@FreeBSD.org)
Received: from gitrepo.freebsd.org ([127.0.1.44])
	by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 2730dCPf016854;
	Wed, 3 Aug 2022 00:39:12 GMT
	(envelope-from git@gitrepo.freebsd.org)
Received: (from git@localhost)
	by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2730dCnR016853;
	Wed, 3 Aug 2022 00:39:12 GMT
	(envelope-from git)
Date: Wed, 3 Aug 2022 00:39:12 GMT
Message-Id: <202208030039.2730dCnR016853@gitrepo.freebsd.org>
To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org,
        dev-commits-src-main@FreeBSD.org
From: Mark Johnston <markj@FreeBSD.org>
Subject: git: 1165fc9a5266 - main - ctfconvert: Give bitfield types names distinct from the base type
List-Id: Commit messages for the main branch of the src repository <dev-commits-src-main.freebsd.org>
List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main
List-Help: <mailto:dev-commits-src-main+help@freebsd.org>
List-Post: <mailto:dev-commits-src-main@freebsd.org>
List-Subscribe: <mailto:dev-commits-src-main+subscribe@freebsd.org>
List-Unsubscribe: <mailto:dev-commits-src-main+unsubscribe@freebsd.org>
Sender: owner-dev-commits-src-main@freebsd.org
X-BeenThere: dev-commits-src-main@freebsd.org
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Git-Committer: markj
X-Git-Repository: src
X-Git-Refname: refs/heads/main
X-Git-Reftype: branch
X-Git-Commit: 1165fc9a526630487a1feb63daef65c5aee1a583
Auto-Submitted: auto-generated
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org;
	s=dkim; t=1659487153;
	h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
	 to:to:cc:mime-version:mime-version:content-type:content-type:
	 content-transfer-encoding:content-transfer-encoding;
	bh=Uiqs43wvV1kLk3C7XIDhJB8dpcG+f6T0aifffZjK4eA=;
	b=aaLIL2T8Z26ims2xVcr+f0a/r6nCazK+7suDMDQn7M8I/9wRS267rO7/ZTOiHGin2BJ4aK
	hkjXBa5Y9jciwsU9lzdQLSG44F37QdQXTjP2m6wdjdMkAqnJdxDvuO4vhcMo2TT1N9bTJv
	q9LLy+RLTo7bHj+0TNCtT2jKWfSav2itXq85UjsZhAQo2V3+nwn/rtTBQSaAZEy6NnCyKe
	3bZi2hmktsUvTNoirnS2mU/FW3/svEHR4dyksYvLcq96m6RbzPCu6H+/sJr13SwX2VTmod
	jUa5ne1mzlhNC0Q0KKg/P0oGrylsF/aiS6+ijM6lPjJesCsPJkeMjNQOzr4+3Q==
ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1659487153; a=rsa-sha256; cv=none;
	b=SNER33yYk87lj1Exwl83N4XHDM4Z+7aAFMLcTRfO7ZEQ+Cu6JxGs0A1EuT51+S/rKJySHP
	DSLZU41eNi0YKqqZ2wO2kokIfu6LA8A1Yj3aUs1XZK77RVSCrFyhQteWUkBRlToidp04aE
	KSIdTDk/RllY/dQ3OuwYkm+1Ug6cGQc0hDLS+BDmS48CvX2IE10CVdqDzObglLKfqGuC9X
	m5BKJBlxk0fSaKAZJ10L9ya/+nhLK0ElzxNorMnkB2yn5Ad0OjpHSXcRX1a+v6BlRrSdpO
	8Atlq1P0C9NAGgG5MKu1+Nc5rh0kxflLSv+6UooNsMD8XhGaxzJh8WCzwXozuQ==
ARC-Authentication-Results: i=1;
	mx1.freebsd.org;
	none
X-ThisMailContainsUnwantedMimeParts: N

The branch main has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=1165fc9a526630487a1feb63daef65c5aee1a583

commit 1165fc9a526630487a1feb63daef65c5aee1a583
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2022-08-03 00:32:17 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2022-08-03 00:32:17 +0000

    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
---
 cddl/contrib/opensolaris/tools/ctf/common/memory.c | 14 ++++++++++++++
 cddl/contrib/opensolaris/tools/ctf/common/memory.h |  1 +
 cddl/contrib/opensolaris/tools/ctf/cvt/dwarf.c     |  7 ++++---
 3 files changed, 19 insertions(+), 3 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)
 	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");
 		}
 	}