Update/correct copyright notices.
[deliverable/binutils-gdb.git] / gdb / inftarg.c
CommitLineData
c906108c 1/* Target-vector operations for controlling Unix child processes, for GDB.
b6ba6518
KB
2 Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000
3 Free Software Foundation, Inc.
c906108c
SS
4 Contributed by Cygnus Support.
5
c5aa993b 6 ## Contains temporary hacks..
c906108c 7
c5aa993b 8 This file is part of GDB.
c906108c 9
c5aa993b
JM
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 2 of the License, or
13 (at your option) any later version.
c906108c 14
c5aa993b
JM
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.
c906108c 19
c5aa993b
JM
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place - Suite 330,
23 Boston, MA 02111-1307, USA. */
c906108c
SS
24
25#include "defs.h"
c5aa993b 26#include "frame.h" /* required by inferior.h */
c906108c
SS
27#include "inferior.h"
28#include "target.h"
29#include "gdbcore.h"
30#include "command.h"
31#include "gdb_stat.h"
32#include <signal.h>
33#include <sys/types.h>
34#include <fcntl.h>
35
03f2053f 36#include "gdb_wait.h"
c906108c 37
a14ed312
KB
38extern struct symtab_and_line *child_enable_exception_callback (enum
39 exception_event_kind,
40 int);
c906108c 41
a14ed312
KB
42extern struct exception_event_record
43 *child_get_current_exception_event (void);
c906108c 44
a14ed312 45extern void _initialize_inftarg (void);
c906108c 46
a14ed312 47static void child_prepare_to_store (void);
c906108c
SS
48
49#ifndef CHILD_WAIT
a14ed312 50static int child_wait (int, struct target_waitstatus *);
c906108c
SS
51#endif /* CHILD_WAIT */
52
53#if !defined(CHILD_POST_WAIT)
a14ed312 54void child_post_wait (int, int);
c906108c
SS
55#endif
56
a14ed312 57static void child_open (char *, int);
c906108c 58
a14ed312 59static void child_files_info (struct target_ops *);
c906108c 60
a14ed312 61static void child_detach (char *, int);
c906108c 62
a14ed312 63static void child_detach_from_process (int, char *, int, int);
c906108c 64
a14ed312 65static void child_attach (char *, int);
c906108c 66
a14ed312 67static void child_attach_to_process (char *, int, int);
c906108c
SS
68
69#if !defined(CHILD_POST_ATTACH)
a14ed312 70extern void child_post_attach (int);
c906108c
SS
71#endif
72
a14ed312 73static void child_require_attach (char *, int);
c906108c 74
a14ed312 75static void child_require_detach (int, char *, int);
c906108c 76
a14ed312 77static void ptrace_me (void);
c906108c 78
a14ed312 79static void ptrace_him (int);
c906108c 80
a14ed312 81static void child_create_inferior (char *, char *, char **);
c906108c 82
a14ed312 83static void child_mourn_inferior (void);
c906108c 84
a14ed312 85static int child_can_run (void);
c906108c 86
a14ed312 87static void child_stop (void);
c906108c
SS
88
89#ifndef CHILD_THREAD_ALIVE
a14ed312 90int child_thread_alive (int);
c906108c
SS
91#endif
92
a14ed312 93static void init_child_ops (void);
c906108c
SS
94
95extern char **environ;
96
97struct target_ops child_ops;
98
99int child_suppress_run = 0; /* Non-zero if inftarg should pretend not to
100 be a runnable target. Used by targets
101 that can sit atop inftarg, such as HPUX
102 thread support. */
103
104#ifndef CHILD_WAIT
105
c5aa993b 106/*## */
c906108c
SS
107/* Enable HACK for ttrace work. In
108 * infttrace.c/require_notification_of_events,
109 * this is set to 0 so that the loop in child_wait
110 * won't loop.
111 */
112int not_same_real_pid = 1;
c5aa993b 113/*## */
c906108c
SS
114
115
116/* Wait for child to do something. Return pid of child, or -1 in case
117 of error; store status through argument pointer OURSTATUS. */
118
119static int
fba45db2 120child_wait (int pid, struct target_waitstatus *ourstatus)
c906108c
SS
121{
122 int save_errno;
123 int status;
7a292a7a 124 char *execd_pathname = NULL;
c5aa993b
JM
125 int exit_status;
126 int related_pid;
127 int syscall_id;
128 enum target_waitkind kind;
c906108c 129
c5aa993b
JM
130 do
131 {
132 set_sigint_trap (); /* Causes SIGINT to be passed on to the
133 attached process. */
134 set_sigio_trap ();
c906108c 135
c5aa993b 136 pid = ptrace_wait (inferior_pid, &status);
c906108c 137
c5aa993b 138 save_errno = errno;
c906108c 139
c5aa993b 140 clear_sigio_trap ();
c906108c 141
c5aa993b 142 clear_sigint_trap ();
c906108c 143
c5aa993b
JM
144 if (pid == -1)
145 {
146 if (save_errno == EINTR)
147 continue;
c906108c 148
c5aa993b
JM
149 fprintf_unfiltered (gdb_stderr, "Child process unexpectedly missing: %s.\n",
150 safe_strerror (save_errno));
c906108c 151
c5aa993b
JM
152 /* Claim it exited with unknown signal. */
153 ourstatus->kind = TARGET_WAITKIND_SIGNALLED;
154 ourstatus->value.sig = TARGET_SIGNAL_UNKNOWN;
155 return -1;
156 }
c906108c 157
c5aa993b 158 /* Did it exit?
c906108c 159 */
c5aa993b
JM
160 if (target_has_exited (pid, status, &exit_status))
161 {
162 /* ??rehrauer: For now, ignore this. */
163 continue;
164 }
165
166 if (!target_thread_alive (pid))
167 {
168 ourstatus->kind = TARGET_WAITKIND_SPURIOUS;
169 return pid;
170 }
171
172 if (target_has_forked (pid, &related_pid)
173 && ((pid == inferior_pid) || (related_pid == inferior_pid)))
174 {
175 ourstatus->kind = TARGET_WAITKIND_FORKED;
176 ourstatus->value.related_pid = related_pid;
177 return pid;
178 }
179
180 if (target_has_vforked (pid, &related_pid)
181 && ((pid == inferior_pid) || (related_pid == inferior_pid)))
182 {
183 ourstatus->kind = TARGET_WAITKIND_VFORKED;
184 ourstatus->value.related_pid = related_pid;
185 return pid;
186 }
187
188 if (target_has_execd (pid, &execd_pathname))
189 {
190 /* Are we ignoring initial exec events? (This is likely because
191 we're in the process of starting up the inferior, and another
192 (older) mechanism handles those.) If so, we'll report this
193 as a regular stop, not an exec.
194 */
195 if (inferior_ignoring_startup_exec_events)
196 {
197 inferior_ignoring_startup_exec_events--;
198 }
199 else
200 {
201 ourstatus->kind = TARGET_WAITKIND_EXECD;
202 ourstatus->value.execd_pathname = execd_pathname;
203 return pid;
204 }
205 }
206
207 /* All we must do with these is communicate their occurrence
208 to wait_for_inferior...
209 */
210 if (target_has_syscall_event (pid, &kind, &syscall_id))
211 {
212 ourstatus->kind = kind;
213 ourstatus->value.syscall_id = syscall_id;
214 return pid;
215 }
216
217 /*## } while (pid != inferior_pid); ## *//* Some other child died or stopped */
c906108c 218/* hack for thread testing */
c5aa993b
JM
219 }
220 while ((pid != inferior_pid) && not_same_real_pid);
221/*## */
c906108c
SS
222
223 store_waitstatus (ourstatus, status);
224 return pid;
225}
226#endif /* CHILD_WAIT */
227
228#if !defined(CHILD_POST_WAIT)
229void
fba45db2 230child_post_wait (int pid, int wait_status)
c906108c
SS
231{
232 /* This version of Unix doesn't require a meaningful "post wait"
233 operation.
c5aa993b 234 */
c906108c
SS
235}
236#endif
c5aa993b 237
c906108c
SS
238
239#ifndef CHILD_THREAD_ALIVE
240
241/* Check to see if the given thread is alive.
242
243 FIXME: Is kill() ever the right way to do this? I doubt it, but
244 for now we're going to try and be compatable with the old thread
245 code. */
246int
fba45db2 247child_thread_alive (int pid)
c906108c
SS
248{
249 return (kill (pid, 0) != -1);
250}
251
252#endif
253
254static void
fba45db2 255child_attach_to_process (char *args, int from_tty, int after_fork)
c906108c
SS
256{
257 if (!args)
258 error_no_arg ("process-id to attach");
259
260#ifndef ATTACH_DETACH
261 error ("Can't attach to a process on this machine.");
262#else
263 {
264 char *exec_file;
265 int pid;
266 char *dummy;
267
268 dummy = args;
269 pid = strtol (args, &dummy, 0);
270 /* Some targets don't set errno on errors, grrr! */
271 if ((pid == 0) && (args == dummy))
272 error ("Illegal process-id: %s\n", args);
273
c5aa993b 274 if (pid == getpid ()) /* Trying to masturbate? */
c906108c
SS
275 error ("I refuse to debug myself!");
276
277 if (from_tty)
278 {
279 exec_file = (char *) get_exec_file (0);
280
281 if (after_fork)
c5aa993b
JM
282 printf_unfiltered ("Attaching after fork to %s\n",
283 target_pid_to_str (pid));
c906108c
SS
284 else if (exec_file)
285 printf_unfiltered ("Attaching to program: %s, %s\n", exec_file,
c5aa993b
JM
286 target_pid_to_str (pid));
287 else
288 printf_unfiltered ("Attaching to %s\n", target_pid_to_str (pid));
c906108c
SS
289
290 gdb_flush (gdb_stdout);
291 }
292
293 if (!after_fork)
294 attach (pid);
295 else
296 REQUIRE_ATTACH (pid);
297
298 inferior_pid = pid;
299 push_target (&child_ops);
300 }
c5aa993b 301#endif /* ATTACH_DETACH */
c906108c
SS
302}
303
304
305/* Attach to process PID, then initialize for debugging it. */
306
307static void
fba45db2 308child_attach (char *args, int from_tty)
c906108c
SS
309{
310 child_attach_to_process (args, from_tty, 0);
311}
312
313#if !defined(CHILD_POST_ATTACH)
314void
fba45db2 315child_post_attach (int pid)
c906108c
SS
316{
317 /* This version of Unix doesn't require a meaningful "post attach"
318 operation by a debugger. */
319}
320#endif
321
322static void
fba45db2 323child_require_attach (char *args, int from_tty)
c906108c
SS
324{
325 child_attach_to_process (args, from_tty, 1);
c5aa993b 326}
c906108c
SS
327
328static void
fba45db2 329child_detach_from_process (int pid, char *args, int from_tty, int after_fork)
c906108c
SS
330{
331#ifdef ATTACH_DETACH
332 {
333 int siggnal = 0;
334
335 if (from_tty)
336 {
337 char *exec_file = get_exec_file (0);
338 if (exec_file == 0)
339 exec_file = "";
c5aa993b
JM
340 if (after_fork)
341 printf_unfiltered ("Detaching after fork from %s\n",
342 target_pid_to_str (pid));
343 else
c906108c 344 printf_unfiltered ("Detaching from program: %s, %s\n", exec_file,
c5aa993b 345 target_pid_to_str (pid));
c906108c
SS
346 gdb_flush (gdb_stdout);
347 }
348 if (args)
349 siggnal = atoi (args);
350
351 if (!after_fork)
352 detach (siggnal);
353 else
354 REQUIRE_DETACH (pid, siggnal);
355 }
356#else
357 error ("This version of Unix does not support detaching a process.");
358#endif
359}
360
361/* Take a program previously attached to and detaches it.
362 The program resumes execution and will no longer stop
363 on signals, etc. We'd better not have left any breakpoints
364 in the program or it'll die when it hits one. For this
365 to work, it may be necessary for the process to have been
366 previously attached. It *might* work if the program was
367 started via the normal ptrace (PTRACE_TRACEME). */
368
369static void
fba45db2 370child_detach (char *args, int from_tty)
c906108c
SS
371{
372 child_detach_from_process (inferior_pid, args, from_tty, 0);
373 inferior_pid = 0;
374 unpush_target (&child_ops);
375}
376
377static void
fba45db2 378child_require_detach (int pid, char *args, int from_tty)
c906108c
SS
379{
380 child_detach_from_process (pid, args, from_tty, 1);
381}
382
383
384/* Get ready to modify the registers array. On machines which store
385 individual registers, this doesn't need to do anything. On machines
386 which store all the registers in one fell swoop, this makes sure
387 that registers contains all the registers from the program being
388 debugged. */
389
390static void
fba45db2 391child_prepare_to_store (void)
c906108c
SS
392{
393#ifdef CHILD_PREPARE_TO_STORE
394 CHILD_PREPARE_TO_STORE ();
395#endif
396}
397
398/* Print status information about what we're accessing. */
399
400static void
fba45db2 401child_files_info (struct target_ops *ignore)
c906108c
SS
402{
403 printf_unfiltered ("\tUsing the running image of %s %s.\n",
c5aa993b 404 attach_flag ? "attached" : "child", target_pid_to_str (inferior_pid));
c906108c
SS
405}
406
407/* ARGSUSED */
408static void
fba45db2 409child_open (char *arg, int from_tty)
c906108c
SS
410{
411 error ("Use the \"run\" command to start a Unix child process.");
412}
413
414/* Stub function which causes the inferior that runs it, to be ptrace-able
415 by its parent process. */
416
417static void
fba45db2 418ptrace_me (void)
c906108c
SS
419{
420 /* "Trace me, Dr. Memory!" */
421 call_ptrace (0, 0, (PTRACE_ARG3_TYPE) 0, 0);
422}
423
424/* Stub function which causes the GDB that runs it, to start ptrace-ing
425 the child process. */
426
c5aa993b 427static void
fba45db2 428ptrace_him (int pid)
c906108c
SS
429{
430 push_target (&child_ops);
431
432 /* On some targets, there must be some explicit synchronization
433 between the parent and child processes after the debugger
434 forks, and before the child execs the debuggee program. This
435 call basically gives permission for the child to exec.
c5aa993b 436 */
c906108c
SS
437
438 target_acknowledge_created_inferior (pid);
439
440 /* START_INFERIOR_TRAPS_EXPECTED is defined in inferior.h,
441 * and will be 1 or 2 depending on whether we're starting
442 * without or with a shell.
443 */
444 startup_inferior (START_INFERIOR_TRAPS_EXPECTED);
445
446 /* On some targets, there must be some explicit actions taken after
447 the inferior has been started up.
c5aa993b 448 */
c906108c
SS
449 target_post_startup_inferior (pid);
450}
451
452/* Start an inferior Unix child process and sets inferior_pid to its pid.
453 EXEC_FILE is the file to run.
454 ALLARGS is a string containing the arguments to the program.
455 ENV is the environment vector to pass. Errors reported with error(). */
456
457static void
fba45db2 458child_create_inferior (char *exec_file, char *allargs, char **env)
c906108c 459{
c906108c 460#ifdef HPUXHPPA
c906108c
SS
461 fork_inferior (exec_file, allargs, env, ptrace_me, ptrace_him, pre_fork_inferior, NULL);
462#else
c5aa993b 463 fork_inferior (exec_file, allargs, env, ptrace_me, ptrace_him, NULL, NULL);
c906108c
SS
464#endif
465 /* We are at the first instruction we care about. */
466 /* Pedal to the metal... */
2acceee2 467 proceed ((CORE_ADDR) -1, TARGET_SIGNAL_0, 0);
c906108c
SS
468}
469
470#if !defined(CHILD_POST_STARTUP_INFERIOR)
471void
fba45db2 472child_post_startup_inferior (int pid)
c906108c
SS
473{
474 /* This version of Unix doesn't require a meaningful "post startup inferior"
475 operation by a debugger.
c5aa993b 476 */
c906108c
SS
477}
478#endif
479
480#if !defined(CHILD_ACKNOWLEDGE_CREATED_INFERIOR)
481void
fba45db2 482child_acknowledge_created_inferior (int pid)
c906108c
SS
483{
484 /* This version of Unix doesn't require a meaningful "acknowledge created inferior"
485 operation by a debugger.
c5aa993b 486 */
c906108c
SS
487}
488#endif
489
490
491void
fba45db2 492child_clone_and_follow_inferior (int child_pid, int *followed_child)
c906108c
SS
493{
494 clone_and_follow_inferior (child_pid, followed_child);
495
496 /* Don't resume CHILD_PID; it's stopped where it ought to be, until
497 the decision gets made elsewhere how to continue it.
c5aa993b 498 */
c906108c
SS
499}
500
501
502#if !defined(CHILD_POST_FOLLOW_INFERIOR_BY_CLONE)
503void
fba45db2 504child_post_follow_inferior_by_clone (void)
c906108c
SS
505{
506 /* This version of Unix doesn't require a meaningful "post follow inferior"
507 operation by a clone debugger.
c5aa993b 508 */
c906108c
SS
509}
510#endif
511
512#if !defined(CHILD_INSERT_FORK_CATCHPOINT)
513int
fba45db2 514child_insert_fork_catchpoint (int pid)
c906108c
SS
515{
516 /* This version of Unix doesn't support notification of fork events. */
517 return 0;
518}
519#endif
520
521#if !defined(CHILD_REMOVE_FORK_CATCHPOINT)
522int
fba45db2 523child_remove_fork_catchpoint (int pid)
c906108c
SS
524{
525 /* This version of Unix doesn't support notification of fork events. */
526 return 0;
527}
528#endif
529
530#if !defined(CHILD_INSERT_VFORK_CATCHPOINT)
531int
fba45db2 532child_insert_vfork_catchpoint (int pid)
c906108c
SS
533{
534 /* This version of Unix doesn't support notification of vfork events. */
535 return 0;
536}
537#endif
538
539#if !defined(CHILD_REMOVE_VFORK_CATCHPOINT)
540int
fba45db2 541child_remove_vfork_catchpoint (int pid)
c906108c
SS
542{
543 /* This version of Unix doesn't support notification of vfork events. */
544 return 0;
545}
546#endif
547
548#if !defined(CHILD_HAS_FORKED)
549int
fba45db2 550child_has_forked (int pid, int *child_pid)
c906108c
SS
551{
552 /* This version of Unix doesn't support notification of fork events. */
553 return 0;
554}
555#endif
556
557
558#if !defined(CHILD_HAS_VFORKED)
559int
fba45db2 560child_has_vforked (int pid, int *child_pid)
c906108c
SS
561{
562 /* This version of Unix doesn't support notification of vfork events.
c5aa993b 563 */
c906108c
SS
564 return 0;
565}
566#endif
567
568
569#if !defined(CHILD_CAN_FOLLOW_VFORK_PRIOR_TO_EXEC)
570int
fba45db2 571child_can_follow_vfork_prior_to_exec (void)
c906108c
SS
572{
573 /* This version of Unix doesn't support notification of vfork events.
574 However, if it did, it probably wouldn't allow vforks to be followed
575 before the following exec.
c5aa993b 576 */
c906108c
SS
577 return 0;
578}
579#endif
580
581
582#if !defined(CHILD_POST_FOLLOW_VFORK)
583void
fba45db2
KB
584child_post_follow_vfork (int parent_pid, int followed_parent, int child_pid,
585 int followed_child)
c906108c
SS
586{
587 /* This version of Unix doesn't require a meaningful "post follow vfork"
588 operation by a clone debugger.
c5aa993b 589 */
c906108c
SS
590}
591#endif
592
593#if !defined(CHILD_INSERT_EXEC_CATCHPOINT)
594int
fba45db2 595child_insert_exec_catchpoint (int pid)
c906108c
SS
596{
597 /* This version of Unix doesn't support notification of exec events. */
598 return 0;
599}
600#endif
601
602#if !defined(CHILD_REMOVE_EXEC_CATCHPOINT)
603int
fba45db2 604child_remove_exec_catchpoint (int pid)
c906108c
SS
605{
606 /* This version of Unix doesn't support notification of exec events. */
607 return 0;
608}
609#endif
610
611#if !defined(CHILD_HAS_EXECD)
612int
fba45db2 613child_has_execd (int pid, char **execd_pathname)
c906108c
SS
614{
615 /* This version of Unix doesn't support notification of exec events.
c5aa993b 616 */
c906108c
SS
617 return 0;
618}
619#endif
620
621
622#if !defined(CHILD_REPORTED_EXEC_EVENTS_PER_EXEC_CALL)
623int
fba45db2 624child_reported_exec_events_per_exec_call (void)
c906108c
SS
625{
626 /* This version of Unix doesn't support notification of exec events.
c5aa993b 627 */
c906108c
SS
628 return 1;
629}
630#endif
631
632
633#if !defined(CHILD_HAS_SYSCALL_EVENT)
634int
fba45db2 635child_has_syscall_event (int pid, enum target_waitkind *kind, int *syscall_id)
c906108c
SS
636{
637 /* This version of Unix doesn't support notification of syscall events.
c5aa993b 638 */
c906108c
SS
639 return 0;
640}
641#endif
642
643
644#if !defined(CHILD_HAS_EXITED)
645int
fba45db2 646child_has_exited (int pid, int wait_status, int *exit_status)
c906108c
SS
647{
648 if (WIFEXITED (wait_status))
649 {
650 *exit_status = WEXITSTATUS (wait_status);
651 return 1;
652 }
653
654 if (WIFSIGNALED (wait_status))
655 {
c5aa993b 656 *exit_status = 0; /* ?? Don't know what else to say here. */
c906108c
SS
657 return 1;
658 }
659
660 /* ?? Do we really need to consult the event state, too? Assume the
c5aa993b 661 wait_state alone suffices.
c906108c
SS
662 */
663 return 0;
664}
665#endif
666
667
668static void
fba45db2 669child_mourn_inferior (void)
c906108c 670{
c906108c 671 unpush_target (&child_ops);
c906108c
SS
672 generic_mourn_inferior ();
673}
674
675static int
fba45db2 676child_can_run (void)
c906108c
SS
677{
678 /* This variable is controlled by modules that sit atop inftarg that may layer
679 their own process structure atop that provided here. hpux-thread.c does
680 this because of the Hpux user-mode level thread model. */
681
682 return !child_suppress_run;
683}
684
685/* Send a SIGINT to the process group. This acts just like the user typed a
686 ^C on the controlling terminal.
687
688 XXX - This may not be correct for all systems. Some may want to use
689 killpg() instead of kill (-pgrp). */
690
691static void
fba45db2 692child_stop (void)
c906108c
SS
693{
694 extern pid_t inferior_process_group;
695
696 kill (-inferior_process_group, SIGINT);
697}
698
699#if !defined(CHILD_ENABLE_EXCEPTION_CALLBACK)
700struct symtab_and_line *
fba45db2 701child_enable_exception_callback (enum exception_event_kind kind, int enable)
c906108c
SS
702{
703 return (struct symtab_and_line *) NULL;
704}
705#endif
706
707#if !defined(CHILD_GET_CURRENT_EXCEPTION_EVENT)
708struct exception_event_record *
fba45db2 709child_get_current_exception_event (void)
c906108c
SS
710{
711 return (struct exception_event_record *) NULL;
712}
713#endif
714
715
716#if !defined(CHILD_PID_TO_EXEC_FILE)
717char *
fba45db2 718child_pid_to_exec_file (int pid)
c906108c
SS
719{
720 /* This version of Unix doesn't support translation of a process ID
721 to the filename of the executable file.
c5aa993b 722 */
c906108c
SS
723 return NULL;
724}
725#endif
726
727char *
fba45db2 728child_core_file_to_sym_file (char *core)
c906108c
SS
729{
730 /* The target stratum for a running executable need not support
731 this operation.
c5aa993b 732 */
c906108c
SS
733 return NULL;
734}
c5aa993b 735\f
c906108c 736
ed9a39eb
JM
737#if !defined(CHILD_PID_TO_STR)
738char *
fba45db2 739child_pid_to_str (int pid)
ed9a39eb
JM
740{
741 return normal_pid_to_str (pid);
742}
743#endif
c906108c 744
c906108c 745static void
fba45db2 746init_child_ops (void)
c906108c
SS
747{
748 child_ops.to_shortname = "child";
749 child_ops.to_longname = "Unix child process";
750 child_ops.to_doc = "Unix child process (started by the \"run\" command).";
751 child_ops.to_open = child_open;
752 child_ops.to_attach = child_attach;
753 child_ops.to_post_attach = child_post_attach;
754 child_ops.to_require_attach = child_require_attach;
755 child_ops.to_detach = child_detach;
756 child_ops.to_require_detach = child_require_detach;
757 child_ops.to_resume = child_resume;
758 child_ops.to_wait = child_wait;
759 child_ops.to_post_wait = child_post_wait;
760 child_ops.to_fetch_registers = fetch_inferior_registers;
761 child_ops.to_store_registers = store_inferior_registers;
762 child_ops.to_prepare_to_store = child_prepare_to_store;
763 child_ops.to_xfer_memory = child_xfer_memory;
764 child_ops.to_files_info = child_files_info;
765 child_ops.to_insert_breakpoint = memory_insert_breakpoint;
766 child_ops.to_remove_breakpoint = memory_remove_breakpoint;
767 child_ops.to_terminal_init = terminal_init_inferior;
768 child_ops.to_terminal_inferior = terminal_inferior;
769 child_ops.to_terminal_ours_for_output = terminal_ours_for_output;
770 child_ops.to_terminal_ours = terminal_ours;
771 child_ops.to_terminal_info = child_terminal_info;
772 child_ops.to_kill = kill_inferior;
773 child_ops.to_create_inferior = child_create_inferior;
774 child_ops.to_post_startup_inferior = child_post_startup_inferior;
775 child_ops.to_acknowledge_created_inferior = child_acknowledge_created_inferior;
776 child_ops.to_clone_and_follow_inferior = child_clone_and_follow_inferior;
777 child_ops.to_post_follow_inferior_by_clone = child_post_follow_inferior_by_clone;
778 child_ops.to_insert_fork_catchpoint = child_insert_fork_catchpoint;
779 child_ops.to_remove_fork_catchpoint = child_remove_fork_catchpoint;
780 child_ops.to_insert_vfork_catchpoint = child_insert_vfork_catchpoint;
781 child_ops.to_remove_vfork_catchpoint = child_remove_vfork_catchpoint;
782 child_ops.to_has_forked = child_has_forked;
783 child_ops.to_has_vforked = child_has_vforked;
784 child_ops.to_can_follow_vfork_prior_to_exec = child_can_follow_vfork_prior_to_exec;
785 child_ops.to_post_follow_vfork = child_post_follow_vfork;
786 child_ops.to_insert_exec_catchpoint = child_insert_exec_catchpoint;
787 child_ops.to_remove_exec_catchpoint = child_remove_exec_catchpoint;
788 child_ops.to_has_execd = child_has_execd;
789 child_ops.to_reported_exec_events_per_exec_call = child_reported_exec_events_per_exec_call;
790 child_ops.to_has_syscall_event = child_has_syscall_event;
791 child_ops.to_has_exited = child_has_exited;
792 child_ops.to_mourn_inferior = child_mourn_inferior;
793 child_ops.to_can_run = child_can_run;
794 child_ops.to_thread_alive = child_thread_alive;
ed9a39eb 795 child_ops.to_pid_to_str = child_pid_to_str;
c906108c
SS
796 child_ops.to_stop = child_stop;
797 child_ops.to_enable_exception_callback = child_enable_exception_callback;
798 child_ops.to_get_current_exception_event = child_get_current_exception_event;
799 child_ops.to_pid_to_exec_file = child_pid_to_exec_file;
800 child_ops.to_core_file_to_sym_file = child_core_file_to_sym_file;
801 child_ops.to_stratum = process_stratum;
802 child_ops.to_has_all_memory = 1;
803 child_ops.to_has_memory = 1;
804 child_ops.to_has_stack = 1;
805 child_ops.to_has_registers = 1;
806 child_ops.to_has_execution = 1;
807 child_ops.to_magic = OPS_MAGIC;
808}
809
810void
fba45db2 811_initialize_inftarg (void)
c906108c
SS
812{
813#ifdef HAVE_OPTIONAL_PROC_FS
814 char procname[32];
815 int fd;
816
817 /* If we have an optional /proc filesystem (e.g. under OSF/1),
818 don't add ptrace support if we can access the running GDB via /proc. */
819#ifndef PROC_NAME_FMT
820#define PROC_NAME_FMT "/proc/%05d"
821#endif
822 sprintf (procname, PROC_NAME_FMT, getpid ());
823 if ((fd = open (procname, O_RDONLY)) >= 0)
824 {
825 close (fd);
826 return;
827 }
828#endif
829
830 init_child_ops ();
831 add_target (&child_ops);
832}
This page took 0.133348 seconds and 4 git commands to generate.