Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Keith Seitz <keiths@redhat.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 1/2] regdat.sh: generate const_target_desc_up for register descriptions
Date: Thu, 18 Jun 2026 07:23:55 -0700	[thread overview]
Message-ID: <3b7d26075e66f53cafc44f571165de54527d923b.1781792506.git.keiths@redhat.com> (raw)
In-Reply-To: <cover.1781792506.git.keiths@redhat.com>

Late last year, a patch propagated the use of target_desc unique
pointers (commit 1a5362ce51ef79ffb61caa20c93284dc368dc74a).  At the
time, the "old regformats/regdat.sh [weren't] changed because their
target_desc objects are statically allocated in the generated files."

Unfortunately that re-introduced ODR violations on ppc64le:

CXXLD  gdbserver
../../src/gdbserver/../gdb/arch/ppc-linux-tdesc.h:46:29: error: ‘tdesc_powerpc_isa207_htm_vsx64l’ violates the C++ One Definition Rule [-Werror=odr]
   46 | extern const_target_desc_up tdesc_powerpc_isa207_htm_vsx64l;
      |                             ^
powerpc-isa207-htm-vsx64l-generated.cc:26:27: note: ‘tdesc_powerpc_isa207_htm_vsx64l’ was previously declared here
   26 | const struct target_desc *tdesc_powerpc_isa207_htm_vsx64l;
      |                           ^
powerpc-isa207-htm-vsx64l-generated.cc:26:27: note: code may be misoptimized unless ‘-fno-strict-aliasing’ is used

Update regdat.sh so that generated init_registers_* code matches the
const-unique_ptr-based target description API, resolving the ODR violation.

A follow-up patch updates various gdbserver architectures to
accommodate this API change.

Tested on ppc64le and s390x Fedora 43 and mips-linux
cross build (all with LTO).

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28444
---
 gdb/regformats/regdat.sh | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/gdb/regformats/regdat.sh b/gdb/regformats/regdat.sh
index aeb41f6b7ad..af2bdc28810 100755
--- a/gdb/regformats/regdat.sh
+++ b/gdb/regformats/regdat.sh
@@ -125,7 +125,7 @@ do
   if test "${type}" = "name"; then
     name="${entry}"
 
-    echo "const struct target_desc *tdesc_${name};"
+    echo "const_target_desc_up tdesc_${name};"
     echo ""
 
     # This is necessary for -Wmissing-declarations.
@@ -134,9 +134,8 @@ do
     echo "void"
     echo "init_registers_${name} (void)"
     echo "{"
-    echo "  static struct target_desc tdesc_${name}_s;"
-    echo "  struct target_desc *result = &tdesc_${name}_s;"
-    echo "  struct tdesc_feature *feature = tdesc_create_feature (result, \"${name}\");"
+    echo "  target_desc_up result = allocate_target_description ();"
+    echo "  struct tdesc_feature *feature = tdesc_create_feature (result.get (), \"${name}\");"
     continue
   elif test "${type}" = "xmltarget"; then
     xmltarget="${entry}"
@@ -195,12 +194,12 @@ echo
 osabi_enum=$(grep "${osabi}" "$2" | sed 's/.*(\([^,]\+\),.*/GDB_OSABI_\1/')
 
 cat <<EOF
-  result->xmltarget = xmltarget_${name};
+  result.get ()->xmltarget = xmltarget_${name};
 #endif
 
-  init_target_desc (result, expedite_regs_${name}, ${osabi_enum});
+  init_target_desc (result.get (), expedite_regs_${name}, ${osabi_enum});
 
-  tdesc_${name} = result;
+  tdesc_${name} = std::move (result);
 }
 EOF
 
-- 
2.53.0


  reply	other threads:[~2026-06-18 14:24 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-18 14:23 [PATCH 0/2] Fix ODR violations in regformat target descriptions Keith Seitz
2026-06-18 14:23 ` Keith Seitz [this message]
2026-06-18 15:52   ` [PATCH 1/2] regdat.sh: generate const_target_desc_up for register descriptions Simon Marchi
2026-06-18 14:23 ` [PATCH 2/2] [gdbserver] Use const_target_desc_up for regformat tdescs Keith Seitz
2026-06-18 15:57 ` [PATCH 0/2] Fix ODR violations in regformat target descriptions Simon Marchi
2026-06-18 17:10   ` Tom Tromey
2026-07-07 19:49     ` Keith Seitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3b7d26075e66f53cafc44f571165de54527d923b.1781792506.git.keiths@redhat.com \
    --to=keiths@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox