* gdbarch.sh (fetch_tls_load_module_address): New architecture method.

* gdbarch.c, gdbarch.h: Regenerate.
	* dwarf2loc.c (dwarf_expr_tls_address): Fetch TLS load module
	address and pass this address, instead of the objfile address, to
	target_get_thread_local_address().
	* linux-thread-db.c (thread_db_get_thread_local_address): Change
	second parameter from type ``struct objfile *'' to CORE_ADDR.  Do
	not call svr4_fetch_objfile_link_map() to fetch the load module
	address.
	* target.h (struct target_ops): Change second parameter of
	``to_get_thread_local_address'' from ``struct objfile *'' to
	``CORE_ADDR''.
	* alpha-linux-tdep.c (solib-svr4.h): Include.
	(alpha_linux_init_abi): Register TLS load module fetcher.
	* amd64-linux-tdep.c (amd64_linux_init_abi): Likewise.
	* hppa-linux-tdep.c (hppa_linux_init_abi): Likewise.
	* i386-linux-tdep.c (i386_linux_init_abi): Likewise.
	* ia64-linux-tdep.c (solib-svr4.h): Include.
	(ia64_linux_init_abi): Register TLS load module fetcher.
	* m32r-linux-tdep.c (m32r_linux_init_abi): Likewise.
	* m68klinux-tdep.c (m68k_linux_init_abi): Likewise.
	* mips-linux-tdep.c (mips_linux_init_abi): Likewise.
	* s390-tdep.c (s390_gdbarch_init): Likewise.
	* sparc-linux-tdep.c (sparc32_linux_init_abi): Likewise.
	* sparc64-linux-tdep.c (solib-svr4.h): Include.
	(sparc64_linux_init_abi): Register TLS load module fetcher.
	* Makefile.in (alpha-linux-tdep.o, ia64-linux-tdep.o)
	(sparc-linux-tdep.o): Update dependencies.
This commit is contained in:
Kevin Buettner 2005-03-31 19:58:26 +00:00
parent 0e867e7957
commit b275693032
21 changed files with 189 additions and 22 deletions

View file

@ -1,3 +1,34 @@
2005-03-31 Kevin Buettner <kevinb@redhat.com>
* gdbarch.sh (fetch_tls_load_module_address): New architecture method.
* gdbarch.c, gdbarch.h: Regenerate.
* dwarf2loc.c (dwarf_expr_tls_address): Fetch TLS load module
address and pass this address, instead of the objfile address, to
target_get_thread_local_address().
* linux-thread-db.c (thread_db_get_thread_local_address): Change
second parameter from type ``struct objfile *'' to CORE_ADDR. Do
not call svr4_fetch_objfile_link_map() to fetch the load module
address.
* target.h (struct target_ops): Change second parameter of
``to_get_thread_local_address'' from ``struct objfile *'' to
``CORE_ADDR''.
* alpha-linux-tdep.c (solib-svr4.h): Include.
(alpha_linux_init_abi): Register TLS load module fetcher.
* amd64-linux-tdep.c (amd64_linux_init_abi): Likewise.
* hppa-linux-tdep.c (hppa_linux_init_abi): Likewise.
* i386-linux-tdep.c (i386_linux_init_abi): Likewise.
* ia64-linux-tdep.c (solib-svr4.h): Include.
(ia64_linux_init_abi): Register TLS load module fetcher.
* m32r-linux-tdep.c (m32r_linux_init_abi): Likewise.
* m68klinux-tdep.c (m68k_linux_init_abi): Likewise.
* mips-linux-tdep.c (mips_linux_init_abi): Likewise.
* s390-tdep.c (s390_gdbarch_init): Likewise.
* sparc-linux-tdep.c (sparc32_linux_init_abi): Likewise.
* sparc64-linux-tdep.c (solib-svr4.h): Include.
(sparc64_linux_init_abi): Register TLS load module fetcher.
* Makefile.in (alpha-linux-tdep.o, ia64-linux-tdep.o)
(sparc-linux-tdep.o): Update dependencies.
2005-03-29 Daniel Jacobowitz <dan@codesourcery.com>
* c-valprint.c (c_value_print): Fix up some formatting. Use

