Fix up complaints.h for namespace use
[deliverable/binutils-gdb.git] / gdb / nat / windows-nat.h
CommitLineData
ae1f8880
TT
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>
3c76026d
TT
23#include <vector>
24
25#include "target/waitstatus.h"
ae1f8880 26
4834dad0
TT
27namespace windows_nat
28{
29
ae1f8880
TT
30/* Thread information structure used to track extra information about
31 each thread. */
32struct windows_thread_info
33{
e9534bd2
TT
34 windows_thread_info (DWORD tid_, HANDLE h_, CORE_ADDR tlb)
35 : tid (tid_),
36 h (h_),
37 thread_local_base (tlb)
38 {
39 }
40
65bafd5b
TT
41 ~windows_thread_info ();
42
e9534bd2
TT
43 DISABLE_COPY_AND_ASSIGN (windows_thread_info);
44
98a03287
TT
45 /* Ensure that this thread has been suspended. */
46 void suspend ();
47
48 /* Resume the thread if it has been suspended. */
49 void resume ();
50
ae1f8880
TT
51 /* The Win32 thread identifier. */
52 DWORD tid;
53
54 /* The handle to the thread. */
55 HANDLE h;
56
57 /* Thread Information Block address. */
58 CORE_ADDR thread_local_base;
59
62fe396b
TT
60 /* This keeps track of whether SuspendThread was called on this
61 thread. -1 means there was a failure or that the thread was
62 explicitly not suspended, 1 means it was called, and 0 means it
63 was not. */
e9534bd2 64 int suspended = 0;
ae1f8880
TT
65
66#ifdef _WIN32_WCE
67 /* The context as retrieved right after suspending the thread. */
e9534bd2 68 CONTEXT base_context {};
ae1f8880
TT
69#endif
70
71 /* The context of the thread, including any manipulations. */
72 union
73 {
e9534bd2 74 CONTEXT context {};
ae1f8880
TT
75#ifdef __x86_64__
76 WOW64_CONTEXT wow64_context;
77#endif
78 };
79
80 /* Whether debug registers changed since we last set CONTEXT back to
81 the thread. */
62fe396b 82 bool debug_registers_changed = false;
ae1f8880
TT
83
84 /* Nonzero if CONTEXT is invalidated and must be re-read from the
85 inferior thread. */
62fe396b 86 bool reload_context = false;
ae1f8880 87
0a4afda3
TT
88 /* True if this thread is currently stopped at a software
89 breakpoint. This is used to offset the PC when needed. */
90 bool stopped_at_software_breakpoint = false;
91
ae1f8880 92 /* The name of the thread, allocated by xmalloc. */
2950fdf7 93 gdb::unique_xmalloc_ptr<char> name;
ae1f8880
TT
94};
95
28688adf
TT
96
97/* Possible values to pass to 'thread_rec'. */
98enum thread_disposition_type
99{
100 /* Do not invalidate the thread's context, and do not suspend the
101 thread. */
102 DONT_INVALIDATE_CONTEXT,
103 /* Invalidate the context, but do not suspend the thread. */
104 DONT_SUSPEND,
105 /* Invalidate the context and suspend the thread. */
106 INVALIDATE_CONTEXT
107};
108
109/* Find a thread record given a thread id. THREAD_DISPOSITION
110 controls whether the thread is suspended, and whether the context
111 is invalidated.
112
113 This function must be supplied by the embedding application. */
114extern windows_thread_info *thread_rec (ptid_t ptid,
115 thread_disposition_type disposition);
116
d41b524f
TT
117
118/* Handle OUTPUT_DEBUG_STRING_EVENT from child process. Updates
119 OURSTATUS and returns the thread id if this represents a thread
120 change (this is specific to Cygwin), otherwise 0.
121
122 Cygwin prepends its messages with a "cygwin:". Interpret this as
123 a Cygwin signal. Otherwise just print the string as a warning.
124
125 This function must be supplied by the embedding application. */
126extern int handle_output_debug_string (struct target_waitstatus *ourstatus);
127
3c76026d
TT
128/* Currently executing process */
129extern HANDLE current_process_handle;
130extern DWORD current_process_id;
131extern DWORD main_thread_id;
132extern enum gdb_signal last_sig;
133
134/* The current debug event from WaitForDebugEvent or from a pending
135 stop. */
136extern DEBUG_EVENT current_event;
137
138/* The most recent event from WaitForDebugEvent. Unlike
139 current_event, this is guaranteed never to come from a pending
140 stop. This is important because only data from the most recent
141 event from WaitForDebugEvent can be used when calling
142 ContinueDebugEvent. */
143extern DEBUG_EVENT last_wait_event;
144
145/* Info on currently selected thread */
146extern windows_thread_info *current_windows_thread;
147
148/* The ID of the thread for which we anticipate a stop event.
149 Normally this is -1, meaning we'll accept an event in any
150 thread. */
151extern DWORD desired_stop_thread_id;
152
153/* A single pending stop. See "pending_stops" for more
154 information. */
155struct pending_stop
156{
157 /* The thread id. */
158 DWORD thread_id;
159
160 /* The target waitstatus we computed. */
161 target_waitstatus status;
162
163 /* The event. A few fields of this can be referenced after a stop,
164 and it seemed simplest to store the entire event. */
165 DEBUG_EVENT event;
166};
167
168/* A vector of pending stops. Sometimes, Windows will report a stop
169 on a thread that has been ostensibly suspended. We believe what
170 happens here is that two threads hit a breakpoint simultaneously,
171 and the Windows kernel queues the stop events. However, this can
172 result in the strange effect of trying to single step thread A --
173 leaving all other threads suspended -- and then seeing a stop in
174 thread B. To handle this scenario, we queue all such "pending"
175 stops here, and then process them once the step has completed. See
176 PR gdb/22992. */
177extern std::vector<pending_stop> pending_stops;
178
179/* Contents of $_siginfo */
180extern EXCEPTION_RECORD siginfo_er;
181
9d8679cc
TT
182/* Return the name of the DLL referenced by H at ADDRESS. UNICODE
183 determines what sort of string is read from the inferior. Returns
184 the name of the DLL, or NULL on error. If a name is returned, it
185 is stored in a static buffer which is valid until the next call to
186 get_image_name. */
187extern const char *get_image_name (HANDLE h, void *address, int unicode);
188
4834dad0
TT
189}
190
ae1f8880 191#endif
This page took 0.049503 seconds and 4 git commands to generate.