1 /* Target operations for the remote server for GDB.
2 Copyright (C) 2002, 2003, 2004, 2005
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 2 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, write to the Free Software
21 Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 Boston, MA 02110-1301, USA. */
27 /* This structure describes how to resume a particular thread (or
28 all threads) based on the client's request. If thread is -1, then
29 this entry applies to all threads. These are generally passed around
30 as an array, and terminated by a thread == -1 entry. */
36 /* If non-zero, leave this thread stopped. */
39 /* If non-zero, we want to single-step. */
42 /* If non-zero, send this signal when we resume. */
48 /* Start a new process.
50 PROGRAM is a path to the program to execute.
51 ARGS is a standard NULL-terminated array of arguments,
52 to be passed to the inferior as ``argv''.
54 Returns the new PID on success, -1 on failure. Registers the new
55 process with the process list. */
57 int (*create_inferior) (char *program, char **args);
59 /* Attach to a running process.
61 PID is the process ID to attach to, specified by the user
64 int (*attach) (unsigned long pid);
66 /* Kill all inferiors. */
70 /* Detach from all inferiors. */
72 void (*detach) (void);
74 /* Return 1 iff the thread with process ID PID is alive. */
76 int (*thread_alive) (unsigned long pid);
78 /* Resume the inferior process. */
80 void (*resume) (struct thread_resume *resume_info);
82 /* Wait for the inferior process to change state.
84 STATUS will be filled in with a response code to send to GDB.
86 Returns the signal which caused the process to stop, in the
87 remote protocol numbering (e.g. TARGET_SIGNAL_STOP), or the
88 exit code as an integer if *STATUS is 'W'. */
90 unsigned char (*wait) (char *status);
92 /* Fetch registers from the inferior process.
94 If REGNO is -1, fetch all registers; otherwise, fetch at least REGNO. */
96 void (*fetch_registers) (int regno);
98 /* Store registers to the inferior process.
100 If REGNO is -1, store all registers; otherwise, store at least REGNO. */
102 void (*store_registers) (int regno);
104 /* Read memory from the inferior process. This should generally be
105 called through read_inferior_memory, which handles breakpoint shadowing.
107 Read LEN bytes at MEMADDR into a buffer at MYADDR.
109 Returns 0 on success and errno on failure. */
111 int (*read_memory) (CORE_ADDR memaddr, unsigned char *myaddr, int len);
113 /* Write memory to the inferior process. This should generally be
114 called through write_inferior_memory, which handles breakpoint shadowing.
116 Write LEN bytes from the buffer at MYADDR to MEMADDR.
118 Returns 0 on success and errno on failure. */
120 int (*write_memory) (CORE_ADDR memaddr, const unsigned char *myaddr,
123 /* Query GDB for the values of any symbols we're interested in.
124 This function is called whenever we receive a "qSymbols::"
125 query, which corresponds to every time more symbols (might)
126 become available. NULL if we aren't interested in any
129 void (*look_up_symbols) (void);
131 /* Send a signal to the inferior process, however is appropriate. */
132 void (*send_signal) (int);
134 /* Read auxiliary vector data from the inferior process.
136 Read LEN bytes at OFFSET into a buffer at MYADDR. */
138 int (*read_auxv) (CORE_ADDR offset, unsigned char *myaddr,
141 /* Insert and remove a hardware watchpoint.
142 Returns 0 on success, -1 on failure and 1 on unsupported.
143 The type is coded as follows:
146 4 = access watchpoint
149 int (*insert_watchpoint) (char type, CORE_ADDR addr, int len);
150 int (*remove_watchpoint) (char type, CORE_ADDR addr, int len);
152 /* Returns 1 if target was stopped due to a watchpoint hit, 0 otherwise. */
154 int (*stopped_by_watchpoint) (void);
156 /* Returns the address associated with the watchpoint that hit, if any;
157 returns 0 otherwise. */
159 CORE_ADDR (*stopped_data_address) (void);
161 /* Reports the text, data offsets of the executable. This is
162 needed for uclinux where the executable is relocated during load
165 int (*read_offsets) (CORE_ADDR *text, CORE_ADDR *data);
168 extern struct target_ops *the_target;
170 void set_target_ops (struct target_ops *);
172 #define create_inferior(program, args) \
173 (*the_target->create_inferior) (program, args)
175 #define myattach(pid) \
176 (*the_target->attach) (pid)
178 #define kill_inferior() \
179 (*the_target->kill) ()
181 #define detach_inferior() \
182 (*the_target->detach) ()
184 #define mythread_alive(pid) \
185 (*the_target->thread_alive) (pid)
187 #define fetch_inferior_registers(regno) \
188 (*the_target->fetch_registers) (regno)
190 #define store_inferior_registers(regno) \
191 (*the_target->store_registers) (regno)
193 unsigned char mywait (char *statusp, int connected_wait);
195 int read_inferior_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len);
197 int write_inferior_memory (CORE_ADDR memaddr, const unsigned char *myaddr,
200 void set_desired_inferior (int id);
202 #endif /* TARGET_H */