aboutsummaryrefslogtreecommitdiff
path: root/gdb/windows-nat.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/windows-nat.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/windows-nat.c')
-rw-r--r--gdb/windows-nat.c51
1 files changed, 33 insertions, 18 deletions
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index f2f42f7..5966b88 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -191,6 +191,7 @@ typedef struct thread_info_struct
struct thread_info_struct *next;
DWORD id;
HANDLE h;
+ CORE_ADDR thread_local_base;
char *name;
int suspended;
int reload_context;
@@ -320,7 +321,7 @@ thread_rec (DWORD id, int get_context)
/* Add a thread to the thread list. */
static thread_info *
-windows_add_thread (ptid_t ptid, HANDLE h)
+windows_add_thread (ptid_t ptid, HANDLE h, void *tlb)
{
thread_info *th;
DWORD id;
@@ -335,6 +336,7 @@ windows_add_thread (ptid_t ptid, HANDLE h)
th = XZALLOC (thread_info);
th->id = id;
th->h = h;
+ th->thread_local_base = (CORE_ADDR) (uintptr_t) tlb;
th->next = thread_head.next;
thread_head.next = th;
add_thread (ptid);
@@ -1074,15 +1076,6 @@ display_selectors (char * args, int from_tty)
}
}
-static struct cmd_list_element *info_w32_cmdlist = NULL;
-
-static void
-info_w32_command (char *args, int from_tty)
-{
- help_list (info_w32_cmdlist, "info w32 ", class_info, gdb_stdout);
-}
-
-
#define DEBUG_EXCEPTION_SIMPLE(x) if (debug_exceptions) \
printf_unfiltered ("gdb: Target exception %s at %s\n", x, \
host_address_to_string (\
@@ -1271,9 +1264,11 @@ fake_create_process (void)
/* We can not debug anything in that case. */
}
main_thread_id = current_event.dwThreadId;
- current_thread = windows_add_thread (ptid_build (current_event.dwProcessId, 0,
- current_event.dwThreadId),
- current_event.u.CreateThread.hThread);
+ current_thread = windows_add_thread (
+ ptid_build (current_event.dwProcessId, 0,
+ current_event.dwThreadId),
+ current_event.u.CreateThread.hThread,
+ current_event.u.CreateThread.lpThreadLocalBase);
return main_thread_id;
}
@@ -1447,7 +1442,9 @@ get_windows_debug_event (struct target_ops *ops,
retval = current_event.dwThreadId;
th = windows_add_thread (ptid_build (current_event.dwProcessId, 0,
current_event.dwThreadId),
- current_event.u.CreateThread.hThread);
+ current_event.u.CreateThread.hThread,
+ current_event.u.CreateThread.lpThreadLocalBase);
+
break;
case EXIT_THREAD_DEBUG_EVENT:
@@ -1481,7 +1478,8 @@ get_windows_debug_event (struct target_ops *ops,
/* Add the main thread */
th = windows_add_thread (ptid_build (current_event.dwProcessId, 0,
current_event.dwThreadId),
- current_event.u.CreateProcessInfo.hThread);
+ current_event.u.CreateProcessInfo.hThread,
+ current_event.u.CreateProcessInfo.lpThreadLocalBase);
retval = current_event.dwThreadId;
break;
@@ -2266,6 +2264,24 @@ windows_xfer_partial (struct target_ops *ops, enum target_object object,
}
}
+/* Provide thread local base, i.e. Thread Information Block address.
+ Returns 1 if ptid is found and sets *ADDR to thread_local_base. */
+
+static int
+windows_get_tib_address (ptid_t ptid, CORE_ADDR *addr)
+{
+ thread_info *th;
+
+ th = thread_rec (ptid_get_tid (ptid), 0);
+ if (th == NULL)
+ return 0;
+
+ if (addr != NULL)
+ *addr = th->thread_local_base;
+
+ return 1;
+}
+
static ptid_t
windows_get_ada_task_ptid (long lwp, long thread)
{
@@ -2314,6 +2330,7 @@ init_windows_ops (void)
windows_ops.to_has_execution = default_child_has_execution;
windows_ops.to_pid_to_exec_file = windows_pid_to_exec_file;
windows_ops.to_get_ada_task_ptid = windows_get_ada_task_ptid;
+ windows_ops.to_get_tib_address = windows_get_tib_address;
i386_use_watchpoints (&windows_ops);
@@ -2415,9 +2432,7 @@ Show whether to display kernel exceptions in child process."), NULL,
NULL, /* FIXME: i18n: */
&setlist, &showlist);
- add_prefix_cmd ("w32", class_info, info_w32_command,
- _("Print information specific to Win32 debugging."),
- &info_w32_cmdlist, "info w32 ", 0, &infolist);
+ init_w32_command_list ();
add_cmd ("selector", class_info, display_selectors,
_("Display selectors infos."),