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