Commit | Line | Data |
---|---|---|
5bf970f9 AC |
1 | /* Default child (native) target interface, for GDB when running under |
2 | Unix. | |
3 | ||
197e01b6 | 4 | Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, |
ee057212 | 5 | 1998, 1999, 2000, 2001, 2002, 2004, 2005 Free Software Foundation, Inc. |
5bf970f9 AC |
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 | |
197e01b6 EZ |
21 | Foundation, Inc., 51 Franklin Street, Fifth Floor, |
22 | Boston, MA 02110-1301, USA. */ | |
5bf970f9 AC |
23 | |
24 | #include "defs.h" | |
25 | #include "regcache.h" | |
26 | #include "memattr.h" | |
27 | #include "symtab.h" | |
28 | #include "target.h" | |
29 | #include "inferior.h" | |
7681f339 | 30 | #include "gdb_string.h" |
5bf970f9 AC |
31 | |
32 | /* Fetch register REGNUM from the inferior. If REGNUM is -1, do this | |
33 | for all registers. */ | |
34 | ||
35 | static void | |
36 | inf_child_fetch_inferior_registers (int regnum) | |
37 | { | |
38 | if (regnum == -1) | |
39 | { | |
40 | for (regnum = 0; regnum < NUM_REGS; regnum++) | |
41 | regcache_raw_supply (current_regcache, regnum, NULL); | |
42 | } | |
43 | else | |
44 | regcache_raw_supply (current_regcache, regnum, NULL); | |
45 | } | |
46 | ||
47 | /* Store register REGNUM back into the inferior. If REGNUM is -1, do | |
48 | this for all registers (including the floating point registers). */ | |
49 | ||
50 | static void | |
51 | inf_child_store_inferior_registers (int regnum) | |
52 | { | |
53 | } | |
54 | ||
5bf970f9 AC |
55 | static void |
56 | inf_child_post_attach (int pid) | |
57 | { | |
58 | /* This version of Unix doesn't require a meaningful "post attach" | |
59 | operation by a debugger. */ | |
60 | } | |
61 | ||
62 | /* Get ready to modify the registers array. On machines which store | |
63 | individual registers, this doesn't need to do anything. On | |
64 | machines which store all the registers in one fell swoop, this | |
65 | makes sure that registers contains all the registers from the | |
66 | program being debugged. */ | |
67 | ||
68 | static void | |
69 | inf_child_prepare_to_store (void) | |
70 | { | |
71 | } | |
72 | ||
73 | static void | |
74 | inf_child_open (char *arg, int from_tty) | |
75 | { | |
8a3fe4f8 | 76 | error (_("Use the \"run\" command to start a Unix child process.")); |
5bf970f9 AC |
77 | } |
78 | ||
79 | static void | |
80 | inf_child_post_startup_inferior (ptid_t ptid) | |
81 | { | |
82 | /* This version of Unix doesn't require a meaningful "post startup | |
83 | inferior" operation by a debugger. */ | |
84 | } | |
85 | ||
86 | static void | |
87 | inf_child_acknowledge_created_inferior (int pid) | |
88 | { | |
89 | /* This version of Unix doesn't require a meaningful "acknowledge | |
90 | created inferior" operation by a debugger. */ | |
91 | } | |
92 | ||
fa113d1a | 93 | static void |
5bf970f9 AC |
94 | inf_child_insert_fork_catchpoint (int pid) |
95 | { | |
96 | /* This version of Unix doesn't support notification of fork | |
97 | events. */ | |
5bf970f9 AC |
98 | } |
99 | ||
100 | static int | |
101 | inf_child_remove_fork_catchpoint (int pid) | |
102 | { | |
103 | /* This version of Unix doesn't support notification of fork | |
104 | events. */ | |
105 | return 0; | |
106 | } | |
107 | ||
fa113d1a | 108 | static void |
5bf970f9 AC |
109 | inf_child_insert_vfork_catchpoint (int pid) |
110 | { | |
111 | /* This version of Unix doesn't support notification of vfork | |
112 | events. */ | |
5bf970f9 AC |
113 | } |
114 | ||
115 | static int | |
116 | inf_child_remove_vfork_catchpoint (int pid) | |
117 | { | |
118 | /* This version of Unix doesn't support notification of vfork | |
119 | events. */ | |
120 | return 0; | |
121 | } | |
122 | ||
123 | static int | |
ee057212 | 124 | inf_child_follow_fork (struct target_ops *ops, int follow_child) |
5bf970f9 AC |
125 | { |
126 | /* This version of Unix doesn't support following fork or vfork | |
127 | events. */ | |
128 | return 0; | |
129 | } | |
130 | ||
fa113d1a | 131 | static void |
5bf970f9 AC |
132 | inf_child_insert_exec_catchpoint (int pid) |
133 | { | |
134 | /* This version of Unix doesn't support notification of exec | |
135 | events. */ | |
5bf970f9 AC |
136 | } |
137 | ||
138 | static int | |
139 | inf_child_remove_exec_catchpoint (int pid) | |
140 | { | |
141 | /* This version of Unix doesn't support notification of exec | |
142 | events. */ | |
143 | return 0; | |
144 | } | |
145 | ||
146 | static int | |
147 | inf_child_reported_exec_events_per_exec_call (void) | |
148 | { | |
149 | /* This version of Unix doesn't support notification of exec | |
150 | events. */ | |
151 | return 1; | |
152 | } | |
153 | ||
154 | static int | |
155 | inf_child_can_run (void) | |
156 | { | |
157 | return 1; | |
158 | } | |
159 | ||
160 | static struct symtab_and_line * | |
161 | inf_child_enable_exception_callback (enum exception_event_kind kind, | |
162 | int enable) | |
163 | { | |
164 | return (struct symtab_and_line *) NULL; | |
165 | } | |
166 | ||
167 | static struct exception_event_record * | |
168 | inf_child_get_current_exception_event (void) | |
169 | { | |
170 | return (struct exception_event_record *) NULL; | |
171 | } | |
172 | ||
173 | static char * | |
174 | inf_child_pid_to_exec_file (int pid) | |
175 | { | |
176 | /* This version of Unix doesn't support translation of a process ID | |
177 | to the filename of the executable file. */ | |
178 | return NULL; | |
179 | } | |
180 | ||
5bf970f9 AC |
181 | struct target_ops * |
182 | inf_child_target (void) | |
183 | { | |
184 | struct target_ops *t = XZALLOC (struct target_ops); | |
185 | t->to_shortname = "child"; | |
186 | t->to_longname = "Unix child process"; | |
187 | t->to_doc = "Unix child process (started by the \"run\" command)."; | |
188 | t->to_open = inf_child_open; | |
189 | t->to_post_attach = inf_child_post_attach; | |
7681f339 AC |
190 | t->to_fetch_registers = inf_child_fetch_inferior_registers; |
191 | t->to_store_registers = inf_child_store_inferior_registers; | |
5bf970f9 AC |
192 | t->to_prepare_to_store = inf_child_prepare_to_store; |
193 | t->to_insert_breakpoint = memory_insert_breakpoint; | |
194 | t->to_remove_breakpoint = memory_remove_breakpoint; | |
195 | t->to_terminal_init = terminal_init_inferior; | |
196 | t->to_terminal_inferior = terminal_inferior; | |
197 | t->to_terminal_ours_for_output = terminal_ours_for_output; | |
198 | t->to_terminal_save_ours = terminal_save_ours; | |
199 | t->to_terminal_ours = terminal_ours; | |
200 | t->to_terminal_info = child_terminal_info; | |
201 | t->to_post_startup_inferior = inf_child_post_startup_inferior; | |
202 | t->to_acknowledge_created_inferior = inf_child_acknowledge_created_inferior; | |
203 | t->to_insert_fork_catchpoint = inf_child_insert_fork_catchpoint; | |
204 | t->to_remove_fork_catchpoint = inf_child_remove_fork_catchpoint; | |
205 | t->to_insert_vfork_catchpoint = inf_child_insert_vfork_catchpoint; | |
206 | t->to_remove_vfork_catchpoint = inf_child_remove_vfork_catchpoint; | |
207 | t->to_follow_fork = inf_child_follow_fork; | |
208 | t->to_insert_exec_catchpoint = inf_child_insert_exec_catchpoint; | |
209 | t->to_remove_exec_catchpoint = inf_child_remove_exec_catchpoint; | |
210 | t->to_reported_exec_events_per_exec_call = | |
211 | inf_child_reported_exec_events_per_exec_call; | |
212 | t->to_can_run = inf_child_can_run; | |
213 | t->to_enable_exception_callback = inf_child_enable_exception_callback; | |
214 | t->to_get_current_exception_event = inf_child_get_current_exception_event; | |
215 | t->to_pid_to_exec_file = inf_child_pid_to_exec_file; | |
216 | t->to_stratum = process_stratum; | |
217 | t->to_has_all_memory = 1; | |
218 | t->to_has_memory = 1; | |
219 | t->to_has_stack = 1; | |
220 | t->to_has_registers = 1; | |
221 | t->to_has_execution = 1; | |
222 | t->to_magic = OPS_MAGIC; | |
223 | return t; | |
224 | } |