aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdbserver/win32-i386-low.cc20
-rw-r--r--gdbserver/win32-low.cc41
-rw-r--r--gdbserver/win32-low.h3
3 files changed, 36 insertions, 28 deletions
diff --git a/gdbserver/win32-i386-low.cc b/gdbserver/win32-i386-low.cc
index 2b18c2c..8560408 100644
--- a/gdbserver/win32-i386-low.cc
+++ b/gdbserver/win32-i386-low.cc
@@ -85,7 +85,7 @@ win32_get_current_dr (int dr)
case DR: \
return th->wow64_context.Dr ## DR
- if (wow64_process)
+ if (windows_process.wow64_process)
{
switch (dr)
{
@@ -245,7 +245,7 @@ i386_get_thread_context (windows_thread_info *th)
again:
#ifdef __x86_64__
- if (wow64_process)
+ if (windows_process.wow64_process)
th->wow64_context.ContextFlags = (CONTEXT_FULL
| CONTEXT_FLOATING_POINT
| CONTEXT_DEBUG_REGISTERS
@@ -259,7 +259,7 @@ i386_get_thread_context (windows_thread_info *th)
BOOL ret;
#ifdef __x86_64__
- if (wow64_process)
+ if (windows_process.wow64_process)
ret = Wow64GetThreadContext (th->h, &th->wow64_context);
else
#endif
@@ -288,7 +288,7 @@ i386_prepare_to_resume (windows_thread_info *th)
win32_require_context (th);
#ifdef __x86_64__
- if (wow64_process)
+ if (windows_process.wow64_process)
{
th->wow64_context.Dr0 = dr->dr_mirror[0];
th->wow64_context.Dr1 = dr->dr_mirror[1];
@@ -324,7 +324,7 @@ static void
i386_single_step (windows_thread_info *th)
{
#ifdef __x86_64__
- if (wow64_process)
+ if (windows_process.wow64_process)
th->wow64_context.EFlags |= FLAG_TRACE_BIT;
else
#endif
@@ -466,7 +466,7 @@ i386_fetch_inferior_register (struct regcache *regcache,
{
const int *mappings;
#ifdef __x86_64__
- if (!wow64_process)
+ if (!windows_process.wow64_process)
mappings = amd64_mappings;
else
#endif
@@ -474,7 +474,7 @@ i386_fetch_inferior_register (struct regcache *regcache,
char *context_offset;
#ifdef __x86_64__
- if (wow64_process)
+ if (windows_process.wow64_process)
context_offset = (char *) &th->wow64_context + mappings[r];
else
#endif
@@ -502,7 +502,7 @@ i386_store_inferior_register (struct regcache *regcache,
{
const int *mappings;
#ifdef __x86_64__
- if (!wow64_process)
+ if (!windows_process.wow64_process)
mappings = amd64_mappings;
else
#endif
@@ -510,7 +510,7 @@ i386_store_inferior_register (struct regcache *regcache,
char *context_offset;
#ifdef __x86_64__
- if (wow64_process)
+ if (windows_process.wow64_process)
context_offset = (char *) &th->wow64_context + mappings[r];
else
#endif
@@ -550,7 +550,7 @@ i386_win32_num_regs (void)
{
int num_regs;
#ifdef __x86_64__
- if (!wow64_process)
+ if (!windows_process.wow64_process)
num_regs = sizeof (amd64_mappings) / sizeof (amd64_mappings[0]);
else
#endif
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index afeed1a..192ea46 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -38,7 +38,8 @@
using namespace windows_nat;
-static windows_process_info windows_process;
+/* See win32-low.h. */
+windows_process_info windows_process;
#ifndef USE_WIN32API
#include <sys/cygwin.h>
@@ -113,7 +114,7 @@ static void
win32_get_thread_context (windows_thread_info *th)
{
#ifdef __x86_64__
- if (wow64_process)
+ if (windows_process.wow64_process)
memset (&th->wow64_context, 0, sizeof (WOW64_CONTEXT));
else
#endif
@@ -127,7 +128,7 @@ static void
win32_set_thread_context (windows_thread_info *th)
{
#ifdef __x86_64__
- if (wow64_process)
+ if (windows_process.wow64_process)
Wow64SetThreadContext (th->h, &th->wow64_context);
else
#endif
@@ -150,7 +151,7 @@ win32_require_context (windows_thread_info *th)
{
DWORD context_flags;
#ifdef __x86_64__
- if (wow64_process)
+ if (windows_process.wow64_process)
context_flags = th->wow64_context.ContextFlags;
else
#endif
@@ -192,7 +193,7 @@ child_add_thread (DWORD pid, DWORD tid, HANDLE h, void *tlb)
#ifdef __x86_64__
/* For WOW64 processes, this is actually the pointer to the 64bit TIB,
and the 32bit TIB is exactly 2 pages after it. */
- if (wow64_process)
+ if (windows_process.wow64_process)
base += 2 * 4096; /* page size = 4096 */
#endif
th = new windows_thread_info (tid, h, base);
@@ -354,19 +355,20 @@ do_initial_child_stuff (HANDLE proch, DWORD pid, int attached)
error ("Check if WOW64 process failed (error %d): %s\n",
(int) err, strwinerror (err));
}
- wow64_process = wow64;
+ windows_process.wow64_process = wow64;
- if (wow64_process
+ if (windows_process.wow64_process
&& (Wow64GetThreadContext == nullptr
|| Wow64SetThreadContext == nullptr))
error ("WOW64 debugging is not supported on this system.\n");
- ignore_first_breakpoint = !attached && wow64_process;
+ windows_process.ignore_first_breakpoint
+ = !attached && windows_process.wow64_process;
#endif
proc = add_process (pid, attached);
#ifdef __x86_64__
- if (wow64_process)
+ if (windows_process.wow64_process)
proc->tdesc = wow64_win32_tdesc;
else
#endif
@@ -440,7 +442,7 @@ continue_one_thread (thread_info *thread, int thread_id)
{
DWORD *context_flags;
#ifdef __x86_64__
- if (wow64_process)
+ if (windows_process.wow64_process)
context_flags = &th->wow64_context.ContextFlags;
else
#endif
@@ -913,7 +915,7 @@ win32_process_target::resume (thread_resume *resume_info, size_t n)
DWORD *context_flags;
#ifdef __x86_64__
- if (wow64_process)
+ if (windows_process.wow64_process)
context_flags = &th->wow64_context.ContextFlags;
else
#endif
@@ -1419,19 +1421,22 @@ win32_process_target::qxfer_siginfo (const char *annex,
#ifdef __x86_64__
EXCEPTION_RECORD32 er32;
- if (wow64_process)
+ if (windows_process.wow64_process)
{
buf = (char *) &er32;
bufsize = sizeof (er32);
- er32.ExceptionCode = siginfo_er.ExceptionCode;
- er32.ExceptionFlags = siginfo_er.ExceptionFlags;
- er32.ExceptionRecord = (uintptr_t) siginfo_er.ExceptionRecord;
- er32.ExceptionAddress = (uintptr_t) siginfo_er.ExceptionAddress;
- er32.NumberParameters = siginfo_er.NumberParameters;
+ er32.ExceptionCode = windows_process.siginfo_er.ExceptionCode;
+ er32.ExceptionFlags = windows_process.siginfo_er.ExceptionFlags;
+ er32.ExceptionRecord
+ = (uintptr_t) windows_process.siginfo_er.ExceptionRecord;
+ er32.ExceptionAddress
+ = (uintptr_t) windows_process.siginfo_er.ExceptionAddress;
+ er32.NumberParameters = windows_process.siginfo_er.NumberParameters;
int i;
for (i = 0; i < EXCEPTION_MAXIMUM_PARAMETERS; i++)
- er32.ExceptionInformation[i] = siginfo_er.ExceptionInformation[i];
+ er32.ExceptionInformation[i]
+ = windows_process.siginfo_er.ExceptionInformation[i];
}
#endif
diff --git a/gdbserver/win32-low.h b/gdbserver/win32-low.h
index a1d7457..c5f40dd 100644
--- a/gdbserver/win32-low.h
+++ b/gdbserver/win32-low.h
@@ -162,6 +162,9 @@ public:
const char *thread_name (ptid_t thread) override;
};
+/* The sole Windows process. */
+extern windows_nat::windows_process_info windows_process;
+
/* Retrieve the context for this thread, if not already retrieved. */
extern void win32_require_context (windows_nat::windows_thread_info *th);