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
23 #include "nat/windows-nat.h"
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
;
31 struct win32_target_ops
33 /* Architecture-specific setup. */
34 void (*arch_setup
) (void);
36 /* The number of target registers. */
39 /* Perform initializations on startup. */
40 void (*initial_stuff
) (void);
42 /* Fetch the context from the inferior. */
43 void (*get_thread_context
) (windows_nat::windows_thread_info
*th
);
45 /* Called just before resuming the thread. */
46 void (*prepare_to_resume
) (windows_nat::windows_thread_info
*th
);
48 /* Called when a thread was added. */
49 void (*thread_added
) (windows_nat::windows_thread_info
*th
);
51 /* Fetch register from gdbserver regcache data. */
52 void (*fetch_inferior_register
) (struct regcache
*regcache
,
53 windows_nat::windows_thread_info
*th
,
56 /* Store a new register value into the thread context of TH. */
57 void (*store_inferior_register
) (struct regcache
*regcache
,
58 windows_nat::windows_thread_info
*th
,
61 void (*single_step
) (windows_nat::windows_thread_info
*th
);
63 const unsigned char *breakpoint
;
66 /* Get the PC register from REGCACHE. */
67 CORE_ADDR (*get_pc
) (struct regcache
*regcache
);
68 /* Set the PC register in REGCACHE. */
69 void (*set_pc
) (struct regcache
*regcache
, CORE_ADDR newpc
);
71 /* Breakpoint/Watchpoint related functions. See target.h for comments. */
72 int (*supports_z_point_type
) (char z_type
);
73 int (*insert_point
) (enum raw_bkpt_type type
, CORE_ADDR addr
,
74 int size
, struct raw_breakpoint
*bp
);
75 int (*remove_point
) (enum raw_bkpt_type type
, CORE_ADDR addr
,
76 int size
, struct raw_breakpoint
*bp
);
77 int (*stopped_by_watchpoint
) (void);
78 CORE_ADDR (*stopped_data_address
) (void);
81 extern struct win32_target_ops the_low_target
;
83 /* Target ops definitions for a Win32 target. */
85 class win32_process_target
: public process_stratum_target
89 int create_inferior (const char *program
,
90 const std::vector
<char *> &program_args
) override
;
92 int attach (unsigned long pid
) override
;
94 int kill (process_info
*proc
) override
;
96 int detach (process_info
*proc
) override
;
98 void mourn (process_info
*proc
) override
;
100 void join (int pid
) override
;
102 bool thread_alive (ptid_t pid
) override
;
104 void resume (thread_resume
*resume_info
, size_t n
) override
;
106 ptid_t
wait (ptid_t ptid
, target_waitstatus
*status
,
107 int options
) override
;
109 void fetch_registers (regcache
*regcache
, int regno
) override
;
111 void store_registers (regcache
*regcache
, int regno
) override
;
113 int read_memory (CORE_ADDR memaddr
, unsigned char *myaddr
,
116 int write_memory (CORE_ADDR memaddr
, const unsigned char *myaddr
,
119 void request_interrupt () override
;
121 bool supports_z_point_type (char z_type
) override
;
123 int insert_point (enum raw_bkpt_type type
, CORE_ADDR addr
,
124 int size
, raw_breakpoint
*bp
) override
;
126 int remove_point (enum raw_bkpt_type type
, CORE_ADDR addr
,
127 int size
, raw_breakpoint
*bp
) override
;
129 bool supports_hardware_single_step () override
;
131 bool stopped_by_watchpoint () override
;
133 CORE_ADDR
stopped_data_address () override
;
136 void hostio_last_error (char *buf
) override
;
139 bool supports_qxfer_siginfo () override
;
141 int qxfer_siginfo (const char *annex
, unsigned char *readbuf
,
142 unsigned const char *writebuf
,
143 CORE_ADDR offset
, int len
) override
;
145 bool supports_get_tib_address () override
;
147 int get_tib_address (ptid_t ptid
, CORE_ADDR
*addr
) override
;
149 const gdb_byte
*sw_breakpoint_from_kind (int kind
, int *size
) override
;
151 CORE_ADDR
read_pc (regcache
*regcache
) override
;
153 void write_pc (regcache
*regcache
, CORE_ADDR pc
) override
;
156 /* Retrieve the context for this thread, if not already retrieved. */
157 extern void win32_require_context (windows_nat::windows_thread_info
*th
);
159 /* Map the Windows error number in ERROR to a locale-dependent error
160 message string and return a pointer to it. Typically, the values
161 for ERROR come from GetLastError.
163 The string pointed to shall not be modified by the application,
164 but may be overwritten by a subsequent call to strwinerror
166 The strwinerror function does not change the current setting
168 extern char * strwinerror (DWORD error
);
170 /* in wincecompat.c */
172 extern void to_back_slashes (char *);
174 #endif /* GDBSERVER_WIN32_LOW_H */