aboutsummaryrefslogtreecommitdiff
path: root/gdb/remote.c
diff options
context:
space:
mode:
authorPierre Muller <muller@sourceware.org>2010-04-16 07:49:37 +0000
committerPierre Muller <muller@sourceware.org>2010-04-16 07:49:37 +0000
commit711e434b390a0b953862435eb81f3b89e720b030 (patch)
tree7be00803eab69a63ea7b8b3bce7bd88c77377920 /gdb/remote.c
parentcae3f17beefe8fb818861f8527720236969a0cfa (diff)
downloadgdb-711e434b390a0b953862435eb81f3b89e720b030.zip
gdb-711e434b390a0b953862435eb81f3b89e720b030.tar.gz
gdb-711e434b390a0b953862435eb81f3b89e720b030.tar.bz2
Support for Windows OS Thread Information Block.
* NEWS: Document new feature. * remote.c (PACKET_qGetTIBAddr): New enum element. (remote_get_tib_address): New function. (init_remote_ops): Set to_get_tib_address field to remote_get_tib_address. (_initialize_remote): Add add_packet_config_cmd for PACKET_qGetTIBAddr. * target.c (update_current_target): Set default value for new to_get_tib_address field. * target.h (target_ops): New field to_get_tib_address. (target_get_tib_address): New macro. * windows-nat.c (thread_info): Add thread_local_base field. (windows_add_thread): Add tlb argument of type 'void *'. (fake_create_process): Adapt windows_add_thread call. (get_windows_debug_event): Idem. (windows_get_tib_address): New function. (init_windows_ops): Set to_get_tib_address field to remote_get_tib_address. (_initialize_windows_nat): Replace info_w32_cmdlist initialization by a call to init_w32_command_list. (info_w32_command, info_w32_cmdlist): Removed from here... to windows-tdep.c file. * windows-tdep.h (info_w32_cmdlist): Declare. (init_w32_command_list): New external function declaration. * windows-tdep.c: Add several headers. (info_w32_cmdlist): to here, made global. (thread_information_32): New struct. (thread_information_64): New struct. (TIB_NAME): New char array. (MAX_TIB32, MAX_TIB64, FULL_TIB_SIZE): New constants. (maint_display_all_tib): New static variable. (windows_get_tlb_type): New function. (tlb_value_read, tlb_value_write): New functions. (tlb_value_funcs): New static struct. (tlb_make_value): New function. (display_one_tib): New function. (display_tib): New function. (show_maint_show_all_tib):New function. (info_w32_command): Moved from windows-nat.c. (init_w32_command_list): New function. (_initialize_windows_tdep): New function. New "maint set/show show-all-tib" command New "$_tlb" internal variable. gdbserver/ChangeLog entry: * server.c (handle_query): Handle 'qGetTIBAddr' query. * target.h (target_ops): New get_tib_address field. * win32-low.h (win32_thread_info): Add thread_local_base field. * win32-low.c (child_add_thread): Add tlb argument. Set thread_local_base field to TLB. (get_child_debug_event): Adapt to child_add_thread change. (win32_get_tib_address): New function. (win32_target_ops): Set get_tib_address field to win32_get_tib_address. * linux-low.c (linux_target_ops): Set get_tib_address field to NULL. doc/ChangeLog entry: gdb.texinfo ($_tlb): Document new automatic convinience variable. (info w32 thread-information-block): Document new command. (qGetTIBAddress): Document new gdbserver query. (maint set/show show-all-tib): Document new command.
Diffstat (limited to 'gdb/remote.c')
-rw-r--r--gdb/remote.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/gdb/remote.c b/gdb/remote.c
index 591c9f6..669c13b 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -1136,6 +1136,7 @@ enum {
PACKET_qXfer_spu_write,
PACKET_qXfer_osdata,
PACKET_qXfer_threads,
+ PACKET_qGetTIBAddr,
PACKET_qGetTLSAddr,
PACKET_qSupported,
PACKET_QPassSignals,
@@ -8437,6 +8438,48 @@ remote_get_thread_local_address (struct target_ops *ops,
return 0;
}
+/* Provide thread local base, i.e. Thread Information Block address.
+ Returns 1 if ptid is found and thread_local_base is non zero. */
+
+int
+remote_get_tib_address (ptid_t ptid, CORE_ADDR *addr)
+{
+ if (remote_protocol_packets[PACKET_qGetTIBAddr].support != PACKET_DISABLE)
+ {
+ struct remote_state *rs = get_remote_state ();
+ char *p = rs->buf;
+ char *endp = rs->buf + get_remote_packet_size ();
+ enum packet_result result;
+
+ strcpy (p, "qGetTIBAddr:");
+ p += strlen (p);
+ p = write_ptid (p, endp, ptid);
+ *p++ = '\0';
+
+ putpkt (rs->buf);
+ getpkt (&rs->buf, &rs->buf_size, 0);
+ result = packet_ok (rs->buf,
+ &remote_protocol_packets[PACKET_qGetTIBAddr]);
+ if (result == PACKET_OK)
+ {
+ ULONGEST result;
+
+ unpack_varlen_hex (rs->buf, &result);
+ if (addr)
+ *addr = (CORE_ADDR) result;
+ return 1;
+ }
+ else if (result == PACKET_UNKNOWN)
+ error (_("Remote target doesn't support qGetTIBAddr packet"));
+ else
+ error (_("Remote target failed to process qGetTIBAddr request"));
+ }
+ else
+ error (_("qGetTIBAddr not supported or disabled on this target"));
+ /* Not reached. */
+ return 0;
+}
+
/* Support for inferring a target description based on the current
architecture and the size of a 'g' packet. While the 'g' packet
can have any size (since optional registers can be left off the
@@ -9904,6 +9947,7 @@ Specify the serial device it is connected to\n\
remote_ops.to_set_circular_trace_buffer = remote_set_circular_trace_buffer;
remote_ops.to_core_of_thread = remote_core_of_thread;
remote_ops.to_verify_memory = remote_verify_memory;
+ remote_ops.to_get_tib_address = remote_get_tib_address;
}
/* Set up the extended remote vector by making a copy of the standard
@@ -10323,6 +10367,10 @@ Show the maximum size of the address (in bits) in a memory packet."), NULL,
"qGetTLSAddr", "get-thread-local-storage-address",
0);
+ add_packet_config_cmd (&remote_protocol_packets[PACKET_qGetTIBAddr],
+ "qGetTIBAddr", "get-thread-information-block-address",
+ 0);
+
add_packet_config_cmd (&remote_protocol_packets[PACKET_bc],
"bc", "reverse-continue", 0);