aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdbserver/linux-x86-low.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/gdbserver/linux-x86-low.c')
-rw-r--r--gdb/gdbserver/linux-x86-low.c169
1 files changed, 32 insertions, 137 deletions
diff --git a/gdb/gdbserver/linux-x86-low.c b/gdb/gdbserver/linux-x86-low.c
index b39026c..49f6b2d 100644
--- a/gdb/gdbserver/linux-x86-low.c
+++ b/gdb/gdbserver/linux-x86-low.c
@@ -757,7 +757,7 @@ x86_linux_read_description (void)
{
have_ptrace_getfpxregs = 0;
have_ptrace_getregset = 0;
- return tdesc_i386_mmx_linux;
+ return i386_linux_read_description (X86_XSTATE_X87);
}
else
have_ptrace_getfpxregs = 1;
@@ -809,7 +809,7 @@ x86_linux_read_description (void)
/* Check the native XCR0 only if PTRACE_GETREGSET is available. */
xcr0_features = (have_ptrace_getregset
- && (xcr0 & X86_XSTATE_ALL_MASK));
+ && (xcr0 & X86_XSTATE_ALL_MASK));
if (xcr0_features)
x86_xcr0 = xcr0;
@@ -817,103 +817,35 @@ x86_linux_read_description (void)
if (machine == EM_X86_64)
{
#ifdef __x86_64__
- if (is_elf64)
- {
- if (xcr0_features)
- {
- switch (xcr0 & X86_XSTATE_ALL_MASK)
- {
- case X86_XSTATE_AVX_MPX_AVX512_PKU_MASK:
- return tdesc_amd64_avx_mpx_avx512_pku_linux;
-
- case X86_XSTATE_AVX_AVX512_MASK:
- return tdesc_amd64_avx_avx512_linux;
-
- case X86_XSTATE_AVX_MPX_MASK:
- return tdesc_amd64_avx_mpx_linux;
-
- case X86_XSTATE_MPX_MASK:
- return tdesc_amd64_mpx_linux;
+ const target_desc *tdesc = NULL;
- case X86_XSTATE_AVX_MASK:
- return tdesc_amd64_avx_linux;
-
- default:
- return tdesc_amd64_linux;
- }
- }
- else
- return tdesc_amd64_linux;
- }
- else
+ if (xcr0_features)
{
- if (xcr0_features)
- {
- switch (xcr0 & X86_XSTATE_ALL_MASK)
- {
- case X86_XSTATE_AVX_MPX_AVX512_PKU_MASK:
- /* No x32 MPX and PKU, fall back to avx_avx512. */
- return tdesc_x32_avx_avx512_linux;
-
- case X86_XSTATE_AVX_AVX512_MASK:
- return tdesc_x32_avx_avx512_linux;
-
- case X86_XSTATE_MPX_MASK: /* No MPX on x32. */
- case X86_XSTATE_AVX_MASK:
- return tdesc_x32_avx_linux;
-
- default:
- return tdesc_x32_linux;
- }
- }
- else
- return tdesc_x32_linux;
+ tdesc = amd64_linux_read_description (xcr0 & X86_XSTATE_ALL_MASK,
+ !is_elf64);
}
+
+ if (tdesc == NULL)
+ tdesc = amd64_linux_read_description (X86_XSTATE_SSE_MASK, !is_elf64);
+ return tdesc;
#endif
}
else
{
- if (xcr0_features)
- {
- switch (xcr0 & X86_XSTATE_ALL_MASK)
- {
- case X86_XSTATE_AVX_MPX_AVX512_PKU_MASK:
- return tdesc_i386_avx_mpx_avx512_pku_linux;
-
- case (X86_XSTATE_AVX_AVX512_MASK):
- return tdesc_i386_avx_avx512_linux;
+ const target_desc *tdesc = NULL;
- case (X86_XSTATE_MPX_MASK):
- return tdesc_i386_mpx_linux;
-
- case (X86_XSTATE_AVX_MPX_MASK):
- return tdesc_i386_avx_mpx_linux;
+ if (xcr0_features)
+ tdesc = i386_linux_read_description (xcr0 & X86_XSTATE_ALL_MASK);
- case (X86_XSTATE_AVX_MASK):
- return tdesc_i386_avx_linux;
+ if (tdesc == NULL)
+ tdesc = i386_linux_read_description (X86_XSTATE_SSE);
- default:
- return tdesc_i386_linux;
- }
- }
- else
- return tdesc_i386_linux;
+ return tdesc;
}
gdb_assert_not_reached ("failed to return tdesc");
}
-/* Callback for find_inferior. Stops iteration when a thread with a
- given PID is found. */
-
-static int
-same_process_callback (struct inferior_list_entry *entry, void *data)
-{
- int pid = *(int *) data;
-
- return (ptid_get_pid (entry->id) == pid);
-}
-
/* Callback for for_each_inferior. Calls the arch_setup routine for
each process. */
@@ -923,9 +855,7 @@ x86_arch_setup_process_callback (struct inferior_list_entry *entry)
int pid = ptid_get_pid (entry->id);
/* Look up any thread of this processes. */
- current_thread
- = (struct thread_info *) find_inferior (&all_threads,
- same_process_callback, &pid);
+ current_thread = find_any_thread_of_pid (pid);
the_low_target.arch_setup ();
}
@@ -2897,37 +2827,13 @@ x86_get_ipa_tdesc_idx (void)
const struct target_desc *tdesc = regcache->tdesc;
#ifdef __x86_64__
- if (tdesc == tdesc_amd64_linux || tdesc == tdesc_amd64_linux_no_xml
- || tdesc == tdesc_x32_linux)
- return X86_TDESC_SSE;
- if (tdesc == tdesc_amd64_avx_linux || tdesc == tdesc_x32_avx_linux)
- return X86_TDESC_AVX;
- if (tdesc == tdesc_amd64_mpx_linux)
- return X86_TDESC_MPX;
- if (tdesc == tdesc_amd64_avx_mpx_linux)
- return X86_TDESC_AVX_MPX;
- if (tdesc == tdesc_amd64_avx_mpx_avx512_pku_linux || tdesc == tdesc_x32_avx_avx512_linux)
- return X86_TDESC_AVX_MPX_AVX512_PKU;
- if (tdesc == tdesc_amd64_avx_avx512_linux)
- return X86_TDESC_AVX_AVX512;
+ return amd64_get_ipa_tdesc_idx (tdesc);
#endif
- if (tdesc == tdesc_i386_mmx_linux)
- return X86_TDESC_MMX;
- if (tdesc == tdesc_i386_linux || tdesc == tdesc_i386_linux_no_xml)
+ if (tdesc == tdesc_i386_linux_no_xml)
return X86_TDESC_SSE;
- if (tdesc == tdesc_i386_avx_linux)
- return X86_TDESC_AVX;
- if (tdesc == tdesc_i386_mpx_linux)
- return X86_TDESC_MPX;
- if (tdesc == tdesc_i386_avx_mpx_linux)
- return X86_TDESC_AVX_MPX;
- if (tdesc == tdesc_i386_avx_mpx_avx512_pku_linux)
- return X86_TDESC_AVX_MPX_AVX512_PKU;
- if (tdesc == tdesc_i386_avx_avx512_linux)
- return X86_TDESC_AVX_AVX512;
- return 0;
+ return i386_get_ipa_tdesc_idx (tdesc);
}
/* This is initialized assuming an amd64 target.
@@ -2981,31 +2887,20 @@ initialize_low_arch (void)
{
/* Initialize the Linux target descriptions. */
#ifdef __x86_64__
- init_registers_amd64_linux ();
- init_registers_amd64_avx_linux ();
- init_registers_amd64_mpx_linux ();
- init_registers_amd64_avx_mpx_linux ();
- init_registers_amd64_avx_avx512_linux ();
- init_registers_amd64_avx_mpx_avx512_pku_linux ();
-
- init_registers_x32_linux ();
- init_registers_x32_avx_linux ();
- init_registers_x32_avx_avx512_linux ();
-
- tdesc_amd64_linux_no_xml = XNEW (struct target_desc);
- copy_target_description (tdesc_amd64_linux_no_xml, tdesc_amd64_linux);
+ tdesc_amd64_linux_no_xml = allocate_target_description ();
+ copy_target_description (tdesc_amd64_linux_no_xml,
+ amd64_linux_read_description (X86_XSTATE_SSE_MASK,
+ false));
tdesc_amd64_linux_no_xml->xmltarget = xmltarget_amd64_linux_no_xml;
#endif
- init_registers_i386_linux ();
- init_registers_i386_mmx_linux ();
- init_registers_i386_avx_linux ();
- init_registers_i386_mpx_linux ();
- init_registers_i386_avx_mpx_linux ();
- init_registers_i386_avx_avx512_linux ();
- init_registers_i386_avx_mpx_avx512_pku_linux ();
-
- tdesc_i386_linux_no_xml = XNEW (struct target_desc);
- copy_target_description (tdesc_i386_linux_no_xml, tdesc_i386_linux);
+
+#if GDB_SELF_TEST
+ initialize_low_tdesc ();
+#endif
+
+ tdesc_i386_linux_no_xml = allocate_target_description ();
+ copy_target_description (tdesc_i386_linux_no_xml,
+ i386_linux_read_description (X86_XSTATE_SSE_MASK));
tdesc_i386_linux_no_xml->xmltarget = xmltarget_i386_linux_no_xml;
initialize_regsets_info (&x86_regsets_info);