* [review] Share some Windows-related globals
@ 2019-10-29 18:16 Tom Tromey (Code Review)
2019-11-26 23:57 ` Luis Machado (Code Review)
0 siblings, 1 reply; 4+ messages in thread
From: Tom Tromey (Code Review) @ 2019-10-29 18:16 UTC (permalink / raw)
To: gdb-patches
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/419
......................................................................
Share some Windows-related globals
This moves some Windows-related globals into nat/windows-nat.c,
sharing them between gdb and gdbserver.
Change-Id: I3f861053e285afa3b3fff2d7892fdee2e59ab2c0
gdb/ChangeLog
2019-10-29 Tom Tromey <tromey@adacore.com>
* windows-nat.c (current_process_handle, current_process_id)
(main_thread_id, last_sig, current_event, last_wait_event)
(current_windows_thread, desired_stop_thread_id, pending_stops)
(last_stop_was_breakpoint, struct pending_stop): Move to
nat/windows-nat.c.
(display_selectors, fake_create_process)
(get_windows_debug_event): Update.
* nat/windows-nat.h (current_process_handle, current_process_id)
(main_thread_id, last_sig, current_event, last_wait_event)
(current_windows_thread, desired_stop_thread_id, pending_stops)
(last_stop_was_breakpoint): Declare.
(struct pending_stop): Move from windows-nat.c.
* nat/windows-nat.c (current_process_handle, current_process_id)
(main_thread_id, last_sig, current_event, last_wait_event)
(current_windows_thread, desired_stop_thread_id, pending_stops)
(last_stop_was_breakpoint): New globals. Move from windows-nat.c.
gdb/gdbserver/ChangeLog
2019-10-29 Tom Tromey <tromey@adacore.com>
* win32-low.c (current_process_handle, current_process_id)
(main_thread_id, last_sig, current_event): Move to
nat/windows-nat.c.
Change-Id: I9fbc0f8d65ed3f79d3b5061504141e5472b03057
---
M gdb/ChangeLog
M gdb/gdbserver/ChangeLog
M gdb/gdbserver/win32-low.c
M gdb/nat/windows-nat.c
M gdb/nat/windows-nat.h
M gdb/windows-nat.c
6 files changed, 117 insertions(+), 80 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 3ef67ab..4434f9a 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,24 @@
2019-10-29 Tom Tromey <tromey@adacore.com>
+ * windows-nat.c (current_process_handle, current_process_id)
+ (main_thread_id, last_sig, current_event, last_wait_event)
+ (current_windows_thread, desired_stop_thread_id, pending_stops)
+ (last_stop_was_breakpoint, struct pending_stop): Move to
+ nat/windows-nat.c.
+ (display_selectors, fake_create_process)
+ (get_windows_debug_event): Update.
+ * nat/windows-nat.h (current_process_handle, current_process_id)
+ (main_thread_id, last_sig, current_event, last_wait_event)
+ (current_windows_thread, desired_stop_thread_id, pending_stops)
+ (last_stop_was_breakpoint): Declare.
+ (struct pending_stop): Move from windows-nat.c.
+ * nat/windows-nat.c (current_process_handle, current_process_id)
+ (main_thread_id, last_sig, current_event, last_wait_event)
+ (current_windows_thread, desired_stop_thread_id, pending_stops)
+ (last_stop_was_breakpoint): New globals. Move from windows-nat.c.
+
+2019-10-29 Tom Tromey <tromey@adacore.com>
+
* windows-nat.c (get_image_name): Move to nat/windows-nat.c.
(handle_load_dll): Update.
* nat/windows-nat.c (get_image_name): Move from windows-nat.c.
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index 8a5acb8..646ca7f 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,5 +1,11 @@
2019-10-29 Tom Tromey <tromey@adacore.com>
+ * win32-low.c (current_process_handle, current_process_id)
+ (main_thread_id, last_sig, current_event): Move to
+ nat/windows-nat.c.
+
+2019-10-29 Tom Tromey <tromey@adacore.com>
+
* win32-low.c (get_image_name): Remove.
(handle_load_dll): Update.
diff --git a/gdb/gdbserver/win32-low.c b/gdb/gdbserver/win32-low.c
index a458b6e..4cf60b2 100644
--- a/gdb/gdbserver/win32-low.c
+++ b/gdb/gdbserver/win32-low.c
@@ -71,13 +71,6 @@
/* Globals. */
static int attaching = 0;
-static HANDLE current_process_handle = NULL;
-static DWORD current_process_id = 0;
-static DWORD main_thread_id = 0;
-static enum gdb_signal last_sig = GDB_SIGNAL_0;
-
-/* The current debug event from WaitForDebugEvent. */
-static DEBUG_EVENT current_event;
/* A status that hasn't been reported to the core yet, and so
win32_wait should return it next, instead of fetching the next
diff --git a/gdb/nat/windows-nat.c b/gdb/nat/windows-nat.c
index 3b55bb5..70ce6fd 100644
--- a/gdb/nat/windows-nat.c
+++ b/gdb/nat/windows-nat.c
@@ -22,6 +22,18 @@
namespace windows_nat
{
+HANDLE current_process_handle;
+DWORD current_process_id;
+DWORD main_thread_id;
+enum gdb_signal last_sig = GDB_SIGNAL_0;
+DEBUG_EVENT current_event;
+DEBUG_EVENT last_wait_event;
+windows_thread_info *current_windows_thread;
+DWORD desired_stop_thread_id = -1;
+std::vector<pending_stop> pending_stops;
+bool last_stop_was_breakpoint = false;
+
+
windows_thread_info::~windows_thread_info ()
{
CloseHandle (h);
diff --git a/gdb/nat/windows-nat.h b/gdb/nat/windows-nat.h
index 0ee24e8..c497d73 100644
--- a/gdb/nat/windows-nat.h
+++ b/gdb/nat/windows-nat.h
@@ -21,6 +21,8 @@
#include <windows.h>
+#include "target/waitstatus.h"
+
namespace windows_nat
{
@@ -101,6 +103,62 @@
extern windows_thread_info *thread_rec (ptid_t ptid,
thread_disposition_type disposition);
+/* Currently executing process */
+extern HANDLE current_process_handle;
+extern DWORD current_process_id;
+extern DWORD main_thread_id;
+extern enum gdb_signal last_sig;
+
+/* The current debug event from WaitForDebugEvent or from a pending
+ stop. */
+extern DEBUG_EVENT current_event;
+
+/* The most recent event from WaitForDebugEvent. Unlike
+ current_event, this is guaranteed never to come from a pending
+ stop. This is important because only data from the most recent
+ event from WaitForDebugEvent can be used when calling
+ ContinueDebugEvent. */
+extern DEBUG_EVENT last_wait_event;
+
+/* Info on currently selected thread */
+extern windows_thread_info *current_windows_thread;
+
+/* The ID of the thread for which we anticipate a stop event.
+ Normally this is -1, meaning we'll accept an event in any
+ thread. */
+extern DWORD desired_stop_thread_id;
+
+/* A single pending stop. See "pending_stops" for more
+ information. */
+struct pending_stop
+{
+ /* The thread id. */
+ DWORD thread_id;
+
+ /* The target waitstatus we computed. */
+ target_waitstatus status;
+
+ /* The event. A few fields of this can be referenced after a stop,
+ and it seemed simplest to store the entire event. */
+ DEBUG_EVENT event;
+};
+
+/* A vector of pending stops. Sometimes, Windows will report a stop
+ on a thread that has been ostensibly suspended. We believe what
+ happens here is that two threads hit a breakpoint simultaneously,
+ and the Windows kernel queues the stop events. However, this can
+ result in the strange effect of trying to single step thread A --
+ leaving all other threads suspended -- and then seeing a stop in
+ thread B. To handle this scenario, we queue all such "pending"
+ stops here, and then process them once the step has completed. See
+ PR gdb/22992. */
+extern std::vector<pending_stop> pending_stops;
+
+/* This is true if the most recently reported stop was due to a
+ breakpoint. */
+extern bool last_stop_was_breakpoint;
+
+
/* Return the name of the DLL referenced by H at ADDRESS. UNICODE
determines what sort of string is read from the inferior. Returns
the name of the DLL, or NULL on error. If a name is returned, it
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index 0533f64..3762af3 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -213,26 +213,8 @@
static unsigned long cygwin_get_dr6 (void);
static unsigned long cygwin_get_dr7 (void);
-static enum gdb_signal last_sig = GDB_SIGNAL_0;
-/* Set if a signal was received from the debugged process. */
-
static std::vector<windows_thread_info *> thread_list;
-/* The process and thread handles for the above context. */
-
-/* The current debug event from WaitForDebugEvent or from a pending
- stop. */
-static DEBUG_EVENT current_event;
-
-/* The most recent event from WaitForDebugEvent. Unlike
- current_event, this is guaranteed never to come from a pending
- stop. This is important because only data from the most recent
- event from WaitForDebugEvent can be used when calling
- ContinueDebugEvent. */
-static DEBUG_EVENT last_wait_event;
-
-static HANDLE current_process_handle; /* Currently executing process */
-static windows_thread_info *current_thread; /* Info on currently selected thread */
/* Counts of things. */
static int exception_count = 0;
@@ -300,41 +282,6 @@
#endif /* 0 */
-/* The ID of the thread for which we anticipate a stop event.
- Normally this is -1, meaning we'll accept an event in any
- thread. */
-static DWORD desired_stop_thread_id = -1;
-
-/* A single pending stop. See "pending_stops" for more
- information. */
-struct pending_stop
-{
- /* The thread id. */
- DWORD thread_id;
-
- /* The target waitstatus we computed. */
- target_waitstatus status;
-
- /* The event. A few fields of this can be referenced after a stop,
- and it seemed simplest to store the entire event. */
- DEBUG_EVENT event;
-};
-
-/* A vector of pending stops. Sometimes, Windows will report a stop
- on a thread that has been ostensibly suspended. We believe what
- happens here is that two threads hit a breakpoint simultaneously,
- and the Windows kernel queues the stop events. However, this can
- result in the strange effect of trying to single step thread A --
- leaving all other threads suspended -- and then seeing a stop in
- thread B. To handle this scenario, we queue all such "pending"
- stops here, and then process them once the step has completed. See
- PR gdb/22992. */
-static std::vector<pending_stop> pending_stops;
-
-/* This is true if the most recently reported stop was due to a
- breakpoint. */
-static bool last_stop_was_breakpoint = false;
-
struct windows_nat_target final : public x86_nat_target<inf_child_target>
{
void close () override;
@@ -1073,7 +1020,7 @@
static void
display_selectors (const char * args, int from_tty)
{
- if (!current_thread)
+ if (!current_windows_thread)
{
puts_filtered ("Impossible to display selectors now.\n");
return;
@@ -1082,30 +1029,30 @@
{
puts_filtered ("Selector $cs\n");
- display_selector (current_thread->h,
- current_thread->context.SegCs);
+ display_selector (current_windows_thread->h,
+ current_windows_thread->context.SegCs);
puts_filtered ("Selector $ds\n");
- display_selector (current_thread->h,
- current_thread->context.SegDs);
+ display_selector (current_windows_thread->h,
+ current_windows_thread->context.SegDs);
puts_filtered ("Selector $es\n");
- display_selector (current_thread->h,
- current_thread->context.SegEs);
+ display_selector (current_windows_thread->h,
+ current_windows_thread->context.SegEs);
puts_filtered ("Selector $ss\n");
- display_selector (current_thread->h,
- current_thread->context.SegSs);
+ display_selector (current_windows_thread->h,
+ current_windows_thread->context.SegSs);
puts_filtered ("Selector $fs\n");
- display_selector (current_thread->h,
- current_thread->context.SegFs);
+ display_selector (current_windows_thread->h,
+ current_windows_thread->context.SegFs);
puts_filtered ("Selector $gs\n");
- display_selector (current_thread->h,
- current_thread->context.SegGs);
+ display_selector (current_windows_thread->h,
+ current_windows_thread->context.SegGs);
}
else
{
int sel;
sel = parse_and_eval_long (args);
printf_filtered ("Selector \"%s\"\n",args);
- display_selector (current_thread->h, sel);
+ display_selector (current_windows_thread->h, sel);
}
}
@@ -1380,7 +1327,7 @@
(unsigned) GetLastError ());
/* We can not debug anything in that case. */
}
- current_thread
+ current_windows_thread
= windows_add_thread (ptid_t (current_event.dwProcessId,
current_event.dwThreadId, 0),
current_event.u.CreateThread.hThread,
@@ -1543,8 +1490,9 @@
current_event = iter->event;
inferior_ptid = ptid_t (current_event.dwProcessId, thread_id, 0);
- current_thread = thread_rec (inferior_ptid, INVALIDATE_CONTEXT);
- current_thread->reload_context = 1;
+ current_windows_thread = thread_rec (inferior_ptid,
+ INVALIDATE_CONTEXT);
+ current_windows_thread->reload_context = 1;
DEBUG_EVENTS (("get_windows_debug_event - "
"pending stop found in 0x%x (desired=0x%x)\n",
@@ -1744,9 +1692,10 @@
else
{
inferior_ptid = ptid_t (current_event.dwProcessId, thread_id, 0);
- current_thread = th;
- if (!current_thread)
- current_thread = thread_rec (inferior_ptid, INVALIDATE_CONTEXT);
+ current_windows_thread = th;
+ if (!current_windows_thread)
+ current_windows_thread = thread_rec (inferior_ptid,
+ INVALIDATE_CONTEXT);
}
out:
--
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I9fbc0f8d65ed3f79d3b5061504141e5472b03057
Gerrit-Change-Number: 419
Gerrit-PatchSet: 1
Gerrit-Owner: Tom Tromey <tromey@sourceware.org>
Gerrit-MessageType: newchange
^ permalink raw reply [flat|nested] 4+ messages in thread
* [review] Share some Windows-related globals
2019-10-29 18:16 [review] Share some Windows-related globals Tom Tromey (Code Review)
@ 2019-11-26 23:57 ` Luis Machado (Code Review)
0 siblings, 0 replies; 4+ messages in thread
From: Luis Machado (Code Review) @ 2019-11-26 23:57 UTC (permalink / raw)
To: Tom Tromey, gdb-patches
Luis Machado has posted comments on this change.
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/419
......................................................................
Patch Set 1: Code-Review+1
LGTM
--
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I9fbc0f8d65ed3f79d3b5061504141e5472b03057
Gerrit-Change-Number: 419
Gerrit-PatchSet: 1
Gerrit-Owner: Tom Tromey <tromey@sourceware.org>
Gerrit-Reviewer: Luis Machado <luis.machado@linaro.org>
Gerrit-Comment-Date: Tue, 26 Nov 2019 23:57:22 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
^ permalink raw reply [flat|nested] 4+ messages in thread
* [review] Share some Windows-related globals
2019-11-26 17:21 Tom Tromey (Code Review)
@ 2019-11-29 19:17 ` Pedro Alves (Code Review)
0 siblings, 0 replies; 4+ messages in thread
From: Pedro Alves (Code Review) @ 2019-11-29 19:17 UTC (permalink / raw)
To: Tom Tromey, gdb-patches
Pedro Alves has posted comments on this change.
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/710
......................................................................
Patch Set 1: Code-Review+2
(1 comment)
LGTM, with nit below.
| --- gdb/nat/windows-nat.h
| +++ gdb/nat/windows-nat.h
| @@ -108,7 +150,19 @@ };
| +/* A vector of pending stops. Sometimes, Windows will report a stop
| + on a thread that has been ostensibly suspended. We believe what
| + happens here is that two threads hit a breakpoint simultaneously,
| + and the Windows kernel queues the stop events. However, this can
| + result in the strange effect of trying to single step thread A --
| + leaving all other threads suspended -- and then seeing a stop in
| + thread B. To handle this scenario, we queue all such "pending"
| + stops here, and then process them once the step has completed. See
| + PR gdb/22992. */
| +extern std::vector<pending_stop> pending_stops;
PS1, Line 159:
#include <vector>.
| +
| +
| /* Return the name of the DLL referenced by H at ADDRESS. UNICODE
| determines what sort of string is read from the inferior. Returns
| the name of the DLL, or NULL on error. If a name is returned, it
| is stored in a static buffer which is valid until the next call to
| get_image_name. */
| extern const char *get_image_name (HANDLE h, void *address, int unicode);
|
--
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I3f861053e285afa3b3fff2d7892fdee2e59ab2c0
Gerrit-Change-Number: 710
Gerrit-PatchSet: 1
Gerrit-Owner: Tom Tromey <tromey@sourceware.org>
Gerrit-Reviewer: Pedro Alves <palves@redhat.com>
Gerrit-Comment-Date: Fri, 29 Nov 2019 19:17:17 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
^ permalink raw reply [flat|nested] 4+ messages in thread
* [review] Share some Windows-related globals
@ 2019-11-26 17:21 Tom Tromey (Code Review)
2019-11-29 19:17 ` Pedro Alves (Code Review)
0 siblings, 1 reply; 4+ messages in thread
From: Tom Tromey (Code Review) @ 2019-11-26 17:21 UTC (permalink / raw)
To: gdb-patches
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/710
......................................................................
Share some Windows-related globals
This moves some Windows-related globals into nat/windows-nat.c,
sharing them between gdb and gdbserver.
gdb/ChangeLog
2019-11-26 Tom Tromey <tromey@adacore.com>
* windows-nat.c (current_process_handle, current_process_id)
(main_thread_id, last_sig, current_event, last_wait_event)
(current_windows_thread, desired_stop_thread_id, pending_stops)
(struct pending_stop): Move to nat/windows-nat.c.
(display_selectors, fake_create_process)
(get_windows_debug_event): Update.
* nat/windows-nat.h (current_process_handle, current_process_id)
(main_thread_id, last_sig, current_event, last_wait_event)
(current_windows_thread, desired_stop_thread_id, pending_stops)
(struct pending_stop): Move from windows-nat.c.
* nat/windows-nat.c (current_process_handle, current_process_id)
(main_thread_id, last_sig, current_event, last_wait_event)
(current_windows_thread, desired_stop_thread_id, pending_stops):
New globals. Move from windows-nat.c.
gdb/gdbserver/ChangeLog
2019-11-26 Tom Tromey <tromey@adacore.com>
* win32-low.c (current_process_handle, current_process_id)
(main_thread_id, last_sig, current_event): Move to
nat/windows-nat.c.
Change-Id: I3f861053e285afa3b3fff2d7892fdee2e59ab2c0
---
M gdb/ChangeLog
M gdb/gdbserver/ChangeLog
M gdb/gdbserver/win32-low.c
M gdb/nat/windows-nat.c
M gdb/nat/windows-nat.h
M gdb/windows-nat.c
6 files changed, 114 insertions(+), 80 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 911c6a1..b0921f9 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,22 @@
2019-11-26 Tom Tromey <tromey@adacore.com>
+ * windows-nat.c (current_process_handle, current_process_id)
+ (main_thread_id, last_sig, current_event, last_wait_event)
+ (current_windows_thread, desired_stop_thread_id, pending_stops)
+ (struct pending_stop): Move to nat/windows-nat.c.
+ (display_selectors, fake_create_process)
+ (get_windows_debug_event): Update.
+ * nat/windows-nat.h (current_process_handle, current_process_id)
+ (main_thread_id, last_sig, current_event, last_wait_event)
+ (current_windows_thread, desired_stop_thread_id, pending_stops)
+ (struct pending_stop): Move from windows-nat.c.
+ * nat/windows-nat.c (current_process_handle, current_process_id)
+ (main_thread_id, last_sig, current_event, last_wait_event)
+ (current_windows_thread, desired_stop_thread_id, pending_stops):
+ New globals. Move from windows-nat.c.
+
+2019-11-26 Tom Tromey <tromey@adacore.com>
+
* windows-nat.c (get_image_name): Move to nat/windows-nat.c.
(handle_load_dll): Update.
* nat/windows-nat.c (get_image_name): Move from windows-nat.c.
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index fff6640..8349b8d 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,5 +1,11 @@
2019-11-26 Tom Tromey <tromey@adacore.com>
+ * win32-low.c (current_process_handle, current_process_id)
+ (main_thread_id, last_sig, current_event): Move to
+ nat/windows-nat.c.
+
+2019-11-26 Tom Tromey <tromey@adacore.com>
+
* win32-low.c (get_image_name): Remove.
(handle_load_dll): Update.
diff --git a/gdb/gdbserver/win32-low.c b/gdb/gdbserver/win32-low.c
index a458b6e..4cf60b2 100644
--- a/gdb/gdbserver/win32-low.c
+++ b/gdb/gdbserver/win32-low.c
@@ -71,13 +71,6 @@
/* Globals. */
static int attaching = 0;
-static HANDLE current_process_handle = NULL;
-static DWORD current_process_id = 0;
-static DWORD main_thread_id = 0;
-static enum gdb_signal last_sig = GDB_SIGNAL_0;
-
-/* The current debug event from WaitForDebugEvent. */
-static DEBUG_EVENT current_event;
/* A status that hasn't been reported to the core yet, and so
win32_wait should return it next, instead of fetching the next
diff --git a/gdb/nat/windows-nat.c b/gdb/nat/windows-nat.c
index e0ebe3a..57bbae1 100644
--- a/gdb/nat/windows-nat.c
+++ b/gdb/nat/windows-nat.c
@@ -22,6 +22,17 @@
namespace windows_nat
{
+HANDLE current_process_handle;
+DWORD current_process_id;
+DWORD main_thread_id;
+enum gdb_signal last_sig = GDB_SIGNAL_0;
+DEBUG_EVENT current_event;
+DEBUG_EVENT last_wait_event;
+windows_thread_info *current_windows_thread;
+DWORD desired_stop_thread_id = -1;
+std::vector<pending_stop> pending_stops;
+
+
windows_thread_info::~windows_thread_info ()
{
CloseHandle (h);
diff --git a/gdb/nat/windows-nat.h b/gdb/nat/windows-nat.h
index e38b69e..de53f2f 100644
--- a/gdb/nat/windows-nat.h
+++ b/gdb/nat/windows-nat.h
@@ -21,6 +21,8 @@
#include <windows.h>
+#include "target/waitstatus.h"
+
namespace windows_nat
{
@@ -105,6 +107,58 @@
extern windows_thread_info *thread_rec (ptid_t ptid,
thread_disposition_type disposition);
+/* Currently executing process */
+extern HANDLE current_process_handle;
+extern DWORD current_process_id;
+extern DWORD main_thread_id;
+extern enum gdb_signal last_sig;
+
+/* The current debug event from WaitForDebugEvent or from a pending
+ stop. */
+extern DEBUG_EVENT current_event;
+
+/* The most recent event from WaitForDebugEvent. Unlike
+ current_event, this is guaranteed never to come from a pending
+ stop. This is important because only data from the most recent
+ event from WaitForDebugEvent can be used when calling
+ ContinueDebugEvent. */
+extern DEBUG_EVENT last_wait_event;
+
+/* Info on currently selected thread */
+extern windows_thread_info *current_windows_thread;
+
+/* The ID of the thread for which we anticipate a stop event.
+ Normally this is -1, meaning we'll accept an event in any
+ thread. */
+extern DWORD desired_stop_thread_id;
+
+/* A single pending stop. See "pending_stops" for more
+ information. */
+struct pending_stop
+{
+ /* The thread id. */
+ DWORD thread_id;
+
+ /* The target waitstatus we computed. */
+ target_waitstatus status;
+
+ /* The event. A few fields of this can be referenced after a stop,
+ and it seemed simplest to store the entire event. */
+ DEBUG_EVENT event;
+};
+
+/* A vector of pending stops. Sometimes, Windows will report a stop
+ on a thread that has been ostensibly suspended. We believe what
+ happens here is that two threads hit a breakpoint simultaneously,
+ and the Windows kernel queues the stop events. However, this can
+ result in the strange effect of trying to single step thread A --
+ leaving all other threads suspended -- and then seeing a stop in
+ thread B. To handle this scenario, we queue all such "pending"
+ stops here, and then process them once the step has completed. See
+ PR gdb/22992. */
+extern std::vector<pending_stop> pending_stops;
+
+
/* Return the name of the DLL referenced by H at ADDRESS. UNICODE
determines what sort of string is read from the inferior. Returns
the name of the DLL, or NULL on error. If a name is returned, it
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index 1752010..fad3952 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -213,26 +213,8 @@
static unsigned long cygwin_get_dr6 (void);
static unsigned long cygwin_get_dr7 (void);
-static enum gdb_signal last_sig = GDB_SIGNAL_0;
-/* Set if a signal was received from the debugged process. */
-
static std::vector<windows_thread_info *> thread_list;
-/* The process and thread handles for the above context. */
-
-/* The current debug event from WaitForDebugEvent or from a pending
- stop. */
-static DEBUG_EVENT current_event;
-
-/* The most recent event from WaitForDebugEvent. Unlike
- current_event, this is guaranteed never to come from a pending
- stop. This is important because only data from the most recent
- event from WaitForDebugEvent can be used when calling
- ContinueDebugEvent. */
-static DEBUG_EVENT last_wait_event;
-
-static HANDLE current_process_handle; /* Currently executing process */
-static windows_thread_info *current_thread; /* Info on currently selected thread */
/* Counts of things. */
static int exception_count = 0;
@@ -300,37 +282,6 @@
#endif /* 0 */
-/* The ID of the thread for which we anticipate a stop event.
- Normally this is -1, meaning we'll accept an event in any
- thread. */
-static DWORD desired_stop_thread_id = -1;
-
-/* A single pending stop. See "pending_stops" for more
- information. */
-struct pending_stop
-{
- /* The thread id. */
- DWORD thread_id;
-
- /* The target waitstatus we computed. */
- target_waitstatus status;
-
- /* The event. A few fields of this can be referenced after a stop,
- and it seemed simplest to store the entire event. */
- DEBUG_EVENT event;
-};
-
-/* A vector of pending stops. Sometimes, Windows will report a stop
- on a thread that has been ostensibly suspended. We believe what
- happens here is that two threads hit a breakpoint simultaneously,
- and the Windows kernel queues the stop events. However, this can
- result in the strange effect of trying to single step thread A --
- leaving all other threads suspended -- and then seeing a stop in
- thread B. To handle this scenario, we queue all such "pending"
- stops here, and then process them once the step has completed. See
- PR gdb/22992. */
-static std::vector<pending_stop> pending_stops;
-
struct windows_nat_target final : public x86_nat_target<inf_child_target>
{
void close () override;
@@ -351,7 +302,7 @@
bool stopped_by_sw_breakpoint () override
{
- return current_thread->stopped_at_breakpoint;
+ return current_windows_thread->stopped_at_breakpoint;
}
bool supports_stopped_by_sw_breakpoint () override
@@ -1094,7 +1045,7 @@
static void
display_selectors (const char * args, int from_tty)
{
- if (!current_thread)
+ if (!current_windows_thread)
{
puts_filtered ("Impossible to display selectors now.\n");
return;
@@ -1103,30 +1054,30 @@
{
puts_filtered ("Selector $cs\n");
- display_selector (current_thread->h,
- current_thread->context.SegCs);
+ display_selector (current_windows_thread->h,
+ current_windows_thread->context.SegCs);
puts_filtered ("Selector $ds\n");
- display_selector (current_thread->h,
- current_thread->context.SegDs);
+ display_selector (current_windows_thread->h,
+ current_windows_thread->context.SegDs);
puts_filtered ("Selector $es\n");
- display_selector (current_thread->h,
- current_thread->context.SegEs);
+ display_selector (current_windows_thread->h,
+ current_windows_thread->context.SegEs);
puts_filtered ("Selector $ss\n");
- display_selector (current_thread->h,
- current_thread->context.SegSs);
+ display_selector (current_windows_thread->h,
+ current_windows_thread->context.SegSs);
puts_filtered ("Selector $fs\n");
- display_selector (current_thread->h,
- current_thread->context.SegFs);
+ display_selector (current_windows_thread->h,
+ current_windows_thread->context.SegFs);
puts_filtered ("Selector $gs\n");
- display_selector (current_thread->h,
- current_thread->context.SegGs);
+ display_selector (current_windows_thread->h,
+ current_windows_thread->context.SegGs);
}
else
{
int sel;
sel = parse_and_eval_long (args);
printf_filtered ("Selector \"%s\"\n",args);
- display_selector (current_thread->h, sel);
+ display_selector (current_windows_thread->h, sel);
}
}
@@ -1400,7 +1351,7 @@
(unsigned) GetLastError ());
/* We can not debug anything in that case. */
}
- current_thread
+ current_windows_thread
= windows_add_thread (ptid_t (current_event.dwProcessId,
current_event.dwThreadId, 0),
current_event.u.CreateThread.hThread,
@@ -1563,8 +1514,9 @@
current_event = iter->event;
inferior_ptid = ptid_t (current_event.dwProcessId, thread_id, 0);
- current_thread = thread_rec (inferior_ptid, INVALIDATE_CONTEXT);
- current_thread->reload_context = 1;
+ current_windows_thread = thread_rec (inferior_ptid,
+ INVALIDATE_CONTEXT);
+ current_windows_thread->reload_context = 1;
DEBUG_EVENTS (("get_windows_debug_event - "
"pending stop found in 0x%x (desired=0x%x)\n",
@@ -1773,9 +1725,10 @@
else
{
inferior_ptid = ptid_t (current_event.dwProcessId, thread_id, 0);
- current_thread = th;
- if (!current_thread)
- current_thread = thread_rec (inferior_ptid, INVALIDATE_CONTEXT);
+ current_windows_thread = th;
+ if (!current_windows_thread)
+ current_windows_thread = thread_rec (inferior_ptid,
+ INVALIDATE_CONTEXT);
}
out:
@@ -1833,14 +1786,14 @@
{
ptid_t result = ptid_t (current_event.dwProcessId, retval, 0);
- if (current_thread != nullptr)
+ if (current_windows_thread != nullptr)
{
- current_thread->stopped_at_breakpoint = false;
+ current_windows_thread->stopped_at_breakpoint = false;
if (current_event.dwDebugEventCode == EXCEPTION_DEBUG_EVENT
&& (current_event.u.Exception.ExceptionRecord.ExceptionCode
== EXCEPTION_BREAKPOINT)
&& windows_initialization_done)
- current_thread->stopped_at_breakpoint = true;
+ current_windows_thread->stopped_at_breakpoint = true;
}
return result;
--
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I3f861053e285afa3b3fff2d7892fdee2e59ab2c0
Gerrit-Change-Number: 710
Gerrit-PatchSet: 1
Gerrit-Owner: Tom Tromey <tromey@sourceware.org>
Gerrit-MessageType: newchange
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-11-29 19:17 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-29 18:16 [review] Share some Windows-related globals Tom Tromey (Code Review)
2019-11-26 23:57 ` Luis Machado (Code Review)
2019-11-26 17:21 Tom Tromey (Code Review)
2019-11-29 19:17 ` Pedro Alves (Code Review)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).