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