public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] Introduce fetch_pending_stop
@ 2020-04-08 20:51 Tom Tromey
0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2020-04-08 20:51 UTC (permalink / raw)
To: gdb-cvs
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=d2977bc4253614907058d3a339875683d8215065
commit d2977bc4253614907058d3a339875683d8215065
Author: Tom Tromey <tromey@adacore.com>
Date: Wed Apr 8 14:33:35 2020 -0600
Introduce fetch_pending_stop
This introduces a new "fetch_pending_stop" function and changes gdb to
use it. This function removes the first matching pending stop from
the list of such stops.
gdb/ChangeLog
2020-04-08 Tom Tromey <tromey@adacore.com>
* windows-nat.c (get_windows_debug_event): Use
fetch_pending_stop.
* nat/windows-nat.h (fetch_pending_stop): Declare.
* nat/windows-nat.c (fetch_pending_stop): New function.
Diff:
---
gdb/ChangeLog | 7 +++++++
gdb/nat/windows-nat.c | 28 ++++++++++++++++++++++++++++
gdb/nat/windows-nat.h | 7 +++++++
gdb/windows-nat.c | 29 +++++++++--------------------
4 files changed, 51 insertions(+), 20 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 3929faf089e..738c6c2d779 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,10 @@
+2020-04-08 Tom Tromey <tromey@adacore.com>
+
+ * windows-nat.c (get_windows_debug_event): Use
+ fetch_pending_stop.
+ * nat/windows-nat.h (fetch_pending_stop): Declare.
+ * nat/windows-nat.c (fetch_pending_stop): New function.
+
2020-04-08 Tom Tromey <tromey@adacore.com>
* windows-nat.c (windows_continue): Use matching_pending_stop and
diff --git a/gdb/nat/windows-nat.c b/gdb/nat/windows-nat.c
index 2c2454b6f6f..823471eb4da 100644
--- a/gdb/nat/windows-nat.c
+++ b/gdb/nat/windows-nat.c
@@ -343,6 +343,34 @@ matching_pending_stop (bool debug_events)
/* See nat/windows-nat.h. */
+gdb::optional<pending_stop>
+fetch_pending_stop (bool debug_events)
+{
+ gdb::optional<pending_stop> result;
+ for (auto iter = pending_stops.begin ();
+ iter != pending_stops.end ();
+ ++iter)
+ {
+ if (desired_stop_thread_id == -1
+ || desired_stop_thread_id == iter->thread_id)
+ {
+ result = *iter;
+ current_event = iter->event;
+
+ DEBUG_EVENTS (("get_windows_debug_event - "
+ "pending stop found in 0x%x (desired=0x%x)\n",
+ iter->thread_id, desired_stop_thread_id));
+
+ pending_stops.erase (iter);
+ break;
+ }
+ }
+
+ return result;
+}
+
+/* See nat/windows-nat.h. */
+
BOOL
continue_last_debug_event (DWORD continue_status, bool debug_events)
{
diff --git a/gdb/nat/windows-nat.h b/gdb/nat/windows-nat.h
index 0e9316577ba..68b72d4bbd2 100644
--- a/gdb/nat/windows-nat.h
+++ b/gdb/nat/windows-nat.h
@@ -22,6 +22,7 @@
#include <windows.h>
#include <vector>
+#include "gdbsupport/gdb_optional.h"
#include "target/waitstatus.h"
namespace windows_nat
@@ -231,6 +232,12 @@ extern handle_exception_result handle_exception
extern bool matching_pending_stop (bool debug_events);
+/* See if a pending stop matches DESIRED_STOP_THREAD_ID. If so,
+ remove it from the list of pending stops, set 'current_event', and
+ return it. Otherwise, return an empty optional. */
+
+extern gdb::optional<pending_stop> fetch_pending_stop (bool debug_events);
+
/* A simple wrapper for ContinueDebugEvent that continues the last
waited-for event. If DEBUG_EVENTS is true, logging will be
enabled. */
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index d04dc06f3bf..2ee7a2412a9 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -1522,29 +1522,18 @@ windows_nat_target::get_windows_debug_event (int pid,
/* If there is a relevant pending stop, report it now. See the
comment by the definition of "pending_stops" for details on why
this is needed. */
- for (auto iter = pending_stops.begin ();
- iter != pending_stops.end ();
- ++iter)
+ gdb::optional<pending_stop> stop = fetch_pending_stop (debug_events);
+ if (stop.has_value ())
{
- if (desired_stop_thread_id == -1
- || desired_stop_thread_id == iter->thread_id)
- {
- thread_id = iter->thread_id;
- *ourstatus = iter->status;
- current_event = iter->event;
-
- inferior_ptid = ptid_t (current_event.dwProcessId, thread_id, 0);
- current_windows_thread = thread_rec (inferior_ptid,
- INVALIDATE_CONTEXT);
- current_windows_thread->reload_context = 1;
+ thread_id = stop->thread_id;
+ *ourstatus = stop->status;
- DEBUG_EVENTS (("get_windows_debug_event - "
- "pending stop found in 0x%x (desired=0x%x)\n",
- thread_id, desired_stop_thread_id));
+ inferior_ptid = ptid_t (current_event.dwProcessId, thread_id, 0);
+ current_windows_thread = thread_rec (inferior_ptid,
+ INVALIDATE_CONTEXT);
+ current_windows_thread->reload_context = 1;
- pending_stops.erase (iter);
- return thread_id;
- }
+ return thread_id;
}
last_sig = GDB_SIGNAL_0;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-04-08 20:51 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-08 20:51 [binutils-gdb] Introduce fetch_pending_stop Tom Tromey
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).