From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17684 invoked by alias); 6 Dec 2004 21:31:52 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 16560 invoked from network); 6 Dec 2004 21:31:16 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org with SMTP; 6 Dec 2004 21:31:16 -0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.11/8.12.11) with ESMTP id iB6LVGZT011883 for ; Mon, 6 Dec 2004 16:31:16 -0500 Received: from pobox.corp.redhat.com (pobox.corp.redhat.com [172.16.52.156]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id iB6LVGr05533 for ; Mon, 6 Dec 2004 16:31:16 -0500 Received: from localhost.localdomain (vpn50-35.rdu.redhat.com [172.16.50.35]) by pobox.corp.redhat.com (8.12.8/8.12.8) with ESMTP id iB6LVFGE016488 for ; Mon, 6 Dec 2004 16:31:16 -0500 Received: from ironwood.lan (ironwood.lan [192.168.64.8]) by localhost.localdomain (8.12.11/8.12.10) with SMTP id iB6LVA8l014803 for ; Mon, 6 Dec 2004 14:31:10 -0700 Date: Mon, 06 Dec 2004 21:57:00 -0000 From: Kevin Buettner To: gdb-patches@sources.redhat.com Subject: [RFC] Generic support for qGetTLSAddr packet Message-ID: <20041206143109.7e29789f.kevinb@redhat.com> Organization: Red Hat Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-SW-Source: 2004-12/txt/msg00170.txt.bz2 The patch below implements support for the qGetTLSAddr packet. See: http://sources.redhat.com/ml/gdb/2004-11/msg00189.html This patch also adds a new gdbarch method for fetching the OS / ABI specific load module parameters. Still to come are three patches. They do the following: - Add documentation of remote_qGetTLSAddr_load_module_params to gdbint.texinfo. - Instantiate remote_qGetTLSAddr_load_module_params for GNU/Linux running on an i386. - Provide an implementation of the qGetTLSAddr packet for gdbserver. The documentation patch for the qGetTLSAddr packet has already been posted. It may be found at: http://sources.redhat.com/ml/gdb-patches/2004-12/msg00168.html Comments? * gdbarch.sh (remote_qGetTLSAddr_load_module_params): New method. * gdbarch.c, gdbarch.h: Regenerate. * 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.352 diff -u -p -r1.352 gdbarch.sh --- gdbarch.sh 3 Dec 2004 23:59:52 -0000 1.352 +++ gdbarch.sh 6 Dec 2004 20:59:23 -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: 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 6 Dec 2004 20:59:24 -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, "\