Update/correct copyright notices.
[deliverable/binutils-gdb.git] / gdb / inftarg.c
1 /* Target-vector operations for controlling Unix child processes, for GDB.
2 Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000
3 Free Software Foundation, Inc.
4 Contributed by Cygnus Support.
5
6 ## Contains temporary hacks..
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 2 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, write to the Free Software
22 Foundation, Inc., 59 Temple Place - Suite 330,
23 Boston, MA 02111-1307, USA. */
24
25 #include "defs.h"
26 #include "frame.h" /* required by inferior.h */
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
36 #include "gdb_wait.h"
37
38 extern struct symtab_and_line *child_enable_exception_callback (enum
39 exception_event_kind,
40 int);
41
42 extern struct exception_event_record
43 *child_get_current_exception_event (void);
44
45 extern void _initialize_inftarg (void);
46
47 static void child_prepare_to_store (void);
48
49 #ifndef CHILD_WAIT
50 static int child_wait (int, struct target_waitstatus *);
51 #endif /* CHILD_WAIT */
52
53 #if !defined(CHILD_POST_WAIT)
54 void child_post_wait (int, int);
55 #endif
56
57 static void child_open (char *, int);
58
59 static void child_files_info (struct target_ops *);
60
61 static void child_detach (char *, int);
62
63 static void child_detach_from_process (int, char *, int, int);
64
65 static void child_attach (char *, int);
66
67 static void child_attach_to_process (char *, int, int);
68
69 #if !defined(CHILD_POST_ATTACH)
70 extern void child_post_attach (int);
71 #endif
72
73 static void child_require_attach (char *, int);
74
75 static void child_require_detach (int, char *, int);
76
77 static void ptrace_me (void);
78
79 static void ptrace_him (int);
80
81 static void child_create_inferior (char *, char *, char **);
82
83 static void child_mourn_inferior (void);
84
85 static int child_can_run (void);
86
87 static void child_stop (void);
88
89 #ifndef CHILD_THREAD_ALIVE
90 int child_thread_alive (int);
91 #endif
92
93 static void init_child_ops (void);
94
95 extern char **environ;
96
97 struct target_ops child_ops;
98
99 int 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
106 /*## */
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 */
112 int not_same_real_pid = 1;
113 /*## */
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
119 static int
120 child_wait (int pid, struct target_waitstatus *ourstatus)
121 {
122 int save_errno;
123 int status;
124 char *execd_pathname = NULL;
125 int exit_status;
126 int related_pid;
127 int syscall_id;
128 enum target_waitkind kind;
129
130 do
131 {
132 set_sigint_trap (); /* Causes SIGINT to be passed on to the
133 attached process. */
134 set_sigio_trap ();
135
136 pid = ptrace_wait (inferior_pid, &status);
137
138 save_errno = errno;
139
140 clear_sigio_trap ();
141
142 clear_sigint_trap ();
143
144 if (pid == -1)
145 {
146 if (save_errno == EINTR)
147 continue;
148
149 fprintf_unfiltered (gdb_stderr, "Child process unexpectedly missing: %s.\n",
150 safe_strerror (save_errno));
151
152 /* Claim it exited with unknown signal. */
153 ourstatus->kind = TARGET_WAITKIND_SIGNALLED;
154 ourstatus->value.sig = TARGET_SIGNAL_UNKNOWN;
155 return -1;
156 }
157
158 /* Did it exit?
159 */
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 */
218 /* hack for thread testing */
219 }
220 while ((pid != inferior_pid) && not_same_real_pid);
221 /*## */
222
223 store_waitstatus (ourstatus, status);
224 return pid;
225 }
226 #endif /* CHILD_WAIT */
227
228 #if !defined(CHILD_POST_WAIT)
229 void
230 child_post_wait (int pid, int wait_status)
231 {
232 /* This version of Unix doesn't require a meaningful "post wait"
233 operation.
234 */
235 }
236 #endif
237
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. */
246 int
247 child_thread_alive (int pid)
248 {
249 return (kill (pid, 0) != -1);
250 }
251
252 #endif
253
254 static void
255 child_attach_to_process (char *args, int from_tty, int after_fork)
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
274 if (pid == getpid ()) /* Trying to masturbate? */
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)
282 printf_unfiltered ("Attaching after fork to %s\n",
283 target_pid_to_str (pid));
284 else if (exec_file)
285 printf_unfiltered ("Attaching to program: %s, %s\n", exec_file,
286 target_pid_to_str (pid));
287 else
288 printf_unfiltered ("Attaching to %s\n", target_pid_to_str (pid));
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 }
301 #endif /* ATTACH_DETACH */
302 }
303
304
305 /* Attach to process PID, then initialize for debugging it. */
306
307 static void
308 child_attach (char *args, int from_tty)
309 {
310 child_attach_to_process (args, from_tty, 0);
311 }
312
313 #if !defined(CHILD_POST_ATTACH)
314 void
315 child_post_attach (int pid)
316 {
317 /* This version of Unix doesn't require a meaningful "post attach"
318 operation by a debugger. */
319 }
320 #endif
321
322 static void
323 child_require_attach (char *args, int from_tty)
324 {
325 child_attach_to_process (args, from_tty, 1);
326 }
327
328 static void
329 child_detach_from_process (int pid, char *args, int from_tty, int after_fork)
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 = "";
340 if (after_fork)
341 printf_unfiltered ("Detaching after fork from %s\n",
342 target_pid_to_str (pid));
343 else
344 printf_unfiltered ("Detaching from program: %s, %s\n", exec_file,
345 target_pid_to_str (pid));
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
369 static void
370 child_detach (char *args, int from_tty)
371 {
372 child_detach_from_process (inferior_pid, args, from_tty, 0);
373 inferior_pid = 0;
374 unpush_target (&child_ops);
375 }
376
377 static void
378 child_require_detach (int pid, char *args, int from_tty)
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
390 static void
391 child_prepare_to_store (void)
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
400 static void
401 child_files_info (struct target_ops *ignore)
402 {
403 printf_unfiltered ("\tUsing the running image of %s %s.\n",
404 attach_flag ? "attached" : "child", target_pid_to_str (inferior_pid));
405 }
406
407 /* ARGSUSED */
408 static void
409 child_open (char *arg, int from_tty)
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
417 static void
418 ptrace_me (void)
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
427 static void
428 ptrace_him (int pid)
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.
436 */
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.
448 */
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
457 static void
458 child_create_inferior (char *exec_file, char *allargs, char **env)
459 {
460 #ifdef HPUXHPPA
461 fork_inferior (exec_file, allargs, env, ptrace_me, ptrace_him, pre_fork_inferior, NULL);
462 #else
463 fork_inferior (exec_file, allargs, env, ptrace_me, ptrace_him, NULL, NULL);
464 #endif
465 /* We are at the first instruction we care about. */
466 /* Pedal to the metal... */
467 proceed ((CORE_ADDR) -1, TARGET_SIGNAL_0, 0);
468 }
469
470 #if !defined(CHILD_POST_STARTUP_INFERIOR)
471 void
472 child_post_startup_inferior (int pid)
473 {
474 /* This version of Unix doesn't require a meaningful "post startup inferior"
475 operation by a debugger.
476 */
477 }
478 #endif
479
480 #if !defined(CHILD_ACKNOWLEDGE_CREATED_INFERIOR)
481 void
482 child_acknowledge_created_inferior (int pid)
483 {
484 /* This version of Unix doesn't require a meaningful "acknowledge created inferior"
485 operation by a debugger.
486 */
487 }
488 #endif
489
490
491 void
492 child_clone_and_follow_inferior (int child_pid, int *followed_child)
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.
498 */
499 }
500
501
502 #if !defined(CHILD_POST_FOLLOW_INFERIOR_BY_CLONE)
503 void
504 child_post_follow_inferior_by_clone (void)
505 {
506 /* This version of Unix doesn't require a meaningful "post follow inferior"
507 operation by a clone debugger.
508 */
509 }
510 #endif
511
512 #if !defined(CHILD_INSERT_FORK_CATCHPOINT)
513 int
514 child_insert_fork_catchpoint (int pid)
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)
522 int
523 child_remove_fork_catchpoint (int pid)
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)
531 int
532 child_insert_vfork_catchpoint (int pid)
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)
540 int
541 child_remove_vfork_catchpoint (int pid)
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)
549 int
550 child_has_forked (int pid, int *child_pid)
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)
559 int
560 child_has_vforked (int pid, int *child_pid)
561 {
562 /* This version of Unix doesn't support notification of vfork events.
563 */
564 return 0;
565 }
566 #endif
567
568
569 #if !defined(CHILD_CAN_FOLLOW_VFORK_PRIOR_TO_EXEC)
570 int
571 child_can_follow_vfork_prior_to_exec (void)
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.
576 */
577 return 0;
578 }
579 #endif
580
581
582 #if !defined(CHILD_POST_FOLLOW_VFORK)
583 void
584 child_post_follow_vfork (int parent_pid, int followed_parent, int child_pid,
585 int followed_child)
586 {
587 /* This version of Unix doesn't require a meaningful "post follow vfork"
588 operation by a clone debugger.
589 */
590 }
591 #endif
592
593 #if !defined(CHILD_INSERT_EXEC_CATCHPOINT)
594 int
595 child_insert_exec_catchpoint (int pid)
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)
603 int
604 child_remove_exec_catchpoint (int pid)
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)
612 int
613 child_has_execd (int pid, char **execd_pathname)
614 {
615 /* This version of Unix doesn't support notification of exec events.
616 */
617 return 0;
618 }
619 #endif
620
621
622 #if !defined(CHILD_REPORTED_EXEC_EVENTS_PER_EXEC_CALL)
623 int
624 child_reported_exec_events_per_exec_call (void)
625 {
626 /* This version of Unix doesn't support notification of exec events.
627 */
628 return 1;
629 }
630 #endif
631
632
633 #if !defined(CHILD_HAS_SYSCALL_EVENT)
634 int
635 child_has_syscall_event (int pid, enum target_waitkind *kind, int *syscall_id)
636 {
637 /* This version of Unix doesn't support notification of syscall events.
638 */
639 return 0;
640 }
641 #endif
642
643
644 #if !defined(CHILD_HAS_EXITED)
645 int
646 child_has_exited (int pid, int wait_status, int *exit_status)
647 {
648 if (WIFEXITED (wait_status))
649 {
650 *exit_status = WEXITSTATUS (wait_status);
651 return 1;
652 }
653
654 if (WIFSIGNALED (wait_status))
655 {
656 *exit_status = 0; /* ?? Don't know what else to say here. */
657 return 1;
658 }
659
660 /* ?? Do we really need to consult the event state, too? Assume the
661 wait_state alone suffices.
662 */
663 return 0;
664 }
665 #endif
666
667
668 static void
669 child_mourn_inferior (void)
670 {
671 unpush_target (&child_ops);
672 generic_mourn_inferior ();
673 }
674
675 static int
676 child_can_run (void)
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
691 static void
692 child_stop (void)
693 {
694 extern pid_t inferior_process_group;
695
696 kill (-inferior_process_group, SIGINT);
697 }
698
699 #if !defined(CHILD_ENABLE_EXCEPTION_CALLBACK)
700 struct symtab_and_line *
701 child_enable_exception_callback (enum exception_event_kind kind, int enable)
702 {
703 return (struct symtab_and_line *) NULL;
704 }
705 #endif
706
707 #if !defined(CHILD_GET_CURRENT_EXCEPTION_EVENT)
708 struct exception_event_record *
709 child_get_current_exception_event (void)
710 {
711 return (struct exception_event_record *) NULL;
712 }
713 #endif
714
715
716 #if !defined(CHILD_PID_TO_EXEC_FILE)
717 char *
718 child_pid_to_exec_file (int pid)
719 {
720 /* This version of Unix doesn't support translation of a process ID
721 to the filename of the executable file.
722 */
723 return NULL;
724 }
725 #endif
726
727 char *
728 child_core_file_to_sym_file (char *core)
729 {
730 /* The target stratum for a running executable need not support
731 this operation.
732 */
733 return NULL;
734 }
735 \f
736
737 #if !defined(CHILD_PID_TO_STR)
738 char *
739 child_pid_to_str (int pid)
740 {
741 return normal_pid_to_str (pid);
742 }
743 #endif
744
745 static void
746 init_child_ops (void)
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;
795 child_ops.to_pid_to_str = child_pid_to_str;
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
810 void
811 _initialize_inftarg (void)
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.063441 seconds and 5 git commands to generate.