Commit | Line | Data |
---|---|---|
68070c10 | 1 | /* Internal interfaces for the Win32 specific target code for gdbserver. |
3666a048 | 2 | Copyright (C) 2007-2021 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; | |
32 | ||
7d186bc0 HD |
33 | typedef BOOL (WINAPI *winapi_Wow64GetThreadContext) (HANDLE, PWOW64_CONTEXT); |
34 | extern winapi_Wow64GetThreadContext win32_Wow64GetThreadContext; | |
35 | #endif | |
3aee8918 | 36 | |
68070c10 PA |
37 | struct win32_target_ops |
38 | { | |
d05b4ac3 UW |
39 | /* Architecture-specific setup. */ |
40 | void (*arch_setup) (void); | |
41 | ||
34b34921 | 42 | /* The number of target registers. */ |
7d186bc0 | 43 | int (*num_regs) (void); |
68070c10 | 44 | |
34b34921 | 45 | /* Perform initializations on startup. */ |
68070c10 PA |
46 | void (*initial_stuff) (void); |
47 | ||
34b34921 | 48 | /* Fetch the context from the inferior. */ |
4834dad0 | 49 | void (*get_thread_context) (windows_nat::windows_thread_info *th); |
68070c10 | 50 | |
a2abc7de | 51 | /* Called just before resuming the thread. */ |
4834dad0 | 52 | void (*prepare_to_resume) (windows_nat::windows_thread_info *th); |
34b34921 PA |
53 | |
54 | /* Called when a thread was added. */ | |
4834dad0 | 55 | void (*thread_added) (windows_nat::windows_thread_info *th); |
34b34921 PA |
56 | |
57 | /* Fetch register from gdbserver regcache data. */ | |
442ea881 | 58 | void (*fetch_inferior_register) (struct regcache *regcache, |
4834dad0 TT |
59 | windows_nat::windows_thread_info *th, |
60 | int r); | |
34b34921 PA |
61 | |
62 | /* Store a new register value into the thread context of TH. */ | |
442ea881 | 63 | void (*store_inferior_register) (struct regcache *regcache, |
4834dad0 TT |
64 | windows_nat::windows_thread_info *th, |
65 | int r); | |
68070c10 | 66 | |
4834dad0 | 67 | void (*single_step) (windows_nat::windows_thread_info *th); |
68070c10 PA |
68 | |
69 | const unsigned char *breakpoint; | |
70 | int breakpoint_len; | |
aa5ca48f | 71 | |
e54e5929 TT |
72 | /* Amount by which to decrement the PC after a breakpoint is |
73 | hit. */ | |
74 | int decr_pc_after_break; | |
75 | ||
d6225aff TT |
76 | /* Get the PC register from REGCACHE. */ |
77 | CORE_ADDR (*get_pc) (struct regcache *regcache); | |
78 | /* Set the PC register in REGCACHE. */ | |
79 | void (*set_pc) (struct regcache *regcache, CORE_ADDR newpc); | |
80 | ||
aa5ca48f | 81 | /* Breakpoint/Watchpoint related functions. See target.h for comments. */ |
802e8e6d PA |
82 | int (*supports_z_point_type) (char z_type); |
83 | int (*insert_point) (enum raw_bkpt_type type, CORE_ADDR addr, | |
84 | int size, struct raw_breakpoint *bp); | |
85 | int (*remove_point) (enum raw_bkpt_type type, CORE_ADDR addr, | |
86 | int size, struct raw_breakpoint *bp); | |
aa5ca48f DE |
87 | int (*stopped_by_watchpoint) (void); |
88 | CORE_ADDR (*stopped_data_address) (void); | |
68070c10 PA |
89 | }; |
90 | ||
91 | extern struct win32_target_ops the_low_target; | |
92 | ||
5ef9273d TBA |
93 | /* Target ops definitions for a Win32 target. */ |
94 | ||
52405d85 | 95 | class win32_process_target : public process_stratum_target |
5ef9273d TBA |
96 | { |
97 | public: | |
98 | ||
15295543 TBA |
99 | int create_inferior (const char *program, |
100 | const std::vector<char *> &program_args) override; | |
ef03dad8 TBA |
101 | |
102 | int attach (unsigned long pid) override; | |
c6885a57 TBA |
103 | |
104 | int kill (process_info *proc) override; | |
9061c9cf TBA |
105 | |
106 | int detach (process_info *proc) override; | |
8adb37b9 TBA |
107 | |
108 | void mourn (process_info *proc) override; | |
95a49a39 TBA |
109 | |
110 | void join (int pid) override; | |
13d3d99b TBA |
111 | |
112 | bool thread_alive (ptid_t pid) override; | |
0e4d7e35 TBA |
113 | |
114 | void resume (thread_resume *resume_info, size_t n) override; | |
6532e7e3 TBA |
115 | |
116 | ptid_t wait (ptid_t ptid, target_waitstatus *status, | |
b60cea74 | 117 | target_wait_flags options) override; |
a5a4d4cd TBA |
118 | |
119 | void fetch_registers (regcache *regcache, int regno) override; | |
120 | ||
121 | void store_registers (regcache *regcache, int regno) override; | |
e2558df3 TBA |
122 | |
123 | int read_memory (CORE_ADDR memaddr, unsigned char *myaddr, | |
124 | int len) override; | |
125 | ||
126 | int write_memory (CORE_ADDR memaddr, const unsigned char *myaddr, | |
127 | int len) override; | |
eb497a2a TBA |
128 | |
129 | void request_interrupt () override; | |
a2b2297a TBA |
130 | |
131 | bool supports_z_point_type (char z_type) override; | |
7e0bde70 TBA |
132 | |
133 | int insert_point (enum raw_bkpt_type type, CORE_ADDR addr, | |
134 | int size, raw_breakpoint *bp) override; | |
135 | ||
136 | int remove_point (enum raw_bkpt_type type, CORE_ADDR addr, | |
137 | int size, raw_breakpoint *bp) override; | |
22aa6223 TBA |
138 | |
139 | bool supports_hardware_single_step () override; | |
6eeb5c55 TBA |
140 | |
141 | bool stopped_by_watchpoint () override; | |
142 | ||
143 | CORE_ADDR stopped_data_address () override; | |
ea06bbaa TBA |
144 | |
145 | #ifdef _WIN32_WCE | |
146 | void hostio_last_error (char *buf) override; | |
147 | #endif | |
d7abedf7 TBA |
148 | |
149 | bool supports_qxfer_siginfo () override; | |
150 | ||
151 | int qxfer_siginfo (const char *annex, unsigned char *readbuf, | |
152 | unsigned const char *writebuf, | |
153 | CORE_ADDR offset, int len) override; | |
4e2e869c TBA |
154 | |
155 | bool supports_get_tib_address () override; | |
156 | ||
157 | int get_tib_address (ptid_t ptid, CORE_ADDR *addr) override; | |
d367006f TBA |
158 | |
159 | const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) override; | |
d6225aff TT |
160 | |
161 | CORE_ADDR read_pc (regcache *regcache) override; | |
162 | ||
163 | void write_pc (regcache *regcache, CORE_ADDR pc) override; | |
523d4f80 TT |
164 | |
165 | bool stopped_by_sw_breakpoint () override; | |
166 | ||
167 | bool supports_stopped_by_sw_breakpoint () override; | |
5ef9273d TBA |
168 | }; |
169 | ||
a2abc7de | 170 | /* Retrieve the context for this thread, if not already retrieved. */ |
4834dad0 | 171 | extern void win32_require_context (windows_nat::windows_thread_info *th); |
a2abc7de | 172 | |
68070c10 PA |
173 | /* Map the Windows error number in ERROR to a locale-dependent error |
174 | message string and return a pointer to it. Typically, the values | |
175 | for ERROR come from GetLastError. | |
176 | ||
177 | The string pointed to shall not be modified by the application, | |
178 | but may be overwritten by a subsequent call to strwinerror | |
179 | ||
180 | The strwinerror function does not change the current setting | |
181 | of GetLastError. */ | |
182 | extern char * strwinerror (DWORD error); | |
183 | ||
1a5c2598 | 184 | #endif /* GDBSERVER_WIN32_LOW_H */ |