Which version of gdb are you using? I've found I had to patch several versions of gdb when building gdbserver for non-x86 platforms, possibly due to less QA testing of these "obscure" platforms on the gdb dev side.

I at least encountered issues with ARM and MIPS on some of the 6 and/or 7 branch of gdb. Patches were only about 20-30 lines max.

I'm maintaining a collection of statically linked gdbserver executables[1] for various embedded platforms so I'd be happy to write a patch to address the issues in gdb and send them to you and upstream if they can be fixed on the gdb side of things. I need to add those platforms anyway so it's no bother.

I'll take a look today to see if I can patch any errors in gdb to get a functional build but if it's in fact a musl issue I'll have to defer.

Have you had success building the same gdbserver versions with glibc or uClibc for the same architectures?

Adam

1. https://github.com/mzpqnxow/embedded-toolkit/tree/master/prebuilt_static_bins/gdbserver

On Sat, Jun 3, 2017 at 10:35 Khem Raj <raj.khem@gmail.com> wrote:
Hi Thomas



On Sat, Jun 3, 2017 at 7:14 AM, Thomas Petazzoni
<thomas.petazzoni@free-electrons.com> wrote:
> Hello,
>
> We are building a number of toolchains, some of them using the musl C
> library, and are seeing that gdbserver fails to build with musl on a
> number of architectures. We have used musl 1.1.16, i.e the latest
> version.
>
> Here are the failures that we see:
>
>  - On SuperH:
>
>    usr/sh4-buildroot-linux-musl/sysroot/usr/include/asm/ptrace_32.h:44:8: error: redefinition of 'struct pt_regs'
>
>  - On PowerPC64 and PowerPC64le:
>
>    usr/powerpc64-buildroot-linux-musl/sysroot/usr/include/asm/ptrace.h:31:8: error: redefinition of 'struct pt_regs'
>    usr/powerpc64le-buildroot-linux-musl/sysroot/usr/include/asm/ptrace.h:31:8: error: redefinition of 'struct pt_regs'
>
>  - On PowerPC:
>
>    usr/powerpc-buildroot-linux-musl/sysroot/usr/include/asm/ptrace.h:31:8: error: redefinition of 'struct pt_regs'


for ppe issues you can use something like
http://git.yoctoproject.org/clean/cgit.cgi/poky/tree/meta/recipes-devtools/gdb/gdb/0004-ppc-ptrace-Define-pt_regs-uapi_pt_regs-on-GLIBC-syst.patch

>
>  - On Microblaze, little endian and big endian
>
>    usr/microblaze-buildroot-linux-musl/sysroot/usr/include/sys/procfs.h:30:2: error: unknown type name 'elf_gregset_t'
>    error: 'Elf64_auxv_t' undeclared (first use in this function)
>    error: 'Elf32_auxv_t' undeclared (first use in this function)
>    ...
>
> On all those architectures, gdbserver builds fine with other C libraries.
>
> I had a brief look at the commits in musl since 1.1.16 and couldn't
> spot anything that looked related.
>
> Are you interested in fixing those issues? If needed, I can provide an
> easy way of reproducing those build failures.
>
> Thanks!
>
> Thomas
> --
> Thomas Petazzoni, CTO, Free Electrons
> Embedded Linux and Kernel engineering
> http://free-electrons.com