From: Kevin Buettner <kevinb@redhat.com>
To: gdb-patches@sources.redhat.com
Subject: [RFC] Generic support for qGetTLSAddr packet
Date: Mon, 06 Dec 2004 21:57:00 -0000 [thread overview]
Message-ID: <20041206143109.7e29789f.kevinb@redhat.com> (raw)
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, "\
next reply other threads:[~2004-12-06 21:31 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-12-06 21:57 Kevin Buettner [this message]
2004-12-06 22:51 ` Mark Kettenis
2004-12-06 23:06 ` Daniel Jacobowitz
2004-12-08 0:24 ` Kevin Buettner
2004-12-08 0:38 ` Kevin Buettner
2004-12-08 1:39 ` Daniel Jacobowitz
2004-12-06 23:46 ` Kevin Buettner
2004-12-12 18:17 ` Andrew Cagney
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20041206143109.7e29789f.kevinb@redhat.com \
--to=kevinb@redhat.com \
--cc=gdb-patches@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox