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. */
43 /* Start a new process.
45 PROGRAM is a path to the program to execute.
46 ARGS is a standard NULL-terminated array of arguments,
47 to be passed to the inferior as ``argv''.
49 Returns the new PID on success, -1 on failure. Registers the new
50 process with the process list. */
52 int (*create_inferior) (char *program, char **args);
54 /* Attach to a running process.
56 PID is the process ID to attach to, specified by the user
59 Returns -1 if attaching is unsupported, 0 on success, and calls
62 int (*attach) (unsigned long pid);
64 /* Kill all inferiors. */
68 /* Detach from all inferiors.
69 Return -1 on failure, and 0 on success. */
73 /* Wait for inferiors to end. */
77 /* Return 1 iff the thread with process ID PID is alive. */
79 int (*thread_alive) (unsigned long pid);
81 /* Resume the inferior process. */
83 void (*resume) (struct thread_resume *resume_info, size_t n);
85 /* Wait for the inferior process to change state.
87 STATUS will be filled in with a response code to send to GDB.
89 Returns the signal which caused the process to stop, in the
90 remote protocol numbering (e.g. TARGET_SIGNAL_STOP), or the
91 exit code as an integer if *STATUS is 'W'. */
93 unsigned char (*wait) (char *status);
95 /* Fetch registers from the inferior process.
97 If REGNO is -1, fetch all registers; otherwise, fetch at least REGNO. */
99 void (*fetch_registers) (int regno);
101 /* Store registers to the inferior process.
103 If REGNO is -1, store all registers; otherwise, store at least REGNO. */
105 void (*store_registers) (int regno);
107 /* Read memory from the inferior process. This should generally be
108 called through read_inferior_memory, which handles breakpoint shadowing.
110 Read LEN bytes at MEMADDR into a buffer at MYADDR.
112 Returns 0 on success and errno on failure. */
114 int (*read_memory) (CORE_ADDR memaddr, unsigned char *myaddr, int len);
116 /* Write memory to the inferior process. This should generally be
117 called through write_inferior_memory, which handles breakpoint shadowing.
119 Write LEN bytes from the buffer at MYADDR to MEMADDR.
121 Returns 0 on success and errno on failure. */
123 int (*write_memory) (CORE_ADDR memaddr, const unsigned char *myaddr,
126 /* Query GDB for the values of any symbols we're interested in.
127 This function is called whenever we receive a "qSymbols::"
128 query, which corresponds to every time more symbols (might)
129 become available. NULL if we aren't interested in any
132 void (*look_up_symbols) (void);
134 /* Send an interrupt request to the inferior process,
135 however is appropriate. */
137 void (*request_interrupt) (void);
139 /* Read auxiliary vector data from the inferior process.
141 Read LEN bytes at OFFSET into a buffer at MYADDR. */
143 int (*read_auxv) (CORE_ADDR offset, unsigned char *myaddr,
146 /* Insert and remove a hardware watchpoint.
147 Returns 0 on success, -1 on failure and 1 on unsupported.
148 The type is coded as follows:
151 4 = access watchpoint
154 int (*insert_watchpoint) (char type, CORE_ADDR addr, int len);
155 int (*remove_watchpoint) (char type, CORE_ADDR addr, int len);
157 /* Returns 1 if target was stopped due to a watchpoint hit, 0 otherwise. */
159 int (*stopped_by_watchpoint) (void);
161 /* Returns the address associated with the watchpoint that hit, if any;
162 returns 0 otherwise. */
164 CORE_ADDR (*stopped_data_address) (void);
166 /* Reports the text, data offsets of the executable. This is
167 needed for uclinux where the executable is relocated during load
170 int (*read_offsets) (CORE_ADDR *text, CORE_ADDR *data);
172 /* Fetch the address associated with a specific thread local storage
173 area, determined by the specified THREAD, OFFSET, and LOAD_MODULE.
174 Stores it in *ADDRESS and returns zero on success; otherwise returns
175 an error code. A return value of -1 means this system does not
176 support the operation. */
178 int (*get_tls_address) (struct thread_info *thread, CORE_ADDR offset,
179 CORE_ADDR load_module, CORE_ADDR *address);
181 /* Read/Write from/to spufs using qXfer packets. */
182 int (*qxfer_spu) (const char *annex, unsigned char *readbuf,
183 unsigned const char *writebuf, CORE_ADDR offset, int len);
185 /* Fill BUF with an hostio error packet representing the last hostio
187 void (*hostio_last_error) (char *buf);
189 /* Read/Write OS data using qXfer packets. */
190 int (*qxfer_osdata) (const char *annex, unsigned char *readbuf,
191 unsigned const char *writebuf, CORE_ADDR offset,
194 /* Read/Write extra signal info. */
195 int (*qxfer_siginfo) (const char *annex, unsigned char *readbuf,
196 unsigned const char *writebuf,
197 CORE_ADDR offset, int len);
200 extern struct target_ops *the_target;
202 void set_target_ops (struct target_ops *);
204 #define create_inferior(program, args) \
205 (*the_target->create_inferior) (program, args)
207 #define myattach(pid) \
208 (*the_target->attach) (pid)
210 #define kill_inferior() \
211 (*the_target->kill) ()
213 #define detach_inferior() \
214 (*the_target->detach) ()
216 #define mythread_alive(pid) \
217 (*the_target->thread_alive) (pid)
219 #define fetch_inferior_registers(regno) \
220 (*the_target->fetch_registers) (regno)
222 #define store_inferior_registers(regno) \
223 (*the_target->store_registers) (regno)
225 #define join_inferior() \
226 (*the_target->join) ()
228 unsigned char mywait (char *statusp, int connected_wait);
230 int read_inferior_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len);
232 int write_inferior_memory (CORE_ADDR memaddr, const unsigned char *myaddr,
235 void set_desired_inferior (int id);
237 #endif /* TARGET_H */