From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25498 invoked by alias); 20 May 2012 22:49:14 -0000 Received: (qmail 25483 invoked by uid 22791); 20 May 2012 22:49:11 -0000 X-SWARE-Spam-Status: No, hits=-4.9 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; Sun, 20 May 2012 22:48:55 +0000 Received: by qady23 with SMTP id y23so1605307qad.14 for ; Sun, 20 May 2012 15:48:54 -0700 (PDT) MIME-Version: 1.0 Received: by 10.229.135.10 with SMTP id l10mr9508836qct.6.1337554134593; Sun, 20 May 2012 15:48:54 -0700 (PDT) Received: by 10.229.169.130 with HTTP; Sun, 20 May 2012 15:48:54 -0700 (PDT) In-Reply-To: <201205202138.q4KLcWBf011913@glazunov.sibelius.xs4all.nl> References: <20120511181737.GP29339@adacore.com> <201205202043.q4KKhRGw022215@glazunov.sibelius.xs4all.nl> <201205202138.q4KLcWBf011913@glazunov.sibelius.xs4all.nl> Date: Sun, 20 May 2012 22:49:00 -0000 Message-ID: Subject: Re: Three weeks to branching (gdb 7.5 release) From: "H.J. Lu" To: Mark Kettenis Cc: brobecker@adacore.com, 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-05/txt/msg00755.txt.bz2 On Sun, May 20, 2012 at 2:38 PM, Mark Kettenis wr= ote: >> Date: Sun, 20 May 2012 14:24:46 -0700 >> From: "H.J. Lu" >> >> On Sun, May 20, 2012 at 1:43 PM, Mark Kettenis = wrote: >> >> Date: Sun, 20 May 2012 08:40:26 -0700 >> >> From: "H.J. Lu" >> >> >> >> On Fri, May 11, 2012 at 11:43 AM, H.J. Lu wrote: >> >> > On Fri, May 11, 2012 at 11:17 AM, Joel Brobecker wrote: >> >> >> Hello, >> >> >> >> >> >> Just a quick heads up: The current tentative date for branching >> >> >> GDB (7.5 release) is Mon Jun 4th, which is a little over three wee= ks >> >> >> away. >> >> >> >> >> >> I've created a wiki page for known issues that need to be fixed >> >> >> before then: >> >> >> >> >> >> =E1 =E1http://sourceware.org/gdb/wiki/GDB_7.5_Release >> >> >> >> >> >> When you add an issue, please make sure you add a name so we know >> >> >> who is coordinating the effort. =E1If you don't know who can work >> >> >> on it, please just post the issue here, and we'll try to find some >> >> >> help. >> >> >> >> >> >> I only know of one issue, which is a noticeable performance degrad= ation >> >> >> that was reported a while ago: >> >> >> >> >> > >> >> > I'd like to merge x32 into GDB 7.5. =E1My x32 change is on hjl/x32/= master >> >> > branch at >> >> > >> >> > http://sourceware.org/git/?p=3Dgdb.git;a=3Dsummary >> >> > >> >> > The current diff only has 864 lines. =E1One patch: >> >> > >> >> > http://sourceware.org/ml/gdb-patches/2012-05/msg00097.html >> >> > >> >> > isn't reviewed yet. =E1I will open a meta bug for x32 integration. >> >> > >> >> >> >> I opened: >> >> >> >> http://sourceware.org/bugzilla/show_bug.cgi?id=3D14099 >> >> >> >> Thanks for help from everyone. =E1The full GDBserver x32 support >> >> as well as partial GDB x32 support have been checked in. =E1The >> >> remaining patches are: >> >> >> >> http://sourceware.org/ml/gdb-patches/2012-04/msg00195.html >> >> http://sourceware.org/ml/gdb-patches/2012-04/msg00191.html >> >> http://sourceware.org/ml/gdb-patches/2012-05/msg00744.html >> >> http://sourceware.org/ml/gdb-patches/2012-05/msg00531.html >> >> http://sourceware.org/ml/gdb-patches/2012-05/msg00533.html >> >> http://sourceware.org/ml/gdb-patches/2012-05/msg00489.html >> >> http://sourceware.org/ml/gdb-patches/2012-05/msg00438.html >> >> http://sourceware.org/ml/gdb-patches/2012-05/msg00097.html >> >> >> >> I would appreciate help to get them reviewed and approved. >> > >> > As I wrote before, I don't think adding lots if if-statements is the >> > proper way to add a new ABI to GDB. =E1The proper way is to do it like >> > the diff below. =E1In that diff, I'm not entirely confident that calli= ng >> > amd64_linux_init_abi() from amd64_x32_linux_init_abi() makes all that >> > much sense. =E1For example the amd64_linux_record_tdep stuff probably >> > isn't right for the x32 ABI. =E1But at least this will give us a >> > starting point where we won't end up adding >> > >> > =E1if (gdbarch_ptr_bit (gdbarch) =3D=3D 32) >> > =E1 =E1{ >> > =E1 =E1 =E1... >> > =E1 =E1} >> >> Please take a look at >> >> http://sourceware.org/ml/gdb-patches/2012-04/msg00195.html >> >> It doesn't add any =A0(gdbarch_ptr_bit (gdbarch) =3D=3D 32). =A0It just = changes >> it to bits_per_word. =A0I add one =A0"gdbarch_ptr_bit (gdbarch) =3D=3D 3= 2" in >> amd64_linux_sigtramp_start and I will remove them from >> >> http://sourceware.org/ml/gdb-patches/2012-05/msg00744.html > > Well, I'm also thining about the future here. =A0Stuff you haven't > addressed yet in your diff series and stuff that will be added later. > >> > 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 =E112 May 2012 08:54:03 -0000 =E1 =E1 =E11.50 >> > +++ amd64-linux-tdep.c =E120 May 2012 20:31:53 -0000 >> > @@ -1543,6 +1543,24 @@ amd64_linux_init_abi (struct gdbarch_inf >> > >> > =E1 tdep->i386_syscall_record =3D amd64_linux_syscall_record; >> > =E1} >> > + >> > +static void >> > +amd64_x32_linux_init_abi(struct gdbarch_info info, struct gdbarch *gd= barch) >> > +{ >> > + =E1struct gdbarch_tdep *tdep =3D gdbarch_tdep (gdbarch); >> > + =E1const struct target_desc *tdesc =3D info.target_desc; >> > + >> > + =E1amd64_linux_init_abi (info, gdbarch); >> > + =E1amd64_x32_init_abi (info, gdbarch); >> > + >> > + =E1if (! tdesc_has_registers (tdesc)) >> > + =E1 =E1tdesc =3D tdesc_amd64_linux; >> >> I assume you meant tdesc_x32_linux here. =A0The problem is >> when we reach here, if (! tdesc_has_registers (tdesc)) will always >> be false since tdep->tdesc has been set by amd64_linux_init_abi. >> >> > + =E1tdep->tdesc =3D tdesc; >> > + >> > + =E1/* GNU/Linux uses SVR4-style shared libraries. =E1*/ >> > + =E1set_solib_svr4_fetch_link_map_offsets >> > + =E1 =E1(gdbarch, svr4_ilp32_fetch_link_map_offsets); >> > +} >> > >> > >> > =E1/* Provide a prototype to silence -Wmissing-prototypes. =E1*/ >> > @@ -1553,6 +1571,8 @@ _initialize_amd64_linux_tdep (void) >> > =E1{ >> > =E1 gdbarch_register_osabi (bfd_arch_i386, bfd_mach_x86_64, >> > =E1 =E1 =E1 =E1 =E1 =E1 =E1 =E1 =E1 =E1 =E1 =E1 =E1GDB_OSABI_LINUX, am= d64_linux_init_abi); >> > + =E1gdbarch_register_osabi (bfd_arch_i386, bfd_mach_x64_32, >> > + =E1 =E1 =E1 =E1 =E1 =E1 =E1 =E1 =E1 =E1 =E1 =E1 GDB_OSABI_LINUX, amd= 64_x32_linux_init_abi); >> > >> > =E1 /* Initialize the Linux target description. =E1*/ >> > =E1 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 =E1 =E1 =E1 =E114 May 2012 18:56:40 -0000 =E1 =E1 =E1= 1.104 >> > +++ amd64-tdep.c =E1 =E1 =E1 =E120 May 2012 20:31:54 -0000 >> > @@ -258,7 +258,8 @@ static const char *amd64_word_names[] =3D >> > =E1static const char *amd64_dword_names[] =3D >> > =E1{ >> > =E1 "eax", "ebx", "ecx", "edx", "esi", "edi", "ebp", "esp", >> > - =E1"r8d", "r9d", "r10d", "r11d", "r12d", "r13d", "r14d", "r15d" >> > + =E1"r8d", "r9d", "r10d", "r11d", "r12d", "r13d", "r14d", "r15d", >> > + =E1"eip" >> > =E1}; >> > >> > =E1/* Return the name of register REGNUM. =E1*/ >> > @@ -2729,6 +2730,43 @@ amd64_init_abi (struct gdbarch_info info >> > =E1 set_gdbarch_stap_parse_special_token (gdbarch, >> > =E1 =E1 =E1 =E1 =E1 =E1 =E1 =E1 =E1 =E1 =E1 =E1 =E1 =E1 =E1 =E1 =E1 = =E1 =E1 =E1i386_stap_parse_special_token); >> > =E1} >> > + >> > + >> > +static struct type * >> > +amd64_x32_pseudo_register_type (struct gdbarch *gdbarch, int regnum) >> > +{ >> > + =E1struct gdbarch_tdep *tdep =3D gdbarch_tdep (gdbarch); >> > + >> > + =E1switch (regnum - tdep->eax_regnum) >> > + =E1 =E1{ >> > + =E1 =E1case AMD64_RBP_REGNUM: =E1 =E1 /* %ebp */ >> > + =E1 =E1case AMD64_RSP_REGNUM: =E1 =E1 /* %esp */ >> > + =E1 =E1 =E1return builtin_type (gdbarch)->builtin_data_ptr; >> > + =E1 =E1case AMD64_RIP_REGNUM: =E1 =E1 /* %eip */ >> > + =E1 =E1 =E1return builtin_type (gdbarch)->builtin_func_ptr; >> > + =E1 =E1} >> > + >> > + =E1return i386_pseudo_register_type (gdbarch, regnum); >> > +} >> > + >> > +void >> > +amd64_x32_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) >> > +{ >> > + =E1struct gdbarch_tdep *tdep =3D gdbarch_tdep (gdbarch); >> > + =E1const struct target_desc *tdesc =3D info.target_desc; >> > + >> > + =E1amd64_init_abi (info, gdbarch); >> > + >> > + =E1if (! tdesc_has_registers (tdesc)) >> > + =E1 =E1tdesc =3D tdesc_x32; >> >> Again, " if (! tdesc_has_registers (tdesc))" will always false >> since tdep->tdesc has been set in amd64_init_abi. > > I don't think that's true. =A0Here tdesc comes from info.target_desc, > not tdep->tdesc, so the check should still do the right thing. =A0In > fact it must do the right thing, since amd64_linux_init_abi() does the > same thing already. Does this one look OK. I extracted x32_init_abi from amd64_x32_init_abi since amd64_x32_linux_init_abi can't call amd64_init_abi after calling amd64_linux_init_abi. Thanks. --=20 H.J. --- 2012-05-20 Mark Kettenis H.J. Lu * amd64-linux-tdep.c (amd64_x32_linux_init_abi): New functiom. (_initialize_amd64_linux_tdep): Register bfd_mach_x64_32 with amd64_x32_linux_init_abi. * amd64-tdep.c (amd64_x32_pseudo_register_type): New function. (amd64_x32_pseudo_register_name): Likewise. (x32_init_abi): Likewise. (amd64_x32_init_abi): Likewise. * amd64-tdep.h (amd64_x32_init_abi): New prototype. (x32_init_abi): Likewise. * i386-tdep.c (i386_pseudo_register_type): Make it global. (i386_gdbarch_init): Initialize sp_regnum_from_eax and pc_regnum_from_eax to -1. Update SP regnum from sp_regnum_from_eax and PC regnum from pc_regnum_from_eax if needed. * i386-tdep.h (gdbarch_tdep): Add sp_regnum_from_eax and pc_regnum_from_eax. (i386_pseudo_register_type): New prototype. diff --git a/gdb/amd64-linux-tdep.c b/gdb/amd64-linux-tdep.c index 22a3464..470680d 100644 --- a/gdb/amd64-linux-tdep.c +++ b/gdb/amd64-linux-tdep.c @@ -1543,6 +1558,26 @@ amd64_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) tdep->i386_syscall_record =3D amd64_linux_syscall_record; } + +static void +amd64_x32_linux_init_abi (struct gdbarch_info info, + struct gdbarch *gdbarch) +{ + struct gdbarch_tdep *tdep =3D gdbarch_tdep (gdbarch); + const struct target_desc *tdesc =3D info.target_desc; + + amd64_linux_init_abi (info, gdbarch); + + if (! tdesc_has_registers (tdesc)) + tdesc =3D tdesc_amd64_linux; + tdep->tdesc =3D tdesc; + + x32_init_abi (gdbarch); + + /* GNU/Linux uses SVR4-style shared libraries. */ + set_solib_svr4_fetch_link_map_offsets + (gdbarch, svr4_ilp32_fetch_link_map_offsets); +} /* Provide a prototype to silence -Wmissing-prototypes. */ @@ -1553,6 +1588,8 @@ _initialize_amd64_linux_tdep (void) { gdbarch_register_osabi (bfd_arch_i386, bfd_mach_x86_64, GDB_OSABI_LINUX, amd64_linux_init_abi); + gdbarch_register_osabi (bfd_arch_i386, bfd_mach_x64_32, + GDB_OSABI_LINUX, amd64_x32_linux_init_abi); /* Initialize the Linux target description. */ initialize_tdesc_amd64_linux (); diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c index df91a51..efa9f5e 100644 --- a/gdb/amd64-tdep.c +++ b/gdb/amd64-tdep.c @@ -261,6 +261,28 @@ static const char *amd64_dword_names[] =3D "r8d", "r9d", "r10d", "r11d", "r12d", "r13d", "r14d", "r15d" }; +/* Return the GDB type object for the "standard" data type of data in + register REGNUM. Only used for x32. */ + +static struct type * +amd64_x32_pseudo_register_type (struct gdbarch *gdbarch, int regnum) +{ + /* Use pointer types for ebp, esp and eip registers in x32. */ + struct gdbarch_tdep *tdep =3D gdbarch_tdep (gdbarch); + switch (regnum - tdep->eax_regnum) + { + default: + break; + case AMD64_RBP_REGNUM: /* ebp */ + case AMD64_RSP_REGNUM: /* esp */ + return builtin_type (gdbarch)->builtin_data_ptr; + case AMD64_RIP_REGNUM: /* eip */ + return builtin_type (gdbarch)->builtin_func_ptr; + } + + return i386_pseudo_register_type (gdbarch, regnum); +} + /* Return the name of register REGNUM. */ static const char * @@ -279,6 +301,17 @@ amd64_pseudo_register_name (struct gdbarch *gdbarch, int regnum) return i386_pseudo_register_name (gdbarch, regnum); } +/* Return the name of register REGNUM. Only used for x32. */ + +static const char * +amd64_x32_pseudo_register_name (struct gdbarch *gdbarch, int regnum) +{ + struct gdbarch_tdep *tdep =3D gdbarch_tdep (gdbarch); + if ((regnum - tdep->eax_regnum) =3D=3D AMD64_RIP_REGNUM) + return "eip"; + return amd64_pseudo_register_name (gdbarch, regnum); +} + static struct value * amd64_pseudo_register_read_value (struct gdbarch *gdbarch, struct regcache *regcache, @@ -2730,6 +2803,37 @@ amd64_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) i386_stap_parse_special_token); } +void +x32_init_abi (struct gdbarch *gdbarch) +{ + struct gdbarch_tdep *tdep =3D gdbarch_tdep (gdbarch); + + tdep->num_dword_regs =3D 17; + tdep->sp_regnum_from_eax =3D AMD64_RSP_REGNUM; + tdep->pc_regnum_from_eax =3D AMD64_RIP_REGNUM; + + set_tdesc_pseudo_register_type (gdbarch, amd64_x32_pseudo_register_type); + set_tdesc_pseudo_register_name (gdbarch, amd64_x32_pseudo_register_name); + + set_gdbarch_long_bit (gdbarch, 32); + set_gdbarch_ptr_bit (gdbarch, 32); +} + +void +amd64_x32_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) +{ + struct gdbarch_tdep *tdep =3D gdbarch_tdep (gdbarch); + const struct target_desc *tdesc =3D info.target_desc; + + amd64_init_abi (info, gdbarch); + + if (! tdesc_has_registers (tdesc)) + tdesc =3D tdesc_x32; + tdep->tdesc =3D tdesc; + + x32_init_abi (gdbarch); +} + /* Provide a prototype to silence -Wmissing-prototypes. */ void _initialize_amd64_tdep (void); diff --git a/gdb/amd64-tdep.h b/gdb/amd64-tdep.h index 1ed109c..401b379 100644 --- a/gdb/amd64-tdep.h +++ b/gdb/amd64-tdep.h @@ -80,6 +80,9 @@ extern void amd64_displaced_step_fixup (struct gdbarch *gdbarch, struct regcache *regs); extern void amd64_init_abi (struct gdbarch_info info, struct gdbarch *gdba= rch); +extern void amd64_x32_init_abi (struct gdbarch_info info, + struct gdbarch *gdbarch); +extern void x32_init_abi (struct gdbarch *gdbarch); /* Fill register REGNUM in REGCACHE with the appropriate floating-point or SSE register value from *FXSAVE. If REGNUM is 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)) @@ -7787,6 +7787,9 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) tdep->num_mmx_regs =3D 8; tdep->num_ymm_regs =3D 0; + tdep->sp_regnum_from_eax =3D -1; + tdep->pc_regnum_from_eax =3D -1; + tdesc_data =3D tdesc_data_alloc (); set_gdbarch_relocate_instruction (gdbarch, i386_relocate_instruction); @@ -7831,6 +7834,14 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) /* Support dword pseudo-register if it hasn't been disabled. */ tdep->eax_regnum =3D ymm0_regnum; ymm0_regnum +=3D tdep->num_dword_regs; + if (tdep->sp_regnum_from_eax !=3D -1) + set_gdbarch_sp_regnum (gdbarch, + (tdep->eax_regnum + + tdep->sp_regnum_from_eax)); + if (tdep->pc_regnum_from_eax !=3D -1) + set_gdbarch_pc_regnum (gdbarch, + (tdep->eax_regnum + + tdep->pc_regnum_from_eax)); } else tdep->eax_regnum =3D -1; 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 @@ -149,6 +149,14 @@ struct gdbarch_tdep of pseudo dword register support. */ int eax_regnum; + /* Register number for SP, relative to %eax. Set this to -1 to + indicate the absence of pseudo SP register support. */ + int sp_regnum_from_eax; + + /* Register number for PC, relative to %eax. Set this to -1 to + indicate the absence of pseudo PC register support. */ + int pc_regnum_from_eax; + /* Number of core registers. */ int num_core_regs; @@ -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);