Commit | Line | Data |
---|---|---|
ce3a066d DJ |
1 | /* Target operations for the remote server for GDB. |
2 | Copyright 2002 | |
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 | |
21 | Foundation, Inc., 59 Temple Place - Suite 330, | |
22 | Boston, MA 02111-1307, USA. */ | |
23 | ||
24 | #ifndef TARGET_H | |
25 | #define TARGET_H | |
26 | ||
27 | struct target_ops | |
28 | { | |
29 | /* Start a new process. | |
30 | ||
31 | PROGRAM is a path to the program to execute. | |
32 | ARGS is a standard NULL-terminated array of arguments, | |
33 | to be passed to the inferior as ``argv''. | |
34 | ||
a9fa9f7d | 35 | Returns the new PID on success, -1 on failure. Registers the new |
ce3a066d DJ |
36 | process with the process list. */ |
37 | ||
38 | int (*create_inferior) (char *program, char **args); | |
39 | ||
40 | /* Attach to a running process. | |
41 | ||
42 | PID is the process ID to attach to, specified by the user | |
43 | or a higher layer. */ | |
44 | ||
45 | int (*attach) (int pid); | |
46 | ||
47 | /* Kill all inferiors. */ | |
48 | ||
49 | void (*kill) (void); | |
50 | ||
6ad8ae5c DJ |
51 | /* Detach from all inferiors. */ |
52 | ||
53 | void (*detach) (void); | |
54 | ||
ce3a066d DJ |
55 | /* Return 1 iff the thread with process ID PID is alive. */ |
56 | ||
57 | int (*thread_alive) (int pid); | |
58 | ||
59 | /* Resume the inferior process. | |
60 | ||
61 | If STEP is non-zero, we want to single-step. | |
62 | ||
63 | If SIGNAL is nonzero, send the process that signal as we resume it. | |
64 | */ | |
65 | ||
66 | void (*resume) (int step, int signo); | |
67 | ||
68 | /* Wait for the inferior process to change state. | |
69 | ||
70 | STATUSP will be filled in with a response code to send to GDB. | |
71 | ||
72 | Returns the signal which caused the process to stop. */ | |
73 | ||
74 | unsigned char (*wait) (char *status); | |
75 | ||
76 | /* Fetch registers from the inferior process. | |
77 | ||
78 | If REGNO is -1, fetch all registers; otherwise, fetch at least REGNO. */ | |
79 | ||
80 | void (*fetch_registers) (int regno); | |
81 | ||
82 | /* Store registers to the inferior process. | |
83 | ||
84 | If REGNO is -1, store all registers; otherwise, store at least REGNO. */ | |
85 | ||
86 | void (*store_registers) (int regno); | |
87 | ||
611cb4a5 DJ |
88 | /* Read memory from the inferior process. This should generally be |
89 | called through read_inferior_memory, which handles breakpoint shadowing. | |
ce3a066d DJ |
90 | |
91 | Read LEN bytes at MEMADDR into a buffer at MYADDR. */ | |
92 | ||
93 | void (*read_memory) (CORE_ADDR memaddr, char *myaddr, int len); | |
94 | ||
611cb4a5 DJ |
95 | /* Write memory to the inferior process. This should generally be |
96 | called through write_inferior_memory, which handles breakpoint shadowing. | |
ce3a066d DJ |
97 | |
98 | Write LEN bytes from the buffer at MYADDR to MEMADDR. | |
99 | ||
100 | Returns 0 on success and errno on failure. */ | |
101 | ||
611cb4a5 | 102 | int (*write_memory) (CORE_ADDR memaddr, const char *myaddr, int len); |
2f2893d9 DJ |
103 | |
104 | /* Query GDB for the values of any symbols we're interested in. | |
105 | This function is called whenever we receive a "qSymbols::" | |
106 | query, which corresponds to every time more symbols (might) | |
611cb4a5 DJ |
107 | become available. NULL if we aren't interested in any |
108 | symbols. */ | |
2f2893d9 DJ |
109 | |
110 | void (*look_up_symbols) (void); | |
e5379b03 DJ |
111 | |
112 | /* Send a signal to the inferior process, however is appropriate. */ | |
113 | void (*send_signal) (int); | |
ce3a066d DJ |
114 | }; |
115 | ||
116 | extern struct target_ops *the_target; | |
117 | ||
118 | void set_target_ops (struct target_ops *); | |
119 | ||
120 | #define create_inferior(program, args) \ | |
121 | (*the_target->create_inferior) (program, args) | |
122 | ||
123 | #define myattach(pid) \ | |
124 | (*the_target->attach) (pid) | |
125 | ||
126 | #define kill_inferior() \ | |
127 | (*the_target->kill) () | |
128 | ||
6ad8ae5c DJ |
129 | #define detach_inferior() \ |
130 | (*the_target->detach) () | |
131 | ||
ce3a066d DJ |
132 | #define mythread_alive(pid) \ |
133 | (*the_target->thread_alive) (pid) | |
134 | ||
135 | #define myresume(step,signo) \ | |
136 | (*the_target->resume) (step, signo) | |
137 | ||
ce3a066d DJ |
138 | #define fetch_inferior_registers(regno) \ |
139 | (*the_target->fetch_registers) (regno) | |
140 | ||
141 | #define store_inferior_registers(regno) \ | |
142 | (*the_target->store_registers) (regno) | |
143 | ||
0d62e5e8 DJ |
144 | unsigned char mywait (char *statusp, int connected_wait); |
145 | ||
611cb4a5 | 146 | void read_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len); |
ce3a066d | 147 | |
0d62e5e8 DJ |
148 | int write_inferior_memory (CORE_ADDR memaddr, const char *myaddr, int len); |
149 | ||
150 | void set_desired_inferior (int id); | |
ce3a066d DJ |
151 | |
152 | #endif /* TARGET_H */ |