Share windows_thread_info between gdb and gdbserver
authorTom Tromey <tromey@adacore.com>
Wed, 8 Apr 2020 20:33:35 +0000 (14:33 -0600)
committerTom Tromey <tromey@adacore.com>
Wed, 8 Apr 2020 20:47:57 +0000 (14:47 -0600)
This introduces a new file, nat/windows-nat.h, which holds the
definition of windows_thread_info.  This is now shared between gdb and
gdbserver.

Note that the two implementations different slightly.  gdb had a
couple of fields ("name" and "reload_context") that gdbserver did not;
while gdbserver had one field ("base_context") that gdb did not, plus
better comments.  The new file preserves all the fields, and the
comments.

gdb/ChangeLog
2020-04-08  Tom Tromey  <tromey@adacore.com>

* windows-nat.c (struct windows_thread_info): Remove.
* nat/windows-nat.h: New file.

gdbserver/ChangeLog
2020-04-08  Tom Tromey  <tromey@adacore.com>

* win32-low.h (struct windows_thread_info): Remove.

gdb/ChangeLog
gdb/nat/windows-nat.h [new file with mode: 0644]
gdb/windows-nat.c
gdbserver/ChangeLog
gdbserver/win32-low.h

index 1c46aafadd2c3671344c4297bdb70ce208fd05fe..c2e6d60fd6fe0ef3b6683430ab4562149a699fa6 100644 (file)
@@ -1,3 +1,8 @@
+2020-04-08  Tom Tromey  <tromey@adacore.com>
+
+       * windows-nat.c (struct windows_thread_info): Remove.
+       * nat/windows-nat.h: New file.
+
 2020-04-08  Tom Tromey  <tromey@adacore.com>
 
        * windows-nat.c (struct windows_thread_info) <tid>: Rename from "id".
diff --git a/gdb/nat/windows-nat.h b/gdb/nat/windows-nat.h
new file mode 100644 (file)
index 0000000..71df097
--- /dev/null
@@ -0,0 +1,66 @@
+/* Internal interfaces for the Windows code
+   Copyright (C) 1995-2020 Free Software Foundation, Inc.
+
+   This file is part of GDB.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#ifndef NAT_WINDOWS_NAT_H
+#define NAT_WINDOWS_NAT_H
+
+#include <windows.h>
+
+/* Thread information structure used to track extra information about
+   each thread.  */
+struct windows_thread_info
+{
+  /* The Win32 thread identifier.  */
+  DWORD tid;
+
+  /* The handle to the thread.  */
+  HANDLE h;
+
+  /* Thread Information Block address.  */
+  CORE_ADDR thread_local_base;
+
+  /* Non zero if SuspendThread was called on this thread.  */
+  int suspended;
+
+#ifdef _WIN32_WCE
+  /* The context as retrieved right after suspending the thread. */
+  CONTEXT base_context;
+#endif
+
+  /* The context of the thread, including any manipulations.  */
+  union
+  {
+    CONTEXT context;
+#ifdef __x86_64__
+    WOW64_CONTEXT wow64_context;
+#endif
+  };
+
+  /* Whether debug registers changed since we last set CONTEXT back to
+     the thread.  */
+  int debug_registers_changed;
+
+  /* Nonzero if CONTEXT is invalidated and must be re-read from the
+     inferior thread.  */
+  int reload_context;
+
+  /* The name of the thread, allocated by xmalloc.  */
+  char *name;
+};
+
+#endif
index 837359e9786190801b564c32682729f672908f00..9368396b0fcd61b77263c7543d210a020544caf7 100644 (file)
@@ -70,6 +70,7 @@
 #include "gdbsupport/gdb_tilde_expand.h"
 #include "gdbsupport/pathstuff.h"
 #include "gdbsupport/gdb_wait.h"
+#include "nat/windows-nat.h"
 
 #define STATUS_WX86_BREAKPOINT 0x4000001F
 #define STATUS_WX86_SINGLE_STEP 0x4000001E
@@ -244,25 +245,6 @@ static unsigned long cygwin_get_dr7 (void);
 static enum gdb_signal last_sig = GDB_SIGNAL_0;
 /* Set if a signal was received from the debugged process.  */
 
-/* Thread information structure used to track information that is
-   not available in gdb's thread structure.  */
-struct windows_thread_info
-  {
-    DWORD tid;
-    HANDLE h;
-    CORE_ADDR thread_local_base;
-    char *name;
-    int suspended;
-    int reload_context;
-    union
-      {
-       CONTEXT context;
-#ifdef __x86_64__
-       WOW64_CONTEXT wow64_context;
-#endif
-      };
-  };
-
 static std::vector<windows_thread_info *> thread_list;
 
 /* The process and thread handles for the above context.  */
index 234d842ae1c299efd76cf02ffd93b339786f74f7..3923429cfc2071c006c72913226c55736bfcde17 100644 (file)
@@ -1,3 +1,7 @@
+2020-04-08  Tom Tromey  <tromey@adacore.com>
+
+       * win32-low.h (struct windows_thread_info): Remove.
+
 2020-04-08  Tom Tromey  <tromey@adacore.com>
 
        * win32-low.h (struct windows_thread_info): Rename from
index 2bd94e85288288e2f5f37208cbeaa0ab74e2d090..28ac2b082d9d45ba0b07f3836b9947dccfd7104a 100644 (file)
@@ -20,6 +20,7 @@
 #define GDBSERVER_WIN32_LOW_H
 
 #include <windows.h>
+#include "nat/windows-nat.h"
 
 struct target_desc;
 
@@ -27,35 +28,6 @@ struct target_desc;
    Windows ports support neither bi-arch nor multi-process.  */
 extern const struct target_desc *win32_tdesc;
 
-/* Thread information structure used to track extra information about
-   each thread.  */
-struct windows_thread_info
-{
-  /* The Win32 thread identifier.  */
-  DWORD tid;
-
-  /* The handle to the thread.  */
-  HANDLE h;
-
-  /* Thread Information Block address.  */
-  CORE_ADDR thread_local_base;
-
-  /* Non zero if SuspendThread was called on this thread.  */
-  int suspended;
-
-#ifdef _WIN32_WCE
-  /* The context as retrieved right after suspending the thread. */
-  CONTEXT base_context;
-#endif
-
-  /* The context of the thread, including any manipulations.  */
-  CONTEXT context;
-
-  /* Whether debug registers changed since we last set CONTEXT back to
-     the thread.  */
-  int debug_registers_changed;
-};
-
 struct win32_target_ops
 {
   /* Architecture-specific setup.  */
This page took 0.032058 seconds and 4 git commands to generate.