[2/3,nios2] use PTRACE_GETREGSET/SETREGSET in gdbserver

Message ID 55393FFE.80009@codesourcery.com
State New, archived
Headers

Commit Message

Sandra Loosemore April 23, 2015, 6:54 p.m. UTC
  When glibc support for nios2 was submitted upstream, we were asked to 
change the ptrace register query interface from 
PTRACE_GETREGS/PTRACE_SETREGS to PTRACE_GETREGSET/PTRACE_SETREGSET. 
This patch makes the corresponding change to gdbserver (there is no 
native GDB support for this target yet).

OK to commit?

-Sandra
  

Comments

Yao Qi April 28, 2015, 11:18 a.m. UTC | #1
Sandra Loosemore <sandra@codesourcery.com> writes:

> When glibc support for nios2 was submitted upstream, we were asked to
> change the ptrace register query interface from
> PTRACE_GETREGS/PTRACE_SETREGS to
> PTRACE_GETREGSET/PTRACE_SETREGSET. This patch makes the corresponding
> change to gdbserver (there is no native GDB support for this target
> yet).

Hi Sandra,
Could you show me the discussion archive about ptrace interface change
request?

>
> diff --git a/gdb/gdbserver/linux-nios2-low.c b/gdb/gdbserver/linux-nios2-low.c
> index e2fbb89..7bd3c97 100644
> --- a/gdb/gdbserver/linux-nios2-low.c
> +++ b/gdb/gdbserver/linux-nios2-low.c
> @@ -21,6 +21,7 @@
>  
>  #include "server.h"
>  #include "linux-low.h"
> +#include "elf/common.h"

The new include should be mentioned in the ChangeLog entry.
  
Pedro Alves April 28, 2015, 11:24 a.m. UTC | #2
On 04/28/2015 12:18 PM, Yao Qi wrote:
> Sandra Loosemore <sandra@codesourcery.com> writes:
> 
>> When glibc support for nios2 was submitted upstream, we were asked to
>> change the ptrace register query interface from
>> PTRACE_GETREGS/PTRACE_SETREGS to
>> PTRACE_GETREGSET/PTRACE_SETREGSET. This patch makes the corresponding
>> change to gdbserver (there is no native GDB support for this target
>> yet).
> 
> Hi Sandra,
> Could you show me the discussion archive about ptrace interface change
> request?

I don't know about a glibc discussion, but I'm to blame for requesting
that on the kernel side:

  https://lkml.org/lkml/2014/4/25/683

Thanks,
Pedro Alves
  
Sandra Loosemore April 28, 2015, 3:11 p.m. UTC | #3
On 04/28/2015 05:24 AM, Pedro Alves wrote:
> On 04/28/2015 12:18 PM, Yao Qi wrote:
>> Sandra Loosemore <sandra@codesourcery.com> writes:
>>
>>> When glibc support for nios2 was submitted upstream, we were asked to
>>> change the ptrace register query interface from
>>> PTRACE_GETREGS/PTRACE_SETREGS to
>>> PTRACE_GETREGSET/PTRACE_SETREGSET. This patch makes the corresponding
>>> change to gdbserver (there is no native GDB support for this target
>>> yet).
>>
>> Hi Sandra,
>> Could you show me the discussion archive about ptrace interface change
>> request?
>
> I don't know about a glibc discussion, but I'm to blame for requesting
> that on the kernel side:
>
>    https://lkml.org/lkml/2014/4/25/683

Thanks, Pedro, for digging this up; I was mis-remembering in thinking 
that this change came from the glibc review.  It indeed came from the 
kernel submission instead.

-Sandra
  

Patch

diff --git a/gdb/gdbserver/linux-nios2-low.c b/gdb/gdbserver/linux-nios2-low.c
index e2fbb89..7bd3c97 100644
--- a/gdb/gdbserver/linux-nios2-low.c
+++ b/gdb/gdbserver/linux-nios2-low.c
@@ -21,6 +21,7 @@ 
 
 #include "server.h"
 #include "linux-low.h"
+#include "elf/common.h"
 #include <sys/ptrace.h>
 #include <endian.h>
 #include "gdb_proc_service.h"
@@ -32,7 +33,7 @@ 
 
 /* The following definition must agree with the number of registers
    defined in "struct user_regs" in GLIBC
-   (ports/sysdeps/unix/sysv/linux/nios2/sys/user.h), and also with
+   (sysdeps/unix/sysv/linux/nios2/sys/user.h), and also with
    NIOS2_NUM_REGS in GDB proper.  */
 
 #define nios2_num_regs 49
@@ -163,8 +164,6 @@  ps_get_thread_area (const struct ps_prochandle *ph,
   return PS_OK;
 }
 
-#ifdef HAVE_PTRACE_GETREGS
-
 /* Helper functions to collect/supply a single register REGNO.  */
 
 static void
@@ -205,14 +204,12 @@  nios2_store_gregset (struct regcache *regcache, const void *buf)
   for (i = 0; i < nios2_num_regs; i++)
     nios2_supply_register (regcache, i, regset + i);
 }
-#endif /* HAVE_PTRACE_GETREGS */
 
 static struct regset_info nios2_regsets[] =
 {
-#ifdef HAVE_PTRACE_GETREGS
-  { PTRACE_GETREGS, PTRACE_SETREGS, 0, nios2_num_regs * 4, GENERAL_REGS,
+  { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_PRSTATUS,
+    nios2_num_regs * 4, GENERAL_REGS,
     nios2_fill_gregset, nios2_store_gregset },
-#endif /* HAVE_PTRACE_GETREGS */
   { 0, 0, 0, -1, -1, NULL, NULL }
 };