This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Three weeks to branching (gdb 7.5 release)


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]