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