]>
Commit | Line | Data |
---|---|---|
68070c10 | 1 | /* Internal interfaces for the Win32 specific target code for gdbserver. |
213516ef | 2 | Copyright (C) 2007-2023 Free Software Foundation, Inc. |
68070c10 PA |
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 | |
a9762ec7 | 8 | the Free Software Foundation; either version 3 of the License, or |
68070c10 PA |
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 | |
a9762ec7 | 17 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
68070c10 | 18 | |
1a5c2598 TT |
19 | #ifndef GDBSERVER_WIN32_LOW_H |
20 | #define GDBSERVER_WIN32_LOW_H | |
21 | ||
68070c10 | 22 | #include <windows.h> |
ae1f8880 | 23 | #include "nat/windows-nat.h" |
68070c10 | 24 | |
3aee8918 PA |
25 | struct target_desc; |
26 | ||
27 | /* The inferior's target description. This is a global because the | |
28 | Windows ports support neither bi-arch nor multi-process. */ | |
29 | extern const struct target_desc *win32_tdesc; | |
7d186bc0 HD |
30 | #ifdef __x86_64__ |
31 | extern const struct target_desc *wow64_win32_tdesc; | |
7d186bc0 | 32 | #endif |
3aee8918 | 33 | |
68070c10 PA |
34 | struct win32_target_ops |
35 | { | |
d05b4ac3 UW |
36 | /* Architecture-specific setup. */ |
37 | void (*arch_setup) (void); | |
38 | ||
34b34921 | 39 | /* The number of target registers. */ |
7d186bc0 | 40 | int (*num_regs) (void); |
68070c10 | 41 | |
34b34921 | 42 | /* Perform initializations on startup. */ |
68070c10 PA |
43 | void (*initial_stuff) (void); |
44 | ||
34b34921 | 45 | /* Fetch the context from the inferior. */ |
4834dad0 | 46 | void (*get_thread_context) (windows_nat::windows_thread_info *th); |
68070c10 | 47 | |
a2abc7de | 48 | /* Called just before resuming the thread. */ |
4834dad0 | 49 | void (*prepare_to_resume) (windows_nat::windows_thread_info *th); |
34b34921 PA |
50 | |
51 | /* Called when a thread was added. */ | |
4834dad0 | 52 | void (*thread_added) (windows_nat::windows_thread_info *th); |
34b34921 PA |
53 | |
54 | /* Fetch register from gdbserver regcache data. */ | |
442ea881 | 55 | void (*fetch_inferior_register) (struct regcache *regcache, |
4834dad0 TT |
56 | windows_nat::windows_thread_info *th, |
57 | int r); | |
34b34921 PA |
58 | |
59 | /* Store a new register value into the thread context of TH. */ | |
442ea881 | 60 | void (*store_inferior_register) (struct regcache *regcache, |
4834dad0 TT |
61 | windows_nat::windows_thread_info *th, |
62 | int r); | |
68070c10 | 63 | |
4834dad0 | 64 | void (*single_step) (windows_nat::windows_thread_info *th); |
68070c10 PA |
65 | |
66 | const unsigned char *breakpoint; | |
67 | int breakpoint_len; | |
aa5ca48f | 68 | |
e54e5929 TT |
69 | /* Amount by which to decrement the PC after a breakpoint is |
70 | hit. */ | |
71 | int decr_pc_after_break; | |
72 | ||
d6225aff TT |
73 | /* Get the PC register from REGCACHE. */ |
74 | CORE_ADDR (*get_pc) (struct regcache *regcache); | |
75 | /* Set the PC register in REGCACHE. */ | |
76 | void (*set_pc) (struct regcache *regcache, CORE_ADDR newpc); | |
77 | ||
aa5ca48f | 78 | /* Breakpoint/Watchpoint related functions. See target.h for comments. */ |
802e8e6d PA |
79 | int (*supports_z_point_type) (char z_type); |
80 | int (*insert_point) (enum raw_bkpt_type type, CORE_ADDR addr, | |
81 | int size, struct raw_breakpoint *bp); | |
82 | int (*remove_point) (enum raw_bkpt_type type, CORE_ADDR addr, | |
83 | int size, struct raw_breakpoint *bp); | |
aa5ca48f DE |
84 | int (*stopped_by_watchpoint) (void); |
85 | CORE_ADDR (*stopped_data_address) (void); | |
68070c10 PA |
86 | }; |
87 | ||
88 | extern struct win32_target_ops the_low_target; | |
89 | ||
5ef9273d TBA |
90 | /* Target ops definitions for a Win32 target. */ |
91 | ||
52405d85 | 92 | class win32_process_target : public process_stratum_target |
5ef9273d TBA |
93 | { |
94 | public: | |
95 | ||
15295543 TBA |
96 | int create_inferior (const char *program, |
97 | const std::vector<char *> &program_args) override; | |
ef03dad8 TBA |
98 | |
99 | int attach (unsigned long pid) override; | |
c6885a57 TBA |
100 | |
101 | int kill (process_info *proc) override; | |
9061c9cf TBA |
102 | |
103 | int detach (process_info *proc) override; | |
8adb37b9 TBA |
104 | |
105 | void mourn (process_info *proc) override; | |
95a49a39 TBA |
106 | |
107 | void join (int pid) override; | |
13d3d99b TBA |
108 | |
109 | bool thread_alive (ptid_t pid) override; | |
0e4d7e35 TBA |
110 | |
111 | void resume (thread_resume *resume_info, size_t n) override; | |
6532e7e3 TBA |
112 | |
113 | ptid_t wait (ptid_t ptid, target_waitstatus *status, | |
b60cea74 | 114 | target_wait_flags options) override; |
a5a4d4cd TBA |
115 | |
116 | void fetch_registers (regcache *regcache, int regno) override; | |
117 | ||
118 | void store_registers (regcache *regcache, int regno) override; | |
e2558df3 TBA |
119 | |
120 | int read_memory (CORE_ADDR memaddr, unsigned char *myaddr, | |
121 | int len) override; | |
122 | ||
123 | int write_memory (CORE_ADDR memaddr, const unsigned char *myaddr, | |
124 | int len) override; | |
eb497a2a TBA |
125 | |
126 | void request_interrupt () override; | |
a2b2297a TBA |
127 | |
128 | bool supports_z_point_type (char z_type) override; | |
7e0bde70 TBA |
129 | |
130 | int insert_point (enum raw_bkpt_type type, CORE_ADDR addr, | |
131 | int size, raw_breakpoint *bp) override; | |
132 | ||
133 | int remove_point (enum raw_bkpt_type type, CORE_ADDR addr, | |
134 | int size, raw_breakpoint *bp) override; | |
22aa6223 TBA |
135 | |
136 | bool supports_hardware_single_step () override; | |
6eeb5c55 TBA |
137 | |
138 | bool stopped_by_watchpoint () override; | |
139 | ||
140 | CORE_ADDR stopped_data_address () override; | |
ea06bbaa | 141 | |
d7abedf7 TBA |
142 | bool supports_qxfer_siginfo () override; |
143 | ||
144 | int qxfer_siginfo (const char *annex, unsigned char *readbuf, | |
145 | unsigned const char *writebuf, | |
146 | CORE_ADDR offset, int len) override; | |
4e2e869c TBA |
147 | |
148 | bool supports_get_tib_address () override; | |
149 | ||
150 | int get_tib_address (ptid_t ptid, CORE_ADDR *addr) override; | |
d367006f TBA |
151 | |
152 | const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) override; | |
d6225aff TT |
153 | |
154 | CORE_ADDR read_pc (regcache *regcache) override; | |
155 | ||
156 | void write_pc (regcache *regcache, CORE_ADDR pc) override; | |
523d4f80 TT |
157 | |
158 | bool stopped_by_sw_breakpoint () override; | |
159 | ||
160 | bool supports_stopped_by_sw_breakpoint () override; | |
42a59714 TT |
161 | |
162 | const char *thread_name (ptid_t thread) override; | |
fcab5839 TT |
163 | |
164 | bool supports_pid_to_exec_file () override | |
165 | { return true; } | |
166 | ||
167 | const char *pid_to_exec_file (int pid) override; | |
bcb9251f TT |
168 | |
169 | bool supports_disable_randomization () override | |
170 | { | |
171 | return windows_nat::disable_randomization_available (); | |
172 | } | |
5ef9273d TBA |
173 | }; |
174 | ||
20489cca TT |
175 | struct gdbserver_windows_process : public windows_nat::windows_process_info |
176 | { | |
177 | windows_nat::windows_thread_info *thread_rec | |
178 | (ptid_t ptid, | |
179 | windows_nat::thread_disposition_type disposition) override; | |
180 | int handle_output_debug_string (struct target_waitstatus *ourstatus) override; | |
181 | void handle_load_dll (const char *dll_name, LPVOID base) override; | |
182 | void handle_unload_dll () override; | |
183 | bool handle_access_violation (const EXCEPTION_RECORD *rec) override; | |
184 | ||
185 | int attaching = 0; | |
186 | ||
187 | /* A status that hasn't been reported to the core yet, and so | |
188 | win32_wait should return it next, instead of fetching the next | |
189 | debug event off the win32 API. */ | |
190 | struct target_waitstatus cached_status; | |
191 | ||
192 | /* Non zero if an interrupt request is to be satisfied by suspending | |
193 | all threads. */ | |
194 | int soft_interrupt_requested = 0; | |
195 | ||
196 | /* Non zero if the inferior is stopped in a simulated breakpoint done | |
197 | by suspending all the threads. */ | |
198 | int faked_breakpoint = 0; | |
199 | ||
200 | /* True if current_process_handle needs to be closed. */ | |
201 | bool open_process_used = false; | |
202 | ||
203 | /* Zero during the child initialization phase, and nonzero | |
204 | otherwise. */ | |
205 | int child_initialization_done = 0; | |
206 | }; | |
207 | ||
801eb70f | 208 | /* The sole Windows process. */ |
20489cca | 209 | extern gdbserver_windows_process windows_process; |
801eb70f | 210 | |
a2abc7de | 211 | /* Retrieve the context for this thread, if not already retrieved. */ |
4834dad0 | 212 | extern void win32_require_context (windows_nat::windows_thread_info *th); |
a2abc7de | 213 | |
1a5c2598 | 214 | #endif /* GDBSERVER_WIN32_LOW_H */ |