2004-09-16 Andrew Cagney <cagney@gnu.org>
[deliverable/binutils-gdb.git] / gdb / inf-child.c
1 /* Default child (native) target interface, for GDB when running under
2 Unix.
3
4 Copyright 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
5 1998, 1999, 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
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 #include "defs.h"
25 #include "regcache.h"
26 #include "memattr.h"
27 #include "symtab.h"
28 #include "target.h"
29 #include "inferior.h"
30 #include "gdb_string.h"
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
55 void
56 inf_child_post_wait (ptid_t ptid, int wait_status)
57 {
58 /* This version of Unix doesn't require a meaningful "post wait"
59 operation.
60 */
61 }
62
63 static void
64 inf_child_post_attach (int pid)
65 {
66 /* This version of Unix doesn't require a meaningful "post attach"
67 operation by a debugger. */
68 }
69
70 /* Get ready to modify the registers array. On machines which store
71 individual registers, this doesn't need to do anything. On
72 machines which store all the registers in one fell swoop, this
73 makes sure that registers contains all the registers from the
74 program being debugged. */
75
76 static void
77 inf_child_prepare_to_store (void)
78 {
79 }
80
81 static void
82 inf_child_open (char *arg, int from_tty)
83 {
84 error ("Use the \"run\" command to start a Unix child process.");
85 }
86
87 static void
88 inf_child_post_startup_inferior (ptid_t ptid)
89 {
90 /* This version of Unix doesn't require a meaningful "post startup
91 inferior" operation by a debugger. */
92 }
93
94 static void
95 inf_child_acknowledge_created_inferior (int pid)
96 {
97 /* This version of Unix doesn't require a meaningful "acknowledge
98 created inferior" operation by a debugger. */
99 }
100
101 static int
102 inf_child_insert_fork_catchpoint (int pid)
103 {
104 /* This version of Unix doesn't support notification of fork
105 events. */
106 return 0;
107 }
108
109 static int
110 inf_child_remove_fork_catchpoint (int pid)
111 {
112 /* This version of Unix doesn't support notification of fork
113 events. */
114 return 0;
115 }
116
117 static int
118 inf_child_insert_vfork_catchpoint (int pid)
119 {
120 /* This version of Unix doesn't support notification of vfork
121 events. */
122 return 0;
123 }
124
125 static int
126 inf_child_remove_vfork_catchpoint (int pid)
127 {
128 /* This version of Unix doesn't support notification of vfork
129 events. */
130 return 0;
131 }
132
133 static int
134 inf_child_follow_fork (int follow_child)
135 {
136 /* This version of Unix doesn't support following fork or vfork
137 events. */
138 return 0;
139 }
140
141 static int
142 inf_child_insert_exec_catchpoint (int pid)
143 {
144 /* This version of Unix doesn't support notification of exec
145 events. */
146 return 0;
147 }
148
149 static int
150 inf_child_remove_exec_catchpoint (int pid)
151 {
152 /* This version of Unix doesn't support notification of exec
153 events. */
154 return 0;
155 }
156
157 static int
158 inf_child_reported_exec_events_per_exec_call (void)
159 {
160 /* This version of Unix doesn't support notification of exec
161 events. */
162 return 1;
163 }
164
165 static int
166 inf_child_can_run (void)
167 {
168 return 1;
169 }
170
171 static struct symtab_and_line *
172 inf_child_enable_exception_callback (enum exception_event_kind kind,
173 int enable)
174 {
175 return (struct symtab_and_line *) NULL;
176 }
177
178 static struct exception_event_record *
179 inf_child_get_current_exception_event (void)
180 {
181 return (struct exception_event_record *) NULL;
182 }
183
184 static char *
185 inf_child_pid_to_exec_file (int pid)
186 {
187 /* This version of Unix doesn't support translation of a process ID
188 to the filename of the executable file. */
189 return NULL;
190 }
191
192 struct target_ops *
193 inf_child_target (void)
194 {
195 struct target_ops *t = XZALLOC (struct target_ops);
196 t->to_shortname = "child";
197 t->to_longname = "Unix child process";
198 t->to_doc = "Unix child process (started by the \"run\" command).";
199 t->to_open = inf_child_open;
200 t->to_post_attach = inf_child_post_attach;
201 t->to_post_wait = inf_child_post_wait;
202 t->to_fetch_registers = inf_child_fetch_inferior_registers;
203 t->to_store_registers = inf_child_store_inferior_registers;
204 t->to_prepare_to_store = inf_child_prepare_to_store;
205 t->to_insert_breakpoint = memory_insert_breakpoint;
206 t->to_remove_breakpoint = memory_remove_breakpoint;
207 t->to_terminal_init = terminal_init_inferior;
208 t->to_terminal_inferior = terminal_inferior;
209 t->to_terminal_ours_for_output = terminal_ours_for_output;
210 t->to_terminal_save_ours = terminal_save_ours;
211 t->to_terminal_ours = terminal_ours;
212 t->to_terminal_info = child_terminal_info;
213 t->to_post_startup_inferior = inf_child_post_startup_inferior;
214 t->to_acknowledge_created_inferior = inf_child_acknowledge_created_inferior;
215 t->to_insert_fork_catchpoint = inf_child_insert_fork_catchpoint;
216 t->to_remove_fork_catchpoint = inf_child_remove_fork_catchpoint;
217 t->to_insert_vfork_catchpoint = inf_child_insert_vfork_catchpoint;
218 t->to_remove_vfork_catchpoint = inf_child_remove_vfork_catchpoint;
219 t->to_follow_fork = inf_child_follow_fork;
220 t->to_insert_exec_catchpoint = inf_child_insert_exec_catchpoint;
221 t->to_remove_exec_catchpoint = inf_child_remove_exec_catchpoint;
222 t->to_reported_exec_events_per_exec_call =
223 inf_child_reported_exec_events_per_exec_call;
224 t->to_can_run = inf_child_can_run;
225 t->to_enable_exception_callback = inf_child_enable_exception_callback;
226 t->to_get_current_exception_event = inf_child_get_current_exception_event;
227 t->to_pid_to_exec_file = inf_child_pid_to_exec_file;
228 t->to_stratum = process_stratum;
229 t->to_has_all_memory = 1;
230 t->to_has_memory = 1;
231 t->to_has_stack = 1;
232 t->to_has_registers = 1;
233 t->to_has_execution = 1;
234 t->to_magic = OPS_MAGIC;
235 return t;
236 }
This page took 0.045347 seconds and 5 git commands to generate.