mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-12-09 17:12:54 +00:00
Centralize i386 linux target descriptions
This patch moves all the tdesc_i386*_linux target descriptions to a function i386_linux_read_description, which returns the right target description according to xcr0. This also remove the duplication in getting target descriptions in corefile and native target. v3: Add comment and remove an extra space. gdb: 2017-04-27 Yao Qi <yao.qi@linaro.org> * i386-linux-tdep.c (i386_linux_read_description): New function. (i386_linux_core_read_description): Call i386_linux_read_description. * i386-linux-tdep.h (i386_linux_read_description): Declare. (tdesc_i386_linux, tdesc_i386_mmx_linux): Remove declarations. (tdesc_i386_avx_linux, tdesc_i386_mpx_linux): Likewise (tdesc_i386_avx_mpx_linux, tdesc_i386_avx_avx512_linux): Likewise. (tdesc_i386_avx_mpx_avx512_pku_linux): Likewise. * x86-linux-nat.c (x86_linux_read_description): Call i386_linux_read_description.
This commit is contained in:
@@ -678,16 +678,11 @@ i386_linux_core_read_xcr0 (bfd *abfd)
|
|||||||
return xcr0;
|
return xcr0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get Linux/x86 target description from core dump. */
|
/* See i386-linux-tdep.h. */
|
||||||
|
|
||||||
static const struct target_desc *
|
const struct target_desc *
|
||||||
i386_linux_core_read_description (struct gdbarch *gdbarch,
|
i386_linux_read_description (uint64_t xcr0)
|
||||||
struct target_ops *target,
|
|
||||||
bfd *abfd)
|
|
||||||
{
|
{
|
||||||
/* Linux/i386. */
|
|
||||||
uint64_t xcr0 = i386_linux_core_read_xcr0 (abfd);
|
|
||||||
|
|
||||||
switch ((xcr0 & X86_XSTATE_ALL_MASK))
|
switch ((xcr0 & X86_XSTATE_ALL_MASK))
|
||||||
{
|
{
|
||||||
case X86_XSTATE_AVX_MPX_AVX512_PKU_MASK:
|
case X86_XSTATE_AVX_MPX_AVX512_PKU_MASK:
|
||||||
@@ -708,10 +703,27 @@ i386_linux_core_read_description (struct gdbarch *gdbarch,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get Linux/x86 target description from core dump. */
|
||||||
|
|
||||||
|
static const struct target_desc *
|
||||||
|
i386_linux_core_read_description (struct gdbarch *gdbarch,
|
||||||
|
struct target_ops *target,
|
||||||
|
bfd *abfd)
|
||||||
|
{
|
||||||
|
/* Linux/i386. */
|
||||||
|
uint64_t xcr0 = i386_linux_core_read_xcr0 (abfd);
|
||||||
|
const struct target_desc *tdesc = i386_linux_read_description (xcr0);
|
||||||
|
|
||||||
|
if (tdesc != NULL)
|
||||||
|
return tdesc;
|
||||||
|
|
||||||
if (bfd_get_section_by_name (abfd, ".reg-xfp") != NULL)
|
if (bfd_get_section_by_name (abfd, ".reg-xfp") != NULL)
|
||||||
return tdesc_i386_linux;
|
return i386_linux_read_description (X86_XSTATE_SSE_MASK);
|
||||||
else
|
else
|
||||||
return tdesc_i386_mmx_linux;
|
return i386_linux_read_description (X86_XSTATE_X87_MASK);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Similar to i386_supply_fpregset, but use XSAVE extended state. */
|
/* Similar to i386_supply_fpregset, but use XSAVE extended state. */
|
||||||
@@ -835,7 +847,7 @@ i386_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
|
|||||||
set_gdbarch_num_regs (gdbarch, I386_LINUX_NUM_REGS);
|
set_gdbarch_num_regs (gdbarch, I386_LINUX_NUM_REGS);
|
||||||
|
|
||||||
if (! tdesc_has_registers (tdesc))
|
if (! tdesc_has_registers (tdesc))
|
||||||
tdesc = tdesc_i386_linux;
|
tdesc = i386_linux_read_description (X86_XSTATE_SSE_MASK);
|
||||||
tdep->tdesc = tdesc;
|
tdep->tdesc = tdesc;
|
||||||
|
|
||||||
feature = tdesc_find_feature (tdesc, "org.gnu.gdb.i386.linux");
|
feature = tdesc_find_feature (tdesc, "org.gnu.gdb.i386.linux");
|
||||||
|
|||||||
@@ -42,14 +42,8 @@ extern uint64_t i386_linux_core_read_xcr0 (bfd *abfd);
|
|||||||
extern void i386_linux_handle_segmentation_fault (struct gdbarch *gdbarch,
|
extern void i386_linux_handle_segmentation_fault (struct gdbarch *gdbarch,
|
||||||
struct ui_out *uiout);
|
struct ui_out *uiout);
|
||||||
|
|
||||||
/* Linux target description. */
|
/* Return the target description according to XCR0. */
|
||||||
extern struct target_desc *tdesc_i386_linux;
|
extern const struct target_desc *i386_linux_read_description (uint64_t xcr0);
|
||||||
extern struct target_desc *tdesc_i386_mmx_linux;
|
|
||||||
extern struct target_desc *tdesc_i386_avx_linux;
|
|
||||||
extern struct target_desc *tdesc_i386_mpx_linux;
|
|
||||||
extern struct target_desc *tdesc_i386_avx_mpx_linux;
|
|
||||||
extern struct target_desc *tdesc_i386_avx_avx512_linux;
|
|
||||||
extern struct target_desc *tdesc_i386_avx_mpx_avx512_pku_linux;
|
|
||||||
|
|
||||||
/* Format of XSAVE extended state is:
|
/* Format of XSAVE extended state is:
|
||||||
struct
|
struct
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ x86_linux_read_description (struct target_ops *ops)
|
|||||||
{
|
{
|
||||||
have_ptrace_getfpxregs = 0;
|
have_ptrace_getfpxregs = 0;
|
||||||
have_ptrace_getregset = TRIBOOL_FALSE;
|
have_ptrace_getregset = TRIBOOL_FALSE;
|
||||||
return tdesc_i386_mmx_linux;
|
return i386_linux_read_description (X86_XSTATE_X87_MASK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -230,21 +230,13 @@ x86_linux_read_description (struct target_ops *ops)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
switch (xcr0_features_bits)
|
const struct target_desc * tdesc
|
||||||
{
|
= i386_linux_read_description (xcr0_features_bits);
|
||||||
case X86_XSTATE_AVX_MPX_AVX512_PKU_MASK:
|
|
||||||
return tdesc_i386_avx_mpx_avx512_pku_linux;
|
if (tdesc == NULL)
|
||||||
case X86_XSTATE_AVX_AVX512_MASK:
|
tdesc = i386_linux_read_description (X86_XSTATE_SSE_MASK);
|
||||||
return tdesc_i386_avx_avx512_linux;
|
|
||||||
case X86_XSTATE_MPX_MASK:
|
return tdesc;
|
||||||
return tdesc_i386_mpx_linux;
|
|
||||||
case X86_XSTATE_AVX_MPX_MASK:
|
|
||||||
return tdesc_i386_avx_mpx_linux;
|
|
||||||
case X86_XSTATE_AVX_MASK:
|
|
||||||
return tdesc_i386_avx_linux;
|
|
||||||
default:
|
|
||||||
return tdesc_i386_linux;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gdb_assert_not_reached ("failed to return tdesc");
|
gdb_assert_not_reached ("failed to return tdesc");
|
||||||
|
|||||||
Reference in New Issue
Block a user