From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18579 invoked by alias); 27 Mar 2012 16:12:17 -0000 Received: (qmail 18566 invoked by uid 22791); 27 Mar 2012 16:12:14 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_00,TW_EG,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from sibelius.xs4all.nl (HELO glazunov.sibelius.xs4all.nl) (83.163.83.176) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 27 Mar 2012 16:12:00 +0000 Received: from glazunov.sibelius.xs4all.nl (kettenis@localhost [127.0.0.1]) by glazunov.sibelius.xs4all.nl (8.14.5/8.14.3) with ESMTP id q2RGBukt006247; Tue, 27 Mar 2012 18:11:56 +0200 (CEST) Received: (from kettenis@localhost) by glazunov.sibelius.xs4all.nl (8.14.5/8.14.3/Submit) id q2RGBs2N025666; Tue, 27 Mar 2012 18:11:54 +0200 (CEST) Date: Tue, 27 Mar 2012 16:12:00 -0000 Message-Id: <201203271611.q2RGBs2N025666@glazunov.sibelius.xs4all.nl> From: Mark Kettenis To: thiago.bauermann@linaro.org CC: gdb-patches@sourceware.org In-reply-to: <1332802002.30339.16.camel@hactar> (message from Thiago Jung Bauermann on Mon, 26 Mar 2012 19:46:42 -0300) Subject: Re: [RFA] handle android bionic ptrace in gdbserver. References: <1332802002.30339.16.camel@hactar> Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-03/txt/msg00912.txt.bz2 > From: Thiago Jung Bauermann > 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 > > * 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 *); > > >