(Fix date for):
[deliverable/binutils-gdb.git] / gdb / inf-child.c
CommitLineData
5bf970f9
AC
1/* Default child (native) target interface, for GDB when running under
2 Unix.
3
6aba47ca 4 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998,
0fb0cc75 5 1999, 2000, 2001, 2002, 2004, 2005, 2007, 2008, 2009
9b254dd1 6 Free Software Foundation, Inc.
5bf970f9
AC
7
8 This file is part of GDB.
9
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
a9762ec7 12 the Free Software Foundation; either version 3 of the License, or
5bf970f9
AC
13 (at your option) any later version.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
a9762ec7 21 along with this program. If not, see <http://www.gnu.org/licenses/>. */
5bf970f9
AC
22
23#include "defs.h"
24#include "regcache.h"
25#include "memattr.h"
26#include "symtab.h"
27#include "target.h"
28#include "inferior.h"
7681f339 29#include "gdb_string.h"
2c0b251b 30#include "inf-child.h"
5bf970f9
AC
31
32/* Fetch register REGNUM from the inferior. If REGNUM is -1, do this
33 for all registers. */
34
35static void
28439f5e
PA
36inf_child_fetch_inferior_registers (struct target_ops *ops,
37 struct regcache *regcache, int regnum)
5bf970f9
AC
38{
39 if (regnum == -1)
40 {
b1a653ae
UW
41 for (regnum = 0;
42 regnum < gdbarch_num_regs (get_regcache_arch (regcache));
43 regnum++)
56be3814 44 regcache_raw_supply (regcache, regnum, NULL);
5bf970f9
AC
45 }
46 else
56be3814 47 regcache_raw_supply (regcache, regnum, NULL);
5bf970f9
AC
48}
49
50/* Store register REGNUM back into the inferior. If REGNUM is -1, do
51 this for all registers (including the floating point registers). */
52
53static void
28439f5e
PA
54inf_child_store_inferior_registers (struct target_ops *ops,
55 struct regcache *regcache, int regnum)
5bf970f9
AC
56{
57}
58
5bf970f9
AC
59static void
60inf_child_post_attach (int pid)
61{
62 /* This version of Unix doesn't require a meaningful "post attach"
63 operation by a debugger. */
64}
65
66/* Get ready to modify the registers array. On machines which store
67 individual registers, this doesn't need to do anything. On
68 machines which store all the registers in one fell swoop, this
69 makes sure that registers contains all the registers from the
70 program being debugged. */
71
72static void
316f2060 73inf_child_prepare_to_store (struct regcache *regcache)
5bf970f9
AC
74{
75}
76
77static void
78inf_child_open (char *arg, int from_tty)
79{
8a3fe4f8 80 error (_("Use the \"run\" command to start a Unix child process."));
5bf970f9
AC
81}
82
83static void
84inf_child_post_startup_inferior (ptid_t ptid)
85{
86 /* This version of Unix doesn't require a meaningful "post startup
87 inferior" operation by a debugger. */
88}
89
90static void
91inf_child_acknowledge_created_inferior (int pid)
92{
93 /* This version of Unix doesn't require a meaningful "acknowledge
94 created inferior" operation by a debugger. */
95}
96
fa113d1a 97static void
5bf970f9
AC
98inf_child_insert_fork_catchpoint (int pid)
99{
100 /* This version of Unix doesn't support notification of fork
101 events. */
5bf970f9
AC
102}
103
104static int
105inf_child_remove_fork_catchpoint (int pid)
106{
107 /* This version of Unix doesn't support notification of fork
108 events. */
109 return 0;
110}
111
fa113d1a 112static void
5bf970f9
AC
113inf_child_insert_vfork_catchpoint (int pid)
114{
115 /* This version of Unix doesn't support notification of vfork
116 events. */
5bf970f9
AC
117}
118
119static int
120inf_child_remove_vfork_catchpoint (int pid)
121{
122 /* This version of Unix doesn't support notification of vfork
123 events. */
124 return 0;
125}
126
127static int
ee057212 128inf_child_follow_fork (struct target_ops *ops, int follow_child)
5bf970f9
AC
129{
130 /* This version of Unix doesn't support following fork or vfork
131 events. */
132 return 0;
133}
134
fa113d1a 135static void
5bf970f9
AC
136inf_child_insert_exec_catchpoint (int pid)
137{
138 /* This version of Unix doesn't support notification of exec
139 events. */
5bf970f9
AC
140}
141
142static int
143inf_child_remove_exec_catchpoint (int pid)
144{
145 /* This version of Unix doesn't support notification of exec
146 events. */
147 return 0;
148}
149
5bf970f9
AC
150static int
151inf_child_can_run (void)
152{
153 return 1;
154}
155
5bf970f9
AC
156static char *
157inf_child_pid_to_exec_file (int pid)
158{
159 /* This version of Unix doesn't support translation of a process ID
160 to the filename of the executable file. */
161 return NULL;
162}
163
5bf970f9
AC
164struct target_ops *
165inf_child_target (void)
166{
167 struct target_ops *t = XZALLOC (struct target_ops);
168 t->to_shortname = "child";
169 t->to_longname = "Unix child process";
170 t->to_doc = "Unix child process (started by the \"run\" command).";
171 t->to_open = inf_child_open;
172 t->to_post_attach = inf_child_post_attach;
7681f339
AC
173 t->to_fetch_registers = inf_child_fetch_inferior_registers;
174 t->to_store_registers = inf_child_store_inferior_registers;
5bf970f9
AC
175 t->to_prepare_to_store = inf_child_prepare_to_store;
176 t->to_insert_breakpoint = memory_insert_breakpoint;
177 t->to_remove_breakpoint = memory_remove_breakpoint;
178 t->to_terminal_init = terminal_init_inferior;
179 t->to_terminal_inferior = terminal_inferior;
180 t->to_terminal_ours_for_output = terminal_ours_for_output;
181 t->to_terminal_save_ours = terminal_save_ours;
182 t->to_terminal_ours = terminal_ours;
183 t->to_terminal_info = child_terminal_info;
184 t->to_post_startup_inferior = inf_child_post_startup_inferior;
185 t->to_acknowledge_created_inferior = inf_child_acknowledge_created_inferior;
186 t->to_insert_fork_catchpoint = inf_child_insert_fork_catchpoint;
187 t->to_remove_fork_catchpoint = inf_child_remove_fork_catchpoint;
188 t->to_insert_vfork_catchpoint = inf_child_insert_vfork_catchpoint;
189 t->to_remove_vfork_catchpoint = inf_child_remove_vfork_catchpoint;
190 t->to_follow_fork = inf_child_follow_fork;
191 t->to_insert_exec_catchpoint = inf_child_insert_exec_catchpoint;
192 t->to_remove_exec_catchpoint = inf_child_remove_exec_catchpoint;
5bf970f9 193 t->to_can_run = inf_child_can_run;
5bf970f9
AC
194 t->to_pid_to_exec_file = inf_child_pid_to_exec_file;
195 t->to_stratum = process_stratum;
196 t->to_has_all_memory = 1;
197 t->to_has_memory = 1;
198 t->to_has_stack = 1;
199 t->to_has_registers = 1;
200 t->to_has_execution = 1;
201 t->to_magic = OPS_MAGIC;
202 return t;
203}
This page took 0.335437 seconds and 4 git commands to generate.