diff options
author | Pierre Muller <muller@sourceware.org> | 2010-04-16 07:49:37 +0000 |
---|---|---|
committer | Pierre Muller <muller@sourceware.org> | 2010-04-16 07:49:37 +0000 |
commit | 711e434b390a0b953862435eb81f3b89e720b030 (patch) | |
tree | 7be00803eab69a63ea7b8b3bce7bd88c77377920 /gdb/gdbserver | |
parent | cae3f17beefe8fb818861f8527720236969a0cfa (diff) | |
download | gdb-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/gdbserver')
-rw-r--r-- | gdb/gdbserver/ChangeLog | 13 | ||||
-rw-r--r-- | gdb/gdbserver/linux-low.c | 3 | ||||
-rw-r--r-- | gdb/gdbserver/server.c | 23 | ||||
-rw-r--r-- | gdb/gdbserver/target.h | 3 | ||||
-rw-r--r-- | gdb/gdbserver/win32-low.c | 48 | ||||
-rw-r--r-- | gdb/gdbserver/win32-low.h | 3 |
6 files changed, 84 insertions, 9 deletions
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index 269fb08..b4d509d 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,3 +1,16 @@ +2010-04-16 Pierre Muller <muller@ics.u-strasbg.fr> + + * 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. + 2010-04-12 Pedro Alves <pedro@codesourcery.com> * linux-low.c (linux_mourn): Also remove the process. diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c index 9692f21..6b7b40f 100644 --- a/gdb/gdbserver/linux-low.c +++ b/gdb/gdbserver/linux-low.c @@ -4334,7 +4334,8 @@ static struct target_ops linux_target_ops = { linux_read_pc, linux_write_pc, linux_thread_stopped, - linux_pause_all + linux_pause_all, + NULL, /* get_tib_address (Windows OS specific). */ }; static void diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c index 423a993..9c05c7f 100644 --- a/gdb/gdbserver/server.c +++ b/gdb/gdbserver/server.c @@ -1463,6 +1463,29 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p) /* Otherwise, pretend we do not understand this packet. */ } + /* Windows OS Thread Information Block address support. */ + if (the_target->get_tib_address != NULL + && strncmp ("qGetTIBAddr:", own_buf, 12) == 0) + { + char *annex; + int n; + CORE_ADDR tlb; + ptid_t ptid = read_ptid (own_buf + 12, &annex); + + n = (*the_target->get_tib_address) (ptid, &tlb); + if (n == 1) + { + sprintf (own_buf, "%llx", tlb); + return; + } + else if (n == 0) + { + write_enn (own_buf); + return; + } + return; + } + /* Handle "monitor" commands. */ if (strncmp ("qRcmd,", own_buf, 6) == 0) { diff --git a/gdb/gdbserver/target.h b/gdb/gdbserver/target.h index 4cccb29..fbe1910 100644 --- a/gdb/gdbserver/target.h +++ b/gdb/gdbserver/target.h @@ -309,6 +309,9 @@ struct target_ops /* Pause all threads. */ void (*pause_all) (void); + + /* Read Thread Information Block address. */ + int (*get_tib_address) (ptid_t ptid, CORE_ADDR *address); }; extern struct target_ops *the_target; diff --git a/gdb/gdbserver/win32-low.c b/gdb/gdbserver/win32-low.c index dfdb883..2ade6f7 100644 --- a/gdb/gdbserver/win32-low.c +++ b/gdb/gdbserver/win32-low.c @@ -178,7 +178,7 @@ thread_rec (ptid_t ptid, int get_context) /* Add a thread to the thread list. */ static win32_thread_info * -child_add_thread (DWORD pid, DWORD tid, HANDLE h) +child_add_thread (DWORD pid, DWORD tid, HANDLE h, void *tlb) { win32_thread_info *th; ptid_t ptid = ptid_build (pid, tid, 0); @@ -189,6 +189,7 @@ child_add_thread (DWORD pid, DWORD tid, HANDLE h) th = xcalloc (1, sizeof (*th)); th->tid = tid; th->h = h; + th->thread_local_base = (CORE_ADDR) (uintptr_t) tlb; add_thread (ptid, th); set_inferior_regcache_data ((struct thread_info *) @@ -1455,7 +1456,8 @@ get_child_debug_event (struct target_waitstatus *ourstatus) /* Record the existence of this thread. */ child_add_thread (current_event.dwProcessId, current_event.dwThreadId, - current_event.u.CreateThread.hThread); + current_event.u.CreateThread.hThread, + current_event.u.CreateThread.lpThreadLocalBase); break; case EXIT_THREAD_DEBUG_EVENT: @@ -1485,7 +1487,8 @@ get_child_debug_event (struct target_waitstatus *ourstatus) /* Add the main thread. */ child_add_thread (current_event.dwProcessId, main_thread_id, - current_event.u.CreateProcessInfo.hThread); + current_event.u.CreateProcessInfo.hThread, + current_event.u.CreateProcessInfo.lpThreadLocalBase); ourstatus->value.related_pid = debug_event_ptid (¤t_event); #ifdef _WIN32_WCE @@ -1753,6 +1756,20 @@ wince_hostio_last_error (char *buf) } #endif +/* Write Windows OS Thread Information Block address. */ + +static int +win32_get_tib_address (ptid_t ptid, CORE_ADDR *addr) +{ + win32_thread_info *th; + th = thread_rec (ptid, 0); + if (th == NULL) + return 0; + if (addr != NULL) + *addr = th->thread_local_base; + return 1; +} + static struct target_ops win32_target_ops = { win32_create_inferior, win32_attach, @@ -1767,21 +1784,36 @@ static struct target_ops win32_target_ops = { win32_store_inferior_registers, win32_read_inferior_memory, win32_write_inferior_memory, - NULL, + NULL, /* lookup_symbols */ win32_request_interrupt, - NULL, + NULL, /* read_auxv */ win32_insert_point, win32_remove_point, win32_stopped_by_watchpoint, win32_stopped_data_address, - NULL, - NULL, - NULL, + NULL, /* read_offsets */ + NULL, /* get_tls_address */ + NULL, /* qxfer_spu */ #ifdef _WIN32_WCE wince_hostio_last_error, #else hostio_last_error_from_errno, #endif + NULL, /* qxfer_osdata */ + NULL, /* qxfer_siginfo */ + NULL, /* supports_non_stop */ + NULL, /* async */ + NULL, /* start_non_stop */ + NULL, /* supports_multi_process */ + NULL, /* handle_monitor_command */ + NULL, /* core_of_thread */ + NULL, /* process_qsupported */ + NULL, /* supports_tracepoints */ + NULL, /* read_pc */ + NULL, /* write_pc */ + NULL, /* thread_stopped */ + NULL, /* pause_all */ + win32_get_tib_address, }; /* Initialize the Win32 backend. */ diff --git a/gdb/gdbserver/win32-low.h b/gdb/gdbserver/win32-low.h index d5ddf16..6e1b8dc 100644 --- a/gdb/gdbserver/win32-low.h +++ b/gdb/gdbserver/win32-low.h @@ -28,6 +28,9 @@ typedef struct win32_thread_info /* The handle to the thread. */ HANDLE h; + /* Thread Information Block address. */ + CORE_ADDR thread_local_base; + /* Non zero if SuspendThread was called on this thread. */ int suspended; |