View file

@ -1669,7 +1669,7 @@ alphabsd-tdep.o: alphabsd-tdep.c $(defs_h) $(alpha_tdep_h) \
alphafbsd-tdep.o: alphafbsd-tdep.c $(defs_h) $(value_h) $(osabi_h) \
$(alpha_tdep_h)
alpha-linux-tdep.o: alpha-linux-tdep.c $(defs_h) $(frame_h) $(gdb_assert_h) \
$(osabi_h) $(alpha_tdep_h)
$(osabi_h) $(solib_svr4_h) $(alpha_tdep_h)
alpha-mdebug-tdep.o: alpha-mdebug-tdep.c $(defs_h) $(frame_h) \
$(frame_unwind_h) $(frame_base_h) $(symtab_h) $(gdbcore_h) \
$(block_h) $(gdb_assert_h) $(alpha_tdep_h) $(mdebugread_h)
@ -2089,7 +2089,7 @@ ia64-linux-nat.o: ia64-linux-nat.c $(defs_h) $(gdb_string_h) $(inferior_h) \
$(target_h) $(gdbcore_h) $(regcache_h) $(ia64_tdep_h) $(gdb_wait_h) \
$(gregset_h)
ia64-linux-tdep.o: ia64-linux-tdep.c $(defs_h) $(ia64_tdep_h) \
$(arch_utils_h) $(gdbcore_h) $(regcache_h) $(osabi_h)
$(arch_utils_h) $(gdbcore_h) $(regcache_h) $(osabi_h) $(solib_svr4_h)
ia64-tdep.o: ia64-tdep.c $(defs_h) $(inferior_h) $(gdbcore_h) \
$(arch_utils_h) $(floatformat_h) $(regcache_h) $(reggroups_h) \
$(frame_h) $(frame_base_h) $(frame_unwind_h) $(doublest_h) \
@ -2570,7 +2570,7 @@ sparc64fbsd-tdep.o: sparc64fbsd-tdep.c $(defs_h) $(frame_h) \
sparc64-linux-nat.o: sparc64-linux-nat.c $(defs_h) $(sparc64_tdep_h) \
$(sparc_nat_h)
sparc64-linux-tdep.o: sparc64-linux-tdep.c $(defs_h) $(gdbarch_h) $(osabi_h) \
$(sparc64_tdep_h)
$(solib_svr4_h) $(sparc64_tdep_h)
sparc64-nat.o: sparc64-nat.c $(defs_h) $(gdbarch_h) $(sparc64_tdep_h) \
$(sparc_nat_h)
sparc64nbsd-nat.o: sparc64nbsd-nat.c $(defs_h) $(regcache_h) $(target_h) \

View file

@ -22,6 +22,7 @@
#include "frame.h"
#include "gdb_assert.h"
#include "osabi.h"
#include "solib-svr4.h"
#include "alpha-tdep.h"
@ -140,6 +141,10 @@ alpha_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
tdep->pc_in_sigtramp = alpha_linux_pc_in_sigtramp;
tdep->jb_pc = 2;
tdep->jb_elt_size = 8;
/* Enable TLS support. */
set_gdbarch_fetch_tls_load_module_address (gdbarch,
svr4_fetch_objfile_link_map);
}
void

View file

@ -218,6 +218,10 @@ amd64_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
/* GNU/Linux uses SVR4-style shared libraries. */
set_solib_svr4_fetch_link_map_offsets
(gdbarch, svr4_lp64_fetch_link_map_offsets);
/* Enable TLS support. */
set_gdbarch_fetch_tls_load_module_address (gdbarch,
svr4_fetch_objfile_link_map);
}

View file

@ -495,6 +495,10 @@ arm_linux_init_abi (struct gdbarch_info info,
/* Shared library handling. */
set_gdbarch_skip_trampoline_code (gdbarch, find_solib_trampoline_target);
set_gdbarch_skip_solib_resolver (gdbarch, glibc_skip_solib_resolver);
/* Enable TLS support. */
set_gdbarch_fetch_tls_load_module_address (gdbarch,
svr4_fetch_objfile_link_map);
}
void

