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