Share thread_rec between gdb and gdbserver
[deliverable/binutils-gdb.git] / gdb / nat / windows-nat.h
1 /* Internal interfaces for the Windows code
2 Copyright (C) 1995-2020 Free Software Foundation, Inc.
3
4 This file is part of GDB.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
18
19 #ifndef NAT_WINDOWS_NAT_H
20 #define NAT_WINDOWS_NAT_H
21
22 #include <windows.h>
23
24 namespace windows_nat
25 {
26
27 /* Thread information structure used to track extra information about
28 each thread. */
29 struct windows_thread_info
30 {
31 windows_thread_info (DWORD tid_, HANDLE h_, CORE_ADDR tlb)
32 : tid (tid_),
33 h (h_),
34 thread_local_base (tlb)
35 {
36 }
37
38 ~windows_thread_info ();
39
40 DISABLE_COPY_AND_ASSIGN (windows_thread_info);
41
42 /* Ensure that this thread has been suspended. */
43 void suspend ();
44
45 /* Resume the thread if it has been suspended. */
46 void resume ();
47
48 /* The Win32 thread identifier. */
49 DWORD tid;
50
51 /* The handle to the thread. */
52 HANDLE h;
53
54 /* Thread Information Block address. */
55 CORE_ADDR thread_local_base;
56
57 /* This keeps track of whether SuspendThread was called on this
58 thread. -1 means there was a failure or that the thread was
59 explicitly not suspended, 1 means it was called, and 0 means it
60 was not. */
61 int suspended = 0;
62
63 #ifdef _WIN32_WCE
64 /* The context as retrieved right after suspending the thread. */
65 CONTEXT base_context {};
66 #endif
67
68 /* The context of the thread, including any manipulations. */
69 union
70 {
71 CONTEXT context {};
72 #ifdef __x86_64__
73 WOW64_CONTEXT wow64_context;
74 #endif
75 };
76
77 /* Whether debug registers changed since we last set CONTEXT back to
78 the thread. */
79 bool debug_registers_changed = false;
80
81 /* Nonzero if CONTEXT is invalidated and must be re-read from the
82 inferior thread. */
83 bool reload_context = false;
84
85 /* True if this thread is currently stopped at a software
86 breakpoint. This is used to offset the PC when needed. */
87 bool stopped_at_software_breakpoint = false;
88
89 /* The name of the thread, allocated by xmalloc. */
90 gdb::unique_xmalloc_ptr<char> name;
91 };
92
93
94 /* Possible values to pass to 'thread_rec'. */
95 enum thread_disposition_type
96 {
97 /* Do not invalidate the thread's context, and do not suspend the
98 thread. */
99 DONT_INVALIDATE_CONTEXT,
100 /* Invalidate the context, but do not suspend the thread. */
101 DONT_SUSPEND,
102 /* Invalidate the context and suspend the thread. */
103 INVALIDATE_CONTEXT
104 };
105
106 /* Find a thread record given a thread id. THREAD_DISPOSITION
107 controls whether the thread is suspended, and whether the context
108 is invalidated.
109
110 This function must be supplied by the embedding application. */
111 extern windows_thread_info *thread_rec (ptid_t ptid,
112 thread_disposition_type disposition);
113
114 }
115
116 #endif
This page took 0.030853 seconds and 4 git commands to generate.