aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPedro Alves <pedro@palves.net>2021-10-21 18:16:58 +0100
committerPedro Alves <pedro@palves.net>2024-05-10 11:25:42 +0100
commit44fff407b759b9238bfdd2b430f3cc4accada3bc (patch)
tree76e421ee7b521facb60770ab06057d6e7aad32d3
parent552616cbb7d24d81690da17a30d067f59993f289 (diff)
downloadgdb-44fff407b759b9238bfdd2b430f3cc4accada3bc.zip
gdb-44fff407b759b9238bfdd2b430f3cc4accada3bc.tar.gz
gdb-44fff407b759b9238bfdd2b430f3cc4accada3bc.tar.bz2
Windows gdb: Introduce continue_last_debug_event_main_thread
We have code using do_synchronously to call continue_last_debug_event, and later patches in the series would need to add the same code in few more places. Factor it out to a continue_last_debug_event_main_thread function so these other places in future patches can just call it. Change-Id: I945e668d2b3daeb9de968219925a7b3c7c7ce9ed
-rw-r--r--gdb/windows-nat.c47
1 files changed, 31 insertions, 16 deletions
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index aa531c4..47b9160 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -354,6 +354,12 @@ private:
needed. */
void wait_for_debug_event_main_thread (DEBUG_EVENT *event);
+ /* This continues the last debug event, dispatching to the worker
+ thread as needed. */
+ void continue_last_debug_event_main_thread (const char *context_str,
+ DWORD continue_status,
+ bool last_call = false);
+
/* Force the process_thread thread to return from WaitForDebugEvent.
PROCESS_ALIVE is set to false if the inferior process exits while
we're trying to break out the process_thread thread. This can
@@ -512,6 +518,28 @@ windows_nat_target::wait_for_debug_event_main_thread (DEBUG_EVENT *event)
m_continued = false;
}
+void
+windows_nat_target::continue_last_debug_event_main_thread
+ (const char *context_str, DWORD continue_status, bool last_call)
+{
+ std::optional<unsigned> err;
+ do_synchronously ([&] ()
+ {
+ if (!continue_last_debug_event (continue_status, debug_events))
+ err = (unsigned) GetLastError ();
+
+ /* On the last call, do not block waiting for an event that will
+ never come. */
+ return !last_call;
+ });
+ if (err.has_value ())
+ throw_winerror_with_name (string_printf (_("ContinueDebugEvent failed: %s"),
+ context_str).c_str (),
+ *err);
+
+ m_continued = !last_call;
+}
+
/* See nat/windows-nat.h. */
windows_thread_info *
@@ -1319,22 +1347,9 @@ windows_nat_target::windows_continue (DWORD continue_status, int id,
th->resume ();
}
- std::optional<unsigned> err;
- do_synchronously ([&] ()
- {
- if (!continue_last_debug_event (continue_status, debug_events))
- err = (unsigned) GetLastError ();
- /* On the last call, do not block waiting for an event that will
- never come. */
- return !last_call;
- });
-
- if (err.has_value ())
- throw_winerror_with_name (_("Failed to resume program execution"
- " - ContinueDebugEvent failed"),
- *err);
-
- m_continued = !last_call;
+ continue_last_debug_event_main_thread
+ (_("Failed to resume program execution"), continue_status,
+ last_call);
return TRUE;
}