130 lines
4.5 KiB
Diff
130 lines
4.5 KiB
Diff
From 67d65c0cf53d1b5ab123386e2c62d8ed22147d34 Mon Sep 17 00:00:00 2001
|
|
From: Jon Turney <jon.turney@dronecode.org.uk>
|
|
Date: Tue, 12 Jan 2016 22:26:26 +0000
|
|
Subject: [PATCH 2/6] 7.8-windows-nat-cygwin
|
|
|
|
Remaining parts of 7.8-windows-nat-cygwin.patch not yet upstream.
|
|
|
|
Signal changes:
|
|
|
|
* Replace have_saved_context with signal_thread_id throughout, and store the
|
|
thread id in it
|
|
|
|
* In thread_rec(), only use the signal saved context if we are retrieving the
|
|
context for the correct thread.
|
|
|
|
* Clear ContextFlags in the signal saved context so we never attempt to restore
|
|
it to the inferior
|
|
|
|
Since the signal context is the context which will be restored after any signal
|
|
handler has been run, to resume to it skips over the actual signal delivery.
|
|
|
|
(Unfortunately, this isn't quite right. If GDB decides it needs to single-step
|
|
after continuing by setting FLAG_TRACE_BIT, we must alter the inferior state. So
|
|
we potentially need to have both the signal saved context, and the actual
|
|
context for the thread. Which is not a straightforward change to make.)
|
|
|
|
Unrelated changes:
|
|
|
|
* An unclear change for detecting if it's an unexpected Cygwin message. Just
|
|
checking for a leading 'cYg' should be enough?
|
|
|
|
* Cast DWORD thread_id to int before returning it from get_windows_event.
|
|
(I don't think this is needed. If DWORD->int is a narrowing conversion, we
|
|
have other problems...)
|
|
|
|
* In one place, clarify that thread_rec()'s second parameter is a bool flag.
|
|
(This should be done everywhere, or not)
|
|
---
|
|
gdb/windows-nat.c | 25 ++++++++++++++++---------
|
|
1 file changed, 16 insertions(+), 9 deletions(-)
|
|
|
|
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
|
|
index 7a139c8d36f..40229478b6f 100644
|
|
--- a/gdb/windows-nat.c
|
|
+++ b/gdb/windows-nat.c
|
|
@@ -99,8 +99,7 @@ struct windows_per_inferior : public windows_process_info
|
|
bool handle_access_violation (const EXCEPTION_RECORD *rec) override;
|
|
|
|
|
|
- int have_saved_context = 0; /* True if we've saved context from a
|
|
- cygwin signal. */
|
|
+ DWORD signal_thread_id; /* Non-zero if we saved context. */
|
|
|
|
uintptr_t dr[8] {};
|
|
|
|
@@ -524,7 +523,7 @@ windows_per_inferior::thread_rec
|
|
/* Nothing. */
|
|
break;
|
|
case INVALIDATE_CONTEXT:
|
|
- if (ptid.lwp () != current_event.dwThreadId)
|
|
+ if (ptid.lwp () != current_event.dwThreadId && ptid.lwp () != signal_thread_id)
|
|
th->suspend ();
|
|
th->reload_context = true;
|
|
break;
|
|
@@ -723,7 +722,7 @@ windows_nat_target::fetch_registers (struct regcache *regcache, int r)
|
|
if (th->reload_context)
|
|
{
|
|
#ifdef __CYGWIN__
|
|
- if (windows_process.have_saved_context)
|
|
+ if (windows_process.signal_thread_id)
|
|
{
|
|
/* Lie about where the program actually is stopped since
|
|
cygwin has informed us that we should consider the signal
|
|
@@ -731,7 +730,7 @@ windows_nat_target::fetch_registers (struct regcache *regcache, int r)
|
|
"saved_context. */
|
|
memcpy (&th->context, &windows_process.saved_context,
|
|
__COPY_CONTEXT_SIZE);
|
|
- windows_process.have_saved_context = 0;
|
|
+ windows_process.signal_thread_id = 0;
|
|
}
|
|
else
|
|
#endif
|
|
@@ -1018,7 +1017,11 @@ windows_per_inferior::handle_output_debug_string
|
|
else if (!startswith (s.get (), _CYGWIN_SIGNAL_STRING))
|
|
{
|
|
#ifdef __CYGWIN__
|
|
- if (!startswith (s.get (), "cYg"))
|
|
+ /* This looks like this is supposed to ignore all other expected Cygwin
|
|
+ debug output (e.g. handle and strace output), but isn't quite right as
|
|
+ strace output might be indicated by any 8 digit hex address. */
|
|
+ if (!startswith (s.get (), "cYg") || (strncmp (s.get () + 3, "FFFFFFFF", 8) != 0
|
|
+ && strncmp (s.get () + 3, "std", 3) != 0))
|
|
#endif
|
|
{
|
|
char *p = strchr (s.get (), '\0');
|
|
@@ -1056,7 +1059,12 @@ windows_per_inferior::handle_output_debug_string
|
|
&saved_context,
|
|
__COPY_CONTEXT_SIZE, &n)
|
|
&& n == __COPY_CONTEXT_SIZE)
|
|
- have_saved_context = 1;
|
|
+ {
|
|
+ signal_thread_id = retval;
|
|
+ saved_context.ContextFlags = 0; /* Don't attempt to call SetContext */
|
|
+ }
|
|
+ else
|
|
+ retval = 0;
|
|
}
|
|
}
|
|
#endif
|
|
@@ -1591,7 +1599,6 @@ windows_nat_target::get_windows_debug_event
|
|
|
|
event_code = windows_process.current_event.dwDebugEventCode;
|
|
ourstatus->set_spurious ();
|
|
- windows_process.have_saved_context = 0;
|
|
|
|
switch (event_code)
|
|
{
|
|
@@ -1808,7 +1815,7 @@ windows_nat_target::get_windows_debug_event
|
|
|
|
if (thread_id == 0)
|
|
return null_ptid;
|
|
- return ptid_t (windows_process.current_event.dwProcessId, thread_id, 0);
|
|
+ return ptid_t (windows_process.current_event.dwProcessId, (int) thread_id, 0);
|
|
}
|
|
|
|
/* Wait for interesting events to occur in the target process. */
|
|
--
|
|
2.44.0.windows.1
|
|
|