Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "H.J. Lu" <hjl.tools@gmail.com>
To: Mark Kettenis <mark.kettenis@xs4all.nl>
Cc: brobecker@adacore.com, gdb-patches@sourceware.org
Subject: Re: Three weeks to branching (gdb 7.5 release)
Date: Fri, 25 May 2012 16:52:00 -0000	[thread overview]
Message-ID: <CAMe9rOo99Cv_=zEc2yXf7fM03zcLEpSfUwUR2-6hcK9BsDLtJw@mail.gmail.com> (raw)
In-Reply-To: <CAMe9rOqmWwEjR88sZYynaHQ9-yv3TDQG3a7=9DaXwLKcoWo_gw@mail.gmail.com>

On Sun, May 20, 2012 at 3:48 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>> I don't think that's true.  Here tdesc comes from info.target_desc,
>> not tdep->tdesc, so the check should still do the right thing.  In
>> 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.

Hi Mark,

Can you take a look at this?

Thanks.

H.J.
> --
> H.J.
> ---
> 2012-05-20  Mark Kettenis  <kettenis@gnu.org>
>            H.J. Lu  <hongjiu.lu@intel.com>
>
>        * 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 = amd64_linux_syscall_record;
>  }
> +
> +static void
> +amd64_x32_linux_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_linux_init_abi (info, gdbarch);
> +
> +  if (! tdesc_has_registers (tdesc))
> +    tdesc = tdesc_amd64_linux;
> +  tdep->tdesc = 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[] =
>   "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 = 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 = gdbarch_tdep (gdbarch);
> +  if ((regnum - tdep->eax_regnum) == 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 = gdbarch_tdep (gdbarch);
> +
> +  tdep->num_dword_regs = 17;
> +  tdep->sp_regnum_from_eax = AMD64_RSP_REGNUM;
> +  tdep->pc_regnum_from_eax = 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 = 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;
> +
> +  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 *gdbarch);
> +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 = 8;
>   tdep->num_ymm_regs = 0;
>
> +  tdep->sp_regnum_from_eax = -1;
> +  tdep->pc_regnum_from_eax = -1;
> +
>   tdesc_data = 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 = ymm0_regnum;
>       ymm0_regnum += tdep->num_dword_regs;
> +      if (tdep->sp_regnum_from_eax != -1)
> +       set_gdbarch_sp_regnum (gdbarch,
> +                              (tdep->eax_regnum
> +                               + tdep->sp_regnum_from_eax));
> +      if (tdep->pc_regnum_from_eax != -1)
> +       set_gdbarch_pc_regnum (gdbarch,
> +                              (tdep->eax_regnum
> +                               + tdep->pc_regnum_from_eax));
>     }
>   else
>     tdep->eax_regnum = -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);



-- 
H.J.


  reply	other threads:[~2012-05-25 16:52 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-11 18:17 Joel Brobecker
2012-05-11 18:43 ` H.J. Lu
2012-05-14 14:45   ` Joel Brobecker
2012-05-20 15:40   ` H.J. Lu
2012-05-20 20:44     ` Mark Kettenis
2012-05-20 21:25       ` H.J. Lu
2012-05-20 21:39         ` Mark Kettenis
2012-05-20 22:49           ` H.J. Lu
2012-05-25 16:52             ` H.J. Lu [this message]
2012-05-28 20:26             ` x32 ABI Support (was Re: Three weeks to branching (gdb 7.5 release)) Mark Kettenis
2012-05-28 21:18               ` H.J. Lu
2012-05-31 18:18                 ` H.J. Lu
2012-06-05 12:58                   ` H.J. Lu
2012-06-05 13:16                     ` Mark Kettenis
2012-06-09 14:30                       ` H.J. Lu
2012-06-10 21:52                   ` Mark Kettenis
2012-06-11 13:42                     ` H.J. Lu
2012-06-12 21:23                       ` Mark Kettenis
2012-06-13 20:29                         ` x32 ABI Support (committed) Mark Kettenis
2012-06-13 20:41                           ` Mark Kettenis
2012-05-12 15:26 ` Three weeks to branching (gdb 7.5 release) Doug Evans
2012-05-20 14:59   ` Doug Evans
2012-06-11 15:35     ` Branching time + 1 week (was: "Re: Three weeks to branching (gdb 7.5 release)") Joel Brobecker
2012-06-11 15:52       ` Doug Evans
2012-06-11 16:00         ` Joel Brobecker
2012-06-21 20:20         ` Joel Brobecker
2012-06-21 20:25           ` Doug Evans
2012-06-22 14:47           ` Jan Kratochvil
2012-06-22 16:32             ` Joel Brobecker
2012-06-22 16:41               ` Jan Kratochvil
2012-06-22 17:38                 ` Branching time + 1 week Tom Tromey
2012-06-22 20:31                 ` Branching time + 1 week (was: "Re: Three weeks to branching (gdb 7.5 release)") Joel Brobecker
2012-06-24  9:14                   ` [commit] gnulib update [Re: Branching time + 1 week] Jan Kratochvil
2012-06-22 16:42               ` Branching time + 1 week (was: "Re: Three weeks to branching (gdb 7.5 release)") H.J. Lu
2012-06-11 15:59       ` H.J. Lu
2012-06-11 16:11         ` Joel Brobecker
2012-06-11 16:20           ` H.J. Lu
2012-05-29 17:17 ` Three weeks to branching (gdb 7.5 release) Jan Kratochvil
2012-05-30 22:04   ` Joel Brobecker
2012-06-07 19:36     ` Maciej W. Rozycki
2012-06-11 14:58       ` Joel Brobecker
2012-06-12 15:39         ` Maciej W. Rozycki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAMe9rOo99Cv_=zEc2yXf7fM03zcLEpSfUwUR2-6hcK9BsDLtJw@mail.gmail.com' \
    --to=hjl.tools@gmail.com \
    --cc=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    --cc=mark.kettenis@xs4all.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox