From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11382 invoked by alias); 11 Jun 2012 13:42:50 -0000 Received: (qmail 11367 invoked by uid 22791); 11 Jun 2012 13:42:47 -0000 X-SWARE-Spam-Status: No, hits=-5.0 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,KHOP_RCVD_TRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE,TW_EG X-Spam-Check-By: sourceware.org Received: from mail-qa0-f48.google.com (HELO mail-qa0-f48.google.com) (209.85.216.48) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 11 Jun 2012 13:42:33 +0000 Received: by qady23 with SMTP id y23so2241324qad.14 for ; Mon, 11 Jun 2012 06:42:32 -0700 (PDT) MIME-Version: 1.0 Received: by 10.224.185.77 with SMTP id cn13mr8141856qab.38.1339422152608; Mon, 11 Jun 2012 06:42:32 -0700 (PDT) Received: by 10.229.192.129 with HTTP; Mon, 11 Jun 2012 06:42:32 -0700 (PDT) In-Reply-To: <201206102151.q5ALpxLu017724@glazunov.sibelius.xs4all.nl> References: <20120511181737.GP29339@adacore.com> <201205202043.q4KKhRGw022215@glazunov.sibelius.xs4all.nl> <201205202138.q4KLcWBf011913@glazunov.sibelius.xs4all.nl> <201205282026.q4SKQ737007589@glazunov.sibelius.xs4all.nl> <201206102151.q5ALpxLu017724@glazunov.sibelius.xs4all.nl> Date: Mon, 11 Jun 2012 13:42:00 -0000 Message-ID: Subject: Re: x32 ABI Support (was Re: Three weeks to branching (gdb 7.5 release)) From: "H.J. Lu" To: Mark Kettenis Cc: gdb-patches@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes 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-06/txt/msg00280.txt.bz2 On Sun, Jun 10, 2012 at 2:51 PM, Mark Kettenis wr= ote: >> Date: Thu, 31 May 2012 11:18:02 -0700 >> From: "H.J. Lu" >> >> > I think this is the wrong approach for x32 support. We should >> > break amd64_x32_init_abi into 2 parts: >> > >> > 1. OS specific part. =A0It should be private to amd64-tdep.c. > > There is no OS specific code in amd64-tdep.c. =A0Only code that > implements the generic OS-agnistic low-level ABI. > >> > 2. Generic part. =A0It should be exported from amd64-tdep.c and can >> > be used by all x32 OSes. > > Yes, and that entry point should be amd64_x32_init_abi(). =A0That is the > pattern that has been established, and I see no reason to deviate from > it. =A0So here is the diff I suggested before again with one change: it > moves most of the amd64 Linux support bits into its own function and > calls that from both amd64_linux_init_abi() and > amd64_x32_linux_init_abi(). =A0I'm sure some of those bits are wrong for > x32, but if you want to fix things up from that end, it is fine with > me. =A0The important bit that I care about is getting the inheritance > structure right. > > > Index: amd64-linux-tdep.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > RCS file: /cvs/src/src/gdb/amd64-linux-tdep.c,v > retrieving revision 1.50 > diff -u -p -r1.50 amd64-linux-tdep.c > --- amd64-linux-tdep.c =A012 May 2012 08:54:03 -0000 =A0 =A0 =A01.50 > +++ amd64-linux-tdep.c =A010 Jun 2012 21:39:08 -0000 > @@ -1288,41 +1288,12 @@ amd64_linux_core_read_description (struc > =A0} > > =A0static void > -amd64_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) > +amd64_linux_init_abi_common(struct gdbarch_info info, struct gdbarch *gd= barch) > =A0{ > =A0 struct gdbarch_tdep *tdep =3D gdbarch_tdep (gdbarch); > - =A0const struct target_desc *tdesc =3D info.target_desc; > - =A0struct tdesc_arch_data *tdesc_data =3D (void *) info.tdep_info; > - =A0const struct tdesc_feature *feature; > - =A0int valid_p; > - > - =A0gdb_assert (tdesc_data); > > =A0 linux_init_abi (info, gdbarch); > > - =A0tdep->gregset_reg_offset =3D amd64_linux_gregset_reg_offset; > - =A0tdep->gregset_num_regs =3D ARRAY_SIZE (amd64_linux_gregset_reg_offse= t); > - =A0tdep->sizeof_gregset =3D 27 * 8; > - > - =A0amd64_init_abi (info, gdbarch); > - > - =A0/* Reserve a number for orig_rax. =A0*/ > - =A0set_gdbarch_num_regs (gdbarch, AMD64_LINUX_NUM_REGS); > - > - =A0if (! tdesc_has_registers (tdesc)) > - =A0 =A0tdesc =3D tdesc_amd64_linux; > - =A0tdep->tdesc =3D tdesc; > - > - =A0feature =3D tdesc_find_feature (tdesc, "org.gnu.gdb.i386.linux"); > - =A0if (feature =3D=3D NULL) > - =A0 =A0return; > - > - =A0valid_p =3D tdesc_numbered_register (feature, tdesc_data, > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= AMD64_LINUX_ORIG_RAX_REGNUM, > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= "orig_rax"); > - =A0if (!valid_p) > - =A0 =A0return; > - > =A0 tdep->sigtramp_p =3D amd64_linux_sigtramp_p; > =A0 tdep->sigcontext_addr =3D amd64_linux_sigcontext_addr; > =A0 tdep->sc_reg_offset =3D amd64_linux_sc_reg_offset; > @@ -1330,10 +1301,6 @@ amd64_linux_init_abi (struct gdbarch_inf > > =A0 tdep->xsave_xcr0_offset =3D I386_LINUX_XSAVE_XCR0_OFFSET; > > - =A0/* GNU/Linux uses SVR4-style shared libraries. =A0*/ > - =A0set_solib_svr4_fetch_link_map_offsets > - =A0 =A0(gdbarch, svr4_lp64_fetch_link_map_offsets); > - > =A0 /* Add the %orig_rax register used for syscall restarting. =A0*/ > =A0 set_gdbarch_write_pc (gdbarch, amd64_linux_write_pc); > > @@ -1543,6 +1510,88 @@ amd64_linux_init_abi (struct gdbarch_inf > > =A0 tdep->i386_syscall_record =3D amd64_linux_syscall_record; > =A0} > + > +static void > +amd64_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) > +{ > + =A0struct gdbarch_tdep *tdep =3D gdbarch_tdep (gdbarch); > + =A0const struct target_desc *tdesc =3D info.target_desc; > + =A0struct tdesc_arch_data *tdesc_data =3D (void *) info.tdep_info; > + =A0const struct tdesc_feature *feature; > + =A0int valid_p; > + > + =A0gdb_assert (tdesc_data); > + > + =A0tdep->gregset_reg_offset =3D amd64_linux_gregset_reg_offset; > + =A0tdep->gregset_num_regs =3D ARRAY_SIZE (amd64_linux_gregset_reg_offse= t); > + =A0tdep->sizeof_gregset =3D 27 * 8; > + > + =A0amd64_init_abi (info, gdbarch); > + > + =A0/* Reserve a number for orig_rax. =A0*/ > + =A0set_gdbarch_num_regs (gdbarch, AMD64_LINUX_NUM_REGS); > + > + =A0if (! tdesc_has_registers (tdesc)) > + =A0 =A0tdesc =3D tdesc_amd64_linux; > + =A0tdep->tdesc =3D tdesc; > + > + =A0feature =3D tdesc_find_feature (tdesc, "org.gnu.gdb.i386.linux"); > + =A0if (feature =3D=3D NULL) > + =A0 =A0return; > + > + =A0valid_p =3D tdesc_numbered_register (feature, tdesc_data, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= AMD64_LINUX_ORIG_RAX_REGNUM, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= "orig_rax"); > + =A0if (!valid_p) > + =A0 =A0return; > + > + =A0amd64_linux_init_abi_common (info, gdbarch); > + > + =A0/* GNU/Linux uses SVR4-style shared libraries. =A0*/ > + =A0set_solib_svr4_fetch_link_map_offsets > + =A0 =A0(gdbarch, svr4_lp64_fetch_link_map_offsets); > +} > + > +static void > +amd64_x32_linux_init_abi(struct gdbarch_info info, struct gdbarch *gdbar= ch) > +{ > + =A0struct gdbarch_tdep *tdep =3D gdbarch_tdep (gdbarch); > + =A0const struct target_desc *tdesc =3D info.target_desc; > + =A0struct tdesc_arch_data *tdesc_data =3D (void *) info.tdep_info; > + =A0const struct tdesc_feature *feature; > + =A0int valid_p; > + > + =A0gdb_assert (tdesc_data); > + > + =A0tdep->gregset_reg_offset =3D amd64_linux_gregset_reg_offset; > + =A0tdep->gregset_num_regs =3D ARRAY_SIZE (amd64_linux_gregset_reg_offse= t); > + =A0tdep->sizeof_gregset =3D 27 * 8; > + > + =A0amd64_x32_init_abi (info, gdbarch); > + > + =A0/* Reserve a number for orig_rax. =A0*/ > + =A0set_gdbarch_num_regs (gdbarch, AMD64_LINUX_NUM_REGS); > + > + =A0if (! tdesc_has_registers (tdesc)) > + =A0 =A0tdesc =3D tdesc_x32_linux; > + =A0tdep->tdesc =3D tdesc; > + > + =A0feature =3D tdesc_find_feature (tdesc, "org.gnu.gdb.i386.linux"); > + =A0if (feature =3D=3D NULL) > + =A0 =A0return; > + > + =A0valid_p =3D tdesc_numbered_register (feature, tdesc_data, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= AMD64_LINUX_ORIG_RAX_REGNUM, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= "orig_rax"); > + =A0if (!valid_p) > + =A0 =A0return; > + > + =A0amd64_linux_init_abi_common (info, gdbarch); > + > + =A0/* GNU/Linux uses SVR4-style shared libraries. =A0*/ > + =A0set_solib_svr4_fetch_link_map_offsets > + =A0 =A0(gdbarch, svr4_ilp32_fetch_link_map_offsets); > +} > > > =A0/* Provide a prototype to silence -Wmissing-prototypes. =A0*/ > @@ -1553,6 +1602,8 @@ _initialize_amd64_linux_tdep (void) > =A0{ > =A0 gdbarch_register_osabi (bfd_arch_i386, bfd_mach_x86_64, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0GDB_OSABI_LINUX, amd64= _linux_init_abi); > + =A0gdbarch_register_osabi (bfd_arch_i386, bfd_mach_x64_32, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 GDB_OSABI_LINUX, amd64_= x32_linux_init_abi); > > =A0 /* Initialize the Linux target description. =A0*/ > =A0 initialize_tdesc_amd64_linux (); > Index: amd64-tdep.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > RCS file: /cvs/src/src/gdb/amd64-tdep.c,v > retrieving revision 1.104 > diff -u -p -r1.104 amd64-tdep.c > --- amd64-tdep.c =A0 =A0 =A0 =A014 May 2012 18:56:40 -0000 =A0 =A0 =A01.1= 04 > +++ amd64-tdep.c =A0 =A0 =A0 =A010 Jun 2012 21:39:09 -0000 > @@ -258,7 +258,8 @@ static const char *amd64_word_names[] =3D > =A0static const char *amd64_dword_names[] =3D > =A0{ > =A0 "eax", "ebx", "ecx", "edx", "esi", "edi", "ebp", "esp", > - =A0"r8d", "r9d", "r10d", "r11d", "r12d", "r13d", "r14d", "r15d" > + =A0"r8d", "r9d", "r10d", "r11d", "r12d", "r13d", "r14d", "r15d", > + =A0"eip" > =A0}; > > =A0/* Return the name of register REGNUM. =A0*/ > @@ -2729,6 +2730,43 @@ amd64_init_abi (struct gdbarch_info info > =A0 set_gdbarch_stap_parse_special_token (gdbarch, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0i386_stap_parse_special_token); > =A0} > + > + > +static struct type * > +amd64_x32_pseudo_register_type (struct gdbarch *gdbarch, int regnum) > +{ > + =A0struct gdbarch_tdep *tdep =3D gdbarch_tdep (gdbarch); > + > + =A0switch (regnum - tdep->eax_regnum) > + =A0 =A0{ > + =A0 =A0case AMD64_RBP_REGNUM: =A0 =A0 /* %ebp */ > + =A0 =A0case AMD64_RSP_REGNUM: =A0 =A0 /* %esp */ > + =A0 =A0 =A0return builtin_type (gdbarch)->builtin_data_ptr; > + =A0 =A0case AMD64_RIP_REGNUM: =A0 =A0 /* %eip */ > + =A0 =A0 =A0return builtin_type (gdbarch)->builtin_func_ptr; > + =A0 =A0} > + > + =A0return i386_pseudo_register_type (gdbarch, regnum); > +} > + > +void > +amd64_x32_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) > +{ > + =A0struct gdbarch_tdep *tdep =3D gdbarch_tdep (gdbarch); > + =A0const struct target_desc *tdesc =3D info.target_desc; > + > + =A0amd64_init_abi (info, gdbarch); > + > + =A0if (! tdesc_has_registers (tdesc)) > + =A0 =A0tdesc =3D tdesc_x32; > + =A0tdep->tdesc =3D tdesc; > + > + =A0tdep->num_dword_regs =3D 17; > + =A0set_tdesc_pseudo_register_type (gdbarch, amd64_x32_pseudo_register_t= ype); > + > + =A0set_gdbarch_long_bit (gdbarch, 32); > + =A0set_gdbarch_ptr_bit (gdbarch, 32); > +} > > =A0/* Provide a prototype to silence -Wmissing-prototypes. =A0*/ > =A0void _initialize_amd64_tdep (void); > Index: amd64-tdep.h > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > RCS file: /cvs/src/src/gdb/amd64-tdep.h,v > retrieving revision 1.21 > diff -u -p -r1.21 amd64-tdep.h > --- amd64-tdep.h =A0 =A0 =A0 =A04 Jan 2012 08:16:56 -0000 =A0 =A0 =A0 1.21 > +++ amd64-tdep.h =A0 =A0 =A0 =A010 Jun 2012 21:39:09 -0000 > @@ -80,6 +80,8 @@ extern void amd64_displaced_step_fixup ( > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0struct regcache *regs); > > =A0extern void amd64_init_abi (struct gdbarch_info info, struct gdbarch *= gdbarch); > +extern void amd64_x32_init_abi (struct gdbarch_info info, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 struct gdba= rch *gdbarch); > > =A0/* Fill register REGNUM in REGCACHE with the appropriate > =A0 =A0floating-point or SSE register value from *FXSAVE. =A0If REGNUM is > > It works with the following patch. Can you check it in? Thanks. --=20 H.J. --- diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index 5b04505..9cc2e30 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -2780,7 +2780,7 @@ i386_mmx_type (struct gdbarch *gdbarch) /* Return the GDB type object for the "standard" data type of data in register REGNUM. */ -static struct type * +struct type * i386_pseudo_register_type (struct gdbarch *gdbarch, int regnum) { if (i386_mmx_regnum_p (gdbarch, regnum)) diff --git a/gdb/i386-tdep.h b/gdb/i386-tdep.h index f297ae7..e1f7c44 100644 --- a/gdb/i386-tdep.h +++ b/gdb/i386-tdep.h @@ -307,6 +315,7 @@ extern int i386_dword_regnum_p (struct gdbarch *gdbarch, int regnum); extern int i386_xmm_regnum_p (struct gdbarch *gdbarch, int regnum); extern int i386_ymm_regnum_p (struct gdbarch *gdbarch, int regnum); +extern struct type *i386_pseudo_register_type (struct gdbarch *, int); extern const char *i386_pseudo_register_name (struct gdbarch *gdbarch, int regnum);