Re: sparc gdbserver bug? (Re: [RFA] handle android bionic ptrace in gdbserver.)

Pedro Alves
2012-03-29T21:29:21Z

On 03/29/2012 07:50 PM, Pedro Alves wrote:

> On 03/29/2012 06:22 PM, H.J. Lu wrote:
>
>> > On Thu, Mar 29, 2012 at 10:02 AM, Pedro Alves <palves@redhat.com> wrote:
>
>>> >> #ifndef __sparc__
>>> >> - res = ptrace (regset->get_request, pid, 0, buf);
>>> >> + res = ptrace (regset->get_request, pid, nt_type, data);
>>> >> #else
>>> >> - res = ptrace (regset->get_request, pid, buf, 0);
>>> >> + res = ptrace (regset->get_request, pid, &iov, data);
>>> >> #endif
>>> >>
>>> >> I think that should have ended up with:
>>> >>
>>> >> #ifndef __sparc__
>>> >> res = ptrace (regset->get_request, pid, nt_type, data);
>>> >> #else
>>> >> res = ptrace (regset->get_request, pid, data, nt_type);
>>> >> #endif
>>> >>
>> >
>> > It may be a typo for sparc branch.
>
> Thanks. I found a sparc-linux machine on the gcc compile farm,
> and since I'm already making changes that affect all gdbserver
> ports, I'll eventually run into it and fix it.

Indeed, gdbserver crashes on SPARC due to that. I've applied the
obvious fix below.

2012-03-29 Pedro Alves <palves@redhat.com>

* linux-low.c (regsets_store_inferior_registers) [__sparc__]:
Correct ptrace arguments.

Index: src/gdb/gdbserver/linux-low.c
===================================================================
--- src.orig/gdb/gdbserver/linux-low.c
+++ src/gdb/gdbserver/linux-low.c
@@ -4036,7 +4036,7 @@ regsets_store_inferior_registers (struct
#ifndef __sparc__
res = ptrace (regset->get_request, pid, nt_type, data);
#else
- res = ptrace (regset->get_request, pid, &iov, data);
+ res = ptrace (regset->get_request, pid, data, nt_type);
#endif

if (res == 0)