ports/devel/gdb/files/commit-b0f87ed032
John Baldwin 8113892617 Update port to GDB 8.3.
New features in GDB 8.3 include support for DWARF index caches and
styling (colors) in the CLI and TUI.  Source code styling is also
available via the new SOURCE_HIGHLIGHT option (enabled by default).
GDB 8.3 also adds support for FreeBSD/riscv64.

In addition, kgdb has been updated for changes in 8.3 along with
support for FreeBSD/riscv64 kernels.

The libc++ helpers have been updated to a newer version which adds
support for std::list<> and std::forward_list<>.  The helpers now
also support Python 3.

Finally, a few post-8.3 patches have been backported which add suport
for TLS (Thread Local Storage) variables on FreeBSD amd64, i386,
powerpc, and riscv architectures.  Note that amd64 and i386 do not
support examining TLS variables in core dumps currently.  This support
along with support for additional architectures require kernel changes
and will be added in the future once the kernel has been updated.

Reviewed by:	pizzamig (maintainer)
Differential Revision:	https://reviews.freebsd.org/D20403
2019-06-01 00:44:08 +00:00

60 lines
1.9 KiB
Text

commit b0f87ed032bb68a9965de81cbf9fd676a83b9174
Author: John Baldwin <jhb@FreeBSD.org>
Date: Tue Mar 12 13:39:02 2019 -0700
Support TLS variables on FreeBSD/riscv.
Derive the pointer to the DTV array from the tp register.
gdb/ChangeLog:
* riscv-fbsd-tdep.c (riscv_fbsd_get_thread_local_address): New.
(riscv_fbsd_init_abi): Install gdbarch
"fetch_tls_load_module_address" and "get_thread_local_address"
methods.
diff --git gdb/riscv-fbsd-tdep.c gdb/riscv-fbsd-tdep.c
index 97ad28f59a..3125a2285e 100644
--- gdb/riscv-fbsd-tdep.c
+++ gdb/riscv-fbsd-tdep.c
@@ -174,6 +174,28 @@ static const struct tramp_frame riscv_fbsd_sigframe =
riscv_fbsd_sigframe_init
};
+/* Implement the "get_thread_local_address" gdbarch method. */
+
+static CORE_ADDR
+riscv_fbsd_get_thread_local_address (struct gdbarch *gdbarch, ptid_t ptid,
+ CORE_ADDR lm_addr, CORE_ADDR offset)
+{
+ struct regcache *regcache;
+
+ regcache = get_thread_arch_regcache (ptid, gdbarch);
+
+ target_fetch_registers (regcache, RISCV_TP_REGNUM);
+
+ ULONGEST tp;
+ if (regcache->cooked_read (RISCV_TP_REGNUM, &tp) != REG_VALID)
+ error (_("Unable to fetch %%tp"));
+
+ /* %tp points to the end of the TCB which contains two pointers.
+ The first pointer in the TCB points to the DTV array. */
+ CORE_ADDR dtv_addr = tp - (gdbarch_ptr_bit (gdbarch) / 8) * 2;
+ return fbsd_get_thread_local_address (gdbarch, dtv_addr, lm_addr, offset);
+}
+
/* Implement the 'init_osabi' method of struct gdb_osabi_handler. */
static void
@@ -193,6 +215,11 @@ riscv_fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
set_gdbarch_iterate_over_regset_sections
(gdbarch, riscv_fbsd_iterate_over_regset_sections);
+
+ set_gdbarch_fetch_tls_load_module_address (gdbarch,
+ svr4_fetch_objfile_link_map);
+ set_gdbarch_get_thread_local_address (gdbarch,
+ riscv_fbsd_get_thread_local_address);
}
void