* gdbarch.sh (remote_qGetTLSAddr_load_module_params): New method. * gdbarch.c, gdbarch.h: Regenerate. * solib-svr4.c, solit-svr4.h (svr4_nptl_remote_qGetTLSAddr_load_module_params): New function. * i386-linux-tdep.c (i386_linux_init_abi): Set remote_qGetTLSAddr_load_module_params method. * remote.c (remote_protocol_qGetTLSAddr): New static global variable. (set_remote_protocol_qGetTLSAddr_packet_cmd) (show_remote_protocol_qGetTLSAddr_packet_cmd) (remote_get_thread_local_address): New functions. (init_all_packet_configs): Initialize remote_protocol_qGetTLSAddr variable. (init_remote_ops): Initialize ``to_get_thread_local_address'' in target vector. (show_remote_cmd): Call show_remote_protocol_qGetTLS_Addr_packet_cmd(). (_initialize_remote): Add support for the "set remote get-thread-local-storage-address-packet' and "show remote get-thread-local-address-packet" commands. Index: gdbarch.sh =================================================================== RCS file: /cvs/src/src/gdb/gdbarch.sh,v retrieving revision 1.350 diff -u -p -r1.350 gdbarch.sh --- gdbarch.sh 31 Oct 2004 21:21:41 -0000 1.350 +++ gdbarch.sh 18 Nov 2004 20:51:26 -0000 @@ -567,6 +567,9 @@ v:=:CORE_ADDR:decr_pc_after_break:::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 + +# Fill in the additional parameters required to remotely fetch a TLS address +F:=:int:remote_qGetTLSAddr_load_module_params:ULONGEST **args_ptr, int *argcnt_ptr, struct objfile *objfile:args_ptr, argcnt_ptr, objfile # v:=:CORE_ADDR:frame_args_skip:::0:::0 M::CORE_ADDR:unwind_pc:struct frame_info *next_frame:next_frame Index: i386-linux-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/i386-linux-tdep.c,v retrieving revision 1.43 diff -u -p -r1.43 i386-linux-tdep.c --- i386-linux-tdep.c 9 Nov 2004 14:28:42 -0000 1.43 +++ i386-linux-tdep.c 18 Nov 2004 20:51:26 -0000 @@ -437,6 +437,9 @@ i386_linux_init_abi (struct gdbarch_info set_gdbarch_skip_solib_resolver (gdbarch, glibc_skip_solib_resolver); dwarf2_frame_set_signal_frame_p (gdbarch, i386_linux_dwarf_signal_frame_p); + + set_gdbarch_remote_qGetTLSAddr_load_module_params + (gdbarch, svr4_nptl_remote_qGetTLSAddr_load_module_params); } /* Provide a prototype to silence -Wmissing-prototypes. */ Index: remote.c =================================================================== RCS file: /cvs/src/src/gdb/remote.c,v retrieving revision 1.153 diff -u -p -r1.153 remote.c --- remote.c 11 Nov 2004 18:59:39 -0000 1.153 +++ remote.c 18 Nov 2004 20:51:26 -0000 @@ -961,6 +961,23 @@ show_remote_protocol_qPart_auxv_packet_c show_packet_config_cmd (&remote_protocol_qPart_auxv); } +/* Should we try the 'qGetTLSAddr' (Get Thread Local Storage Address) request? */ +static struct packet_config remote_protocol_qGetTLSAddr; + +static void +set_remote_protocol_qGetTLSAddr_packet_cmd (char *args, int from_tty, + struct cmd_list_element *c) +{ + update_packet_config (&remote_protocol_qGetTLSAddr); +} + +static void +show_remote_protocol_qGetTLSAddr_packet_cmd (char *args, int from_tty, + struct cmd_list_element *c) +{ + show_packet_config_cmd (&remote_protocol_qGetTLSAddr); +} + static struct packet_config remote_protocol_p; static void @@ -2067,6 +2084,7 @@ init_all_packet_configs (void) downloading. */ update_packet_config (&remote_protocol_binary_download); update_packet_config (&remote_protocol_qPart_auxv); + update_packet_config (&remote_protocol_qGetTLSAddr); } /* Symbol look-up. */ @@ -5233,6 +5251,52 @@ remote_pid_to_str (ptid_t ptid) return buf; } +/* Get the address of the thread local variable in OBJFILE which is + stored at OFFSET within the thread local storage for thread PTID. */ + +static CORE_ADDR +remote_get_thread_local_address (ptid_t ptid, struct objfile *objfile, + CORE_ADDR offset) +{ + if (remote_protocol_qGetTLSAddr.support != PACKET_DISABLE + && gdbarch_remote_qGetTLSAddr_load_module_params_p (current_gdbarch)) + { + struct remote_state *rs = get_remote_state (); + char *buf = alloca (rs->remote_packet_size); + char *p = buf; + int status, argcnt; + ULONGEST *extra_args; + + strcpy (p, "qGetTLSAddr:"); + p += strlen (p); + p += hexnumstr (p, PIDGET (ptid)); + *p++ = ','; + p += hexnumstr (p, offset); + status = gdbarch_remote_qGetTLSAddr_load_module_params + (current_gdbarch, &extra_args, &argcnt, objfile); + if (status) + { + int i; + for (i = 0; i < argcnt; i++) + { + *p++ = ','; + p += hexnumstr (p, extra_args[i]); + } + + putpkt (buf); + getpkt (buf, rs->remote_packet_size, 0); + if (packet_ok (buf, &remote_protocol_qGetTLSAddr) == PACKET_OK) + { + ULONGEST result; + + unpack_varlen_hex (buf, &result); + return result; + } + } + } + error ("Cannot find thread-local values on this target."); +} + static void init_remote_ops (void) { @@ -5272,6 +5336,7 @@ Specify the serial device it is connecte remote_ops.to_stop = remote_stop; remote_ops.to_xfer_partial = remote_xfer_partial; remote_ops.to_rcmd = remote_rcmd; + remote_ops.to_get_thread_local_address = remote_get_thread_local_address; remote_ops.to_stratum = process_stratum; remote_ops.to_has_all_memory = 1; remote_ops.to_has_memory = 1; @@ -5444,6 +5509,7 @@ show_remote_cmd (char *args, int from_tt show_remote_protocol_vcont_packet_cmd (args, from_tty, NULL); show_remote_protocol_binary_download_cmd (args, from_tty, NULL); show_remote_protocol_qPart_auxv_packet_cmd (args, from_tty, NULL); + show_remote_protocol_qGetTLSAddr_packet_cmd (args, from_tty, NULL); } static void @@ -5685,6 +5751,13 @@ in a memory packet.\n", &remote_set_cmdlist, &remote_show_cmdlist, 0); + add_packet_config_cmd (&remote_protocol_qGetTLSAddr, + "qGetTLSAddr", "get-thread-local-storage-address", + set_remote_protocol_qGetTLSAddr_packet_cmd, + show_remote_protocol_qGetTLSAddr_packet_cmd, + &remote_set_cmdlist, &remote_show_cmdlist, + 0); + /* Keep the old ``set remote Z-packet ...'' working. */ add_setshow_auto_boolean_cmd ("Z-packet", class_obscure, &remote_Z_packet_detect, "\ Index: solib-svr4.c =================================================================== RCS file: /cvs/src/src/gdb/solib-svr4.c,v retrieving revision 1.44 diff -u -p -r1.44 solib-svr4.c --- solib-svr4.c 9 Jun 2004 20:03:33 -0000 1.44 +++ solib-svr4.c 18 Nov 2004 20:51:26 -0000 @@ -1443,6 +1443,27 @@ svr4_lp64_fetch_link_map_offsets (void) return lmp; } +int +svr4_nptl_remote_qGetTLSAddr_load_module_params (ULONGEST **args_ptr, + int *argcnt_ptr, + struct objfile *objfile) +{ + CORE_ADDR lm; + + lm = svr4_fetch_objfile_link_map (objfile); + + if (!lm) + return 0; + else + { + static ULONGEST args[1]; + args[0] = lm; + *args_ptr = args; + *argcnt_ptr = 1; + return 1; + } +} + static struct target_so_ops svr4_so_ops; Index: solib-svr4.h =================================================================== RCS file: /cvs/src/src/gdb/solib-svr4.h,v retrieving revision 1.8 diff -u -p -r1.8 solib-svr4.h --- solib-svr4.h 12 Mar 2004 22:01:39 -0000 1.8 +++ solib-svr4.h 18 Nov 2004 20:51:26 -0000 @@ -92,4 +92,8 @@ extern struct link_map_offsets *(*legacy extern struct link_map_offsets *svr4_ilp32_fetch_link_map_offsets (void); extern struct link_map_offsets *svr4_lp64_fetch_link_map_offsets (void); +/* Return OS/ABI specific parameters needed for qGetTLSAddr packet. */ +extern int svr4_nptl_remote_qGetTLSAddr_load_module_params + (ULONGEST **args_ptr, int *argcnt_ptr, struct objfile *objfile); + #endif /* solib-svr4.h */