Commit | Line | Data |
---|---|---|
ce3a066d | 1 | /* Target operations for the remote server for GDB. |
6f0f660e | 2 | Copyright (C) 2002, 2003, 2004, 2005 |
ce3a066d DJ |
3 | Free Software Foundation, Inc. |
4 | ||
5 | Contributed by MontaVista Software. | |
6 | ||
7 | This file is part of GDB. | |
8 | ||
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. | |
13 | ||
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. | |
18 | ||
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 | |
6f0f660e EZ |
21 | Foundation, Inc., 51 Franklin Street, Fifth Floor, |
22 | Boston, MA 02110-1301, USA. */ | |
ce3a066d DJ |
23 | |
24 | #ifndef TARGET_H | |
25 | #define TARGET_H | |
26 | ||
64386c31 DJ |
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. */ | |
31 | ||
32 | struct thread_resume | |
33 | { | |
a1928bad | 34 | unsigned long thread; |
64386c31 DJ |
35 | |
36 | /* If non-zero, leave this thread stopped. */ | |
37 | int leave_stopped; | |
38 | ||
39 | /* If non-zero, we want to single-step. */ | |
40 | int step; | |
41 | ||
42 | /* If non-zero, send this signal when we resume. */ | |
43 | int sig; | |
44 | }; | |
45 | ||
ce3a066d DJ |
46 | struct target_ops |
47 | { | |
48 | /* Start a new process. | |
49 | ||
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''. | |
53 | ||
a9fa9f7d | 54 | Returns the new PID on success, -1 on failure. Registers the new |
ce3a066d DJ |
55 | process with the process list. */ |
56 | ||
57 | int (*create_inferior) (char *program, char **args); | |
58 | ||
59 | /* Attach to a running process. | |
60 | ||
61 | PID is the process ID to attach to, specified by the user | |
62 | or a higher layer. */ | |
63 | ||
a1928bad | 64 | int (*attach) (unsigned long pid); |
ce3a066d DJ |
65 | |
66 | /* Kill all inferiors. */ | |
67 | ||
68 | void (*kill) (void); | |
69 | ||
6ad8ae5c DJ |
70 | /* Detach from all inferiors. */ |
71 | ||
72 | void (*detach) (void); | |
73 | ||
ce3a066d DJ |
74 | /* Return 1 iff the thread with process ID PID is alive. */ |
75 | ||
a1928bad | 76 | int (*thread_alive) (unsigned long pid); |
ce3a066d | 77 | |
64386c31 | 78 | /* Resume the inferior process. */ |
ce3a066d | 79 | |
64386c31 | 80 | void (*resume) (struct thread_resume *resume_info); |
ce3a066d DJ |
81 | |
82 | /* Wait for the inferior process to change state. | |
83 | ||
b80864fb | 84 | STATUS will be filled in with a response code to send to GDB. |
ce3a066d | 85 | |
b80864fb DJ |
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'. */ | |
ce3a066d DJ |
89 | |
90 | unsigned char (*wait) (char *status); | |
91 | ||
92 | /* Fetch registers from the inferior process. | |
93 | ||
94 | If REGNO is -1, fetch all registers; otherwise, fetch at least REGNO. */ | |
95 | ||
96 | void (*fetch_registers) (int regno); | |
aa691b87 | 97 | |
ce3a066d DJ |
98 | /* Store registers to the inferior process. |
99 | ||
100 | If REGNO is -1, store all registers; otherwise, store at least REGNO. */ | |
101 | ||
102 | void (*store_registers) (int regno); | |
103 | ||
611cb4a5 DJ |
104 | /* Read memory from the inferior process. This should generally be |
105 | called through read_inferior_memory, which handles breakpoint shadowing. | |
ce3a066d | 106 | |
c3e735a6 DJ |
107 | Read LEN bytes at MEMADDR into a buffer at MYADDR. |
108 | ||
109 | Returns 0 on success and errno on failure. */ | |
ce3a066d | 110 | |
f450004a | 111 | int (*read_memory) (CORE_ADDR memaddr, unsigned char *myaddr, int len); |
ce3a066d | 112 | |
611cb4a5 DJ |
113 | /* Write memory to the inferior process. This should generally be |
114 | called through write_inferior_memory, which handles breakpoint shadowing. | |
ce3a066d DJ |
115 | |
116 | Write LEN bytes from the buffer at MYADDR to MEMADDR. | |
117 | ||
118 | Returns 0 on success and errno on failure. */ | |
119 | ||
f450004a DJ |
120 | int (*write_memory) (CORE_ADDR memaddr, const unsigned char *myaddr, |
121 | int len); | |
2f2893d9 DJ |
122 | |
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) | |
611cb4a5 DJ |
126 | become available. NULL if we aren't interested in any |
127 | symbols. */ | |
2f2893d9 DJ |
128 | |
129 | void (*look_up_symbols) (void); | |
e5379b03 DJ |
130 | |
131 | /* Send a signal to the inferior process, however is appropriate. */ | |
132 | void (*send_signal) (int); | |
aa691b87 RM |
133 | |
134 | /* Read auxiliary vector data from the inferior process. | |
135 | ||
136 | Read LEN bytes at OFFSET into a buffer at MYADDR. */ | |
137 | ||
f450004a DJ |
138 | int (*read_auxv) (CORE_ADDR offset, unsigned char *myaddr, |
139 | unsigned int len); | |
e013ee27 OF |
140 | |
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: | |
144 | 2 = write watchpoint | |
145 | 3 = read watchpoint | |
146 | 4 = access watchpoint | |
147 | */ | |
148 | ||
149 | int (*insert_watchpoint) (char type, CORE_ADDR addr, int len); | |
150 | int (*remove_watchpoint) (char type, CORE_ADDR addr, int len); | |
151 | ||
152 | /* Returns 1 if target was stopped due to a watchpoint hit, 0 otherwise. */ | |
153 | ||
154 | int (*stopped_by_watchpoint) (void); | |
155 | ||
156 | /* Returns the address associated with the watchpoint that hit, if any; | |
157 | returns 0 otherwise. */ | |
158 | ||
159 | CORE_ADDR (*stopped_data_address) (void); | |
160 | ||
52fb6437 NS |
161 | /* Reports the text, data offsets of the executable. This is |
162 | needed for uclinux where the executable is relocated during load | |
163 | time. */ | |
164 | ||
165 | int (*read_offsets) (CORE_ADDR *text, CORE_ADDR *data); | |
dae5f5cf DJ |
166 | |
167 | /* Fetch the address associated with a specific thread local storage | |
168 | area, determined by the specified THREAD, OFFSET, and LOAD_MODULE. | |
169 | Stores it in *ADDRESS and returns zero on success; otherwise returns | |
170 | an error code. A return value of -1 means this system does not | |
171 | support the operation. */ | |
172 | ||
173 | int (*get_tls_address) (struct thread_info *thread, CORE_ADDR offset, | |
174 | CORE_ADDR load_module, CORE_ADDR *address); | |
ce3a066d DJ |
175 | }; |
176 | ||
177 | extern struct target_ops *the_target; | |
178 | ||
179 | void set_target_ops (struct target_ops *); | |
180 | ||
181 | #define create_inferior(program, args) \ | |
182 | (*the_target->create_inferior) (program, args) | |
183 | ||
184 | #define myattach(pid) \ | |
185 | (*the_target->attach) (pid) | |
186 | ||
187 | #define kill_inferior() \ | |
188 | (*the_target->kill) () | |
189 | ||
6ad8ae5c DJ |
190 | #define detach_inferior() \ |
191 | (*the_target->detach) () | |
192 | ||
ce3a066d DJ |
193 | #define mythread_alive(pid) \ |
194 | (*the_target->thread_alive) (pid) | |
195 | ||
ce3a066d DJ |
196 | #define fetch_inferior_registers(regno) \ |
197 | (*the_target->fetch_registers) (regno) | |
198 | ||
199 | #define store_inferior_registers(regno) \ | |
200 | (*the_target->store_registers) (regno) | |
201 | ||
0d62e5e8 DJ |
202 | unsigned char mywait (char *statusp, int connected_wait); |
203 | ||
f450004a | 204 | int read_inferior_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len); |
ce3a066d | 205 | |
f450004a DJ |
206 | int write_inferior_memory (CORE_ADDR memaddr, const unsigned char *myaddr, |
207 | int len); | |
0d62e5e8 DJ |
208 | |
209 | void set_desired_inferior (int id); | |
ce3a066d DJ |
210 | |
211 | #endif /* TARGET_H */ |