remove target_acknowledge_created_inferior
[platform/upstream/binutils.git] / gdb / inf-child.c
1 /* Default child (native) target interface, for GDB when running under
2    Unix.
3
4    Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998,
5    1999, 2000, 2001, 2002, 2004, 2005, 2007, 2008, 2009, 2010
6    Free Software Foundation, Inc.
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
12    the Free Software Foundation; either version 3 of the License, or
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
21    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
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"
29 #include "gdb_string.h"
30 #include "inf-child.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 (struct target_ops *ops,
37                                     struct regcache *regcache, int regnum)
38 {
39   if (regnum == -1)
40     {
41       for (regnum = 0;
42            regnum < gdbarch_num_regs (get_regcache_arch (regcache));
43            regnum++)
44         regcache_raw_supply (regcache, regnum, NULL);
45     }
46   else
47     regcache_raw_supply (regcache, regnum, NULL);
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
53 static void
54 inf_child_store_inferior_registers (struct target_ops *ops,
55                                     struct regcache *regcache, int regnum)
56 {
57 }
58
59 static void
60 inf_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
72 static void
73 inf_child_prepare_to_store (struct regcache *regcache)
74 {
75 }
76
77 static void
78 inf_child_open (char *arg, int from_tty)
79 {
80   error (_("Use the \"run\" command to start a Unix child process."));
81 }
82
83 static void
84 inf_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
90 static void
91 inf_child_insert_fork_catchpoint (int pid)
92 {
93   /* This version of Unix doesn't support notification of fork
94      events.  */
95 }
96
97 static int
98 inf_child_remove_fork_catchpoint (int pid)
99 {
100   /* This version of Unix doesn't support notification of fork
101      events.  */
102   return 0;
103 }
104
105 static void
106 inf_child_insert_vfork_catchpoint (int pid)
107 {
108   /* This version of Unix doesn't support notification of vfork
109      events.  */
110 }
111
112 static int
113 inf_child_remove_vfork_catchpoint (int pid)
114 {
115   /* This version of Unix doesn't support notification of vfork
116      events.  */
117   return 0;
118 }
119
120 static int
121 inf_child_follow_fork (struct target_ops *ops, int follow_child)
122 {
123   /* This version of Unix doesn't support following fork or vfork
124      events.  */
125   return 0;
126 }
127
128 static void
129 inf_child_insert_exec_catchpoint (int pid)
130 {
131   /* This version of Unix doesn't support notification of exec
132      events.  */
133 }
134
135 static int
136 inf_child_remove_exec_catchpoint (int pid)
137 {
138   /* This version of Unix doesn't support notification of exec
139      events.  */
140   return 0;
141 }
142
143 static int
144 inf_child_set_syscall_catchpoint (int pid, int needed, int any_count,
145                                   int table_size, int *table)
146 {
147   /* This version of Unix doesn't support notification of syscall
148      events.  */
149   return 0;
150 }
151
152 static int
153 inf_child_can_run (void)
154 {
155   return 1;
156 }
157
158 static char *
159 inf_child_pid_to_exec_file (int pid)
160 {
161   /* This version of Unix doesn't support translation of a process ID
162      to the filename of the executable file.  */
163   return NULL;
164 }
165
166 struct target_ops *
167 inf_child_target (void)
168 {
169   struct target_ops *t = XZALLOC (struct target_ops);
170
171   t->to_shortname = "child";
172   t->to_longname = "Unix child process";
173   t->to_doc = "Unix child process (started by the \"run\" command).";
174   t->to_open = inf_child_open;
175   t->to_post_attach = inf_child_post_attach;
176   t->to_fetch_registers = inf_child_fetch_inferior_registers;
177   t->to_store_registers = inf_child_store_inferior_registers;
178   t->to_prepare_to_store = inf_child_prepare_to_store;
179   t->to_insert_breakpoint = memory_insert_breakpoint;
180   t->to_remove_breakpoint = memory_remove_breakpoint;
181   t->to_terminal_init = terminal_init_inferior;
182   t->to_terminal_inferior = terminal_inferior;
183   t->to_terminal_ours_for_output = terminal_ours_for_output;
184   t->to_terminal_save_ours = terminal_save_ours;
185   t->to_terminal_ours = terminal_ours;
186   t->to_terminal_info = child_terminal_info;
187   t->to_post_startup_inferior = inf_child_post_startup_inferior;
188   t->to_insert_fork_catchpoint = inf_child_insert_fork_catchpoint;
189   t->to_remove_fork_catchpoint = inf_child_remove_fork_catchpoint;
190   t->to_insert_vfork_catchpoint = inf_child_insert_vfork_catchpoint;
191   t->to_remove_vfork_catchpoint = inf_child_remove_vfork_catchpoint;
192   t->to_follow_fork = inf_child_follow_fork;
193   t->to_insert_exec_catchpoint = inf_child_insert_exec_catchpoint;
194   t->to_remove_exec_catchpoint = inf_child_remove_exec_catchpoint;
195   t->to_set_syscall_catchpoint = inf_child_set_syscall_catchpoint;
196   t->to_can_run = inf_child_can_run;
197   t->to_pid_to_exec_file = inf_child_pid_to_exec_file;
198   t->to_stratum = process_stratum;
199   t->to_has_all_memory = default_child_has_all_memory;
200   t->to_has_memory = default_child_has_memory;
201   t->to_has_stack = default_child_has_stack;
202   t->to_has_registers = default_child_has_registers;
203   t->to_has_execution = default_child_has_execution;
204   t->to_magic = OPS_MAGIC;
205   return t;
206 }