* [RFA] handle android bionic ptrace in gdbserver.
@ 2012-03-26 22:47 Thiago Jung Bauermann
2012-03-27 16:12 ` Mark Kettenis
0 siblings, 1 reply; 12+ messages in thread
From: Thiago Jung Bauermann @ 2012-03-26 22:47 UTC (permalink / raw)
To: gdb-patches ml
Hi,
This patch fixes gdbserver compilation errors on Android. It expands on
a patch addressing the same issue which was committed a while back:
http://sourceware.org/ml/gdb-patches/2010-01/msg00514.html
Explanation from the post above:
The signature of ptrace on Bionic is:
extern long ptrace(int request, pid_t pid, void *addr, void *data);
The linux manpage defines it as:
long ptrace(enum __ptrace_request request, pid_t pid,
void *addr, void *data);
But glibc defines it as a variadic function:
extern long int ptrace (enum __ptrace_request __request, ...) __THROW;
Ok to commit? It doesn't affect compilation in i386-linux or
armv5tel-linux-gnueabi.
--
[]'s
Thiago Jung Bauermann
Linaro Toolchain Working Group
2012-03-26 Thiago Jung Bauermann <thiago.bauermann@linaro.org>
* linux-low.h (PTRACE_ARG3_TYPE): Move macro from linux-low.c.
(PTRACE_ARG4_TYPE): Likewise.
(PTRACE_XFER_TYPE): Likewise.
* linux-arm-low.c (arm_prepare_to_resume): Cast third argument of
ptrace to PTRACE_ARG3_TYPE.
* linux-low.c (PTRACE_ARG3_TYPE): Move macro to linux-low.h.
(PTRACE_ARG4_TYPE): Likewise.
(PTRACE_XFER_TYPE): Likewise.
(linux_detach_one_lwp): Cast fourth argument of
ptrace to PTRACE_ARG4_TYPE.
(regsets_fetch_inferior_registers): Cast third argument of
ptrace to PTRACE_ARG3_TYPE.
(regsets_store_inferior_registers): Likewise.
diff --git a/gdb/gdbserver/linux-arm-low.c b/gdb/gdbserver/linux-arm-low.c
index 01208ef..9490d7d 100644
--- a/gdb/gdbserver/linux-arm-low.c
+++ b/gdb/gdbserver/linux-arm-low.c
@@ -709,13 +709,15 @@ arm_prepare_to_resume (struct lwp_info *lwp)
errno = 0;
if (arm_hwbp_control_is_enabled (proc_info->bpts[i].control))
- if (ptrace (PTRACE_SETHBPREGS, pid, ((i << 1) + 1),
- &proc_info->bpts[i].address) < 0)
+ if (ptrace (PTRACE_SETHBPREGS, pid,
+ (PTRACE_ARG3_TYPE) ((i << 1) + 1),
+ &proc_info->bpts[i].address) < 0)
perror_with_name ("Unexpected error setting breakpoint address");
if (arm_hwbp_control_is_initialized (proc_info->bpts[i].control))
- if (ptrace (PTRACE_SETHBPREGS, pid, ((i << 1) + 2),
- &proc_info->bpts[i].control) < 0)
+ if (ptrace (PTRACE_SETHBPREGS, pid,
+ (PTRACE_ARG3_TYPE) ((i << 1) + 2),
+ &proc_info->bpts[i].control) < 0)
perror_with_name ("Unexpected error setting breakpoint");
lwp_info->bpts_changed[i] = 0;
@@ -727,13 +729,15 @@ arm_prepare_to_resume (struct lwp_info *lwp)
errno = 0;
if (arm_hwbp_control_is_enabled (proc_info->wpts[i].control))
- if (ptrace (PTRACE_SETHBPREGS, pid, -((i << 1) + 1),
- &proc_info->wpts[i].address) < 0)
+ if (ptrace (PTRACE_SETHBPREGS, pid,
+ (PTRACE_ARG3_TYPE) -((i << 1) + 1),
+ &proc_info->wpts[i].address) < 0)
perror_with_name ("Unexpected error setting watchpoint address");
if (arm_hwbp_control_is_initialized (proc_info->wpts[i].control))
- if (ptrace (PTRACE_SETHBPREGS, pid, -((i << 1) + 2),
- &proc_info->wpts[i].control) < 0)
+ if (ptrace (PTRACE_SETHBPREGS, pid,
+ (PTRACE_ARG3_TYPE) -((i << 1) + 2),
+ &proc_info->wpts[i].control) < 0)
perror_with_name ("Unexpected error setting watchpoint");
lwp_info->wpts_changed[i] = 0;
diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index 1caff5a..2ebef9f 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -239,10 +239,6 @@ struct pending_signals
struct pending_signals *prev;
};
-#define PTRACE_ARG3_TYPE void *
-#define PTRACE_ARG4_TYPE void *
-#define PTRACE_XFER_TYPE long
-
#ifdef HAVE_LINUX_REGSETS
static char *disabled_regsets;
static int num_regsets;
@@ -1149,7 +1145,7 @@ linux_detach_one_lwp (struct inferior_list_entry *entry, void *args)
/* Finally, let it resume. */
if (the_low_target.prepare_to_resume != NULL)
the_low_target.prepare_to_resume (lwp);
- if (ptrace (PTRACE_DETACH, lwpid_of (lwp), 0, sig) < 0)
+ if (ptrace (PTRACE_DETACH, lwpid_of (lwp), 0, (PTRACE_ARG4_TYPE) sig) < 0)
error (_("Can't detach %s: %s"),
target_pid_to_str (ptid_of (lwp)),
strerror (errno));
@@ -3989,7 +3985,8 @@ regsets_fetch_inferior_registers (struct regcache *regcache)
data = buf;
#ifndef __sparc__
- res = ptrace (regset->get_request, pid, nt_type, data);
+ res = ptrace (regset->get_request, pid,
+ (PTRACE_ARG3_TYPE) nt_type, data);
#else
res = ptrace (regset->get_request, pid, data, nt_type);
#endif
@@ -4062,7 +4059,8 @@ regsets_store_inferior_registers (struct regcache *regcache)
data = buf;
#ifndef __sparc__
- res = ptrace (regset->get_request, pid, nt_type, data);
+ res = ptrace (regset->get_request, pid,
+ (PTRACE_ARG3_TYPE) nt_type, data);
#else
res = ptrace (regset->get_request, pid, &iov, data);
#endif
@@ -4074,7 +4072,8 @@ regsets_store_inferior_registers (struct regcache *regcache)
/* Only now do we write the register set. */
#ifndef __sparc__
- res = ptrace (regset->set_request, pid, nt_type, data);
+ res = ptrace (regset->set_request, pid,
+ (PTRACE_ARG3_TYPE) nt_type, data);
#else
res = ptrace (regset->set_request, pid, data, nt_type);
#endif
diff --git a/gdb/gdbserver/linux-low.h b/gdb/gdbserver/linux-low.h
index 3aeae70..cb26ebb 100644
--- a/gdb/gdbserver/linux-low.h
+++ b/gdb/gdbserver/linux-low.h
@@ -24,6 +24,10 @@
#include "gdb_proc_service.h"
+#define PTRACE_ARG3_TYPE void *
+#define PTRACE_ARG4_TYPE void *
+#define PTRACE_XFER_TYPE long
+
#ifdef HAVE_LINUX_REGSETS
typedef void (*regset_fill_func) (struct regcache *, void *);
typedef void (*regset_store_func) (struct regcache *, const void *);
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: [RFA] handle android bionic ptrace in gdbserver. 2012-03-26 22:47 [RFA] handle android bionic ptrace in gdbserver Thiago Jung Bauermann @ 2012-03-27 16:12 ` Mark Kettenis 2012-03-28 0:27 ` Thiago Jung Bauermann 0 siblings, 1 reply; 12+ messages in thread From: Mark Kettenis @ 2012-03-27 16:12 UTC (permalink / raw) To: thiago.bauermann; +Cc: gdb-patches > From: Thiago Jung Bauermann <thiago.bauermann@linaro.org> > Date: Mon, 26 Mar 2012 19:46:42 -0300 > > Hi, > > This patch fixes gdbserver compilation errors on Android. It expands on > a patch addressing the same issue which was committed a while back: > > http://sourceware.org/ml/gdb-patches/2010-01/msg00514.html > > Explanation from the post above: > > The signature of ptrace on Bionic is: > > extern long ptrace(int request, pid_t pid, void *addr, void *data); > > The linux manpage defines it as: > > long ptrace(enum __ptrace_request request, pid_t pid, > void *addr, void *data); > > But glibc defines it as a variadic function: > > extern long int ptrace (enum __ptrace_request __request, ...) __THROW; > > > Ok to commit? It doesn't affect compilation in i386-linux or > armv5tel-linux-gnueabi. Sad to see all this compatibility goo just a different prototype. This could almost certainly be fixed by just fixing the header. Anyway, you should test this on a 64-bit platform. I have a strong suspicion things will break there because of plain integers that are being cast to void *. > 2012-03-26 Thiago Jung Bauermann <thiago.bauermann@linaro.org> > > * linux-low.h (PTRACE_ARG3_TYPE): Move macro from linux-low.c. > (PTRACE_ARG4_TYPE): Likewise. > (PTRACE_XFER_TYPE): Likewise. > * linux-arm-low.c (arm_prepare_to_resume): Cast third argument of > ptrace to PTRACE_ARG3_TYPE. > * linux-low.c (PTRACE_ARG3_TYPE): Move macro to linux-low.h. > (PTRACE_ARG4_TYPE): Likewise. > (PTRACE_XFER_TYPE): Likewise. > (linux_detach_one_lwp): Cast fourth argument of > ptrace to PTRACE_ARG4_TYPE. > (regsets_fetch_inferior_registers): Cast third argument of > ptrace to PTRACE_ARG3_TYPE. > (regsets_store_inferior_registers): Likewise. > > > diff --git a/gdb/gdbserver/linux-arm-low.c b/gdb/gdbserver/linux-arm-low.c > index 01208ef..9490d7d 100644 > --- a/gdb/gdbserver/linux-arm-low.c > +++ b/gdb/gdbserver/linux-arm-low.c > @@ -709,13 +709,15 @@ arm_prepare_to_resume (struct lwp_info *lwp) > errno = 0; > > if (arm_hwbp_control_is_enabled (proc_info->bpts[i].control)) > - if (ptrace (PTRACE_SETHBPREGS, pid, ((i << 1) + 1), > - &proc_info->bpts[i].address) < 0) > + if (ptrace (PTRACE_SETHBPREGS, pid, > + (PTRACE_ARG3_TYPE) ((i << 1) + 1), > + &proc_info->bpts[i].address) < 0) > perror_with_name ("Unexpected error setting breakpoint address"); > > if (arm_hwbp_control_is_initialized (proc_info->bpts[i].control)) > - if (ptrace (PTRACE_SETHBPREGS, pid, ((i << 1) + 2), > - &proc_info->bpts[i].control) < 0) > + if (ptrace (PTRACE_SETHBPREGS, pid, > + (PTRACE_ARG3_TYPE) ((i << 1) + 2), > + &proc_info->bpts[i].control) < 0) > perror_with_name ("Unexpected error setting breakpoint"); > > lwp_info->bpts_changed[i] = 0; > @@ -727,13 +729,15 @@ arm_prepare_to_resume (struct lwp_info *lwp) > errno = 0; > > if (arm_hwbp_control_is_enabled (proc_info->wpts[i].control)) > - if (ptrace (PTRACE_SETHBPREGS, pid, -((i << 1) + 1), > - &proc_info->wpts[i].address) < 0) > + if (ptrace (PTRACE_SETHBPREGS, pid, > + (PTRACE_ARG3_TYPE) -((i << 1) + 1), > + &proc_info->wpts[i].address) < 0) > perror_with_name ("Unexpected error setting watchpoint address"); > > if (arm_hwbp_control_is_initialized (proc_info->wpts[i].control)) > - if (ptrace (PTRACE_SETHBPREGS, pid, -((i << 1) + 2), > - &proc_info->wpts[i].control) < 0) > + if (ptrace (PTRACE_SETHBPREGS, pid, > + (PTRACE_ARG3_TYPE) -((i << 1) + 2), > + &proc_info->wpts[i].control) < 0) > perror_with_name ("Unexpected error setting watchpoint"); > > lwp_info->wpts_changed[i] = 0; > diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c > index 1caff5a..2ebef9f 100644 > --- a/gdb/gdbserver/linux-low.c > +++ b/gdb/gdbserver/linux-low.c > @@ -239,10 +239,6 @@ struct pending_signals > struct pending_signals *prev; > }; > > -#define PTRACE_ARG3_TYPE void * > -#define PTRACE_ARG4_TYPE void * > -#define PTRACE_XFER_TYPE long > - > #ifdef HAVE_LINUX_REGSETS > static char *disabled_regsets; > static int num_regsets; > @@ -1149,7 +1145,7 @@ linux_detach_one_lwp (struct inferior_list_entry *entry, void *args) > /* Finally, let it resume. */ > if (the_low_target.prepare_to_resume != NULL) > the_low_target.prepare_to_resume (lwp); > - if (ptrace (PTRACE_DETACH, lwpid_of (lwp), 0, sig) < 0) > + if (ptrace (PTRACE_DETACH, lwpid_of (lwp), 0, (PTRACE_ARG4_TYPE) sig) < 0) > error (_("Can't detach %s: %s"), > target_pid_to_str (ptid_of (lwp)), > strerror (errno)); > @@ -3989,7 +3985,8 @@ regsets_fetch_inferior_registers (struct regcache *regcache) > data = buf; > > #ifndef __sparc__ > - res = ptrace (regset->get_request, pid, nt_type, data); > + res = ptrace (regset->get_request, pid, > + (PTRACE_ARG3_TYPE) nt_type, data); > #else > res = ptrace (regset->get_request, pid, data, nt_type); > #endif > @@ -4062,7 +4059,8 @@ regsets_store_inferior_registers (struct regcache *regcache) > data = buf; > > #ifndef __sparc__ > - res = ptrace (regset->get_request, pid, nt_type, data); > + res = ptrace (regset->get_request, pid, > + (PTRACE_ARG3_TYPE) nt_type, data); > #else > res = ptrace (regset->get_request, pid, &iov, data); > #endif > @@ -4074,7 +4072,8 @@ regsets_store_inferior_registers (struct regcache *regcache) > > /* Only now do we write the register set. */ > #ifndef __sparc__ > - res = ptrace (regset->set_request, pid, nt_type, data); > + res = ptrace (regset->set_request, pid, > + (PTRACE_ARG3_TYPE) nt_type, data); > #else > res = ptrace (regset->set_request, pid, data, nt_type); > #endif > diff --git a/gdb/gdbserver/linux-low.h b/gdb/gdbserver/linux-low.h > index 3aeae70..cb26ebb 100644 > --- a/gdb/gdbserver/linux-low.h > +++ b/gdb/gdbserver/linux-low.h > @@ -24,6 +24,10 @@ > > #include "gdb_proc_service.h" > > +#define PTRACE_ARG3_TYPE void * > +#define PTRACE_ARG4_TYPE void * > +#define PTRACE_XFER_TYPE long > + > #ifdef HAVE_LINUX_REGSETS > typedef void (*regset_fill_func) (struct regcache *, void *); > typedef void (*regset_store_func) (struct regcache *, const void *); > > > ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFA] handle android bionic ptrace in gdbserver. 2012-03-27 16:12 ` Mark Kettenis @ 2012-03-28 0:27 ` Thiago Jung Bauermann 2012-03-29 16:42 ` Pedro Alves 2012-03-29 17:02 ` sparc gdbserver bug? (Re: [RFA] handle android bionic ptrace in gdbserver.) Pedro Alves 0 siblings, 2 replies; 12+ messages in thread From: Thiago Jung Bauermann @ 2012-03-28 0:27 UTC (permalink / raw) To: Mark Kettenis; +Cc: gdb-patches Hi Mark, On Tue, 2012-03-27 at 18:11 +0200, Mark Kettenis wrote: > > From: Thiago Jung Bauermann <thiago.bauermann@linaro.org> > > Date: Mon, 26 Mar 2012 19:46:42 -0300 > Sad to see all this compatibility goo just a different prototype. > This could almost certainly be fixed by just fixing the header. I completely agree. IMHO in this case the header to be fixed is actually glibc's, since it declares ptrace in a different way than what is supported by the kernel. > Anyway, you should test this on a 64-bit platform. I have a strong > suspicion things will break there because of plain integers that are > being cast to void *. Good catch, that's what happened indeed. I don't know what would be the correct fix. I changed the types of the variables that are passed to ptrace from int to long. At least it hurts the eyes less than two casts in a row. These arguments are currently passed as int but glibc reads them as void * (with a va_arg (ap, void *) call). My impression is that on 64 bit Linux platforms the code currently works either by chance, or by relying on implementation-specific behavior. -- []'s Thiago Jung Bauermann Linaro Toolchain Working Group 2012-03-27 Thiago Jung Bauermann <thiago.bauermann@linaro.org> * linux-low.h (PTRACE_ARG3_TYPE): Move macro from linux-low.c. (PTRACE_ARG4_TYPE): Likewise. (PTRACE_XFER_TYPE): Likewise. * linux-arm-low.c (arm_prepare_to_resume): Cast third argument of ptrace to PTRACE_ARG3_TYPE. * linux-low.c (PTRACE_ARG3_TYPE): Move macro to linux-low.h. (PTRACE_ARG4_TYPE): Likewise. (PTRACE_XFER_TYPE): Likewise. (linux_detach_one_lwp): Cast fourth argument of ptrace to PTRACE_ARG4_TYPE. Change sig to long. (regsets_fetch_inferior_registers): Cast third argument of ptrace to PTRACE_ARG3_TYPE. Change nt_type to long. (regsets_store_inferior_registers): Likewise. diff --git a/gdb/gdbserver/linux-arm-low.c b/gdb/gdbserver/linux-arm-low.c index 01208ef..9490d7d 100644 --- a/gdb/gdbserver/linux-arm-low.c +++ b/gdb/gdbserver/linux-arm-low.c @@ -709,13 +709,15 @@ arm_prepare_to_resume (struct lwp_info *lwp) errno = 0; if (arm_hwbp_control_is_enabled (proc_info->bpts[i].control)) - if (ptrace (PTRACE_SETHBPREGS, pid, ((i << 1) + 1), - &proc_info->bpts[i].address) < 0) + if (ptrace (PTRACE_SETHBPREGS, pid, + (PTRACE_ARG3_TYPE) ((i << 1) + 1), + &proc_info->bpts[i].address) < 0) perror_with_name ("Unexpected error setting breakpoint address"); if (arm_hwbp_control_is_initialized (proc_info->bpts[i].control)) - if (ptrace (PTRACE_SETHBPREGS, pid, ((i << 1) + 2), - &proc_info->bpts[i].control) < 0) + if (ptrace (PTRACE_SETHBPREGS, pid, + (PTRACE_ARG3_TYPE) ((i << 1) + 2), + &proc_info->bpts[i].control) < 0) perror_with_name ("Unexpected error setting breakpoint"); lwp_info->bpts_changed[i] = 0; @@ -727,13 +729,15 @@ arm_prepare_to_resume (struct lwp_info *lwp) errno = 0; if (arm_hwbp_control_is_enabled (proc_info->wpts[i].control)) - if (ptrace (PTRACE_SETHBPREGS, pid, -((i << 1) + 1), - &proc_info->wpts[i].address) < 0) + if (ptrace (PTRACE_SETHBPREGS, pid, + (PTRACE_ARG3_TYPE) -((i << 1) + 1), + &proc_info->wpts[i].address) < 0) perror_with_name ("Unexpected error setting watchpoint address"); if (arm_hwbp_control_is_initialized (proc_info->wpts[i].control)) - if (ptrace (PTRACE_SETHBPREGS, pid, -((i << 1) + 2), - &proc_info->wpts[i].control) < 0) + if (ptrace (PTRACE_SETHBPREGS, pid, + (PTRACE_ARG3_TYPE) -((i << 1) + 2), + &proc_info->wpts[i].control) < 0) perror_with_name ("Unexpected error setting watchpoint"); lwp_info->wpts_changed[i] = 0; diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c index 1caff5a..52ae96c 100644 --- a/gdb/gdbserver/linux-low.c +++ b/gdb/gdbserver/linux-low.c @@ -239,10 +239,6 @@ struct pending_signals struct pending_signals *prev; }; -#define PTRACE_ARG3_TYPE void * -#define PTRACE_ARG4_TYPE void * -#define PTRACE_XFER_TYPE long - #ifdef HAVE_LINUX_REGSETS static char *disabled_regsets; static int num_regsets; @@ -1122,7 +1118,7 @@ linux_detach_one_lwp (struct inferior_list_entry *entry, void *args) struct thread_info *thread = (struct thread_info *) entry; struct lwp_info *lwp = get_thread_lwp (thread); int pid = * (int *) args; - int sig; + long sig; if (ptid_get_pid (entry->id) != pid) return 0; @@ -1149,7 +1145,7 @@ linux_detach_one_lwp (struct inferior_list_entry *entry, void *args) /* Finally, let it resume. */ if (the_low_target.prepare_to_resume != NULL) the_low_target.prepare_to_resume (lwp); - if (ptrace (PTRACE_DETACH, lwpid_of (lwp), 0, sig) < 0) + if (ptrace (PTRACE_DETACH, lwpid_of (lwp), 0, (PTRACE_ARG4_TYPE) sig) < 0) error (_("Can't detach %s: %s"), target_pid_to_str (ptid_of (lwp)), strerror (errno)); @@ -3968,7 +3964,7 @@ regsets_fetch_inferior_registers (struct regcache *regcache) while (regset->size >= 0) { void *buf, *data; - int nt_type, res; + long nt_type, res; if (regset->size == 0 || disabled_regsets[regset - target_regsets]) { @@ -3989,7 +3985,8 @@ regsets_fetch_inferior_registers (struct regcache *regcache) data = buf; #ifndef __sparc__ - res = ptrace (regset->get_request, pid, nt_type, data); + res = ptrace (regset->get_request, pid, + (PTRACE_ARG3_TYPE) nt_type, data); #else res = ptrace (regset->get_request, pid, data, nt_type); #endif @@ -4037,7 +4034,7 @@ regsets_store_inferior_registers (struct regcache *regcache) while (regset->size >= 0) { void *buf, *data; - int nt_type, res; + long nt_type, res; if (regset->size == 0 || disabled_regsets[regset - target_regsets]) { @@ -4062,7 +4059,8 @@ regsets_store_inferior_registers (struct regcache *regcache) data = buf; #ifndef __sparc__ - res = ptrace (regset->get_request, pid, nt_type, data); + res = ptrace (regset->get_request, pid, + (PTRACE_ARG3_TYPE) nt_type, data); #else res = ptrace (regset->get_request, pid, &iov, data); #endif @@ -4074,7 +4072,8 @@ regsets_store_inferior_registers (struct regcache *regcache) /* Only now do we write the register set. */ #ifndef __sparc__ - res = ptrace (regset->set_request, pid, nt_type, data); + res = ptrace (regset->set_request, pid, + (PTRACE_ARG3_TYPE) nt_type, data); #else res = ptrace (regset->set_request, pid, data, nt_type); #endif diff --git a/gdb/gdbserver/linux-low.h b/gdb/gdbserver/linux-low.h index 3aeae70..cb26ebb 100644 --- a/gdb/gdbserver/linux-low.h +++ b/gdb/gdbserver/linux-low.h @@ -24,6 +24,10 @@ #include "gdb_proc_service.h" +#define PTRACE_ARG3_TYPE void * +#define PTRACE_ARG4_TYPE void * +#define PTRACE_XFER_TYPE long + #ifdef HAVE_LINUX_REGSETS typedef void (*regset_fill_func) (struct regcache *, void *); typedef void (*regset_store_func) (struct regcache *, const void *); ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFA] handle android bionic ptrace in gdbserver. 2012-03-28 0:27 ` Thiago Jung Bauermann @ 2012-03-29 16:42 ` Pedro Alves 2012-03-30 20:29 ` Thiago Jung Bauermann 2012-03-29 17:02 ` sparc gdbserver bug? (Re: [RFA] handle android bionic ptrace in gdbserver.) Pedro Alves 1 sibling, 1 reply; 12+ messages in thread From: Pedro Alves @ 2012-03-29 16:42 UTC (permalink / raw) To: Thiago Jung Bauermann; +Cc: Mark Kettenis, gdb-patches On 03/28/2012 01:26 AM, Thiago Jung Bauermann wrote: > Hi Mark, > > On Tue, 2012-03-27 at 18:11 +0200, Mark Kettenis wrote: >>> > > From: Thiago Jung Bauermann <thiago.bauermann@linaro.org> >>> > > Date: Mon, 26 Mar 2012 19:46:42 -0300 >> > Sad to see all this compatibility goo just a different prototype. >> > This could almost certainly be fixed by just fixing the header. > I completely agree. IMHO in this case the header to be fixed is actually > glibc's, since it declares ptrace in a different way than what is > supported by the kernel. The kernel just supports the system call. The man page is really not a part of the kernel. It's a separately maintained project. >> > Anyway, you should test this on a 64-bit platform. I have a strong >> > suspicion things will break there because of plain integers that are >> > being cast to void *. > Good catch, that's what happened indeed. I don't know what would be the > correct fix. I changed the types of the variables that are passed to > ptrace from int to long. At least it hurts the eyes less than two casts > in a row. :-) Honestly, I'd prefer the double cast, in order to leave the ptrace arg type intricacy closest the the ptrace call as possible, instead of that care being spread and diluted about. It's also what other places in the code base already do (both gdb and gdbserver). -- Pedro Alves ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFA] handle android bionic ptrace in gdbserver. 2012-03-29 16:42 ` Pedro Alves @ 2012-03-30 20:29 ` Thiago Jung Bauermann 2012-04-23 18:53 ` Thiago Jung Bauermann 0 siblings, 1 reply; 12+ messages in thread From: Thiago Jung Bauermann @ 2012-03-30 20:29 UTC (permalink / raw) To: Pedro Alves; +Cc: Mark Kettenis, gdb-patches On Thu, 2012-03-29 at 17:42 +0100, Pedro Alves wrote: > On 03/28/2012 01:26 AM, Thiago Jung Bauermann wrote: > > Good catch, that's what happened indeed. I don't know what would be the > > correct fix. I changed the types of the variables that are passed to > > ptrace from int to long. At least it hurts the eyes less than two casts > > > in a row. > > :-) > > Honestly, I'd prefer the double cast, in order to leave the ptrace arg > type intricacy closest the the ptrace call as possible, instead of that care > being spread and diluted about. It's also what other places in the code > base already do (both gdb and gdbserver). Makes sense. I'm still wondering why the current code works on 64 bit Linux platforms though. Updated patch follows. -- []'s Thiago Jung Bauermann Linaro Toolchain Working Group 2012-03-30 Thiago Jung Bauermann <thiago.bauermann@linaro.org> * linux-low.h (PTRACE_ARG3_TYPE): Move macro from linux-low.c. (PTRACE_ARG4_TYPE): Likewise. (PTRACE_XFER_TYPE): Likewise. * linux-arm-low.c (arm_prepare_to_resume): Cast third argument of ptrace to PTRACE_ARG3_TYPE. * linux-low.c (PTRACE_ARG3_TYPE): Move macro to linux-low.h. (PTRACE_ARG4_TYPE): Likewise. (PTRACE_XFER_TYPE): Likewise. (linux_detach_one_lwp): Cast fourth argument of ptrace to long then PTRACE_ARG4_TYPE. (regsets_fetch_inferior_registers): Cast third argument of ptrace to long then PTRACE_ARG3_TYPE. (regsets_store_inferior_registers): Likewise. diff --git a/gdb/gdbserver/linux-arm-low.c b/gdb/gdbserver/linux-arm-low.c index bf1792b..c4d2000 100644 --- a/gdb/gdbserver/linux-arm-low.c +++ b/gdb/gdbserver/linux-arm-low.c @@ -709,13 +709,15 @@ arm_prepare_to_resume (struct lwp_info *lwp) errno = 0; if (arm_hwbp_control_is_enabled (proc_info->bpts[i].control)) - if (ptrace (PTRACE_SETHBPREGS, pid, ((i << 1) + 1), - &proc_info->bpts[i].address) < 0) + if (ptrace (PTRACE_SETHBPREGS, pid, + (PTRACE_ARG3_TYPE) ((i << 1) + 1), + &proc_info->bpts[i].address) < 0) perror_with_name ("Unexpected error setting breakpoint address"); if (arm_hwbp_control_is_initialized (proc_info->bpts[i].control)) - if (ptrace (PTRACE_SETHBPREGS, pid, ((i << 1) + 2), - &proc_info->bpts[i].control) < 0) + if (ptrace (PTRACE_SETHBPREGS, pid, + (PTRACE_ARG3_TYPE) ((i << 1) + 2), + &proc_info->bpts[i].control) < 0) perror_with_name ("Unexpected error setting breakpoint"); lwp_info->bpts_changed[i] = 0; @@ -727,13 +729,15 @@ arm_prepare_to_resume (struct lwp_info *lwp) errno = 0; if (arm_hwbp_control_is_enabled (proc_info->wpts[i].control)) - if (ptrace (PTRACE_SETHBPREGS, pid, -((i << 1) + 1), - &proc_info->wpts[i].address) < 0) + if (ptrace (PTRACE_SETHBPREGS, pid, + (PTRACE_ARG3_TYPE) -((i << 1) + 1), + &proc_info->wpts[i].address) < 0) perror_with_name ("Unexpected error setting watchpoint address"); if (arm_hwbp_control_is_initialized (proc_info->wpts[i].control)) - if (ptrace (PTRACE_SETHBPREGS, pid, -((i << 1) + 2), - &proc_info->wpts[i].control) < 0) + if (ptrace (PTRACE_SETHBPREGS, pid, + (PTRACE_ARG3_TYPE) -((i << 1) + 2), + &proc_info->wpts[i].control) < 0) perror_with_name ("Unexpected error setting watchpoint"); lwp_info->wpts_changed[i] = 0; diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c index 043451d..51f6801 100644 --- a/gdb/gdbserver/linux-low.c +++ b/gdb/gdbserver/linux-low.c @@ -241,10 +241,6 @@ struct pending_signals struct pending_signals *prev; }; -#define PTRACE_ARG3_TYPE void * -#define PTRACE_ARG4_TYPE void * -#define PTRACE_XFER_TYPE long - #ifdef HAVE_LINUX_REGSETS static char *disabled_regsets; static int num_regsets; @@ -1151,7 +1147,8 @@ linux_detach_one_lwp (struct inferior_list_entry *entry, void *args) /* Finally, let it resume. */ if (the_low_target.prepare_to_resume != NULL) the_low_target.prepare_to_resume (lwp); - if (ptrace (PTRACE_DETACH, lwpid_of (lwp), 0, sig) < 0) + if (ptrace (PTRACE_DETACH, lwpid_of (lwp), 0, + (PTRACE_ARG4_TYPE) (long) sig) < 0) error (_("Can't detach %s: %s"), target_pid_to_str (ptid_of (lwp)), strerror (errno)); @@ -3991,7 +3988,8 @@ regsets_fetch_inferior_registers (struct regcache *regcache) data = buf; #ifndef __sparc__ - res = ptrace (regset->get_request, pid, nt_type, data); + res = ptrace (regset->get_request, pid, + (PTRACE_ARG3_TYPE) (long) nt_type, data); #else res = ptrace (regset->get_request, pid, data, nt_type); #endif @@ -4064,7 +4062,8 @@ regsets_store_inferior_registers (struct regcache *regcache) data = buf; #ifndef __sparc__ - res = ptrace (regset->get_request, pid, nt_type, data); + res = ptrace (regset->get_request, pid, + (PTRACE_ARG3_TYPE) (long) nt_type, data); #else res = ptrace (regset->get_request, pid, data, nt_type); #endif @@ -4076,7 +4075,8 @@ regsets_store_inferior_registers (struct regcache *regcache) /* Only now do we write the register set. */ #ifndef __sparc__ - res = ptrace (regset->set_request, pid, nt_type, data); + res = ptrace (regset->set_request, pid, + (PTRACE_ARG3_TYPE) (long) nt_type, data); #else res = ptrace (regset->set_request, pid, data, nt_type); #endif diff --git a/gdb/gdbserver/linux-low.h b/gdb/gdbserver/linux-low.h index 07eda12..de4d1fa 100644 --- a/gdb/gdbserver/linux-low.h +++ b/gdb/gdbserver/linux-low.h @@ -24,6 +24,10 @@ #include "gdb_proc_service.h" +#define PTRACE_ARG3_TYPE void * +#define PTRACE_ARG4_TYPE void * +#define PTRACE_XFER_TYPE long + #ifdef HAVE_LINUX_REGSETS typedef void (*regset_fill_func) (struct regcache *, void *); typedef void (*regset_store_func) (struct regcache *, const void *); ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFA] handle android bionic ptrace in gdbserver. 2012-03-30 20:29 ` Thiago Jung Bauermann @ 2012-04-23 18:53 ` Thiago Jung Bauermann 2012-04-24 13:14 ` Pedro Alves 0 siblings, 1 reply; 12+ messages in thread From: Thiago Jung Bauermann @ 2012-04-23 18:53 UTC (permalink / raw) To: Pedro Alves; +Cc: Mark Kettenis, gdb-patches On Fri, 2012-03-30 at 17:28 -0300, Thiago Jung Bauermann wrote: > Updated patch follows. Ping. > 2012-03-30 Thiago Jung Bauermann <thiago.bauermann@linaro.org> > > * linux-low.h (PTRACE_ARG3_TYPE): Move macro from linux-low.c. > (PTRACE_ARG4_TYPE): Likewise. > (PTRACE_XFER_TYPE): Likewise. > * linux-arm-low.c (arm_prepare_to_resume): Cast third argument > of > ptrace to PTRACE_ARG3_TYPE. > * linux-low.c (PTRACE_ARG3_TYPE): Move macro to linux-low.h. > (PTRACE_ARG4_TYPE): Likewise. > (PTRACE_XFER_TYPE): Likewise. > (linux_detach_one_lwp): Cast fourth argument of > ptrace to long then PTRACE_ARG4_TYPE. > (regsets_fetch_inferior_registers): Cast third argument of > ptrace to long then PTRACE_ARG3_TYPE. > (regsets_store_inferior_registers): Likewise. > > > diff --git a/gdb/gdbserver/linux-arm-low.c > b/gdb/gdbserver/linux-arm-low.c > index bf1792b..c4d2000 100644 > --- a/gdb/gdbserver/linux-arm-low.c > +++ b/gdb/gdbserver/linux-arm-low.c > @@ -709,13 +709,15 @@ arm_prepare_to_resume (struct lwp_info *lwp) > errno = 0; > > if (arm_hwbp_control_is_enabled (proc_info->bpts[i].control)) > - if (ptrace (PTRACE_SETHBPREGS, pid, ((i << 1) + 1), > - &proc_info->bpts[i].address) < 0) > + if (ptrace (PTRACE_SETHBPREGS, pid, > + (PTRACE_ARG3_TYPE) ((i << 1) + 1), > + &proc_info->bpts[i].address) < 0) > perror_with_name ("Unexpected error setting breakpoint > address"); > > if (arm_hwbp_control_is_initialized > (proc_info->bpts[i].control)) > - if (ptrace (PTRACE_SETHBPREGS, pid, ((i << 1) + 2), > - &proc_info->bpts[i].control) < 0) > + if (ptrace (PTRACE_SETHBPREGS, pid, > + (PTRACE_ARG3_TYPE) ((i << 1) + 2), > + &proc_info->bpts[i].control) < 0) > perror_with_name ("Unexpected error setting breakpoint"); > > lwp_info->bpts_changed[i] = 0; > @@ -727,13 +729,15 @@ arm_prepare_to_resume (struct lwp_info *lwp) > errno = 0; > > if (arm_hwbp_control_is_enabled (proc_info->wpts[i].control)) > - if (ptrace (PTRACE_SETHBPREGS, pid, -((i << 1) + 1), > - &proc_info->wpts[i].address) < 0) > + if (ptrace (PTRACE_SETHBPREGS, pid, > + (PTRACE_ARG3_TYPE) -((i << 1) + 1), > + &proc_info->wpts[i].address) < 0) > perror_with_name ("Unexpected error setting watchpoint > address"); > > if (arm_hwbp_control_is_initialized > (proc_info->wpts[i].control)) > - if (ptrace (PTRACE_SETHBPREGS, pid, -((i << 1) + 2), > - &proc_info->wpts[i].control) < 0) > + if (ptrace (PTRACE_SETHBPREGS, pid, > + (PTRACE_ARG3_TYPE) -((i << 1) + 2), > + &proc_info->wpts[i].control) < 0) > perror_with_name ("Unexpected error setting watchpoint"); > > lwp_info->wpts_changed[i] = 0; > diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c > index 043451d..51f6801 100644 > --- a/gdb/gdbserver/linux-low.c > +++ b/gdb/gdbserver/linux-low.c > @@ -241,10 +241,6 @@ struct pending_signals > struct pending_signals *prev; > }; > > -#define PTRACE_ARG3_TYPE void * > -#define PTRACE_ARG4_TYPE void * > -#define PTRACE_XFER_TYPE long > - > #ifdef HAVE_LINUX_REGSETS > static char *disabled_regsets; > static int num_regsets; > @@ -1151,7 +1147,8 @@ linux_detach_one_lwp (struct inferior_list_entry > *entry, void *args) > /* Finally, let it resume. */ > if (the_low_target.prepare_to_resume != NULL) > the_low_target.prepare_to_resume (lwp); > - if (ptrace (PTRACE_DETACH, lwpid_of (lwp), 0, sig) < 0) > + if (ptrace (PTRACE_DETACH, lwpid_of (lwp), 0, > + (PTRACE_ARG4_TYPE) (long) sig) < 0) > error (_("Can't detach %s: %s"), > target_pid_to_str (ptid_of (lwp)), > strerror (errno)); > @@ -3991,7 +3988,8 @@ regsets_fetch_inferior_registers (struct > regcache *regcache) > data = buf; > > #ifndef __sparc__ > - res = ptrace (regset->get_request, pid, nt_type, data); > + res = ptrace (regset->get_request, pid, > + (PTRACE_ARG3_TYPE) (long) nt_type, data); > #else > res = ptrace (regset->get_request, pid, data, nt_type); > #endif > @@ -4064,7 +4062,8 @@ regsets_store_inferior_registers (struct > regcache *regcache) > data = buf; > > #ifndef __sparc__ > - res = ptrace (regset->get_request, pid, nt_type, data); > + res = ptrace (regset->get_request, pid, > + (PTRACE_ARG3_TYPE) (long) nt_type, data); > #else > res = ptrace (regset->get_request, pid, data, nt_type); > #endif > @@ -4076,7 +4075,8 @@ regsets_store_inferior_registers (struct > regcache *regcache) > > /* Only now do we write the register set. */ > #ifndef __sparc__ > - res = ptrace (regset->set_request, pid, nt_type, data); > + res = ptrace (regset->set_request, pid, > + (PTRACE_ARG3_TYPE) (long) nt_type, data); > #else > res = ptrace (regset->set_request, pid, data, nt_type); > #endif > diff --git a/gdb/gdbserver/linux-low.h b/gdb/gdbserver/linux-low.h > index 07eda12..de4d1fa 100644 > --- a/gdb/gdbserver/linux-low.h > +++ b/gdb/gdbserver/linux-low.h > @@ -24,6 +24,10 @@ > > #include "gdb_proc_service.h" > > +#define PTRACE_ARG3_TYPE void * > +#define PTRACE_ARG4_TYPE void * > +#define PTRACE_XFER_TYPE long > + > #ifdef HAVE_LINUX_REGSETS > typedef void (*regset_fill_func) (struct regcache *, void *); > typedef void (*regset_store_func) (struct regcache *, const void *); > -- []'s Thiago Jung Bauermann Linaro Toolchain Working Group ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFA] handle android bionic ptrace in gdbserver. 2012-04-23 18:53 ` Thiago Jung Bauermann @ 2012-04-24 13:14 ` Pedro Alves 2012-04-24 15:08 ` Thiago Jung Bauermann 0 siblings, 1 reply; 12+ messages in thread From: Pedro Alves @ 2012-04-24 13:14 UTC (permalink / raw) To: Thiago Jung Bauermann; +Cc: Mark Kettenis, gdb-patches On 04/23/2012 07:13 PM, Thiago Jung Bauermann wrote: > On Fri, 2012-03-30 at 17:28 -0300, Thiago Jung Bauermann wrote: >> Updated patch follows. > > Ping. Sorry, I thought I had replied already, but looks like I didn't. >> 2012-03-30 Thiago Jung Bauermann <thiago.bauermann@linaro.org> >> >> * linux-low.h (PTRACE_ARG3_TYPE): Move macro from linux-low.c. >> (PTRACE_ARG4_TYPE): Likewise. >> (PTRACE_XFER_TYPE): Likewise. >> * linux-arm-low.c (arm_prepare_to_resume): Cast third argument >> of >> ptrace to PTRACE_ARG3_TYPE. >> * linux-low.c (PTRACE_ARG3_TYPE): Move macro to linux-low.h. >> (PTRACE_ARG4_TYPE): Likewise. >> (PTRACE_XFER_TYPE): Likewise. >> (linux_detach_one_lwp): Cast fourth argument of >> ptrace to long then PTRACE_ARG4_TYPE. >> (regsets_fetch_inferior_registers): Cast third argument of >> ptrace to long then PTRACE_ARG3_TYPE. >> (regsets_store_inferior_registers): Likewise. Okay. -- Pedro Alves ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFA] handle android bionic ptrace in gdbserver. 2012-04-24 13:14 ` Pedro Alves @ 2012-04-24 15:08 ` Thiago Jung Bauermann 0 siblings, 0 replies; 12+ messages in thread From: Thiago Jung Bauermann @ 2012-04-24 15:08 UTC (permalink / raw) To: Pedro Alves; +Cc: Mark Kettenis, gdb-patches On 04/24/2012 09:16 AM, Pedro Alves wrote: > Sorry, I thought I had replied already, but looks like I didn't. No worries. > Okay. Committed. Thanks! -- []'s Thiago Jung Bauermann Linaro Toolchain Working Group ^ permalink raw reply [flat|nested] 12+ messages in thread
* sparc gdbserver bug? (Re: [RFA] handle android bionic ptrace in gdbserver.) 2012-03-28 0:27 ` Thiago Jung Bauermann 2012-03-29 16:42 ` Pedro Alves @ 2012-03-29 17:02 ` Pedro Alves 2012-03-29 17:23 ` H.J. Lu 1 sibling, 1 reply; 12+ messages in thread From: Pedro Alves @ 2012-03-29 17:02 UTC (permalink / raw) To: Thiago Jung Bauermann; +Cc: Mark Kettenis, gdb-patches, H.J. Lu On 03/28/2012 01:26 AM, Thiago Jung Bauermann wrote: > #ifndef __sparc__ > - res = ptrace (regset->get_request, pid, nt_type, data); > + res = ptrace (regset->get_request, pid, > + (PTRACE_ARG3_TYPE) nt_type, data); > #else > res = ptrace (regset->get_request, pid, &iov, data); > #endif BTW, I notice the __sparc__ branch here appears to be broken? (sparc has the last two ptrace arguments reversed...). $ git show d0aa472c commit d0aa472c6770baccb29dc37d0e64a81afda99911 Author: H.J. Lu <hjl.tools@gmail.com> Date: Wed Apr 7 18:49:43 2010 +0000 Add x86 AVX support to gdbserver. ... + + nt_type = regset->nt_type; + if (nt_type) + { + iov.iov_base = buf; + iov.iov_len = regset->size; + data = (void *) &iov; + } + else + data = buf; + #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 ? -- Pedro Alves ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: sparc gdbserver bug? (Re: [RFA] handle android bionic ptrace in gdbserver.) 2012-03-29 17:02 ` sparc gdbserver bug? (Re: [RFA] handle android bionic ptrace in gdbserver.) Pedro Alves @ 2012-03-29 17:23 ` H.J. Lu 2012-03-29 18:50 ` Pedro Alves 0 siblings, 1 reply; 12+ messages in thread From: H.J. Lu @ 2012-03-29 17:23 UTC (permalink / raw) To: Pedro Alves; +Cc: Thiago Jung Bauermann, Mark Kettenis, gdb-patches On Thu, Mar 29, 2012 at 10:02 AM, Pedro Alves <palves@redhat.com> wrote: > On 03/28/2012 01:26 AM, Thiago Jung Bauermann wrote: > >> #ifndef __sparc__ >> - res = ptrace (regset->get_request, pid, nt_type, data); >> + res = ptrace (regset->get_request, pid, >> + (PTRACE_ARG3_TYPE) nt_type, data); >> #else >> res = ptrace (regset->get_request, pid, &iov, data); >> #endif > > > BTW, I notice the __sparc__ branch here appears to be broken? > (sparc has the last two ptrace arguments reversed...). > > $ git show d0aa472c > commit d0aa472c6770baccb29dc37d0e64a81afda99911 > Author: H.J. Lu <hjl.tools@gmail.com> > Date: Wed Apr 7 18:49:43 2010 +0000 > > Add x86 AVX support to gdbserver. > ... > > + > + nt_type = regset->nt_type; > + if (nt_type) > + { > + iov.iov_base = buf; > + iov.iov_len = regset->size; > + data = (void *) &iov; > + } > + else > + data = buf; > + > #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. -- H.J. ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: sparc gdbserver bug? (Re: [RFA] handle android bionic ptrace in gdbserver.) 2012-03-29 17:23 ` H.J. Lu @ 2012-03-29 18:50 ` Pedro Alves 2012-03-29 21:29 ` Pedro Alves 0 siblings, 1 reply; 12+ messages in thread From: Pedro Alves @ 2012-03-29 18:50 UTC (permalink / raw) To: H.J. Lu; +Cc: Thiago Jung Bauermann, Mark Kettenis, gdb-patches 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. -- Pedro Alves ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: sparc gdbserver bug? (Re: [RFA] handle android bionic ptrace in gdbserver.) 2012-03-29 18:50 ` Pedro Alves @ 2012-03-29 21:29 ` Pedro Alves 0 siblings, 0 replies; 12+ messages in thread From: Pedro Alves @ 2012-03-29 21:29 UTC (permalink / raw) To: gdb-patches; +Cc: H.J. Lu, Thiago Jung Bauermann, Mark Kettenis 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) ^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2012-04-24 15:06 UTC | newest] Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2012-03-26 22:47 [RFA] handle android bionic ptrace in gdbserver Thiago Jung Bauermann 2012-03-27 16:12 ` Mark Kettenis 2012-03-28 0:27 ` Thiago Jung Bauermann 2012-03-29 16:42 ` Pedro Alves 2012-03-30 20:29 ` Thiago Jung Bauermann 2012-04-23 18:53 ` Thiago Jung Bauermann 2012-04-24 13:14 ` Pedro Alves 2012-04-24 15:08 ` Thiago Jung Bauermann 2012-03-29 17:02 ` sparc gdbserver bug? (Re: [RFA] handle android bionic ptrace in gdbserver.) Pedro Alves 2012-03-29 17:23 ` H.J. Lu 2012-03-29 18:50 ` Pedro Alves 2012-03-29 21:29 ` Pedro Alves
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox