[PATCH 2/3] Use PTRACE_PEEKUSER to get fs_base/gs_base for x32

H.J. Lu hjl.tools@gmail.com
Tue Jun 26 14:43:00 GMT 2012


On Tue, Jun 26, 2012 at 7:06 AM, Mark Kettenis <mark.kettenis@xs4all.nl> wrote:
>> Date: Tue, 26 Jun 2012 05:48:09 -0700
>> From: "H.J. Lu" <hjl.tools@gmail.com>
>>
>> On Tue, Jun 26, 2012 at 4:31 AM, Mark Kettenis <mark.kettenis@xs4all.nl> wrote:
>> >> Date: Thu, 21 Jun 2012 11:59:36 -0700
>> >> From: "H.J. Lu" <hongjiu.lu@intel.com>
>> >>
>> >> On Thu, Jun 21, 2012 at 11:15:29AM -0700, H.J. Lu wrote:
>> >> > PTRACE_ARCH_PRCTL is obsolete since 2.6.25, where the fs_base and gs_base
>> >> > fields of user_regs_struct can be used directly.  Since x32 support was
>> >> > added to kernel 3.4.0 and PTRACE_ARCH_PRCTL support was removed for x32,
>> >> > we should always use fs_base/gs_base for x32.  OK to install? We
>> >> >
>> >> > Thanks.
>> >>
>> >> Here is a better patch to use the fs_base and gs_base fields of
>> >> struct user_regs_struct to get fs/gs base.  OK to install?
>> >>
>> >> Thanks.
>> >>
>> >>
>> >> H.J.
>> >> ---
>> >> 2012-06-16  Roland McGrath  <roland@hack.frob.com>
>> >>           H.J. Lu  <hongjiu.lu@intel.com>
>> >>
>> >>       * amd64-linux-nat.c: Include <sys/user.h> if
>> >>       HAVE_STRUCT_USER_REGS_STRUCT_FS_BASE or
>> >>       HAVE_STRUCT_USER_REGS_STRUCT_GS_BASE is defined.
>> >>       (ps_get_thread_area): Use PTRACE_PEEKUSER to get fs_base/gs_base
>> >>       if HAVE_STRUCT_USER_REGS_STRUCT_FS_BASE or
>> >>       HAVE_STRUCT_USER_REGS_STRUCT_GS_BASE is defined.
>> >>
>> >>       * configure.ac: Check if the fs_base and gs_base members of
>> >>       `struct user_regs_struct' exist.
>> >>       * config.in: Regenerated.
>> >>       * configure: Likewise.
>> >>
>> >> diff --git a/gdb/amd64-linux-nat.c b/gdb/amd64-linux-nat.c
>> >> index 23eadbd..781456f 100644
>> >> --- a/gdb/amd64-linux-nat.c
>> >> +++ b/gdb/amd64-linux-nat.c
>> >> @@ -34,6 +34,10 @@
>> >>  #include <sys/debugreg.h>
>> >>  #include <sys/syscall.h>
>> >>  #include <sys/procfs.h>
>> >> +#if defined HAVE_STRUCT_USER_REGS_STRUCT_FS_BASE \
>> >> +    || defined HAVE_STRUCT_USER_REGS_STRUCT_GS_BASE
>> >> +#include <sys/user.h>
>> >> +#endif
>> >
>> > Any reason to not just unconditionally include <sys/user.h>?
>> >
>>
>> I can include  <sys/user.h> unconditionally.  OK to install
>> with this change?
>
> Yes.
>

Done.  Thanks.


-- 
H.J.



More information about the Gdb-patches mailing list