From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14612 invoked by alias); 13 Jun 2012 20:29:57 -0000 Received: (qmail 14598 invoked by uid 22791); 13 Jun 2012 20:29:55 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,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; Wed, 13 Jun 2012 20:29:42 +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 q5DKTcJO014462; Wed, 13 Jun 2012 22:29:38 +0200 (CEST) Received: (from kettenis@localhost) by glazunov.sibelius.xs4all.nl (8.14.5/8.14.3/Submit) id q5DKTau7004406; Wed, 13 Jun 2012 22:29:36 +0200 (CEST) Date: Wed, 13 Jun 2012 20:29:00 -0000 Message-Id: <201206132029.q5DKTau7004406@glazunov.sibelius.xs4all.nl> From: Mark Kettenis To: gdb-patches@sourceware.org CC: hjl.tools@gmail.com In-reply-to: <201206122123.q5CLNS3D002137@glazunov.sibelius.xs4all.nl> (message from Mark Kettenis on Tue, 12 Jun 2012 23:23:28 +0200 (CEST)) Subject: Re: x32 ABI Support (committed) 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> <201206122123.q5CLNS3D002137@glazunov.sibelius.xs4all.nl> 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/msg00436.txt.bz2 > Date: Tue, 12 Jun 2012 23:23:28 +0200 (CEST) > From: Mark Kettenis > > > Date: Mon, 11 Jun 2012 06:42:32 -0700 > > From: "H.J. Lu" > > > > It works with the following patch. Can you check it in? > > Started working on that tonight but got sidetracked. Will do my > utmost best to get this committed tomorrow. Ended up splitting out the Linux-specific bits from the generic bits. Generic bits go first. 2012-06-13 Mark Kettenis H.J. Lu * i386-tdep.h (i386_pseudo_register_name): New prototype. * i386-tdep.c (i386_pseudo_register_name): Make public. * amd64-tdep.h (amd64_x32_init_abi): New prototype. * amd64-tdep.c (amd64_dword_names): Add "eip". (amd64_x32_pseudo_register_type): New function (amd64_x32_init_abi): New function. Index: amd64-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/amd64-tdep.c,v retrieving revision 1.105 diff -u -p -r1.105 amd64-tdep.c --- amd64-tdep.c 16 May 2012 14:35:02 -0000 1.105 +++ amd64-tdep.c 13 Jun 2012 20:24:54 -0000 @@ -258,7 +258,8 @@ static const char *amd64_word_names[] = static const char *amd64_dword_names[] = { "eax", "ebx", "ecx", "edx", "esi", "edi", "ebp", "esp", - "r8d", "r9d", "r10d", "r11d", "r12d", "r13d", "r14d", "r15d" + "r8d", "r9d", "r10d", "r11d", "r12d", "r13d", "r14d", "r15d", + "eip" }; /* Return the name of register REGNUM. */ @@ -2729,6 +2730,43 @@ amd64_init_abi (struct gdbarch_info info set_gdbarch_stap_parse_special_token (gdbarch, i386_stap_parse_special_token); } + + +static struct type * +amd64_x32_pseudo_register_type (struct gdbarch *gdbarch, int regnum) +{ + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + + switch (regnum - tdep->eax_regnum) + { + 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); +} + +void +amd64_x32_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) +{ + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + const struct target_desc *tdesc = info.target_desc; + + amd64_init_abi (info, gdbarch); + + if (! tdesc_has_registers (tdesc)) + tdesc = tdesc_x32; + tdep->tdesc = tdesc; + + tdep->num_dword_regs = 17; + set_tdesc_pseudo_register_type (gdbarch, amd64_x32_pseudo_register_type); + + set_gdbarch_long_bit (gdbarch, 32); + set_gdbarch_ptr_bit (gdbarch, 32); +} /* Provide a prototype to silence -Wmissing-prototypes. */ void _initialize_amd64_tdep (void); Index: amd64-tdep.h =================================================================== 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 4 Jan 2012 08:16:56 -0000 1.21 +++ amd64-tdep.h 13 Jun 2012 20:24:54 -0000 @@ -80,6 +80,8 @@ extern void amd64_displaced_step_fixup ( struct regcache *regs); extern void amd64_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch); +extern void amd64_x32_init_abi (struct gdbarch_info info, + struct gdbarch *gdbarch); /* Fill register REGNUM in REGCACHE with the appropriate floating-point or SSE register value from *FXSAVE. If REGNUM is Index: i386-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/i386-tdep.c,v retrieving revision 1.351 diff -u -p -r1.351 i386-tdep.c --- i386-tdep.c 18 May 2012 21:02:48 -0000 1.351 +++ i386-tdep.c 13 Jun 2012 20:24:57 -0000 @@ -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)) Index: i386-tdep.h =================================================================== RCS file: /cvs/src/src/gdb/i386-tdep.h,v retrieving revision 1.78 diff -u -p -r1.78 i386-tdep.h --- i386-tdep.h 27 Apr 2012 20:47:54 -0000 1.78 +++ i386-tdep.h 13 Jun 2012 20:24:57 -0000 @@ -309,6 +309,8 @@ extern int i386_ymm_regnum_p (struct gdb extern const char *i386_pseudo_register_name (struct gdbarch *gdbarch, int regnum); +extern struct type *i386_pseudo_register_type (struct gdbarch *gdbarch, + int regnum); extern void i386_pseudo_register_read_into_value (struct gdbarch *gdbarch, struct regcache *regcache,