Share some inferior-related Windows code
This adds a couple of functions to nat/windows-nat.c and changes gdb and gdbserver to use them. One function checks the list of pending stops for a match (not yet used by gdbserver, but will be in a subsequent patch); and the other is a wrapper for ContinueDebugEvent that always uses the last "real" stop event. gdb/ChangeLog 2020-04-08 Tom Tromey <tromey@adacore.com> * windows-nat.c (windows_continue): Use matching_pending_stop and continue_last_debug_event. * nat/windows-nat.h (matching_pending_stop) (continue_last_debug_event): Declare. * nat/windows-nat.c (DEBUG_EVENTS): New define. (matching_pending_stop, continue_last_debug_event): New functions. gdbserver/ChangeLog 2020-04-08 Tom Tromey <tromey@adacore.com> * win32-low.c (child_continue): Call continue_last_debug_event.
This commit is contained in:
parent
8d30e39577
commit
e758e19c59
|
@ -1,3 +1,13 @@
|
||||||
|
2020-04-08 Tom Tromey <tromey@adacore.com>
|
||||||
|
|
||||||
|
* windows-nat.c (windows_continue): Use matching_pending_stop and
|
||||||
|
continue_last_debug_event.
|
||||||
|
* nat/windows-nat.h (matching_pending_stop)
|
||||||
|
(continue_last_debug_event): Declare.
|
||||||
|
* nat/windows-nat.c (DEBUG_EVENTS): New define.
|
||||||
|
(matching_pending_stop, continue_last_debug_event): New
|
||||||
|
functions.
|
||||||
|
|
||||||
2020-04-08 Tom Tromey <tromey@adacore.com>
|
2020-04-08 Tom Tromey <tromey@adacore.com>
|
||||||
|
|
||||||
* windows-nat.c (MS_VC_EXCEPTION): Move to nat/windows-nat.c.
|
* windows-nat.c (MS_VC_EXCEPTION): Move to nat/windows-nat.c.
|
||||||
|
|
|
@ -37,6 +37,10 @@ DWORD desired_stop_thread_id = -1;
|
||||||
std::vector<pending_stop> pending_stops;
|
std::vector<pending_stop> pending_stops;
|
||||||
EXCEPTION_RECORD siginfo_er;
|
EXCEPTION_RECORD siginfo_er;
|
||||||
|
|
||||||
|
/* Note that 'debug_events' must be locally defined in the relevant
|
||||||
|
functions. */
|
||||||
|
#define DEBUG_EVENTS(x) if (debug_events) debug_printf x
|
||||||
|
|
||||||
windows_thread_info::~windows_thread_info ()
|
windows_thread_info::~windows_thread_info ()
|
||||||
{
|
{
|
||||||
CloseHandle (h);
|
CloseHandle (h);
|
||||||
|
@ -312,4 +316,46 @@ handle_exception (struct target_waitstatus *ourstatus, bool debug_exceptions)
|
||||||
#undef DEBUG_EXCEPTION_SIMPLE
|
#undef DEBUG_EXCEPTION_SIMPLE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* See nat/windows-nat.h. */
|
||||||
|
|
||||||
|
bool
|
||||||
|
matching_pending_stop (bool debug_events)
|
||||||
|
{
|
||||||
|
/* If there are pending stops, and we might plausibly hit one of
|
||||||
|
them, we don't want to actually continue the inferior -- we just
|
||||||
|
want to report the stop. In this case, we just pretend to
|
||||||
|
continue. See the comment by the definition of "pending_stops"
|
||||||
|
for details on why this is needed. */
|
||||||
|
for (const auto &item : pending_stops)
|
||||||
|
{
|
||||||
|
if (desired_stop_thread_id == -1
|
||||||
|
|| desired_stop_thread_id == item.thread_id)
|
||||||
|
{
|
||||||
|
DEBUG_EVENTS (("windows_continue - pending stop anticipated, "
|
||||||
|
"desired=0x%x, item=0x%x\n",
|
||||||
|
desired_stop_thread_id, item.thread_id));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* See nat/windows-nat.h. */
|
||||||
|
|
||||||
|
BOOL
|
||||||
|
continue_last_debug_event (DWORD continue_status, bool debug_events)
|
||||||
|
{
|
||||||
|
DEBUG_EVENTS (("ContinueDebugEvent (cpid=%d, ctid=0x%x, %s);\n",
|
||||||
|
(unsigned) last_wait_event.dwProcessId,
|
||||||
|
(unsigned) last_wait_event.dwThreadId,
|
||||||
|
continue_status == DBG_CONTINUE ?
|
||||||
|
"DBG_CONTINUE" : "DBG_EXCEPTION_NOT_HANDLED"));
|
||||||
|
|
||||||
|
return ContinueDebugEvent (last_wait_event.dwProcessId,
|
||||||
|
last_wait_event.dwThreadId,
|
||||||
|
continue_status);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -225,6 +225,19 @@ typedef enum
|
||||||
extern handle_exception_result handle_exception
|
extern handle_exception_result handle_exception
|
||||||
(struct target_waitstatus *ourstatus, bool debug_exceptions);
|
(struct target_waitstatus *ourstatus, bool debug_exceptions);
|
||||||
|
|
||||||
|
/* Return true if there is a pending stop matching
|
||||||
|
desired_stop_thread_id. If DEBUG_EVENTS is true, logging will be
|
||||||
|
enabled. */
|
||||||
|
|
||||||
|
extern bool matching_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. */
|
||||||
|
|
||||||
|
extern BOOL continue_last_debug_event (DWORD continue_status,
|
||||||
|
bool debug_events);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1239,28 +1239,8 @@ windows_continue (DWORD continue_status, int id, int killed)
|
||||||
|
|
||||||
desired_stop_thread_id = id;
|
desired_stop_thread_id = id;
|
||||||
|
|
||||||
/* If there are pending stops, and we might plausibly hit one of
|
if (matching_pending_stop (debug_events))
|
||||||
them, we don't want to actually continue the inferior -- we just
|
|
||||||
want to report the stop. In this case, we just pretend to
|
|
||||||
continue. See the comment by the definition of "pending_stops"
|
|
||||||
for details on why this is needed. */
|
|
||||||
for (const auto &item : pending_stops)
|
|
||||||
{
|
|
||||||
if (desired_stop_thread_id == -1
|
|
||||||
|| desired_stop_thread_id == item.thread_id)
|
|
||||||
{
|
|
||||||
DEBUG_EVENTS (("windows_continue - pending stop anticipated, "
|
|
||||||
"desired=0x%x, item=0x%x\n",
|
|
||||||
desired_stop_thread_id, item.thread_id));
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DEBUG_EVENTS (("ContinueDebugEvent (cpid=%d, ctid=0x%x, %s);\n",
|
|
||||||
(unsigned) last_wait_event.dwProcessId,
|
|
||||||
(unsigned) last_wait_event.dwThreadId,
|
|
||||||
continue_status == DBG_CONTINUE ?
|
|
||||||
"DBG_CONTINUE" : "DBG_EXCEPTION_NOT_HANDLED"));
|
|
||||||
|
|
||||||
for (windows_thread_info *th : thread_list)
|
for (windows_thread_info *th : thread_list)
|
||||||
if (id == -1 || id == (int) th->tid)
|
if (id == -1 || id == (int) th->tid)
|
||||||
|
@ -1333,9 +1313,7 @@ windows_continue (DWORD continue_status, int id, int killed)
|
||||||
th->suspend ();
|
th->suspend ();
|
||||||
}
|
}
|
||||||
|
|
||||||
res = ContinueDebugEvent (last_wait_event.dwProcessId,
|
res = continue_last_debug_event (continue_status, debug_events);
|
||||||
last_wait_event.dwThreadId,
|
|
||||||
continue_status);
|
|
||||||
|
|
||||||
if (!res)
|
if (!res)
|
||||||
error (_("Failed to resume program execution"
|
error (_("Failed to resume program execution"
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
2020-04-08 Tom Tromey <tromey@adacore.com>
|
||||||
|
|
||||||
|
* win32-low.c (child_continue): Call continue_last_debug_event.
|
||||||
|
|
||||||
2020-04-08 Tom Tromey <tromey@adacore.com>
|
2020-04-08 Tom Tromey <tromey@adacore.com>
|
||||||
|
|
||||||
* win32-low.c (handle_exception): Remove.
|
* win32-low.c (handle_exception): Remove.
|
||||||
|
|
|
@ -433,12 +433,7 @@ child_continue (DWORD continue_status, int thread_id)
|
||||||
});
|
});
|
||||||
faked_breakpoint = 0;
|
faked_breakpoint = 0;
|
||||||
|
|
||||||
if (!ContinueDebugEvent (current_event.dwProcessId,
|
return continue_last_debug_event (continue_status, debug_threads);
|
||||||
current_event.dwThreadId,
|
|
||||||
continue_status))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Fetch register(s) from the current thread context. */
|
/* Fetch register(s) from the current thread context. */
|
||||||
|
|
Loading…
Reference in New Issue