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