From: Yao Qi <qiyaoltc@gmail.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 16/22] Centralize amd64-linux target descriptions
Date: Mon, 21 Aug 2017 15:29:00 -0000 [thread overview]
Message-ID: <1503329347-26711-17-git-send-email-yao.qi@linaro.org> (raw)
In-Reply-To: <1503329347-26711-1-git-send-email-yao.qi@linaro.org>
This patch adds a new function amd64_linux_read_description, which
creates amd64-linux target descriptions according to its two
arguments, xcr0 and is_x32.
gdb:
2017-06-07 Yao Qi <yao.qi@linaro.org>
* amd64-linux-tdep.c (amd64_linux_read_description): New
function.
(amd64_linux_core_read_description): Call
amd64_linux_read_description.
(amd64_linux_init_abi): Likewise.
(amd64_x32_linux_init_abi): Likewise.
* amd64-linux-tdep.h (amd64_linux_read_description): Declare.
* x86-linux-nat.c (x86_linux_read_description): Call
amd64_linux_read_description.
---
gdb/amd64-linux-tdep.c | 46 ++++++++++++++++++++++++++++------------------
gdb/amd64-linux-tdep.h | 6 ++++++
gdb/x86-linux-nat.c | 35 +----------------------------------
3 files changed, 35 insertions(+), 52 deletions(-)
diff --git a/gdb/amd64-linux-tdep.c b/gdb/amd64-linux-tdep.c
index 54c2eb9..85efbef 100644
--- a/gdb/amd64-linux-tdep.c
+++ b/gdb/amd64-linux-tdep.c
@@ -1575,54 +1575,61 @@ amd64_linux_record_signal (struct gdbarch *gdbarch,
return 0;
}
-/* Get Linux/x86 target description from core dump. */
-
-static const struct target_desc *
-amd64_linux_core_read_description (struct gdbarch *gdbarch,
- struct target_ops *target,
- bfd *abfd)
+const target_desc *
+amd64_linux_read_description (uint64_t xcr0_features_bit, bool is_x32)
{
- /* Linux/x86-64. */
- uint64_t xcr0 = i386_linux_core_read_xcr0 (abfd);
-
- switch (xcr0 & X86_XSTATE_ALL_MASK)
+ switch (xcr0_features_bit)
{
case X86_XSTATE_AVX_MPX_AVX512_PKU_MASK:
- if (gdbarch_ptr_bit (gdbarch) == 32)
+ if (is_x32)
/* No MPX, PKU on x32, fallback to AVX-AVX512. */
return tdesc_x32_avx_avx512_linux;
else
return tdesc_amd64_avx_mpx_avx512_pku_linux;
case X86_XSTATE_AVX_AVX512_MASK:
- if (gdbarch_ptr_bit (gdbarch) == 32)
+ if (is_x32)
return tdesc_x32_avx_avx512_linux;
else
return tdesc_amd64_avx_avx512_linux;
case X86_XSTATE_MPX_MASK:
- if (gdbarch_ptr_bit (gdbarch) == 32)
+ if (is_x32)
/* No MPX on x32, fallback to AVX. */
return tdesc_x32_avx_linux;
else
return tdesc_amd64_mpx_linux;
case X86_XSTATE_AVX_MPX_MASK:
- if (gdbarch_ptr_bit (gdbarch) == 32)
+ if (is_x32)
/* No MPX on x32, fallback to AVX. */
return tdesc_x32_avx_linux;
else
return tdesc_amd64_avx_mpx_linux;
case X86_XSTATE_AVX_MASK:
- if (gdbarch_ptr_bit (gdbarch) == 32)
+ if (is_x32)
return tdesc_x32_avx_linux;
else
return tdesc_amd64_avx_linux;
default:
- if (gdbarch_ptr_bit (gdbarch) == 32)
+ if (is_x32)
return tdesc_x32_linux;
else
return tdesc_amd64_linux;
}
}
+/* Get Linux/x86 target description from core dump. */
+
+static const struct target_desc *
+amd64_linux_core_read_description (struct gdbarch *gdbarch,
+ struct target_ops *target,
+ bfd *abfd)
+{
+ /* Linux/x86-64. */
+ uint64_t xcr0 = i386_linux_core_read_xcr0 (abfd);
+
+ return amd64_linux_read_description (xcr0 & X86_XSTATE_ALL_MASK,
+ gdbarch_ptr_bit (gdbarch) == 32);
+}
+
/* Similar to amd64_supply_fpregset, but use XSAVE extended state. */
static void
@@ -1873,7 +1880,8 @@ amd64_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
tdep->gregset_num_regs = ARRAY_SIZE (amd64_linux_gregset_reg_offset);
tdep->sizeof_gregset = 27 * 8;
- amd64_init_abi (info, gdbarch, tdesc_amd64_linux);
+ amd64_init_abi (info, gdbarch,
+ amd64_linux_read_description (X86_XSTATE_SSE_MASK, false));
const target_desc *tdesc = tdep->tdesc;
@@ -2086,7 +2094,9 @@ amd64_x32_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
tdep->gregset_num_regs = ARRAY_SIZE (amd64_linux_gregset_reg_offset);
tdep->sizeof_gregset = 27 * 8;
- amd64_x32_init_abi (info, gdbarch, tdesc_x32_linux);
+ amd64_x32_init_abi (info, gdbarch,
+ amd64_linux_read_description (X86_XSTATE_SSE_MASK,
+ true));
/* Reserve a number for orig_rax. */
set_gdbarch_num_regs (gdbarch, AMD64_LINUX_NUM_REGS);
diff --git a/gdb/amd64-linux-tdep.h b/gdb/amd64-linux-tdep.h
index 7453408..ab134a4 100644
--- a/gdb/amd64-linux-tdep.h
+++ b/gdb/amd64-linux-tdep.h
@@ -43,6 +43,12 @@ extern struct target_desc *tdesc_x32_linux;
extern struct target_desc *tdesc_x32_avx_linux;
extern struct target_desc *tdesc_x32_avx_avx512_linux;
+/* Return the right amd64-linux target descriptions according to
+ XCR0_FEATURES_BIT and IS_X32. */
+
+const target_desc *amd64_linux_read_description (uint64_t xcr0_features_bit,
+ bool is_x32);
+
/* Enum that defines the syscall identifiers for amd64 linux.
Used for process record/replay, these will be translated into
a gdb-canonical set of syscall ids in linux-record.c. */
diff --git a/gdb/x86-linux-nat.c b/gdb/x86-linux-nat.c
index 2c4afb1..4611527 100644
--- a/gdb/x86-linux-nat.c
+++ b/gdb/x86-linux-nat.c
@@ -192,40 +192,7 @@ x86_linux_read_description (struct target_ops *ops)
if (is_64bit)
{
#ifdef __x86_64__
- switch (xcr0_features_bits)
- {
- case X86_XSTATE_AVX_MPX_AVX512_PKU_MASK:
- if (is_x32)
- /* No MPX, PKU on x32, fall back to AVX-AVX512. */
- return tdesc_x32_avx_avx512_linux;
- else
- return tdesc_amd64_avx_mpx_avx512_pku_linux;
- case X86_XSTATE_AVX_AVX512_MASK:
- if (is_x32)
- return tdesc_x32_avx_avx512_linux;
- else
- return tdesc_amd64_avx_avx512_linux;
- case X86_XSTATE_MPX_MASK:
- if (is_x32)
- return tdesc_x32_avx_linux; /* No MPX on x32 using AVX. */
- else
- return tdesc_amd64_mpx_linux;
- case X86_XSTATE_AVX_MPX_MASK:
- if (is_x32)
- return tdesc_x32_avx_linux; /* No MPX on x32 using AVX. */
- else
- return tdesc_amd64_avx_mpx_linux;
- case X86_XSTATE_AVX_MASK:
- if (is_x32)
- return tdesc_x32_avx_linux;
- else
- return tdesc_amd64_avx_linux;
- default:
- if (is_x32)
- return tdesc_x32_linux;
- else
- return tdesc_amd64_linux;
- }
+ return amd64_linux_read_description (xcr0_features_bits, is_x32);
#endif
}
else
--
1.9.1
next prev parent reply other threads:[~2017-08-21 15:29 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-21 15:29 [PATCH 00/22 v4] Make GDB builtin target descriptions more flexible Yao Qi
2017-08-21 15:29 ` [PATCH 15/22] Update comments in amd64_linux_core_read_description Yao Qi
2017-08-21 15:29 ` Yao Qi [this message]
2017-08-21 15:29 ` [PATCH 01/22] Use amd64_target_description to get tdesc_amd64 Yao Qi
2017-08-21 15:29 ` [PATCH 20/22] [GDBserver] Shorten srv_amd64_linux_xmlfiles Yao Qi
2017-08-21 15:29 ` [PATCH 04/22] Let i386_target_description return tdesc_i386_mmx Yao Qi
2017-08-21 15:29 ` [PATCH 03/22] Return X86_XSTATE_SSE_MASK instead of 0 in i386fbsd_core_read_xcr0 Yao Qi
2017-08-21 16:23 ` John Baldwin
2017-08-21 16:46 ` Yao Qi
2017-08-21 17:00 ` John Baldwin
2017-08-21 15:29 ` [PATCH 19/22] [GDBserver] Use pre-generated amd64-linux tdesc as test Yao Qi
2017-08-21 15:29 ` [PATCH 08/22] [GDBserver] Centralize tdesc for i386-linux Yao Qi
2017-08-21 15:29 ` [PATCH 09/22] [GDBserver] unit test to i386_tdesc Yao Qi
2017-08-21 15:29 ` [PATCH 11/22] Share i386-linux target description between GDB and GDBserver Yao Qi
2017-08-21 15:29 ` [PATCH 05/22] Adjust code generated by regformats/regdat.sh Yao Qi
2017-08-21 15:30 ` [PATCH 18/22] Convert amd64-linux target descriptions Yao Qi
2017-08-21 15:31 ` [PATCH 21/22] Remove features/i386/amd64-*linux.c and features/i386/x32-*linux.c Yao Qi
2017-08-21 15:31 ` [PATCH 17/22] Lazily and dynamically create amd64-linux target descriptions Yao Qi
2017-08-21 15:31 ` [PATCH 12/22] Remove features/i386/i386-*linux.c Yao Qi
2017-08-21 15:31 ` [PATCH 22/22] Convert the rest x86 target descriptions Yao Qi
2017-08-21 15:31 ` [PATCH 10/22] Dynamically composite xml in reply to GDB Yao Qi
2017-08-21 15:31 ` [PATCH 14/22] [GDBserver] Shorten srv_i386_linux_xmlfiles Yao Qi
2017-08-21 15:31 ` [PATCH 13/22] [GDBserver] Use pre-generated tdesc as test Yao Qi
2017-08-21 15:31 ` [PATCH 07/22] Return X86_TDESC_MMX in x86_get_ipa_tdesc_idx Yao Qi
2017-08-21 15:31 ` [PATCH 02/22] Use i386_target_description to get tdesc_i386 Yao Qi
2017-08-21 16:23 ` John Baldwin
2017-08-21 15:31 ` [PATCH 06/22] Use VEC for target_desc.reg_defs Yao Qi
2017-09-05 9:04 ` [PATCH 00/22 v4] Make GDB builtin target descriptions more flexible Yao Qi
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=1503329347-26711-17-git-send-email-yao.qi@linaro.org \
--to=qiyaoltc@gmail.com \
--cc=gdb-patches@sourceware.org \
/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