1 /* Internal interfaces for the Win32 specific target code for gdbserver.
2 Copyright (C) 2007-2020 Free Software Foundation, Inc.
4 This file is part of GDB.
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.
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.
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/>. */
19 #ifndef GDBSERVER_WIN32_LOW_H
20 #define GDBSERVER_WIN32_LOW_H
26 /* The inferior's target description. This is a global because the
27 Windows ports support neither bi-arch nor multi-process. */
28 extern const struct target_desc
*win32_tdesc
;
30 /* Thread information structure used to track extra information about
32 typedef struct win32_thread_info
34 /* The Win32 thread identifier. */
37 /* The handle to the thread. */
40 /* Thread Information Block address. */
41 CORE_ADDR thread_local_base
;
43 /* Non zero if SuspendThread was called on this thread. */
47 /* The context as retrieved right after suspending the thread. */
51 /* The context of the thread, including any manipulations. */
54 /* Whether debug registers changed since we last set CONTEXT back to
56 int debug_registers_changed
;
59 struct win32_target_ops
61 /* Architecture-specific setup. */
62 void (*arch_setup
) (void);
64 /* The number of target registers. */
67 /* Perform initializations on startup. */
68 void (*initial_stuff
) (void);
70 /* Fetch the context from the inferior. */
71 void (*get_thread_context
) (win32_thread_info
*th
);
73 /* Called just before resuming the thread. */
74 void (*prepare_to_resume
) (win32_thread_info
*th
);
76 /* Called when a thread was added. */
77 void (*thread_added
) (win32_thread_info
*th
);
79 /* Fetch register from gdbserver regcache data. */
80 void (*fetch_inferior_register
) (struct regcache
*regcache
,
81 win32_thread_info
*th
, int r
);
83 /* Store a new register value into the thread context of TH. */
84 void (*store_inferior_register
) (struct regcache
*regcache
,
85 win32_thread_info
*th
, int r
);
87 void (*single_step
) (win32_thread_info
*th
);
89 const unsigned char *breakpoint
;
92 /* Breakpoint/Watchpoint related functions. See target.h for comments. */
93 int (*supports_z_point_type
) (char z_type
);
94 int (*insert_point
) (enum raw_bkpt_type type
, CORE_ADDR addr
,
95 int size
, struct raw_breakpoint
*bp
);
96 int (*remove_point
) (enum raw_bkpt_type type
, CORE_ADDR addr
,
97 int size
, struct raw_breakpoint
*bp
);
98 int (*stopped_by_watchpoint
) (void);
99 CORE_ADDR (*stopped_data_address
) (void);
102 extern struct win32_target_ops the_low_target
;
104 /* Target ops definitions for a Win32 target. */
106 class win32_process_target
: public process_target
110 int create_inferior (const char *program
,
111 const std::vector
<char *> &program_args
) override
;
113 int attach (unsigned long pid
) override
;
115 int kill (process_info
*proc
) override
;
117 int detach (process_info
*proc
) override
;
119 void mourn (process_info
*proc
) override
;
121 void join (int pid
) override
;
123 bool thread_alive (ptid_t pid
) override
;
125 void resume (thread_resume
*resume_info
, size_t n
) override
;
127 ptid_t
wait (ptid_t ptid
, target_waitstatus
*status
,
128 int options
) override
;
130 void fetch_registers (regcache
*regcache
, int regno
) override
;
132 void store_registers (regcache
*regcache
, int regno
) override
;
134 int read_memory (CORE_ADDR memaddr
, unsigned char *myaddr
,
137 int write_memory (CORE_ADDR memaddr
, const unsigned char *myaddr
,
140 void request_interrupt () override
;
142 bool supports_z_point_type (char z_type
) override
;
144 int insert_point (enum raw_bkpt_type type
, CORE_ADDR addr
,
145 int size
, raw_breakpoint
*bp
) override
;
147 int remove_point (enum raw_bkpt_type type
, CORE_ADDR addr
,
148 int size
, raw_breakpoint
*bp
) override
;
150 bool supports_hardware_single_step () override
;
153 /* Retrieve the context for this thread, if not already retrieved. */
154 extern void win32_require_context (win32_thread_info
*th
);
156 /* Map the Windows error number in ERROR to a locale-dependent error
157 message string and return a pointer to it. Typically, the values
158 for ERROR come from GetLastError.
160 The string pointed to shall not be modified by the application,
161 but may be overwritten by a subsequent call to strwinerror
163 The strwinerror function does not change the current setting
165 extern char * strwinerror (DWORD error
);
167 /* in wincecompat.c */
169 extern void to_back_slashes (char *);
171 #endif /* GDBSERVER_WIN32_LOW_H */