View file

@ -188,7 +188,8 @@ dwarf_expr_tls_address (void *baton, CORE_ADDR offset)
struct dwarf_expr_baton *debaton = (struct dwarf_expr_baton *) baton;
volatile CORE_ADDR addr = 0;
if (target_get_thread_local_address_p ())
if (target_get_thread_local_address_p ()
&& gdbarch_fetch_tls_load_module_address_p (current_gdbarch))
{
ptid_t ptid = inferior_ptid;
struct objfile *objfile = debaton->objfile;
@ -196,7 +197,21 @@ dwarf_expr_tls_address (void *baton, CORE_ADDR offset)
TRY_CATCH (ex, RETURN_MASK_ALL)
{
addr = target_get_thread_local_address (ptid, objfile, offset);
CORE_ADDR lm_addr;
/* Fetch the load module address for this objfile. */
lm_addr = gdbarch_fetch_tls_load_module_address (current_gdbarch,
objfile);
/* If it's 0, throw the appropriate exception. */
if (lm_addr == 0)
{
struct exception e
= { RETURN_ERROR, TLS_LOAD_MODULE_NOT_FOUND_ERROR, 0 };
throw_exception (e);
}
addr = target_get_thread_local_address (ptid, lm_addr, offset);
}
/* If an error occurred, print TLS related messages here. Otherwise,
throw the error to some higher catcher. */

View file

@ -203,6 +203,7 @@ struct gdbarch
CORE_ADDR decr_pc_after_break;
CORE_ADDR deprecated_function_start_offset;
gdbarch_remote_translate_xfer_address_ftype *remote_translate_xfer_address;
gdbarch_fetch_tls_load_module_address_ftype *fetch_tls_load_module_address;
CORE_ADDR frame_args_skip;
gdbarch_unwind_pc_ftype *unwind_pc;
gdbarch_unwind_sp_ftype *unwind_sp;
@ -329,6 +330,7 @@ struct gdbarch startup_gdbarch =
0, /* decr_pc_after_break */
0, /* deprecated_function_start_offset */
generic_remote_translate_xfer_address, /* remote_translate_xfer_address */
0, /* fetch_tls_load_module_address */
0, /* frame_args_skip */
0, /* unwind_pc */
0, /* unwind_sp */
@ -583,6 +585,7 @@ verify_gdbarch (struct gdbarch *current_gdbarch)
/* Skip verify of decr_pc_after_break, invalid_p == 0 */
/* Skip verify of deprecated_function_start_offset, invalid_p == 0 */
/* Skip verify of remote_translate_xfer_address, invalid_p == 0 */
/* Skip verify of fetch_tls_load_module_address, has predicate */
/* Skip verify of frame_args_skip, invalid_p == 0 */
/* Skip verify of unwind_pc, has predicate */
/* Skip verify of unwind_sp, has predicate */
@ -1090,6 +1093,24 @@ gdbarch_dump (struct gdbarch *current_gdbarch, struct ui_file *file)
fprintf_unfiltered (file,
"gdbarch_dump: fetch_pointer_argument = <0x%lx>\n",
(long) current_gdbarch->fetch_pointer_argument);
#ifdef FETCH_TLS_LOAD_MODULE_ADDRESS_P
fprintf_unfiltered (file,
"gdbarch_dump: %s # %s\n",
"FETCH_TLS_LOAD_MODULE_ADDRESS_P()",
XSTRING (FETCH_TLS_LOAD_MODULE_ADDRESS_P ()));
#endif
fprintf_unfiltered (file,
"gdbarch_dump: gdbarch_fetch_tls_load_module_address_p() = %d\n",
gdbarch_fetch_tls_load_module_address_p (current_gdbarch));
#ifdef FETCH_TLS_LOAD_MODULE_ADDRESS
fprintf_unfiltered (file,
"gdbarch_dump: %s # %s\n",
"FETCH_TLS_LOAD_MODULE_ADDRESS(objfile)",
XSTRING (FETCH_TLS_LOAD_MODULE_ADDRESS (objfile)));
#endif
fprintf_unfiltered (file,
"gdbarch_dump: fetch_tls_load_module_address = <0x%lx>\n",
(long) current_gdbarch->fetch_tls_load_module_address);
#ifdef TARGET_FLOAT_BIT
fprintf_unfiltered (file,
"gdbarch_dump: TARGET_FLOAT_BIT # %s\n",
@ -3042,6 +3063,30 @@ set_gdbarch_remote_translate_xfer_address (struct gdbarch *gdbarch,
gdbarch->remote_translate_xfer_address = remote_translate_xfer_address;
}
int
gdbarch_fetch_tls_load_module_address_p (struct gdbarch *gdbarch)
{
gdb_assert (gdbarch != NULL);
return gdbarch->fetch_tls_load_module_address != NULL;
}
CORE_ADDR
gdbarch_fetch_tls_load_module_address (struct gdbarch *gdbarch, struct objfile *objfile)
{
gdb_assert (gdbarch != NULL);
gdb_assert (gdbarch->fetch_tls_load_module_address != NULL);
if (gdbarch_debug >= 2)
fprintf_unfiltered (gdb_stdlog, "gdbarch_fetch_tls_load_module_address called\n");
return gdbarch->fetch_tls_load_module_address (objfile);
}
void
set_gdbarch_fetch_tls_load_module_address (struct gdbarch *gdbarch,
gdbarch_fetch_tls_load_module_address_ftype fetch_tls_load_module_address)
{
gdbarch->fetch_tls_load_module_address = fetch_tls_load_module_address;
}
CORE_ADDR
gdbarch_frame_args_skip (struct gdbarch *gdbarch)
{

View file

@ -977,6 +977,33 @@ typedef void (gdbarch_remote_translate_xfer_address_ftype) (struct gdbarch *gdba
extern void gdbarch_remote_translate_xfer_address (struct gdbarch *gdbarch, struct regcache *regcache, CORE_ADDR gdb_addr, int gdb_len, CORE_ADDR *rem_addr, int *rem_len);
extern void set_gdbarch_remote_translate_xfer_address (struct gdbarch *gdbarch, gdbarch_remote_translate_xfer_address_ftype *remote_translate_xfer_address);
/* Fetch the target specific address used to represent a load module. */
#if defined (FETCH_TLS_LOAD_MODULE_ADDRESS)
/* Legacy for systems yet to multi-arch FETCH_TLS_LOAD_MODULE_ADDRESS */
#if !defined (FETCH_TLS_LOAD_MODULE_ADDRESS_P)
#define FETCH_TLS_LOAD_MODULE_ADDRESS_P() (1)
#endif
#endif
extern int gdbarch_fetch_tls_load_module_address_p (struct gdbarch *gdbarch);
#if !defined (GDB_TM_FILE) && defined (FETCH_TLS_LOAD_MODULE_ADDRESS_P)
#error "Non multi-arch definition of FETCH_TLS_LOAD_MODULE_ADDRESS"
#endif
#if !defined (FETCH_TLS_LOAD_MODULE_ADDRESS_P)
#define FETCH_TLS_LOAD_MODULE_ADDRESS_P() (gdbarch_fetch_tls_load_module_address_p (current_gdbarch))
#endif
typedef CORE_ADDR (gdbarch_fetch_tls_load_module_address_ftype) (struct objfile *objfile);
extern CORE_ADDR gdbarch_fetch_tls_load_module_address (struct gdbarch *gdbarch, struct objfile *objfile);
extern void set_gdbarch_fetch_tls_load_module_address (struct gdbarch *gdbarch, gdbarch_fetch_tls_load_module_address_ftype *fetch_tls_load_module_address);
#if !defined (GDB_TM_FILE) && defined (FETCH_TLS_LOAD_MODULE_ADDRESS)
#error "Non multi-arch definition of FETCH_TLS_LOAD_MODULE_ADDRESS"
#endif
#if !defined (FETCH_TLS_LOAD_MODULE_ADDRESS)
#define FETCH_TLS_LOAD_MODULE_ADDRESS(objfile) (gdbarch_fetch_tls_load_module_address (current_gdbarch, objfile))
#endif
extern CORE_ADDR gdbarch_frame_args_skip (struct gdbarch *gdbarch);
extern void set_gdbarch_frame_args_skip (struct gdbarch *gdbarch, CORE_ADDR frame_args_skip);
#if !defined (GDB_TM_FILE) && defined (FRAME_ARGS_SKIP)

View file

@ -566,6 +566,9 @@ v:=:CORE_ADDR:decr_pc_after_break:::0:::0
v:=:CORE_ADDR:deprecated_function_start_offset:::0:::0
m::void:remote_translate_xfer_address:struct regcache *regcache, CORE_ADDR gdb_addr, int gdb_len, CORE_ADDR *rem_addr, int *rem_len:regcache, gdb_addr, gdb_len, rem_addr, rem_len::generic_remote_translate_xfer_address::0
# Fetch the target specific address used to represent a load module.
F:=:CORE_ADDR:fetch_tls_load_module_address:struct objfile *objfile:objfile
#
v:=:CORE_ADDR:frame_args_skip:::0:::0
M::CORE_ADDR:unwind_pc:struct frame_info *next_frame:next_frame

View file

@ -618,6 +618,10 @@ hppa_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
frame_unwind_append_sniffer (gdbarch, dwarf2_frame_sniffer);
frame_base_append_sniffer (gdbarch, dwarf2_frame_base_sniffer);
#endif
/* Enable TLS support. */
set_gdbarch_fetch_tls_load_module_address (gdbarch,
svr4_fetch_objfile_link_map);
}
void

View file

@ -437,6 +437,10 @@ i386_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
set_gdbarch_skip_solib_resolver (gdbarch, glibc_skip_solib_resolver);
dwarf2_frame_set_signal_frame_p (gdbarch, i386_linux_dwarf_signal_frame_p);
/* Enable TLS support. */
set_gdbarch_fetch_tls_load_module_address (gdbarch,
svr4_fetch_objfile_link_map);
}
/* Provide a prototype to silence -Wmissing-prototypes. */

View file

@ -25,6 +25,7 @@
#include "gdbcore.h"
#include "regcache.h"
#include "osabi.h"
#include "solib-svr4.h"
/* The sigtramp code is in a non-readable (executable-only) region
of memory called the ``gate page''. The addresses in question
@ -124,6 +125,10 @@ ia64_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
tdep->sigcontext_register_address = ia64_linux_sigcontext_register_address;
set_gdbarch_write_pc (gdbarch, ia64_linux_write_pc);
/* Enable TLS support. */
set_gdbarch_fetch_tls_load_module_address (gdbarch,
svr4_fetch_objfile_link_map);
}
void

View file

@ -1230,18 +1230,18 @@ thread_db_pid_to_str (ptid_t ptid)
return normal_pid_to_str (ptid);
}
/* Get the address of the thread local variable in OBJFILE which is
stored at OFFSET within the thread local storage for thread PTID. */
/* Get the address of the thread local variable in load module LM which
is stored at OFFSET within the thread local storage for thread PTID. */
static CORE_ADDR
thread_db_get_thread_local_address (ptid_t ptid, struct objfile *objfile,
thread_db_get_thread_local_address (ptid_t ptid,
CORE_ADDR lm,
CORE_ADDR offset)
{
if (is_thread (ptid))
{
td_err_e err;
void *address;
CORE_ADDR lm;
struct thread_info *thread_info;
/* glibc doesn't provide the needed interface. */
@ -1253,17 +1253,8 @@ thread_db_get_thread_local_address (ptid_t ptid, struct objfile *objfile,
throw_exception (e);
}
/* Get the address of the link map for this objfile. */
lm = svr4_fetch_objfile_link_map (objfile);
/* Whoops, we couldn't find one. Bail out. */
if (!lm)
{
struct exception e
= { RETURN_ERROR, TLS_LOAD_MODULE_NOT_FOUND_ERROR, 0 };
throw_exception (e);
}
/* Caller should have verified that lm != 0. */
gdb_assert (lm != 0);
/* Get info about the thread. */
thread_info = find_thread_pid (ptid);
@ -1302,7 +1293,7 @@ thread_db_get_thread_local_address (ptid_t ptid, struct objfile *objfile,
}
if (target_beneath->to_get_thread_local_address)
return target_beneath->to_get_thread_local_address (ptid, objfile, offset);
return target_beneath->to_get_thread_local_address (ptid, lm, offset);
else
{
struct exception e

View file

@ -419,6 +419,10 @@ m32r_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
/* Core file support. */
set_gdbarch_regset_from_core_section
(gdbarch, m32r_linux_regset_from_core_section);
/* Enable TLS support. */
set_gdbarch_fetch_tls_load_module_address (gdbarch,
svr4_fetch_objfile_link_map);
}
/* Provide a prototype to silence -Wmissing-prototypes. */

View file

@ -306,6 +306,10 @@ m68k_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
set_gdbarch_skip_solib_resolver (gdbarch, glibc_skip_solib_resolver);
set_gdbarch_skip_trampoline_code (gdbarch, find_solib_trampoline_target);
/* Enable TLS support. */
set_gdbarch_fetch_tls_load_module_address (gdbarch,
svr4_fetch_objfile_link_map);
}
void

View file

@ -1195,6 +1195,10 @@ mips_linux_init_abi (struct gdbarch_info info,
set_gdbarch_skip_solib_resolver (gdbarch, mips_linux_skip_resolver);
set_gdbarch_software_single_step (gdbarch, mips_software_single_step);
/* Enable TLS support. */
set_gdbarch_fetch_tls_load_module_address (gdbarch,
svr4_fetch_objfile_link_map);
}
void

View file

@ -1111,6 +1111,10 @@ ppc_linux_init_abi (struct gdbarch_info info,
tramp_frame_prepend_unwinder (gdbarch, &ppc64_linux_sighandler_tramp_frame);
}
set_gdbarch_regset_from_core_section (gdbarch, ppc_linux_regset_from_core_section);
/* Enable TLS support. */
set_gdbarch_fetch_tls_load_module_address (gdbarch,
svr4_fetch_objfile_link_map);
}
void

View file

@ -3007,6 +3007,10 @@ s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_print_insn (gdbarch, print_insn_s390);
/* Enable TLS support. */
set_gdbarch_fetch_tls_load_module_address (gdbarch,
svr4_fetch_objfile_link_map);
return gdbarch;
}

