1 /* Target operations for the remote server for GDB.
2 Copyright (C) 2002, 2003, 2004, 2005, 2007, 2008, 2009
3 Free Software Foundation, Inc.
5 Contributed by MontaVista Software.
7 This file is part of GDB.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
25 /* This structure describes how to resume a particular thread (or all
26 threads) based on the client's request. If thread is -1, then this
27 entry applies to all threads. These are passed around as an
34 /* If non-zero, we want to single-step. */
37 /* If non-zero, send this signal when we resume. */
41 /* Generally, what has the program done? */
44 /* The program has exited. The exit status is in
46 TARGET_WAITKIND_EXITED,
48 /* The program has stopped with a signal. Which signal is in
50 TARGET_WAITKIND_STOPPED,
52 /* The program has terminated with a signal. Which signal is in
54 TARGET_WAITKIND_SIGNALLED,
56 /* The program is letting us know that it dynamically loaded
58 TARGET_WAITKIND_LOADED,
60 /* The program has exec'ed a new executable file. The new file's
61 pathname is pointed to by value.execd_pathname. */
62 TARGET_WAITKIND_EXECD,
64 /* Nothing of interest to GDB happened, but we stopped anyway. */
65 TARGET_WAITKIND_SPURIOUS,
67 /* An event has occurred, but we should wait again. In this case,
68 we want to go back to the event loop and wait there for another
69 event from the inferior. */
70 TARGET_WAITKIND_IGNORE
73 struct target_waitstatus
75 enum target_waitkind kind;
77 /* Forked child pid, execd pathname, exit status or signal number. */
81 enum target_signal sig;
82 unsigned long related_pid;
90 /* Start a new process.
92 PROGRAM is a path to the program to execute.
93 ARGS is a standard NULL-terminated array of arguments,
94 to be passed to the inferior as ``argv''.
96 Returns the new PID on success, -1 on failure. Registers the new
97 process with the process list. */
99 int (*create_inferior) (char *program, char **args);
101 /* Attach to a running process.
103 PID is the process ID to attach to, specified by the user
106 Returns -1 if attaching is unsupported, 0 on success, and calls
107 error() otherwise. */
109 int (*attach) (unsigned long pid);
111 /* Kill all inferiors. */
115 /* Detach from all inferiors.
116 Return -1 on failure, and 0 on success. */
118 int (*detach) (void);
120 /* Wait for inferiors to end. */
124 /* Return 1 iff the thread with process ID PID is alive. */
126 int (*thread_alive) (unsigned long pid);
128 /* Resume the inferior process. */
130 void (*resume) (struct thread_resume *resume_info, size_t n);
132 /* Wait for the inferior process or thread to change state. Store
133 status through argument pointer STATUS. */
135 unsigned long (*wait) (struct target_waitstatus *status);
137 /* Fetch registers from the inferior process.
139 If REGNO is -1, fetch all registers; otherwise, fetch at least REGNO. */
141 void (*fetch_registers) (int regno);
143 /* Store registers to the inferior process.
145 If REGNO is -1, store all registers; otherwise, store at least REGNO. */
147 void (*store_registers) (int regno);
149 /* Read memory from the inferior process. This should generally be
150 called through read_inferior_memory, which handles breakpoint shadowing.
152 Read LEN bytes at MEMADDR into a buffer at MYADDR.
154 Returns 0 on success and errno on failure. */
156 int (*read_memory) (CORE_ADDR memaddr, unsigned char *myaddr, int len);
158 /* Write memory to the inferior process. This should generally be
159 called through write_inferior_memory, which handles breakpoint shadowing.
161 Write LEN bytes from the buffer at MYADDR to MEMADDR.
163 Returns 0 on success and errno on failure. */
165 int (*write_memory) (CORE_ADDR memaddr, const unsigned char *myaddr,
168 /* Query GDB for the values of any symbols we're interested in.
169 This function is called whenever we receive a "qSymbols::"
170 query, which corresponds to every time more symbols (might)
171 become available. NULL if we aren't interested in any
174 void (*look_up_symbols) (void);
176 /* Send an interrupt request to the inferior process,
177 however is appropriate. */
179 void (*request_interrupt) (void);
181 /* Read auxiliary vector data from the inferior process.
183 Read LEN bytes at OFFSET into a buffer at MYADDR. */
185 int (*read_auxv) (CORE_ADDR offset, unsigned char *myaddr,
188 /* Insert and remove a hardware watchpoint.
189 Returns 0 on success, -1 on failure and 1 on unsupported.
190 The type is coded as follows:
193 4 = access watchpoint
196 int (*insert_watchpoint) (char type, CORE_ADDR addr, int len);
197 int (*remove_watchpoint) (char type, CORE_ADDR addr, int len);
199 /* Returns 1 if target was stopped due to a watchpoint hit, 0 otherwise. */
201 int (*stopped_by_watchpoint) (void);
203 /* Returns the address associated with the watchpoint that hit, if any;
204 returns 0 otherwise. */
206 CORE_ADDR (*stopped_data_address) (void);
208 /* Reports the text, data offsets of the executable. This is
209 needed for uclinux where the executable is relocated during load
212 int (*read_offsets) (CORE_ADDR *text, CORE_ADDR *data);
214 /* Fetch the address associated with a specific thread local storage
215 area, determined by the specified THREAD, OFFSET, and LOAD_MODULE.
216 Stores it in *ADDRESS and returns zero on success; otherwise returns
217 an error code. A return value of -1 means this system does not
218 support the operation. */
220 int (*get_tls_address) (struct thread_info *thread, CORE_ADDR offset,
221 CORE_ADDR load_module, CORE_ADDR *address);
223 /* Read/Write from/to spufs using qXfer packets. */
224 int (*qxfer_spu) (const char *annex, unsigned char *readbuf,
225 unsigned const char *writebuf, CORE_ADDR offset, int len);
227 /* Fill BUF with an hostio error packet representing the last hostio
229 void (*hostio_last_error) (char *buf);
231 /* Read/Write OS data using qXfer packets. */
232 int (*qxfer_osdata) (const char *annex, unsigned char *readbuf,
233 unsigned const char *writebuf, CORE_ADDR offset,
236 /* Read/Write extra signal info. */
237 int (*qxfer_siginfo) (const char *annex, unsigned char *readbuf,
238 unsigned const char *writebuf,
239 CORE_ADDR offset, int len);
242 extern struct target_ops *the_target;
244 void set_target_ops (struct target_ops *);
246 #define create_inferior(program, args) \
247 (*the_target->create_inferior) (program, args)
249 #define myattach(pid) \
250 (*the_target->attach) (pid)
252 #define kill_inferior() \
253 (*the_target->kill) ()
255 #define detach_inferior() \
256 (*the_target->detach) ()
258 #define mythread_alive(pid) \
259 (*the_target->thread_alive) (pid)
261 #define fetch_inferior_registers(regno) \
262 (*the_target->fetch_registers) (regno)
264 #define store_inferior_registers(regno) \
265 (*the_target->store_registers) (regno)
267 #define join_inferior() \
268 (*the_target->join) ()
270 unsigned long mywait (struct target_waitstatus *ourstatus, int connected_wait);
272 int read_inferior_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len);
274 int write_inferior_memory (CORE_ADDR memaddr, const unsigned char *myaddr,
277 void set_desired_inferior (int id);
279 #endif /* TARGET_H */