X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=gdbserver%2Flinux-x86-low.cc;h=35dfdd7e0f38416efa2e33fb6b429c314ab30a8f;hb=78e49486944c515dfed6a437edff4c2c15dd1d4e;hp=f6a399e0982379ae41ead2b62bac06b42b01642b;hpb=0dd7b52ede3de7c5e43cc7c0a52a4e2f2b4297b7;p=binutils-gdb.git diff --git a/gdbserver/linux-x86-low.cc b/gdbserver/linux-x86-low.cc index f6a399e0982..35dfdd7e0f3 100644 --- a/gdbserver/linux-x86-low.cc +++ b/gdbserver/linux-x86-low.cc @@ -1,6 +1,6 @@ /* GNU/Linux/x86-64 specific low level interface, for the remote server for GDB. - Copyright (C) 2002-2020 Free Software Foundation, Inc. + Copyright (C) 2002-2021 Free Software Foundation, Inc. This file is part of GDB. @@ -48,9 +48,9 @@ #include "linux-x86-tdesc.h" #ifdef __x86_64__ -static struct target_desc *tdesc_amd64_linux_no_xml; +static target_desc_up tdesc_amd64_linux_no_xml; #endif -static struct target_desc *tdesc_i386_linux_no_xml; +static target_desc_up tdesc_i386_linux_no_xml; static unsigned char jump_insn[] = { 0xe9, 0, 0, 0, 0 }; @@ -58,13 +58,13 @@ static unsigned char small_jump_insn[] = { 0x66, 0xe9, 0, 0 }; /* Backward compatibility for gdb without XML support. */ -static const char *xmltarget_i386_linux_no_xml = "@\ +static const char xmltarget_i386_linux_no_xml[] = "@\ i386\ GNU/Linux\ "; #ifdef __x86_64__ -static const char *xmltarget_amd64_linux_no_xml = "@\ +static const char xmltarget_amd64_linux_no_xml[] = "@\ i386:x86-64\ GNU/Linux\ "; @@ -106,7 +106,7 @@ public: bool supports_z_point_type (char z_type) override; - void process_qsupported (char **features, int count) override; + void process_qsupported (gdb::array_view features) override; bool supports_tracepoints () override; @@ -233,11 +233,7 @@ static const int x86_64_regmap[] = -1, -1, -1, -1, -1, -1, -1, -1, -1, ORIG_RAX * 8, -#ifdef HAVE_STRUCT_USER_REGS_STRUCT_FS_BASE 21 * 8, 22 * 8, -#else - -1, -1, -#endif -1, -1, -1, -1, /* MPX registers BND0 ... BND3. */ -1, -1, /* MPX registers BNDCFGU, BNDSTATUS. */ -1, -1, -1, -1, -1, -1, -1, -1, /* xmm16 ... xmm31 (AVX512) */ @@ -413,19 +409,6 @@ x86_fill_gregset (struct regcache *regcache, void *buf) if (x86_64_regmap[i] != -1) collect_register (regcache, i, ((char *) buf) + x86_64_regmap[i]); -#ifndef HAVE_STRUCT_USER_REGS_STRUCT_FS_BASE - { - unsigned long base; - int lwpid = lwpid_of (current_thread); - - collect_register_by_name (regcache, "fs_base", &base); - ptrace (PTRACE_ARCH_PRCTL, lwpid, &base, ARCH_SET_FS); - - collect_register_by_name (regcache, "gs_base", &base); - ptrace (PTRACE_ARCH_PRCTL, lwpid, &base, ARCH_SET_GS); - } -#endif - return; } @@ -449,7 +432,7 @@ x86_fill_gregset (struct regcache *regcache, void *buf) if (register_size (regcache->tdesc, 0) == 4) { void *ptr = ((gdb_byte *) buf - + i386_regmap[find_regno (regcache->tdesc, "eax")]); + + i386_regmap[find_regno (regcache->tdesc, "eax")]); *(int64_t *) ptr = *(int32_t *) ptr; } @@ -468,18 +451,6 @@ x86_store_gregset (struct regcache *regcache, const void *buf) if (x86_64_regmap[i] != -1) supply_register (regcache, i, ((char *) buf) + x86_64_regmap[i]); -#ifndef HAVE_STRUCT_USER_REGS_STRUCT_FS_BASE - { - unsigned long base; - int lwpid = lwpid_of (current_thread); - - if (ptrace (PTRACE_ARCH_PRCTL, lwpid, &base, ARCH_GET_FS) == 0) - supply_register_by_name (regcache, "fs_base", &base); - - if (ptrace (PTRACE_ARCH_PRCTL, lwpid, &base, ARCH_GET_GS) == 0) - supply_register_by_name (regcache, "gs_base", &base); - } -#endif return; } #endif @@ -928,10 +899,10 @@ x86_linux_read_description (void) /* Don't use XML. */ #ifdef __x86_64__ if (machine == EM_X86_64) - return tdesc_amd64_linux_no_xml; + return tdesc_amd64_linux_no_xml.get (); else #endif - return tdesc_i386_linux_no_xml; + return tdesc_i386_linux_no_xml.get (); } if (have_ptrace_getregset == -1) @@ -1032,18 +1003,15 @@ x86_target::update_xmltarget () PTRACE_GETREGSET. */ void -x86_target::process_qsupported (char **features, int count) +x86_target::process_qsupported (gdb::array_view features) { - int i; - /* Return if gdb doesn't support XML. If gdb sends "xmlRegisters=" with "i386" in qSupported query, it supports x86 XML target descriptions. */ use_xml = 0; - for (i = 0; i < count; i++) - { - const char *feature = features[i]; + for (const char *feature : features) + { if (startswith (feature, "xmlRegisters=")) { char *copy = xstrdup (feature + 13); @@ -1063,6 +1031,7 @@ x86_target::process_qsupported (char **features, int count) free (copy); } } + update_xmltarget (); } @@ -2986,7 +2955,7 @@ x86_target::get_ipa_tdesc_idx () return amd64_get_ipa_tdesc_idx (tdesc); #endif - if (tdesc == tdesc_i386_linux_no_xml) + if (tdesc == tdesc_i386_linux_no_xml.get ()) return X86_TDESC_SSE; return i386_get_ipa_tdesc_idx (tdesc); @@ -3002,14 +2971,14 @@ initialize_low_arch (void) /* Initialize the Linux target descriptions. */ #ifdef __x86_64__ tdesc_amd64_linux_no_xml = allocate_target_description (); - copy_target_description (tdesc_amd64_linux_no_xml, + copy_target_description (tdesc_amd64_linux_no_xml.get (), amd64_linux_read_description (X86_XSTATE_SSE_MASK, false)); tdesc_amd64_linux_no_xml->xmltarget = xmltarget_amd64_linux_no_xml; #endif tdesc_i386_linux_no_xml = allocate_target_description (); - copy_target_description (tdesc_i386_linux_no_xml, + copy_target_description (tdesc_i386_linux_no_xml.get (), i386_linux_read_description (X86_XSTATE_SSE_MASK)); tdesc_i386_linux_no_xml->xmltarget = xmltarget_i386_linux_no_xml;