Commit | Line | Data |
---|---|---|
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 | ||
35 | static void | |
56be3814 | 36 | inf_child_fetch_inferior_registers (struct regcache *regcache, int regnum) |
5bf970f9 AC |
37 | { |
38 | if (regnum == -1) | |
39 | { | |
b1a653ae UW |
40 | for (regnum = 0; |
41 | regnum < gdbarch_num_regs (get_regcache_arch (regcache)); | |
42 | regnum++) | |
56be3814 | 43 | regcache_raw_supply (regcache, regnum, NULL); |
5bf970f9 AC |
44 | } |
45 | else | |
56be3814 | 46 | regcache_raw_supply (regcache, regnum, NULL); |
5bf970f9 AC |
47 | } |
48 | ||
49 | /* Store register REGNUM back into the inferior. If REGNUM is -1, do | |
50 | this for all registers (including the floating point registers). */ | |
51 | ||
52 | static void | |
56be3814 | 53 | inf_child_store_inferior_registers (struct regcache *regcache, int regnum) |
5bf970f9 AC |
54 | { |
55 | } | |
56 | ||
5bf970f9 AC |
57 | static void |
58 | inf_child_post_attach (int pid) | |
59 | { | |
60 | /* This version of Unix doesn't require a meaningful "post attach" | |
61 | operation by a debugger. */ | |
62 | } | |
63 | ||
64 | /* Get ready to modify the registers array. On machines which store | |
65 | individual registers, this doesn't need to do anything. On | |
66 | machines which store all the registers in one fell swoop, this | |
67 | makes sure that registers contains all the registers from the | |
68 | program being debugged. */ | |
69 | ||
70 | static void | |
316f2060 | 71 | inf_child_prepare_to_store (struct regcache *regcache) |
5bf970f9 AC |
72 | { |
73 | } | |
74 | ||
75 | static void | |
76 | inf_child_open (char *arg, int from_tty) | |
77 | { | |
8a3fe4f8 | 78 | error (_("Use the \"run\" command to start a Unix child process.")); |
5bf970f9 AC |
79 | } |
80 | ||
81 | static void | |
82 | inf_child_post_startup_inferior (ptid_t ptid) | |
83 | { | |
84 | /* This version of Unix doesn't require a meaningful "post startup | |
85 | inferior" operation by a debugger. */ | |
86 | } | |
87 | ||
88 | static void | |
89 | inf_child_acknowledge_created_inferior (int pid) | |
90 | { | |
91 | /* This version of Unix doesn't require a meaningful "acknowledge | |
92 | created inferior" operation by a debugger. */ | |
93 | } | |
94 | ||
fa113d1a | 95 | static void |
5bf970f9 AC |
96 | inf_child_insert_fork_catchpoint (int pid) |
97 | { | |
98 | /* This version of Unix doesn't support notification of fork | |
99 | events. */ | |
5bf970f9 AC |
100 | } |
101 | ||
102 | static int | |
103 | inf_child_remove_fork_catchpoint (int pid) | |
104 | { | |
105 | /* This version of Unix doesn't support notification of fork | |
106 | events. */ | |
107 | return 0; | |
108 | } | |
109 | ||
fa113d1a | 110 | static void |
5bf970f9 AC |
111 | inf_child_insert_vfork_catchpoint (int pid) |
112 | { | |
113 | /* This version of Unix doesn't support notification of vfork | |
114 | events. */ | |
5bf970f9 AC |
115 | } |
116 | ||
117 | static int | |
118 | inf_child_remove_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 | |
ee057212 | 126 | inf_child_follow_fork (struct target_ops *ops, int follow_child) |
5bf970f9 AC |
127 | { |
128 | /* This version of Unix doesn't support following fork or vfork | |
129 | events. */ | |
130 | return 0; | |
131 | } | |
132 | ||
fa113d1a | 133 | static void |
5bf970f9 AC |
134 | inf_child_insert_exec_catchpoint (int pid) |
135 | { | |
136 | /* This version of Unix doesn't support notification of exec | |
137 | events. */ | |
5bf970f9 AC |
138 | } |
139 | ||
140 | static int | |
141 | inf_child_remove_exec_catchpoint (int pid) | |
142 | { | |
143 | /* This version of Unix doesn't support notification of exec | |
144 | events. */ | |
145 | return 0; | |
146 | } | |
147 | ||
5bf970f9 AC |
148 | static int |
149 | inf_child_can_run (void) | |
150 | { | |
151 | return 1; | |
152 | } | |
153 | ||
5bf970f9 AC |
154 | static char * |
155 | inf_child_pid_to_exec_file (int pid) | |
156 | { | |
157 | /* This version of Unix doesn't support translation of a process ID | |
158 | to the filename of the executable file. */ | |
159 | return NULL; | |
160 | } | |
161 | ||
5bf970f9 AC |
162 | struct target_ops * |
163 | inf_child_target (void) | |
164 | { | |
165 | struct target_ops *t = XZALLOC (struct target_ops); | |
166 | t->to_shortname = "child"; | |
167 | t->to_longname = "Unix child process"; | |
168 | t->to_doc = "Unix child process (started by the \"run\" command)."; | |
169 | t->to_open = inf_child_open; | |
170 | t->to_post_attach = inf_child_post_attach; | |
7681f339 AC |
171 | t->to_fetch_registers = inf_child_fetch_inferior_registers; |
172 | t->to_store_registers = inf_child_store_inferior_registers; | |
5bf970f9 AC |
173 | t->to_prepare_to_store = inf_child_prepare_to_store; |
174 | t->to_insert_breakpoint = memory_insert_breakpoint; | |
175 | t->to_remove_breakpoint = memory_remove_breakpoint; | |
176 | t->to_terminal_init = terminal_init_inferior; | |
177 | t->to_terminal_inferior = terminal_inferior; | |
178 | t->to_terminal_ours_for_output = terminal_ours_for_output; | |
179 | t->to_terminal_save_ours = terminal_save_ours; | |
180 | t->to_terminal_ours = terminal_ours; | |
181 | t->to_terminal_info = child_terminal_info; | |
182 | t->to_post_startup_inferior = inf_child_post_startup_inferior; | |
183 | t->to_acknowledge_created_inferior = inf_child_acknowledge_created_inferior; | |
184 | t->to_insert_fork_catchpoint = inf_child_insert_fork_catchpoint; | |
185 | t->to_remove_fork_catchpoint = inf_child_remove_fork_catchpoint; | |
186 | t->to_insert_vfork_catchpoint = inf_child_insert_vfork_catchpoint; | |
187 | t->to_remove_vfork_catchpoint = inf_child_remove_vfork_catchpoint; | |
188 | t->to_follow_fork = inf_child_follow_fork; | |
189 | t->to_insert_exec_catchpoint = inf_child_insert_exec_catchpoint; | |
190 | t->to_remove_exec_catchpoint = inf_child_remove_exec_catchpoint; | |
5bf970f9 | 191 | t->to_can_run = inf_child_can_run; |
5bf970f9 AC |
192 | t->to_pid_to_exec_file = inf_child_pid_to_exec_file; |
193 | t->to_stratum = process_stratum; | |
194 | t->to_has_all_memory = 1; | |
195 | t->to_has_memory = 1; | |
196 | t->to_has_stack = 1; | |
197 | t->to_has_registers = 1; | |
198 | t->to_has_execution = 1; | |
199 | t->to_magic = OPS_MAGIC; | |
200 | return t; | |
201 | } |