View file

@ -266,6 +266,10 @@ sparc32_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
set_gdbarch_long_double_format (gdbarch, &floatformat_ieee_double_big);
frame_unwind_append_sniffer (gdbarch, sparc32_linux_sigtramp_frame_sniffer);
/* Enable TLS support. */
set_gdbarch_fetch_tls_load_module_address (gdbarch,
svr4_fetch_objfile_link_map);
}
/* Provide a prototype to silence -Wmissing-prototypes. */

View file

@ -22,6 +22,7 @@
#include "defs.h"
#include "gdbarch.h"
#include "osabi.h"
#include "solib-svr4.h"
#include "sparc64-tdep.h"
@ -35,6 +36,10 @@ sparc64_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
/* ... but doesn't have kernel-assisted single-stepping support. */
set_gdbarch_software_single_step (gdbarch, sparc_software_single_step);
/* Enable TLS support. */
set_gdbarch_fetch_tls_load_module_address (gdbarch,
svr4_fetch_objfile_link_map);
}
/* Provide a prototype to silence -Wmissing-prototypes. */

View file

@ -411,7 +411,7 @@ struct target_ops
thread-local storage hasn't been allocated yet, this function
may return an error. */
CORE_ADDR (*to_get_thread_local_address) (ptid_t ptid,
struct objfile *objfile,
CORE_ADDR load_module_addr,
CORE_ADDR offset);
/* Perform partial transfers on OBJECT. See target_read_partial