From nobody Thu Aug 11 14:36:25 2022 X-Original-To: dev-commits-src-branches@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 4M3Trn5f9sz4Y3Q3; Thu, 11 Aug 2022 14:36:25 +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 4M3Trn4wmSz3Q57; Thu, 11 Aug 2022 14:36:25 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1660228585; 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=8RCgrPCXvW44ty/A3f89tupTc3SCHPY6WSM3tgYqG1U=; b=wLw/XZC9NwxvKyrMWRCpSCx/BrRGd3bmxJapA8F/196EH/6nMfaDokLwRABRljJwzbqsG5 JcWd1IFDDTBtDjVrmW50du8+kUx2OWqHK+QwILzONCBIycIFGRHHdex+JhHGVspqJQhKue 2xv2+vKOO7KykR4UzR2rT89yGugWtcwTWBghjVojRwoLkvx5B81sTBmcMovo6MGeW/uoF9 qq/2Hd9LpR4oAKkpSyM4QjtHUbniUAw2xfF4aDZEBAgUagTT4sZ0TE2S3EdeB0QkfI3mC5 ddrAeMOLV9QLBe6mNv+7ui9WxgPSFHtqi+4WFvwqccxF8fmjxHSyxGL23hUqhQ== 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 4M3Trn42wNzvGR; Thu, 11 Aug 2022 14:36:25 +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 27BEaP2i005268; Thu, 11 Aug 2022 14:36:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 27BEaPuH005267; Thu, 11 Aug 2022 14:36:25 GMT (envelope-from git) Date: Thu, 11 Aug 2022 14:36:25 GMT Message-Id: <202208111436.27BEaPuH005267@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: a853b4c42569 - stable/13 - ctfconvert: Give bitfield types names distinct from the base type List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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/stable/13 X-Git-Reftype: branch X-Git-Commit: a853b4c425697a76c61ffa4fbd8bf7da5454807a Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1660228585; 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=8RCgrPCXvW44ty/A3f89tupTc3SCHPY6WSM3tgYqG1U=; b=KgZL2VXJvhpCoKV7pFkeleZE9LN6u9qLP7L/D4Wr4us1botSiGzp2tQ0AZFJ5qqcDjVWjg NEcYj8qrWjVFBkdVTVCC3XL1pLsfcMNq7hU2LIebM36/an7qTsIzIw7z11wxUgumqVCazC mWoFslop+hBHz3VDRe5Kp5Tg3vuC0NwNy9B2DeA5+Nq4BC8WL2uiseRkCe2sFhkCg62d5t FXTpWR9ohfr3kY8B/YjqJX9vLwFTFXG8p1YuH7CsR5BkAnDV70J6Wbhj364UlZS1q/keEr Gy1Jg8zlWQ246lDAg6WCKu6raZzU4PcuSV1s+KA2BrqV8GJVivYWy7GpVGlw9A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1660228585; a=rsa-sha256; cv=none; b=lE/qHMq3BrNVF7vA/1rxoRHNDSfW+D7JnNuebra7MPorWRn0kBXvF9FxvUpC2761NbsuJF Kt8SBaZOBPYr3nmTTkqpSfuEBwswrdNtCn7BrFdQXZBHwKSscfzqRDlemqV/HuOwOI+2bW Bg1FEGpVLEwu4f4Df/EUrtQUzLC6xKRQz2x2z8tQdOT86ADyT6LJBxSXcR7VX5+T0UD27o LXFeeBMU5YlaqnEIeduUjcdW5Q2c6SLnni1q9m5E9GwNzLJDq7vkFh9l7t+Zk4TNX6q4Q6 FYx5Dg1G1JVU4ZFBB30xjVmX+MDb2SuwWs91sICV1L1l2SG1duoThDc+0aGu5A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=a853b4c425697a76c61ffa4fbd8bf7da5454807a commit a853b4c425697a76c61ffa4fbd8bf7da5454807a Author: Mark Johnston AuthorDate: 2022-08-03 00:32:17 +0000 Commit: Mark Johnston CommitDate: 2022-08-11 14:36:11 +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 Sponsored by: The FreeBSD Foundation (cherry picked from commit 1165fc9a526630487a1feb63daef65c5aee1a583) --- 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"); } }