From: Yao Qi <qiyaoltc@gmail.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 20/25] Centralize amd64-linux target descriptions
Date: Mon, 12 Jun 2017 08:42:00 -0000 [thread overview]
Message-ID: <1497256916-4958-21-git-send-email-yao.qi@linaro.org> (raw)
In-Reply-To: <1497256916-4958-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 | 51 +++++++++++++++++++++++++++-----------------------
gdb/amd64-linux-tdep.h | 6 ++++++
gdb/x86-linux-nat.c | 35 +---------------------------------
3 files changed, 35 insertions(+), 57 deletions(-)
diff --git a/gdb/amd64-linux-tdep.c b/gdb/amd64-linux-tdep.c
index 0e2f285..b9f624d 100644
--- a/gdb/amd64-linux-tdep.c
+++ b/gdb/amd64-linux-tdep.c
@@ -1575,54 +1575,59 @@ 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)
- /* No MPX on x32, fallback to AVX-AVX512. */
+ 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 (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)
- /* No MPX on x32, fallback to AVX-AVX512. */
- return tdesc_x32_avx_linux;
+ 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 (gdbarch_ptr_bit (gdbarch) == 32)
- /* No MPX on x32, fallback to AVX-AVX512. */
- return tdesc_x32_avx_linux;
+ 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 (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
@@ -1883,7 +1888,7 @@ amd64_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
set_gdbarch_num_regs (gdbarch, AMD64_LINUX_NUM_REGS);
if (! tdesc_has_registers (tdesc))
- tdesc = tdesc_amd64_linux;
+ tdesc = amd64_linux_read_description (X86_XSTATE_SSE_MASK, false);
tdep->tdesc = tdesc;
feature = tdesc_find_feature (tdesc, "org.gnu.gdb.i386.linux");
@@ -2100,7 +2105,7 @@ amd64_x32_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
set_gdbarch_num_regs (gdbarch, AMD64_LINUX_NUM_REGS);
if (! tdesc_has_registers (tdesc))
- tdesc = tdesc_x32_linux;
+ tdesc = amd64_linux_read_description (X86_XSTATE_SSE_MASK, true);
tdep->tdesc = tdesc;
feature = tdesc_find_feature (tdesc, "org.gnu.gdb.i386.linux");
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-06-12 8:42 UTC|newest]
Thread overview: 79+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-12 8:42 [PATCH 00/25 V2] Make GDB builtin target descriptions more flexible Yao Qi
2017-06-12 8:42 ` [PATCH 06/25] Generate c for feature instead of tdesc Yao Qi
2017-06-12 14:48 ` Eli Zaretskii
2017-06-13 12:07 ` Yao Qi
2017-06-13 14:49 ` Eli Zaretskii
2017-06-13 15:31 ` Yao Qi
2017-06-13 15:41 ` Eli Zaretskii
2017-06-14 16:21 ` Yao Qi
2017-06-14 16:32 ` Eli Zaretskii
2017-06-15 13:19 ` Yao Qi
2017-06-15 14:45 ` Eli Zaretskii
[not found] ` <d0c0b3b2-e585-acbb-d63e-6be6a6fe11a9@redhat.com>
[not found] ` <86mv90hyci.fsf@gmail.com>
2017-06-22 15:36 ` Pedro Alves
2017-06-22 15:58 ` Yao Qi
2017-06-26 21:38 ` Simon Marchi
2017-06-29 15:24 ` Yao Qi
2017-06-12 8:42 ` [PATCH 11/25] Use VEC for target_desc.reg_defs Yao Qi
2017-06-28 19:01 ` Pedro Alves
2017-06-29 11:05 ` Yao Qi
2017-06-29 11:31 ` Pedro Alves
2017-06-29 13:24 ` Yao Qi
2017-06-12 8:42 ` [PATCH 10/25] Adjust code generated by regformats/regdat.sh Yao Qi
[not found] ` <92ca03ca-e06d-09fc-7243-e52dd29edcef@redhat.com>
2017-06-21 14:28 ` Yao Qi
2017-06-12 8:42 ` [PATCH 17/25] Remove features/i386/i386-*linux.c Yao Qi
2017-06-12 8:42 ` [PATCH 23/25] [GDBserver] Convert amd64-linux target descriptions Yao Qi
2017-06-28 19:00 ` Pedro Alves
2017-06-12 8:42 ` [PATCH 18/25] [GDBserver] Use pre-generated tdesc as test Yao Qi
2017-06-12 8:42 ` [PATCH 19/25] GDBserver: remove srv_i386_linux_xmlfiles Yao Qi
2017-06-12 8:42 ` [PATCH 13/25] Dynamically create tdesc in GDBserver Yao Qi
2017-06-12 8:42 ` [PATCH 03/25] Class-fy tdesc_reg tdesc_type and tdesc_feature Yao Qi
2017-06-19 20:55 ` Simon Marchi
2017-06-19 21:30 ` Simon Marchi
2017-06-20 10:31 ` Yao Qi
2017-06-12 8:42 ` [PATCH 12/25] [GDBserver] Centralize tdesc for i386-linux Yao Qi
2017-06-12 8:42 ` [PATCH 05/25] Use visitor pattern for "maint print c-tdesc" Yao Qi
2017-06-20 23:37 ` Simon Marchi
2017-06-12 8:42 ` [PATCH 08/25] Add "maint check xml-descriptions" to test builtin xml target descriptions Yao Qi
2017-06-28 16:13 ` Pedro Alves
2017-06-12 8:42 ` [PATCH 25/25] Remove features/i386/amd64-*linux.c and features/i386/x32-*linux.c Yao Qi
2017-06-12 8:42 ` [PATCH 24/25] [GDBserver] Use pre-generated amd64-linux tdesc as test Yao Qi
2017-06-12 8:42 ` [PATCH 22/25] Regenerate two regformats/i386/.dat files Yao Qi
2017-06-22 12:43 ` Yao Qi
2017-06-12 8:42 ` [PATCH 07/25] Lazily and dynamically create i386-linux target descriptions Yao Qi
2017-06-20 11:01 ` Pedro Alves
2017-06-20 14:07 ` Yao Qi
2017-06-28 15:30 ` Pedro Alves
2017-06-12 8:42 ` Yao Qi [this message]
2017-06-12 8:42 ` [PATCH 15/25] [RFC] GDBserver unit test to i386_tdesc Yao Qi
2017-06-28 17:22 ` Pedro Alves
2017-06-29 9:27 ` Yao Qi
2017-06-12 8:42 ` [PATCH 14/25] [RFC] GDBserver self test Yao Qi
2017-06-28 17:09 ` Pedro Alves
2017-06-29 9:08 ` Yao Qi
2017-06-12 8:42 ` [PATCH 16/25] Dynamically composite xml in reply to GDB Yao Qi
2017-06-12 8:42 ` [PATCH 04/25] Centralize i386 linux target descriptions Yao Qi
2017-06-19 21:27 ` Simon Marchi
2017-06-12 8:42 ` [PATCH 01/25] Move initialize_tdesc_mips* calls from mips-linux-nat.c to mips-linux-tdep.c Yao Qi
2017-06-12 15:25 ` Maciej W. Rozycki
2017-06-13 8:07 ` Yao Qi
2017-06-12 8:42 ` [PATCH 09/25] Use target_desc fields expedite_regs and xmltarget ifndef IN_PROCESS_AGENT Yao Qi
2017-06-28 16:16 ` Pedro Alves
2017-06-28 17:42 ` Pedro Alves
2017-06-28 17:45 ` Pedro Alves
2017-06-29 11:45 ` Yao Qi
2017-06-12 8:42 ` [PATCH 02/25] Adjust the order of 32bit-linux.xml and 32bit-sse.xml in i386/i386-linux.xml Yao Qi
2017-06-19 20:22 ` Simon Marchi
2017-06-19 21:24 ` Pedro Alves
2017-06-19 21:48 ` Simon Marchi
2017-06-19 21:56 ` Pedro Alves
2017-06-20 9:20 ` Yao Qi
2017-06-20 10:12 ` Pedro Alves
2017-06-20 11:09 ` Yao Qi
2017-06-12 8:42 ` [PATCH 21/25] Lazily and dynamically create amd64-linux target descriptions Yao Qi
2017-06-19 19:59 ` [PATCH 00/25 V2] Make GDB builtin target descriptions more flexible Simon Marchi
2017-06-20 11:02 ` Yao Qi
2017-06-26 14:45 ` Tedeschi, Walfred
2017-06-27 13:49 ` Alan Hayward
2017-06-28 8:28 ` Yao Qi
2017-06-28 8:06 ` Yao Qi
2017-06-28 19:06 ` Pedro Alves
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=1497256916-4958-21-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