]>
Commit | Line | Data |
---|---|---|
c906108c | 1 | /* Target-vector operations for controlling Unix child processes, for GDB. |
1bac305b | 2 | |
197e01b6 | 3 | Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, |
ee057212 | 4 | 2000, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. |
1bac305b | 5 | |
c906108c SS |
6 | Contributed by Cygnus Support. |
7 | ||
c5aa993b | 8 | ## Contains temporary hacks.. |
c906108c | 9 | |
c5aa993b | 10 | This file is part of GDB. |
c906108c | 11 | |
c5aa993b JM |
12 | This program is free software; you can redistribute it and/or modify |
13 | it under the terms of the GNU General Public License as published by | |
14 | the Free Software Foundation; either version 2 of the License, or | |
15 | (at your option) any later version. | |
c906108c | 16 | |
c5aa993b JM |
17 | This program is distributed in the hope that it will be useful, |
18 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 | GNU General Public License for more details. | |
c906108c | 21 | |
c5aa993b JM |
22 | You should have received a copy of the GNU General Public License |
23 | along with this program; if not, write to the Free Software | |
197e01b6 EZ |
24 | Foundation, Inc., 51 Franklin Street, Fifth Floor, |
25 | Boston, MA 02110-1301, USA. */ | |
c906108c SS |
26 | |
27 | #include "defs.h" | |
c5aa993b | 28 | #include "frame.h" /* required by inferior.h */ |
c906108c SS |
29 | #include "inferior.h" |
30 | #include "target.h" | |
31 | #include "gdbcore.h" | |
32 | #include "command.h" | |
33 | #include "gdb_stat.h" | |
34 | #include <signal.h> | |
35 | #include <sys/types.h> | |
36 | #include <fcntl.h> | |
20d2ca3e | 37 | #include "observer.h" |
03f2053f | 38 | #include "gdb_wait.h" |
44270758 | 39 | #include "inflow.h" |
c906108c | 40 | |
a14ed312 KB |
41 | extern struct symtab_and_line *child_enable_exception_callback (enum |
42 | exception_event_kind, | |
43 | int); | |
c906108c | 44 | |
a14ed312 KB |
45 | extern struct exception_event_record |
46 | *child_get_current_exception_event (void); | |
c906108c | 47 | |
a14ed312 | 48 | extern void _initialize_inftarg (void); |
c906108c | 49 | |
a14ed312 | 50 | static void child_prepare_to_store (void); |
c906108c SS |
51 | |
52 | #ifndef CHILD_WAIT | |
39f77062 | 53 | static ptid_t child_wait (ptid_t, struct target_waitstatus *); |
c906108c SS |
54 | #endif /* CHILD_WAIT */ |
55 | ||
a14ed312 | 56 | static void child_open (char *, int); |
c906108c | 57 | |
a14ed312 | 58 | static void child_files_info (struct target_ops *); |
c906108c | 59 | |
a14ed312 | 60 | static void child_detach (char *, int); |
c906108c | 61 | |
a14ed312 | 62 | static void child_attach (char *, int); |
c906108c | 63 | |
c906108c | 64 | #if !defined(CHILD_POST_ATTACH) |
a14ed312 | 65 | extern void child_post_attach (int); |
c906108c SS |
66 | #endif |
67 | ||
a14ed312 | 68 | static void ptrace_me (void); |
c906108c | 69 | |
a14ed312 | 70 | static void ptrace_him (int); |
c906108c | 71 | |
c27cda74 | 72 | static void child_create_inferior (char *, char *, char **, int); |
c906108c | 73 | |
a14ed312 | 74 | static void child_mourn_inferior (void); |
c906108c | 75 | |
a14ed312 | 76 | static int child_can_run (void); |
c906108c | 77 | |
a14ed312 | 78 | static void child_stop (void); |
c906108c SS |
79 | |
80 | #ifndef CHILD_THREAD_ALIVE | |
39f77062 | 81 | int child_thread_alive (ptid_t); |
c906108c SS |
82 | #endif |
83 | ||
a14ed312 | 84 | static void init_child_ops (void); |
c906108c SS |
85 | |
86 | extern char **environ; | |
87 | ||
c906108c SS |
88 | int child_suppress_run = 0; /* Non-zero if inftarg should pretend not to |
89 | be a runnable target. Used by targets | |
90 | that can sit atop inftarg, such as HPUX | |
91 | thread support. */ | |
92 | ||
93 | #ifndef CHILD_WAIT | |
94 | ||
c906108c SS |
95 | /* Wait for child to do something. Return pid of child, or -1 in case |
96 | of error; store status through argument pointer OURSTATUS. */ | |
97 | ||
39f77062 KB |
98 | static ptid_t |
99 | child_wait (ptid_t ptid, struct target_waitstatus *ourstatus) | |
c906108c SS |
100 | { |
101 | int save_errno; | |
102 | int status; | |
7a292a7a | 103 | char *execd_pathname = NULL; |
c5aa993b | 104 | int exit_status; |
c5aa993b JM |
105 | int syscall_id; |
106 | enum target_waitkind kind; | |
39f77062 | 107 | int pid; |
c906108c | 108 | |
c5aa993b JM |
109 | do |
110 | { | |
111 | set_sigint_trap (); /* Causes SIGINT to be passed on to the | |
112 | attached process. */ | |
113 | set_sigio_trap (); | |
c906108c | 114 | |
ee21b650 | 115 | pid = wait (&status); |
c906108c | 116 | |
c5aa993b | 117 | save_errno = errno; |
c906108c | 118 | |
c5aa993b | 119 | clear_sigio_trap (); |
c906108c | 120 | |
c5aa993b | 121 | clear_sigint_trap (); |
c906108c | 122 | |
c5aa993b JM |
123 | if (pid == -1) |
124 | { | |
125 | if (save_errno == EINTR) | |
126 | continue; | |
c906108c | 127 | |
c5aa993b JM |
128 | fprintf_unfiltered (gdb_stderr, "Child process unexpectedly missing: %s.\n", |
129 | safe_strerror (save_errno)); | |
c906108c | 130 | |
c5aa993b JM |
131 | /* Claim it exited with unknown signal. */ |
132 | ourstatus->kind = TARGET_WAITKIND_SIGNALLED; | |
133 | ourstatus->value.sig = TARGET_SIGNAL_UNKNOWN; | |
39f77062 | 134 | return pid_to_ptid (-1); |
c5aa993b | 135 | } |
c906108c | 136 | |
c5aa993b | 137 | /* Did it exit? |
c906108c | 138 | */ |
c5aa993b JM |
139 | if (target_has_exited (pid, status, &exit_status)) |
140 | { | |
141 | /* ??rehrauer: For now, ignore this. */ | |
142 | continue; | |
143 | } | |
144 | ||
39f77062 | 145 | if (!target_thread_alive (pid_to_ptid (pid))) |
c5aa993b JM |
146 | { |
147 | ourstatus->kind = TARGET_WAITKIND_SPURIOUS; | |
39f77062 | 148 | return pid_to_ptid (pid); |
c5aa993b | 149 | } |
47932f85 | 150 | } while (pid != PIDGET (inferior_ptid)); /* Some other child died or stopped */ |
c906108c SS |
151 | |
152 | store_waitstatus (ourstatus, status); | |
39f77062 | 153 | return pid_to_ptid (pid); |
c906108c SS |
154 | } |
155 | #endif /* CHILD_WAIT */ | |
156 | ||
c906108c SS |
157 | #ifndef CHILD_THREAD_ALIVE |
158 | ||
159 | /* Check to see if the given thread is alive. | |
160 | ||
161 | FIXME: Is kill() ever the right way to do this? I doubt it, but | |
162 | for now we're going to try and be compatable with the old thread | |
163 | code. */ | |
164 | int | |
39f77062 | 165 | child_thread_alive (ptid_t ptid) |
c906108c | 166 | { |
39f77062 KB |
167 | pid_t pid = PIDGET (ptid); |
168 | ||
c906108c SS |
169 | return (kill (pid, 0) != -1); |
170 | } | |
171 | ||
172 | #endif | |
173 | ||
4c9ba7e0 DJ |
174 | /* Attach to process PID, then initialize for debugging it. */ |
175 | ||
c906108c | 176 | static void |
4c9ba7e0 | 177 | child_attach (char *args, int from_tty) |
c906108c | 178 | { |
d966f0cb AC |
179 | char *exec_file; |
180 | int pid; | |
181 | char *dummy; | |
182 | ||
c906108c | 183 | if (!args) |
e2e0b3e5 | 184 | error_no_arg (_("process-id to attach")); |
c906108c | 185 | |
d966f0cb AC |
186 | dummy = args; |
187 | pid = strtol (args, &dummy, 0); | |
188 | /* Some targets don't set errno on errors, grrr! */ | |
189 | if ((pid == 0) && (args == dummy)) | |
8a3fe4f8 | 190 | error (_("Illegal process-id: %s."), args); |
d966f0cb AC |
191 | |
192 | if (pid == getpid ()) /* Trying to masturbate? */ | |
8a3fe4f8 | 193 | error (_("I refuse to debug myself!")); |
d966f0cb AC |
194 | |
195 | if (from_tty) | |
196 | { | |
197 | exec_file = (char *) get_exec_file (0); | |
198 | ||
199 | if (exec_file) | |
a3f17187 | 200 | printf_unfiltered (_("Attaching to program: %s, %s\n"), exec_file, |
d966f0cb AC |
201 | target_pid_to_str (pid_to_ptid (pid))); |
202 | else | |
a3f17187 | 203 | printf_unfiltered (_("Attaching to %s\n"), |
d966f0cb AC |
204 | target_pid_to_str (pid_to_ptid (pid))); |
205 | ||
206 | gdb_flush (gdb_stdout); | |
207 | } | |
208 | ||
209 | attach (pid); | |
210 | ||
211 | inferior_ptid = pid_to_ptid (pid); | |
1df84f13 | 212 | push_target (&deprecated_child_ops); |
12b8a2cb DJ |
213 | |
214 | /* Do this first, before anything has had a chance to query the | |
215 | inferior's symbol table or similar. */ | |
216 | observer_notify_inferior_created (¤t_target, from_tty); | |
c906108c SS |
217 | } |
218 | ||
c906108c SS |
219 | #if !defined(CHILD_POST_ATTACH) |
220 | void | |
fba45db2 | 221 | child_post_attach (int pid) |
c906108c SS |
222 | { |
223 | /* This version of Unix doesn't require a meaningful "post attach" | |
224 | operation by a debugger. */ | |
225 | } | |
226 | #endif | |
227 | ||
4c9ba7e0 DJ |
228 | /* Take a program previously attached to and detaches it. |
229 | The program resumes execution and will no longer stop | |
230 | on signals, etc. We'd better not have left any breakpoints | |
231 | in the program or it'll die when it hits one. For this | |
232 | to work, it may be necessary for the process to have been | |
233 | previously attached. It *might* work if the program was | |
234 | started via the normal ptrace (PTRACE_TRACEME). */ | |
c906108c SS |
235 | |
236 | static void | |
4c9ba7e0 | 237 | child_detach (char *args, int from_tty) |
c906108c | 238 | { |
d966f0cb AC |
239 | int siggnal = 0; |
240 | int pid = PIDGET (inferior_ptid); | |
241 | ||
242 | if (from_tty) | |
243 | { | |
244 | char *exec_file = get_exec_file (0); | |
245 | if (exec_file == 0) | |
246 | exec_file = ""; | |
a3f17187 | 247 | printf_unfiltered (_("Detaching from program: %s, %s\n"), exec_file, |
d966f0cb AC |
248 | target_pid_to_str (pid_to_ptid (pid))); |
249 | gdb_flush (gdb_stdout); | |
250 | } | |
251 | if (args) | |
252 | siggnal = atoi (args); | |
253 | ||
254 | detach (siggnal); | |
255 | ||
256 | inferior_ptid = null_ptid; | |
1df84f13 | 257 | unpush_target (&deprecated_child_ops); |
c906108c SS |
258 | } |
259 | ||
c906108c SS |
260 | /* Get ready to modify the registers array. On machines which store |
261 | individual registers, this doesn't need to do anything. On machines | |
262 | which store all the registers in one fell swoop, this makes sure | |
263 | that registers contains all the registers from the program being | |
264 | debugged. */ | |
265 | ||
266 | static void | |
fba45db2 | 267 | child_prepare_to_store (void) |
c906108c SS |
268 | { |
269 | #ifdef CHILD_PREPARE_TO_STORE | |
270 | CHILD_PREPARE_TO_STORE (); | |
271 | #endif | |
272 | } | |
273 | ||
274 | /* Print status information about what we're accessing. */ | |
275 | ||
276 | static void | |
fba45db2 | 277 | child_files_info (struct target_ops *ignore) |
c906108c | 278 | { |
a3f17187 | 279 | printf_unfiltered (_("\tUsing the running image of %s %s.\n"), |
39f77062 | 280 | attach_flag ? "attached" : "child", target_pid_to_str (inferior_ptid)); |
c906108c SS |
281 | } |
282 | ||
c906108c | 283 | static void |
fba45db2 | 284 | child_open (char *arg, int from_tty) |
c906108c | 285 | { |
8a3fe4f8 | 286 | error (_("Use the \"run\" command to start a Unix child process.")); |
c906108c SS |
287 | } |
288 | ||
289 | /* Stub function which causes the inferior that runs it, to be ptrace-able | |
290 | by its parent process. */ | |
291 | ||
292 | static void | |
fba45db2 | 293 | ptrace_me (void) |
c906108c SS |
294 | { |
295 | /* "Trace me, Dr. Memory!" */ | |
655c5466 | 296 | call_ptrace (0, 0, (PTRACE_TYPE_ARG3) 0, 0); |
c906108c SS |
297 | } |
298 | ||
299 | /* Stub function which causes the GDB that runs it, to start ptrace-ing | |
300 | the child process. */ | |
301 | ||
c5aa993b | 302 | static void |
fba45db2 | 303 | ptrace_him (int pid) |
c906108c | 304 | { |
1df84f13 | 305 | push_target (&deprecated_child_ops); |
c906108c SS |
306 | |
307 | /* On some targets, there must be some explicit synchronization | |
308 | between the parent and child processes after the debugger | |
309 | forks, and before the child execs the debuggee program. This | |
310 | call basically gives permission for the child to exec. | |
c5aa993b | 311 | */ |
c906108c SS |
312 | |
313 | target_acknowledge_created_inferior (pid); | |
314 | ||
315 | /* START_INFERIOR_TRAPS_EXPECTED is defined in inferior.h, | |
316 | * and will be 1 or 2 depending on whether we're starting | |
317 | * without or with a shell. | |
318 | */ | |
319 | startup_inferior (START_INFERIOR_TRAPS_EXPECTED); | |
320 | ||
321 | /* On some targets, there must be some explicit actions taken after | |
322 | the inferior has been started up. | |
c5aa993b | 323 | */ |
39f77062 | 324 | target_post_startup_inferior (pid_to_ptid (pid)); |
c906108c SS |
325 | } |
326 | ||
39f77062 | 327 | /* Start an inferior Unix child process and sets inferior_ptid to its pid. |
c906108c SS |
328 | EXEC_FILE is the file to run. |
329 | ALLARGS is a string containing the arguments to the program. | |
330 | ENV is the environment vector to pass. Errors reported with error(). */ | |
331 | ||
332 | static void | |
c27cda74 AC |
333 | child_create_inferior (char *exec_file, char *allargs, char **env, |
334 | int from_tty) | |
c906108c | 335 | { |
c5aa993b | 336 | fork_inferior (exec_file, allargs, env, ptrace_me, ptrace_him, NULL, NULL); |
4c4e409c | 337 | |
c906108c | 338 | /* We are at the first instruction we care about. */ |
20d2ca3e | 339 | observer_notify_inferior_created (¤t_target, from_tty); |
c906108c | 340 | /* Pedal to the metal... */ |
2acceee2 | 341 | proceed ((CORE_ADDR) -1, TARGET_SIGNAL_0, 0); |
c906108c SS |
342 | } |
343 | ||
344 | #if !defined(CHILD_POST_STARTUP_INFERIOR) | |
345 | void | |
39f77062 | 346 | child_post_startup_inferior (ptid_t ptid) |
c906108c SS |
347 | { |
348 | /* This version of Unix doesn't require a meaningful "post startup inferior" | |
349 | operation by a debugger. | |
c5aa993b | 350 | */ |
c906108c SS |
351 | } |
352 | #endif | |
353 | ||
354 | #if !defined(CHILD_ACKNOWLEDGE_CREATED_INFERIOR) | |
355 | void | |
fba45db2 | 356 | child_acknowledge_created_inferior (int pid) |
c906108c SS |
357 | { |
358 | /* This version of Unix doesn't require a meaningful "acknowledge created inferior" | |
359 | operation by a debugger. | |
c5aa993b | 360 | */ |
c906108c SS |
361 | } |
362 | #endif | |
363 | ||
364 | ||
c906108c | 365 | #if !defined(CHILD_INSERT_FORK_CATCHPOINT) |
fa113d1a | 366 | void |
fba45db2 | 367 | child_insert_fork_catchpoint (int pid) |
c906108c | 368 | { |
fa113d1a AC |
369 | /* This version of Unix doesn't support notification of fork |
370 | events. */ | |
c906108c SS |
371 | } |
372 | #endif | |
373 | ||
374 | #if !defined(CHILD_REMOVE_FORK_CATCHPOINT) | |
375 | int | |
fba45db2 | 376 | child_remove_fork_catchpoint (int pid) |
c906108c SS |
377 | { |
378 | /* This version of Unix doesn't support notification of fork events. */ | |
379 | return 0; | |
380 | } | |
381 | #endif | |
382 | ||
383 | #if !defined(CHILD_INSERT_VFORK_CATCHPOINT) | |
fa113d1a | 384 | void |
fba45db2 | 385 | child_insert_vfork_catchpoint (int pid) |
c906108c | 386 | { |
fa113d1a AC |
387 | /* This version of Unix doesn't support notification of vfork |
388 | events. */ | |
c906108c SS |
389 | } |
390 | #endif | |
391 | ||
392 | #if !defined(CHILD_REMOVE_VFORK_CATCHPOINT) | |
393 | int | |
fba45db2 | 394 | child_remove_vfork_catchpoint (int pid) |
c906108c SS |
395 | { |
396 | /* This version of Unix doesn't support notification of vfork events. */ | |
397 | return 0; | |
398 | } | |
399 | #endif | |
400 | ||
6604731b DJ |
401 | #if !defined(CHILD_FOLLOW_FORK) |
402 | int | |
ee057212 | 403 | child_follow_fork (struct target_ops *ops, int follow_child) |
c906108c | 404 | { |
6604731b DJ |
405 | /* This version of Unix doesn't support following fork or vfork events. */ |
406 | return 0; | |
c906108c SS |
407 | } |
408 | #endif | |
409 | ||
410 | #if !defined(CHILD_INSERT_EXEC_CATCHPOINT) | |
fa113d1a | 411 | void |
fba45db2 | 412 | child_insert_exec_catchpoint (int pid) |
c906108c | 413 | { |
fa113d1a AC |
414 | /* This version of Unix doesn't support notification of exec |
415 | events. */ | |
c906108c SS |
416 | } |
417 | #endif | |
418 | ||
419 | #if !defined(CHILD_REMOVE_EXEC_CATCHPOINT) | |
420 | int | |
fba45db2 | 421 | child_remove_exec_catchpoint (int pid) |
c906108c SS |
422 | { |
423 | /* This version of Unix doesn't support notification of exec events. */ | |
424 | return 0; | |
425 | } | |
426 | #endif | |
427 | ||
c906108c SS |
428 | #if !defined(CHILD_REPORTED_EXEC_EVENTS_PER_EXEC_CALL) |
429 | int | |
fba45db2 | 430 | child_reported_exec_events_per_exec_call (void) |
c906108c SS |
431 | { |
432 | /* This version of Unix doesn't support notification of exec events. | |
c5aa993b | 433 | */ |
c906108c SS |
434 | return 1; |
435 | } | |
436 | #endif | |
437 | ||
c906108c SS |
438 | #if !defined(CHILD_HAS_EXITED) |
439 | int | |
fba45db2 | 440 | child_has_exited (int pid, int wait_status, int *exit_status) |
c906108c SS |
441 | { |
442 | if (WIFEXITED (wait_status)) | |
443 | { | |
444 | *exit_status = WEXITSTATUS (wait_status); | |
445 | return 1; | |
446 | } | |
447 | ||
448 | if (WIFSIGNALED (wait_status)) | |
449 | { | |
c5aa993b | 450 | *exit_status = 0; /* ?? Don't know what else to say here. */ |
c906108c SS |
451 | return 1; |
452 | } | |
453 | ||
454 | /* ?? Do we really need to consult the event state, too? Assume the | |
c5aa993b | 455 | wait_state alone suffices. |
c906108c SS |
456 | */ |
457 | return 0; | |
458 | } | |
459 | #endif | |
460 | ||
461 | ||
462 | static void | |
fba45db2 | 463 | child_mourn_inferior (void) |
c906108c | 464 | { |
1df84f13 | 465 | unpush_target (&deprecated_child_ops); |
c906108c SS |
466 | generic_mourn_inferior (); |
467 | } | |
468 | ||
469 | static int | |
fba45db2 | 470 | child_can_run (void) |
c906108c SS |
471 | { |
472 | /* This variable is controlled by modules that sit atop inftarg that may layer | |
473 | their own process structure atop that provided here. hpux-thread.c does | |
474 | this because of the Hpux user-mode level thread model. */ | |
475 | ||
476 | return !child_suppress_run; | |
477 | } | |
478 | ||
479 | /* Send a SIGINT to the process group. This acts just like the user typed a | |
480 | ^C on the controlling terminal. | |
481 | ||
482 | XXX - This may not be correct for all systems. Some may want to use | |
483 | killpg() instead of kill (-pgrp). */ | |
484 | ||
485 | static void | |
fba45db2 | 486 | child_stop (void) |
c906108c | 487 | { |
c906108c SS |
488 | kill (-inferior_process_group, SIGINT); |
489 | } | |
490 | ||
491 | #if !defined(CHILD_ENABLE_EXCEPTION_CALLBACK) | |
492 | struct symtab_and_line * | |
fba45db2 | 493 | child_enable_exception_callback (enum exception_event_kind kind, int enable) |
c906108c SS |
494 | { |
495 | return (struct symtab_and_line *) NULL; | |
496 | } | |
497 | #endif | |
498 | ||
499 | #if !defined(CHILD_GET_CURRENT_EXCEPTION_EVENT) | |
500 | struct exception_event_record * | |
fba45db2 | 501 | child_get_current_exception_event (void) |
c906108c SS |
502 | { |
503 | return (struct exception_event_record *) NULL; | |
504 | } | |
505 | #endif | |
506 | ||
507 | ||
508 | #if !defined(CHILD_PID_TO_EXEC_FILE) | |
509 | char * | |
fba45db2 | 510 | child_pid_to_exec_file (int pid) |
c906108c SS |
511 | { |
512 | /* This version of Unix doesn't support translation of a process ID | |
513 | to the filename of the executable file. | |
c5aa993b | 514 | */ |
c906108c SS |
515 | return NULL; |
516 | } | |
517 | #endif | |
518 | ||
519 | char * | |
fba45db2 | 520 | child_core_file_to_sym_file (char *core) |
c906108c SS |
521 | { |
522 | /* The target stratum for a running executable need not support | |
523 | this operation. | |
c5aa993b | 524 | */ |
c906108c SS |
525 | return NULL; |
526 | } | |
f168dd80 AC |
527 | |
528 | /* Perform a partial transfer to/from the specified object. For | |
529 | memory transfers, fall back to the old memory xfer functions. */ | |
530 | ||
531 | static LONGEST | |
8aa91c1e | 532 | child_xfer_partial (struct target_ops *ops, enum target_object object, |
6c932e54 AC |
533 | const char *annex, gdb_byte *readbuf, |
534 | const gdb_byte *writebuf, ULONGEST offset, LONGEST len) | |
f168dd80 AC |
535 | { |
536 | switch (object) | |
537 | { | |
538 | case TARGET_OBJECT_MEMORY: | |
539 | if (readbuf) | |
540 | return child_xfer_memory (offset, readbuf, len, 0/*write*/, | |
541 | NULL, ops); | |
542 | if (writebuf) | |
f929a579 | 543 | return child_xfer_memory (offset, (void *) writebuf, len, 1/*write*/, |
f168dd80 AC |
544 | NULL, ops); |
545 | return -1; | |
546 | ||
f168dd80 AC |
547 | case TARGET_OBJECT_UNWIND_TABLE: |
548 | #ifndef NATIVE_XFER_UNWIND_TABLE | |
549 | #define NATIVE_XFER_UNWIND_TABLE(OPS,OBJECT,ANNEX,WRITEBUF,READBUF,OFFSET,LEN) (-1) | |
550 | #endif | |
8aa91c1e AC |
551 | return NATIVE_XFER_UNWIND_TABLE (ops, object, annex, readbuf, writebuf, |
552 | offset, len); | |
f168dd80 | 553 | |
f168dd80 | 554 | case TARGET_OBJECT_AUXV: |
2146d243 RM |
555 | #ifndef NATIVE_XFER_AUXV |
556 | #define NATIVE_XFER_AUXV(OPS,OBJECT,ANNEX,WRITEBUF,READBUF,OFFSET,LEN) (-1) | |
f168dd80 | 557 | #endif |
2146d243 RM |
558 | return NATIVE_XFER_AUXV (ops, object, annex, readbuf, writebuf, |
559 | offset, len); | |
f168dd80 AC |
560 | |
561 | default: | |
562 | return -1; | |
563 | } | |
564 | } | |
c906108c | 565 | |
ed9a39eb JM |
566 | #if !defined(CHILD_PID_TO_STR) |
567 | char * | |
39f77062 | 568 | child_pid_to_str (ptid_t ptid) |
ed9a39eb | 569 | { |
39f77062 | 570 | return normal_pid_to_str (ptid); |
ed9a39eb JM |
571 | } |
572 | #endif | |
c906108c | 573 | |
c906108c | 574 | static void |
fba45db2 | 575 | init_child_ops (void) |
c906108c | 576 | { |
1df84f13 AC |
577 | deprecated_child_ops.to_shortname = "child"; |
578 | deprecated_child_ops.to_longname = "Unix child process"; | |
579 | deprecated_child_ops.to_doc = "Unix child process (started by the \"run\" command)."; | |
580 | deprecated_child_ops.to_open = child_open; | |
581 | deprecated_child_ops.to_attach = child_attach; | |
582 | deprecated_child_ops.to_post_attach = child_post_attach; | |
583 | deprecated_child_ops.to_detach = child_detach; | |
584 | deprecated_child_ops.to_resume = child_resume; | |
585 | deprecated_child_ops.to_wait = child_wait; | |
586 | deprecated_child_ops.to_fetch_registers = fetch_inferior_registers; | |
587 | deprecated_child_ops.to_store_registers = store_inferior_registers; | |
588 | deprecated_child_ops.to_prepare_to_store = child_prepare_to_store; | |
c8e73a31 | 589 | deprecated_child_ops.deprecated_xfer_memory = child_xfer_memory; |
1df84f13 AC |
590 | deprecated_child_ops.to_xfer_partial = child_xfer_partial; |
591 | deprecated_child_ops.to_files_info = child_files_info; | |
592 | deprecated_child_ops.to_insert_breakpoint = memory_insert_breakpoint; | |
593 | deprecated_child_ops.to_remove_breakpoint = memory_remove_breakpoint; | |
594 | deprecated_child_ops.to_terminal_init = terminal_init_inferior; | |
595 | deprecated_child_ops.to_terminal_inferior = terminal_inferior; | |
596 | deprecated_child_ops.to_terminal_ours_for_output = terminal_ours_for_output; | |
597 | deprecated_child_ops.to_terminal_save_ours = terminal_save_ours; | |
598 | deprecated_child_ops.to_terminal_ours = terminal_ours; | |
599 | deprecated_child_ops.to_terminal_info = child_terminal_info; | |
600 | deprecated_child_ops.to_kill = kill_inferior; | |
601 | deprecated_child_ops.to_create_inferior = child_create_inferior; | |
602 | deprecated_child_ops.to_post_startup_inferior = child_post_startup_inferior; | |
603 | deprecated_child_ops.to_acknowledge_created_inferior = child_acknowledge_created_inferior; | |
604 | deprecated_child_ops.to_insert_fork_catchpoint = child_insert_fork_catchpoint; | |
605 | deprecated_child_ops.to_remove_fork_catchpoint = child_remove_fork_catchpoint; | |
606 | deprecated_child_ops.to_insert_vfork_catchpoint = child_insert_vfork_catchpoint; | |
607 | deprecated_child_ops.to_remove_vfork_catchpoint = child_remove_vfork_catchpoint; | |
608 | deprecated_child_ops.to_follow_fork = child_follow_fork; | |
609 | deprecated_child_ops.to_insert_exec_catchpoint = child_insert_exec_catchpoint; | |
610 | deprecated_child_ops.to_remove_exec_catchpoint = child_remove_exec_catchpoint; | |
611 | deprecated_child_ops.to_reported_exec_events_per_exec_call = child_reported_exec_events_per_exec_call; | |
612 | deprecated_child_ops.to_has_exited = child_has_exited; | |
613 | deprecated_child_ops.to_mourn_inferior = child_mourn_inferior; | |
614 | deprecated_child_ops.to_can_run = child_can_run; | |
615 | deprecated_child_ops.to_thread_alive = child_thread_alive; | |
616 | deprecated_child_ops.to_pid_to_str = child_pid_to_str; | |
617 | deprecated_child_ops.to_stop = child_stop; | |
618 | deprecated_child_ops.to_enable_exception_callback = child_enable_exception_callback; | |
619 | deprecated_child_ops.to_get_current_exception_event = child_get_current_exception_event; | |
620 | deprecated_child_ops.to_pid_to_exec_file = child_pid_to_exec_file; | |
621 | deprecated_child_ops.to_stratum = process_stratum; | |
622 | deprecated_child_ops.to_has_all_memory = 1; | |
623 | deprecated_child_ops.to_has_memory = 1; | |
624 | deprecated_child_ops.to_has_stack = 1; | |
625 | deprecated_child_ops.to_has_registers = 1; | |
626 | deprecated_child_ops.to_has_execution = 1; | |
627 | deprecated_child_ops.to_magic = OPS_MAGIC; | |
c906108c SS |
628 | } |
629 | ||
630 | void | |
fba45db2 | 631 | _initialize_inftarg (void) |
c906108c SS |
632 | { |
633 | #ifdef HAVE_OPTIONAL_PROC_FS | |
634 | char procname[32]; | |
635 | int fd; | |
636 | ||
637 | /* If we have an optional /proc filesystem (e.g. under OSF/1), | |
638 | don't add ptrace support if we can access the running GDB via /proc. */ | |
639 | #ifndef PROC_NAME_FMT | |
640 | #define PROC_NAME_FMT "/proc/%05d" | |
641 | #endif | |
642 | sprintf (procname, PROC_NAME_FMT, getpid ()); | |
bde58177 AC |
643 | fd = open (procname, O_RDONLY); |
644 | if (fd >= 0) | |
c906108c SS |
645 | { |
646 | close (fd); | |
647 | return; | |
648 | } | |
649 | #endif | |
650 | ||
651 | init_child_ops (); | |
1df84f13 | 652 | add_target (&deprecated_child_ops); |
c906108c | 653 | } |