* [PATCH v2] gdb/s390-linux-nat: use gdb_{g, fp}regset_t to fix build with musl
@ 2026-11-11 21:48 Florian Fuchs
2026-11-12 15:40 ` [PATCH v2] gdb/s390-linux-nat: use gdb_{g,fp}regset_t " Ulrich Weigand
0 siblings, 1 reply; 2+ messages in thread
From: Florian Fuchs @ 2026-11-11 21:48 UTC (permalink / raw)
To: gdb-patches, Andreas Arnez; +Cc: Ulrich Weigand, Florian Fuchs
gdb/gregset.h declares supply_fpregset and fill_fpregset with
gdb_fpregset_t, which nm-linux.h defines as elf_fpregset_t. The s390
native target defines them with fpregset_t instead. On glibc the two
are the same type, so this goes unnoticed. On musl they are distinct
types, so the definitions in s390-linux-nat.c become separate
overloads, and the calls in proc-service.c find no definition:
ld: proc-service.o: in function `ps_lgetfpregs':
proc-service.c:(.text+0x3f0): undefined reference to
`fill_fpregset(regcache const*, elf_fpregset_t*, int)'
ld: proc-service.o: in function `ps_lsetfpregs':
proc-service.c:(.text+0x426): undefined reference to
`supply_fpregset(regcache*, elf_fpregset_t const*)'
Use gdb_fpregset_t in the definitions and the local buffers, like other
Linux native targets do, so they match the declarations in gregset.h.
For consistency, do the same for supply_gregset and fill_gregset with
gdb_gregset_t. gregset_t and elf_gregset_t are currently the same type
on both glibc and musl, so this part is not needed to fix the build.
Tested by cross-building and running GDB for s390x with musl and glibc.
Signed-off-by: Florian Fuchs <fuchsfl@gmail.com>
---
v1->v2: Also use gdb_gregset_t in supply_gregset and fill_gregset, as
Ulrich suggested, and update commit msg accordingly.
v1: https://sourceware.org/pipermail/gdb-patches/2026-November/231790.html
gdb/s390-linux-nat.c | 33 +++++++++++++++++----------------
1 file changed, 17 insertions(+), 16 deletions(-)
diff --git a/gdb/s390-linux-nat.c b/gdb/s390-linux-nat.c
index cffaadf3c28..26cd6f32510 100644
--- a/gdb/s390-linux-nat.c
+++ b/gdb/s390-linux-nat.c
@@ -155,7 +155,7 @@ static s390_linux_nat_target the_s390_linux_nat_target;
make them look like 32-bit registers. */
void
-supply_gregset (struct regcache *regcache, const gregset_t *regp)
+supply_gregset (struct regcache *regcache, const gdb_gregset_t *regp)
{
#ifdef __s390x__
struct gdbarch *gdbarch = regcache->arch ();
@@ -166,7 +166,7 @@ supply_gregset (struct regcache *regcache, const gregset_t *regp)
gdb_byte buf[4];
regcache_supply_regset (&s390_64_gregset, regcache, -1,
- regp, sizeof (gregset_t));
+ regp, sizeof (gdb_gregset_t));
pswm = extract_unsigned_integer ((const gdb_byte *) regp
+ S390_PSWM_OFFSET, 8, byte_order);
pswa = extract_unsigned_integer ((const gdb_byte *) regp
@@ -181,7 +181,7 @@ supply_gregset (struct regcache *regcache, const gregset_t *regp)
#endif
regcache_supply_regset (&s390_gregset, regcache, -1, regp,
- sizeof (gregset_t));
+ sizeof (gdb_gregset_t));
}
/* Fill register REGNO (if it is a general-purpose register) in
@@ -189,14 +189,14 @@ supply_gregset (struct regcache *regcache, const gregset_t *regp)
do this for all registers. */
void
-fill_gregset (const struct regcache *regcache, gregset_t *regp, int regno)
+fill_gregset (const struct regcache *regcache, gdb_gregset_t *regp, int regno)
{
#ifdef __s390x__
struct gdbarch *gdbarch = regcache->arch ();
if (gdbarch_ptr_bit (gdbarch) == 32)
{
regcache_collect_regset (&s390_64_gregset, regcache, regno,
- regp, sizeof (gregset_t));
+ regp, sizeof (gdb_gregset_t));
if (regno == -1
|| regno == S390_PSWM_REGNUM || regno == S390_PSWA_REGNUM)
@@ -233,26 +233,27 @@ fill_gregset (const struct regcache *regcache, gregset_t *regp, int regno)
#endif
regcache_collect_regset (&s390_gregset, regcache, regno, regp,
- sizeof (gregset_t));
+ sizeof (gdb_gregset_t));
}
/* Fill GDB's register array with the floating-point register values
in *REGP. */
void
-supply_fpregset (struct regcache *regcache, const fpregset_t *regp)
+supply_fpregset (struct regcache *regcache, const gdb_fpregset_t *regp)
{
regcache_supply_regset (&s390_fpregset, regcache, -1, regp,
- sizeof (fpregset_t));
+ sizeof (gdb_fpregset_t));
}
/* Fill register REGNO (if it is a general-purpose register) in
*REGP with the value in GDB's register array. If REGNO is -1,
do this for all registers. */
void
-fill_fpregset (const struct regcache *regcache, fpregset_t *regp, int regno)
+fill_fpregset (const struct regcache *regcache, gdb_fpregset_t *regp,
+ int regno)
{
regcache_collect_regset (&s390_fpregset, regcache, regno, regp,
- sizeof (fpregset_t));
+ sizeof (gdb_fpregset_t));
}
/* Find the TID for the current inferior thread to use with ptrace. */
@@ -272,7 +273,7 @@ s390_inferior_tid (void)
static void
fetch_regs (struct regcache *regcache, int tid)
{
- gregset_t regs;
+ gdb_gregset_t regs;
ptrace_area parea;
parea.len = sizeof (regs);
@@ -281,7 +282,7 @@ fetch_regs (struct regcache *regcache, int tid)
if (ptrace (PTRACE_PEEKUSR_AREA, tid, (long) &parea, 0) < 0)
perror_with_name (_("Couldn't get registers"));
- supply_gregset (regcache, (const gregset_t *) ®s);
+ supply_gregset (regcache, ®s);
}
/* Store all valid general-purpose registers in GDB's register cache
@@ -289,7 +290,7 @@ fetch_regs (struct regcache *regcache, int tid)
static void
store_regs (const struct regcache *regcache, int tid, int regnum)
{
- gregset_t regs;
+ gdb_gregset_t regs;
ptrace_area parea;
parea.len = sizeof (regs);
@@ -309,7 +310,7 @@ store_regs (const struct regcache *regcache, int tid, int regnum)
static void
fetch_fpregs (struct regcache *regcache, int tid)
{
- fpregset_t fpregs;
+ gdb_fpregset_t fpregs;
ptrace_area parea;
parea.len = sizeof (fpregs);
@@ -318,7 +319,7 @@ fetch_fpregs (struct regcache *regcache, int tid)
if (ptrace (PTRACE_PEEKUSR_AREA, tid, (long) &parea, 0) < 0)
perror_with_name (_("Couldn't get floating point status"));
- supply_fpregset (regcache, (const fpregset_t *) &fpregs);
+ supply_fpregset (regcache, &fpregs);
}
/* Store all valid floating-point registers in GDB's register cache
@@ -326,7 +327,7 @@ fetch_fpregs (struct regcache *regcache, int tid)
static void
store_fpregs (const struct regcache *regcache, int tid, int regnum)
{
- fpregset_t fpregs;
+ gdb_fpregset_t fpregs;
ptrace_area parea;
parea.len = sizeof (fpregs);
--
2.43.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH v2] gdb/s390-linux-nat: use gdb_{g,fp}regset_t to fix build with musl
2026-11-11 21:48 [PATCH v2] gdb/s390-linux-nat: use gdb_{g, fp}regset_t to fix build with musl Florian Fuchs
@ 2026-11-12 15:40 ` Ulrich Weigand
0 siblings, 0 replies; 2+ messages in thread
From: Ulrich Weigand @ 2026-11-12 15:40 UTC (permalink / raw)
To: Florian Fuchs, gdb-patches, Andreas Arnez; +Cc: Ulrich Weigand
Florian Fuchs <fuchsfl@gmail.com> wrote:
>gdb/gregset.h declares supply_fpregset and fill_fpregset with
>gdb_fpregset_t, which nm-linux.h defines as elf_fpregset_t. The s390
>native target defines them with fpregset_t instead. On glibc the two
>are the same type, so this goes unnoticed. On musl they are distinct
>types, so the definitions in s390-linux-nat.c become separate
>overloads, and the calls in proc-service.c find no definition:
>
>ld: proc-service.o: in function `ps_lgetfpregs':
>proc-service.c:(.text+0x3f0): undefined reference to
> `fill_fpregset(regcache const*, elf_fpregset_t*, int)'
>ld: proc-service.o: in function `ps_lsetfpregs':
>proc-service.c:(.text+0x426): undefined reference to
> `supply_fpregset(regcache*, elf_fpregset_t const*)'
>
>Use gdb_fpregset_t in the definitions and the local buffers, like
other
>Linux native targets do, so they match the declarations in gregset.h.
>For consistency, do the same for supply_gregset and fill_gregset with
>gdb_gregset_t. gregset_t and elf_gregset_t are currently the same type
>on both glibc and musl, so this part is not needed to fix the build.
>
>Tested by cross-building and running GDB for s390x with musl and
glibc.
>
>Signed-off-by: Florian Fuchs <fuchsfl@gmail.com>
Approved-By: Ulrich Weigand <ulrich.weigand@de.ibm.com>
Thanks,
Ulrich
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-12 15:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-11 21:48 [PATCH v2] gdb/s390-linux-nat: use gdb_{g, fp}regset_t to fix build with musl Florian Fuchs
2026-11-12 15:40 ` [PATCH v2] gdb/s390-linux-nat: use gdb_{g,fp}regset_t " Ulrich Weigand
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox