X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=gdb%2Fi386-fbsd-tdep.c;h=0e53453bb6e3366d2a011d280ea755de2fea0143;hb=refs%2Fheads%2Fconcurrent-displaced-stepping-2020-04-01;hp=236f49b6c969614ca8231df277a6e9f262ba8310;hpb=1736a7bd96e8927c3f889a35f9153df4fd19d833;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/i386-fbsd-tdep.c b/gdb/i386-fbsd-tdep.c index 236f49b6c9..0e53453bb6 100644 --- a/gdb/i386-fbsd-tdep.c +++ b/gdb/i386-fbsd-tdep.c @@ -1,6 +1,6 @@ /* Target-dependent code for FreeBSD/i386. - Copyright (C) 2003-2016 Free Software Foundation, Inc. + Copyright (C) 2003-2020 Free Software Foundation, Inc. This file is part of GDB. @@ -24,13 +24,13 @@ #include "regcache.h" #include "regset.h" #include "i386-fbsd-tdep.h" -#include "x86-xstate.h" +#include "gdbsupport/x86-xstate.h" #include "i386-tdep.h" #include "i387-tdep.h" -#include "bsd-uthread.h" #include "fbsd-tdep.h" #include "solib-svr4.h" +#include "inferior.h" /* Support for signal handlers. */ @@ -224,20 +224,6 @@ int i386fbsd_sc_reg_offset[] = 8 + 16 * 4 /* %gs */ }; -/* From /usr/src/lib/libc/i386/gen/_setjmp.S. */ -static int i386fbsd_jmp_buf_reg_offset[] = -{ - -1, /* %eax */ - -1, /* %ecx */ - -1, /* %edx */ - 1 * 4, /* %ebx */ - 2 * 4, /* %esp */ - 3 * 4, /* %ebp */ - 4 * 4, /* %esi */ - 5 * 4, /* %edi */ - 0 * 4 /* %eip */ -}; - /* Get XSAVE extended state xcr0 from core dump. */ uint64_t @@ -248,7 +234,7 @@ i386fbsd_core_read_xcr0 (bfd *abfd) if (xstate) { - size_t size = bfd_section_size (abfd, xstate); + size_t size = bfd_section_size (xstate); /* Check extended state size. */ if (size < X86_XSTATE_AVX_SIZE) @@ -263,14 +249,14 @@ i386fbsd_core_read_xcr0 (bfd *abfd) { warning (_("Couldn't read `xcr0' bytes from " "`.reg-xstate' section in core file.")); - return 0; + return X86_XSTATE_SSE_MASK; } xcr0 = bfd_get_64 (abfd, contents); } } else - xcr0 = 0; + xcr0 = X86_XSTATE_SSE_MASK; return xcr0; } @@ -282,7 +268,7 @@ i386fbsd_core_read_description (struct gdbarch *gdbarch, struct target_ops *target, bfd *abfd) { - return i386_target_description (i386fbsd_core_read_xcr0 (abfd)); + return i386_target_description (i386fbsd_core_read_xcr0 (abfd), true); } /* Similar to i386_supply_fpregset, but use XSAVE extended state. */ @@ -324,52 +310,40 @@ i386fbsd_iterate_over_regset_sections (struct gdbarch *gdbarch, { struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); - cb (".reg", tdep->sizeof_gregset, &i386_gregset, NULL, cb_data); - cb (".reg2", tdep->sizeof_fpregset, &i386_fpregset, NULL, cb_data); + cb (".reg", tdep->sizeof_gregset, tdep->sizeof_gregset, &i386_gregset, NULL, + cb_data); + cb (".reg2", tdep->sizeof_fpregset, tdep->sizeof_fpregset, &i386_fpregset, + NULL, cb_data); if (tdep->xcr0 & X86_XSTATE_AVX) - cb (".reg-xstate", X86_XSTATE_SIZE(tdep->xcr0), - &i386fbsd_xstateregset, "XSAVE extended state", cb_data); + cb (".reg-xstate", X86_XSTATE_SIZE (tdep->xcr0), + X86_XSTATE_SIZE (tdep->xcr0), &i386fbsd_xstateregset, + "XSAVE extended state", cb_data); } -static void -i386fbsd_supply_uthread (struct regcache *regcache, - int regnum, CORE_ADDR addr) +/* Implement the get_thread_local_address gdbarch method. */ + +static CORE_ADDR +i386fbsd_get_thread_local_address (struct gdbarch *gdbarch, ptid_t ptid, + CORE_ADDR lm_addr, CORE_ADDR offset) { - gdb_byte buf[4]; - int i; + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + struct regcache *regcache; - gdb_assert (regnum >= -1); + if (tdep->fsbase_regnum == -1) + error (_("Unable to fetch %%gsbase")); - for (i = 0; i < ARRAY_SIZE (i386fbsd_jmp_buf_reg_offset); i++) - { - if (i386fbsd_jmp_buf_reg_offset[i] != -1 - && (regnum == -1 || regnum == i)) - { - read_memory (addr + i386fbsd_jmp_buf_reg_offset[i], buf, 4); - regcache_raw_supply (regcache, i, buf); - } - } -} + regcache = get_thread_arch_regcache (current_inferior ()->process_target (), + ptid, gdbarch); -static void -i386fbsd_collect_uthread (const struct regcache *regcache, - int regnum, CORE_ADDR addr) -{ - gdb_byte buf[4]; - int i; + target_fetch_registers (regcache, tdep->fsbase_regnum + 1); - gdb_assert (regnum >= -1); + ULONGEST gsbase; + if (regcache->cooked_read (tdep->fsbase_regnum + 1, &gsbase) != REG_VALID) + error (_("Unable to fetch %%gsbase")); - for (i = 0; i < ARRAY_SIZE (i386fbsd_jmp_buf_reg_offset); i++) - { - if (i386fbsd_jmp_buf_reg_offset[i] != -1 - && (regnum == -1 || regnum == i)) - { - regcache_raw_collect (regcache, i, buf); - write_memory (addr + i386fbsd_jmp_buf_reg_offset[i], buf, 4); - } - } + CORE_ADDR dtv_addr = gsbase + gdbarch_ptr_bit (gdbarch) / 8; + return fbsd_get_thread_local_address (gdbarch, dtv_addr, lm_addr, offset); } static void @@ -400,10 +374,6 @@ i386fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) tdep->sc_reg_offset = i386fbsd_sc_reg_offset; tdep->sc_num_regs = ARRAY_SIZE (i386fbsd_sc_reg_offset); - /* FreeBSD provides a user-level threads implementation. */ - bsd_uthread_set_supply_uthread (gdbarch, i386fbsd_supply_uthread); - bsd_uthread_set_collect_uthread (gdbarch, i386fbsd_collect_uthread); - i386_elf_init_abi (info, gdbarch); /* FreeBSD uses SVR4-style shared libraries. */ @@ -474,14 +444,16 @@ i386fbsd4_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) set_gdbarch_core_read_description (gdbarch, i386fbsd_core_read_description); -} - -/* Provide a prototype to silence -Wmissing-prototypes. */ -void _initialize_i386fbsd_tdep (void); + set_gdbarch_fetch_tls_load_module_address (gdbarch, + svr4_fetch_objfile_link_map); + set_gdbarch_get_thread_local_address (gdbarch, + i386fbsd_get_thread_local_address); +} +void _initialize_i386fbsd_tdep (); void -_initialize_i386fbsd_tdep (void) +_initialize_i386fbsd_tdep () { gdbarch_register_osabi (bfd_arch_i386, 0, GDB_OSABI_FREEBSD, i386fbsd4_init_abi);