2003-09-17 Andrew Cagney <cagney@redhat.com>
[deliverable/binutils-gdb.git] / gdb / hppah-nat.c
1 /* Native support code for HPUX PA-RISC.
2 Copyright 1986, 1987, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
3 1998, 1999, 2000, 2001
4 Free Software Foundation, Inc.
5
6 Contributed by the Center for Software Science at the
7 University of Utah (pa-gdb-bugs@cs.utah.edu).
8
9 This file is part of GDB.
10
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 2 of the License, or
14 (at your option) any later version.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 59 Temple Place - Suite 330,
24 Boston, MA 02111-1307, USA. */
25
26
27 #include "defs.h"
28 #include "inferior.h"
29 #include "target.h"
30 #include <sys/ptrace.h>
31 #include "gdbcore.h"
32 #include "gdb_wait.h"
33 #include "regcache.h"
34 #include "gdb_string.h"
35 #include <signal.h>
36
37 extern CORE_ADDR text_end;
38
39 extern int hpux_has_forked (int pid, int *childpid);
40 extern int hpux_has_vforked (int pid, int *childpid);
41 extern int hpux_has_execd (int pid, char **execd_pathname);
42 extern int hpux_has_syscall_event (int pid, enum target_waitkind *kind,
43 int *syscall_id);
44
45 static void fetch_register (int);
46
47 void
48 fetch_inferior_registers (int regno)
49 {
50 if (regno == -1)
51 for (regno = 0; regno < NUM_REGS; regno++)
52 fetch_register (regno);
53 else
54 fetch_register (regno);
55 }
56
57 /* Our own version of the offsetof macro, since we can't assume ANSI C. */
58 #define HPPAH_OFFSETOF(type, member) ((int) (&((type *) 0)->member))
59
60 /* Store our register values back into the inferior.
61 If REGNO is -1, do this for all registers.
62 Otherwise, REGNO specifies which register (so we can save time). */
63
64 void
65 store_inferior_registers (int regno)
66 {
67 unsigned int regaddr;
68 char buf[80];
69 int i;
70 unsigned int offset = U_REGS_OFFSET;
71 int scratch;
72
73 if (regno >= 0)
74 {
75 unsigned int addr, len, offset;
76
77 if (CANNOT_STORE_REGISTER (regno))
78 return;
79
80 offset = 0;
81 len = REGISTER_RAW_SIZE (regno);
82
83 /* Requests for register zero actually want the save_state's
84 ss_flags member. As RM says: "Oh, what a hack!" */
85 if (regno == 0)
86 {
87 save_state_t ss;
88 addr = HPPAH_OFFSETOF (save_state_t, ss_flags);
89 len = sizeof (ss.ss_flags);
90
91 /* Note that ss_flags is always an int, no matter what
92 REGISTER_RAW_SIZE(0) says. Assuming all HP-UX PA machines
93 are big-endian, put it at the least significant end of the
94 value, and zap the rest of the buffer. */
95 offset = REGISTER_RAW_SIZE (0) - len;
96 }
97
98 /* Floating-point registers come from the ss_fpblock area. */
99 else if (regno >= FP0_REGNUM)
100 addr = (HPPAH_OFFSETOF (save_state_t, ss_fpblock)
101 + (DEPRECATED_REGISTER_BYTE (regno) - DEPRECATED_REGISTER_BYTE (FP0_REGNUM)));
102
103 /* Wide registers come from the ss_wide area.
104 I think it's more PC to test (ss_flags & SS_WIDEREGS) to select
105 between ss_wide and ss_narrow than to use the raw register size.
106 But checking ss_flags would require an extra ptrace call for
107 every register reference. Bleah. */
108 else if (len == 8)
109 addr = (HPPAH_OFFSETOF (save_state_t, ss_wide)
110 + DEPRECATED_REGISTER_BYTE (regno));
111
112 /* Narrow registers come from the ss_narrow area. Note that
113 ss_narrow starts with gr1, not gr0. */
114 else if (len == 4)
115 addr = (HPPAH_OFFSETOF (save_state_t, ss_narrow)
116 + (DEPRECATED_REGISTER_BYTE (regno) - DEPRECATED_REGISTER_BYTE (1)));
117 else
118 internal_error (__FILE__, __LINE__,
119 "hppah-nat.c (write_register): unexpected register size");
120
121 #ifdef GDB_TARGET_IS_HPPA_20W
122 /* Unbelieveable. The PC head and tail must be written in 64bit hunks
123 or we will get an error. Worse yet, the oddball ptrace/ttrace
124 layering will not allow us to perform a 64bit register store.
125
126 What a crock. */
127 if (regno == PCOQ_HEAD_REGNUM || regno == PCOQ_TAIL_REGNUM && len == 8)
128 {
129 CORE_ADDR temp;
130
131 temp = *(CORE_ADDR *)&deprecated_registers[DEPRECATED_REGISTER_BYTE (regno)];
132
133 /* Set the priv level (stored in the low two bits of the PC. */
134 temp |= 0x3;
135
136 ttrace_write_reg_64 (PIDGET (inferior_ptid), (CORE_ADDR)addr,
137 (CORE_ADDR)&temp);
138
139 /* If we fail to write the PC, give a true error instead of
140 just a warning. */
141 if (errno != 0)
142 {
143 char *err = safe_strerror (errno);
144 char *msg = alloca (strlen (err) + 128);
145 sprintf (msg, "writing `%s' register: %s",
146 REGISTER_NAME (regno), err);
147 perror_with_name (msg);
148 }
149 return;
150 }
151
152 /* Another crock. HPUX complains if you write a nonzero value to
153 the high part of IPSW. What will it take for HP to catch a
154 clue about building sensible interfaces? */
155 if (regno == IPSW_REGNUM && len == 8)
156 *(int *)&deprecated_registers[DEPRECATED_REGISTER_BYTE (regno)] = 0;
157 #endif
158
159 for (i = 0; i < len; i += sizeof (int))
160 {
161 errno = 0;
162 call_ptrace (PT_WUREGS, PIDGET (inferior_ptid),
163 (PTRACE_ARG3_TYPE) addr + i,
164 *(int *) &deprecated_registers[DEPRECATED_REGISTER_BYTE (regno) + i]);
165 if (errno != 0)
166 {
167 /* Warning, not error, in case we are attached; sometimes
168 the kernel doesn't let us at the registers. */
169 char *err = safe_strerror (errno);
170 char *msg = alloca (strlen (err) + 128);
171 sprintf (msg, "writing `%s' register: %s",
172 REGISTER_NAME (regno), err);
173 /* If we fail to write the PC, give a true error instead of
174 just a warning. */
175 if (regno == PCOQ_HEAD_REGNUM || regno == PCOQ_TAIL_REGNUM)
176 perror_with_name (msg);
177 else
178 warning (msg);
179 return;
180 }
181 }
182 }
183 else
184 for (regno = 0; regno < NUM_REGS; regno++)
185 store_inferior_registers (regno);
186 }
187
188
189 /* Fetch a register's value from the process's U area. */
190 static void
191 fetch_register (int regno)
192 {
193 char buf[MAX_REGISTER_SIZE];
194 unsigned int addr, len, offset;
195 int i;
196
197 offset = 0;
198 len = REGISTER_RAW_SIZE (regno);
199
200 /* Requests for register zero actually want the save_state's
201 ss_flags member. As RM says: "Oh, what a hack!" */
202 if (regno == 0)
203 {
204 save_state_t ss;
205 addr = HPPAH_OFFSETOF (save_state_t, ss_flags);
206 len = sizeof (ss.ss_flags);
207
208 /* Note that ss_flags is always an int, no matter what
209 REGISTER_RAW_SIZE(0) says. Assuming all HP-UX PA machines
210 are big-endian, put it at the least significant end of the
211 value, and zap the rest of the buffer. */
212 offset = REGISTER_RAW_SIZE (0) - len;
213 memset (buf, 0, sizeof (buf));
214 }
215
216 /* Floating-point registers come from the ss_fpblock area. */
217 else if (regno >= FP0_REGNUM)
218 addr = (HPPAH_OFFSETOF (save_state_t, ss_fpblock)
219 + (DEPRECATED_REGISTER_BYTE (regno) - DEPRECATED_REGISTER_BYTE (FP0_REGNUM)));
220
221 /* Wide registers come from the ss_wide area.
222 I think it's more PC to test (ss_flags & SS_WIDEREGS) to select
223 between ss_wide and ss_narrow than to use the raw register size.
224 But checking ss_flags would require an extra ptrace call for
225 every register reference. Bleah. */
226 else if (len == 8)
227 addr = (HPPAH_OFFSETOF (save_state_t, ss_wide)
228 + DEPRECATED_REGISTER_BYTE (regno));
229
230 /* Narrow registers come from the ss_narrow area. Note that
231 ss_narrow starts with gr1, not gr0. */
232 else if (len == 4)
233 addr = (HPPAH_OFFSETOF (save_state_t, ss_narrow)
234 + (DEPRECATED_REGISTER_BYTE (regno) - DEPRECATED_REGISTER_BYTE (1)));
235
236 else
237 internal_error (__FILE__, __LINE__,
238 "hppa-nat.c (fetch_register): unexpected register size");
239
240 for (i = 0; i < len; i += sizeof (int))
241 {
242 errno = 0;
243 /* Copy an int from the U area to buf. Fill the least
244 significant end if len != raw_size. */
245 * (int *) &buf[offset + i] =
246 call_ptrace (PT_RUREGS, PIDGET (inferior_ptid),
247 (PTRACE_ARG3_TYPE) addr + i, 0);
248 if (errno != 0)
249 {
250 /* Warning, not error, in case we are attached; sometimes
251 the kernel doesn't let us at the registers. */
252 char *err = safe_strerror (errno);
253 char *msg = alloca (strlen (err) + 128);
254 sprintf (msg, "reading `%s' register: %s",
255 REGISTER_NAME (regno), err);
256 warning (msg);
257 return;
258 }
259 }
260
261 /* If we're reading an address from the instruction address queue,
262 mask out the bottom two bits --- they contain the privilege
263 level. */
264 if (regno == PCOQ_HEAD_REGNUM || regno == PCOQ_TAIL_REGNUM)
265 buf[len - 1] &= ~0x3;
266
267 supply_register (regno, buf);
268 }
269
270
271 /* Copy LEN bytes to or from inferior's memory starting at MEMADDR
272 to debugger memory starting at MYADDR. Copy to inferior if
273 WRITE is nonzero.
274
275 Returns the length copied, which is either the LEN argument or zero.
276 This xfer function does not do partial moves, since child_ops
277 doesn't allow memory operations to cross below us in the target stack
278 anyway. TARGET is ignored. */
279
280 int
281 child_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
282 struct mem_attrib *mem,
283 struct target_ops *target)
284 {
285 int i;
286 /* Round starting address down to longword boundary. */
287 CORE_ADDR addr = memaddr & - (CORE_ADDR)(sizeof (int));
288 /* Round ending address up; get number of longwords that makes. */
289 int count
290 = (((memaddr + len) - addr) + sizeof (int) - 1) / sizeof (int);
291
292 /* Allocate buffer of that many longwords.
293 Note -- do not use alloca to allocate this buffer since there is no
294 guarantee of when the buffer will actually be deallocated.
295
296 This routine can be called over and over with the same call chain;
297 this (in effect) would pile up all those alloca requests until a call
298 to alloca was made from a point higher than this routine in the
299 call chain. */
300 int *buffer = (int *) xmalloc (count * sizeof (int));
301
302 if (write)
303 {
304 /* Fill start and end extra bytes of buffer with existing memory data. */
305 if (addr != memaddr || len < (int) sizeof (int))
306 {
307 /* Need part of initial word -- fetch it. */
308 buffer[0] = call_ptrace (addr < text_end ? PT_RIUSER : PT_RDUSER,
309 PIDGET (inferior_ptid),
310 (PTRACE_ARG3_TYPE) addr, 0);
311 }
312
313 if (count > 1) /* FIXME, avoid if even boundary */
314 {
315 buffer[count - 1]
316 = call_ptrace (addr < text_end ? PT_RIUSER : PT_RDUSER,
317 PIDGET (inferior_ptid),
318 (PTRACE_ARG3_TYPE) (addr
319 + (count - 1) * sizeof (int)),
320 0);
321 }
322
323 /* Copy data to be written over corresponding part of buffer */
324 memcpy ((char *) buffer + (memaddr & (sizeof (int) - 1)), myaddr, len);
325
326 /* Write the entire buffer. */
327 for (i = 0; i < count; i++, addr += sizeof (int))
328 {
329 int pt_status;
330 int pt_request;
331 /* The HP-UX kernel crashes if you use PT_WDUSER to write into the
332 text segment. FIXME -- does it work to write into the data
333 segment using WIUSER, or do these idiots really expect us to
334 figure out which segment the address is in, so we can use a
335 separate system call for it??! */
336 errno = 0;
337 pt_request = (addr < text_end) ? PT_WIUSER : PT_WDUSER;
338 pt_status = call_ptrace (pt_request,
339 PIDGET (inferior_ptid),
340 (PTRACE_ARG3_TYPE) addr,
341 buffer[i]);
342
343 /* Did we fail? Might we've guessed wrong about which
344 segment this address resides in? Try the other request,
345 and see if that works... */
346 if ((pt_status == -1) && errno)
347 {
348 errno = 0;
349 pt_request = (pt_request == PT_WIUSER) ? PT_WDUSER : PT_WIUSER;
350 pt_status = call_ptrace (pt_request,
351 PIDGET (inferior_ptid),
352 (PTRACE_ARG3_TYPE) addr,
353 buffer[i]);
354
355 /* No, we still fail. Okay, time to punt. */
356 if ((pt_status == -1) && errno)
357 {
358 xfree (buffer);
359 return 0;
360 }
361 }
362 }
363 }
364 else
365 {
366 /* Read all the longwords */
367 for (i = 0; i < count; i++, addr += sizeof (int))
368 {
369 errno = 0;
370 buffer[i] = call_ptrace (addr < text_end ? PT_RIUSER : PT_RDUSER,
371 PIDGET (inferior_ptid),
372 (PTRACE_ARG3_TYPE) addr, 0);
373 if (errno)
374 {
375 xfree (buffer);
376 return 0;
377 }
378 QUIT;
379 }
380
381 /* Copy appropriate bytes out of the buffer. */
382 memcpy (myaddr, (char *) buffer + (memaddr & (sizeof (int) - 1)), len);
383 }
384 xfree (buffer);
385 return len;
386 }
387
388 char *saved_child_execd_pathname = NULL;
389 int saved_vfork_pid;
390 enum {
391 STATE_NONE,
392 STATE_GOT_CHILD,
393 STATE_GOT_EXEC,
394 STATE_GOT_PARENT,
395 STATE_FAKE_EXEC
396 } saved_vfork_state = STATE_NONE;
397
398 int
399 child_follow_fork (int follow_child)
400 {
401 ptid_t last_ptid;
402 struct target_waitstatus last_status;
403 int has_vforked;
404 int parent_pid, child_pid;
405
406 get_last_target_status (&last_ptid, &last_status);
407 has_vforked = (last_status.kind == TARGET_WAITKIND_VFORKED);
408 parent_pid = ptid_get_pid (last_ptid);
409 child_pid = last_status.value.related_pid;
410
411 /* At this point, if we are vforking, breakpoints were already
412 detached from the child in child_wait; and the child has already
413 called execve(). If we are forking, both the parent and child
414 have breakpoints inserted. */
415
416 if (! follow_child)
417 {
418 if (! has_vforked)
419 {
420 detach_breakpoints (child_pid);
421 #ifdef SOLIB_REMOVE_INFERIOR_HOOK
422 SOLIB_REMOVE_INFERIOR_HOOK (child_pid);
423 #endif
424 }
425
426 /* Detach from the child. */
427 printf_unfiltered ("Detaching after fork from %s\n",
428 target_pid_to_str (pid_to_ptid (child_pid)));
429 hppa_require_detach (child_pid, 0);
430
431 /* The parent and child of a vfork share the same address space.
432 Also, on some targets the order in which vfork and exec events
433 are received for parent in child requires some delicate handling
434 of the events.
435
436 For instance, on ptrace-based HPUX we receive the child's vfork
437 event first, at which time the parent has been suspended by the
438 OS and is essentially untouchable until the child's exit or second
439 exec event arrives. At that time, the parent's vfork event is
440 delivered to us, and that's when we see and decide how to follow
441 the vfork. But to get to that point, we must continue the child
442 until it execs or exits. To do that smoothly, all breakpoints
443 must be removed from the child, in case there are any set between
444 the vfork() and exec() calls. But removing them from the child
445 also removes them from the parent, due to the shared-address-space
446 nature of a vfork'd parent and child. On HPUX, therefore, we must
447 take care to restore the bp's to the parent before we continue it.
448 Else, it's likely that we may not stop in the expected place. (The
449 worst scenario is when the user tries to step over a vfork() call;
450 the step-resume bp must be restored for the step to properly stop
451 in the parent after the call completes!)
452
453 Sequence of events, as reported to gdb from HPUX:
454
455 Parent Child Action for gdb to take
456 -------------------------------------------------------
457 1 VFORK Continue child
458 2 EXEC
459 3 EXEC or EXIT
460 4 VFORK
461
462 Now that the child has safely exec'd or exited, we must restore
463 the parent's breakpoints before we continue it. Else, we may
464 cause it run past expected stopping points. */
465
466 if (has_vforked)
467 reattach_breakpoints (parent_pid);
468 }
469 else
470 {
471 /* Needed to keep the breakpoint lists in sync. */
472 if (! has_vforked)
473 detach_breakpoints (child_pid);
474
475 /* Before detaching from the parent, remove all breakpoints from it. */
476 remove_breakpoints ();
477
478 /* Also reset the solib inferior hook from the parent. */
479 #ifdef SOLIB_REMOVE_INFERIOR_HOOK
480 SOLIB_REMOVE_INFERIOR_HOOK (PIDGET (inferior_ptid));
481 #endif
482
483 /* Detach from the parent. */
484 target_detach (NULL, 1);
485
486 /* Attach to the child. */
487 printf_unfiltered ("Attaching after fork to %s\n",
488 target_pid_to_str (pid_to_ptid (child_pid)));
489 hppa_require_attach (child_pid);
490 inferior_ptid = pid_to_ptid (child_pid);
491
492 /* If we vforked, then we've also execed by now. The exec will be
493 reported momentarily. follow_exec () will handle breakpoints, so
494 we don't have to.. */
495 if (!has_vforked)
496 follow_inferior_reset_breakpoints ();
497 }
498
499 if (has_vforked)
500 {
501 /* If we followed the parent, don't try to follow the child's exec. */
502 if (saved_vfork_state != STATE_GOT_PARENT
503 && saved_vfork_state != STATE_FAKE_EXEC)
504 fprintf_unfiltered (gdb_stdout,
505 "hppa: post follow vfork: confused state\n");
506
507 if (! follow_child || saved_vfork_state == STATE_GOT_PARENT)
508 saved_vfork_state = STATE_NONE;
509 else
510 return 1;
511 }
512 return 0;
513 }
514
515 /* Format a process id, given PID. Be sure to terminate
516 this with a null--it's going to be printed via a "%s". */
517 char *
518 child_pid_to_str (ptid_t ptid)
519 {
520 /* Static because address returned */
521 static char buf[30];
522 pid_t pid = PIDGET (ptid);
523
524 /* Extra NUL for paranoia's sake */
525 sprintf (buf, "process %d%c", pid, '\0');
526
527 return buf;
528 }
529
530 /* Format a thread id, given TID. Be sure to terminate
531 this with a null--it's going to be printed via a "%s".
532
533 Note: This is a core-gdb tid, not the actual system tid.
534 See infttrace.c for details. */
535 char *
536 hppa_tid_to_str (ptid_t ptid)
537 {
538 /* Static because address returned */
539 static char buf[30];
540 /* This seems strange, but when I did the ptid conversion, it looked
541 as though a pid was always being passed. - Kevin Buettner */
542 pid_t tid = PIDGET (ptid);
543
544 /* Extra NULLs for paranoia's sake */
545 sprintf (buf, "system thread %d%c", tid, '\0');
546
547 return buf;
548 }
549
550 /*## */
551 /* Enable HACK for ttrace work. In
552 * infttrace.c/require_notification_of_events,
553 * this is set to 0 so that the loop in child_wait
554 * won't loop.
555 */
556 int not_same_real_pid = 1;
557 /*## */
558
559 /* Wait for child to do something. Return pid of child, or -1 in case
560 of error; store status through argument pointer OURSTATUS. */
561
562 ptid_t
563 child_wait (ptid_t ptid, struct target_waitstatus *ourstatus)
564 {
565 int save_errno;
566 int status;
567 char *execd_pathname = NULL;
568 int exit_status;
569 int related_pid;
570 int syscall_id;
571 enum target_waitkind kind;
572 int pid;
573
574 if (saved_vfork_state == STATE_FAKE_EXEC)
575 {
576 saved_vfork_state = STATE_NONE;
577 ourstatus->kind = TARGET_WAITKIND_EXECD;
578 ourstatus->value.execd_pathname = saved_child_execd_pathname;
579 return inferior_ptid;
580 }
581
582 do
583 {
584 set_sigint_trap (); /* Causes SIGINT to be passed on to the
585 attached process. */
586 set_sigio_trap ();
587
588 pid = ptrace_wait (inferior_ptid, &status);
589
590 save_errno = errno;
591
592 clear_sigio_trap ();
593
594 clear_sigint_trap ();
595
596 if (pid == -1)
597 {
598 if (save_errno == EINTR)
599 continue;
600
601 fprintf_unfiltered (gdb_stderr, "Child process unexpectedly missing: %s.\n",
602 safe_strerror (save_errno));
603
604 /* Claim it exited with unknown signal. */
605 ourstatus->kind = TARGET_WAITKIND_SIGNALLED;
606 ourstatus->value.sig = TARGET_SIGNAL_UNKNOWN;
607 return pid_to_ptid (-1);
608 }
609
610 /* Did it exit?
611 */
612 if (target_has_exited (pid, status, &exit_status))
613 {
614 /* ??rehrauer: For now, ignore this. */
615 continue;
616 }
617
618 if (!target_thread_alive (pid_to_ptid (pid)))
619 {
620 ourstatus->kind = TARGET_WAITKIND_SPURIOUS;
621 return pid_to_ptid (pid);
622 }
623
624 if (hpux_has_forked (pid, &related_pid))
625 {
626 /* Ignore the parent's fork event. */
627 if (pid == PIDGET (inferior_ptid))
628 {
629 ourstatus->kind = TARGET_WAITKIND_IGNORE;
630 return inferior_ptid;
631 }
632
633 /* If this is the child's fork event, report that the
634 process has forked. */
635 if (related_pid == PIDGET (inferior_ptid))
636 {
637 ourstatus->kind = TARGET_WAITKIND_FORKED;
638 ourstatus->value.related_pid = pid;
639 return inferior_ptid;
640 }
641 }
642
643 if (hpux_has_vforked (pid, &related_pid))
644 {
645 if (pid == PIDGET (inferior_ptid))
646 {
647 if (saved_vfork_state == STATE_GOT_CHILD)
648 saved_vfork_state = STATE_GOT_PARENT;
649 else if (saved_vfork_state == STATE_GOT_EXEC)
650 saved_vfork_state = STATE_FAKE_EXEC;
651 else
652 fprintf_unfiltered (gdb_stdout,
653 "hppah: parent vfork: confused\n");
654 }
655 else if (related_pid == PIDGET (inferior_ptid))
656 {
657 if (saved_vfork_state == STATE_NONE)
658 saved_vfork_state = STATE_GOT_CHILD;
659 else
660 fprintf_unfiltered (gdb_stdout,
661 "hppah: child vfork: confused\n");
662 }
663 else
664 fprintf_unfiltered (gdb_stdout,
665 "hppah: unknown vfork: confused\n");
666
667 if (saved_vfork_state == STATE_GOT_CHILD)
668 {
669 child_post_startup_inferior (pid_to_ptid (pid));
670 detach_breakpoints (pid);
671 #ifdef SOLIB_REMOVE_INFERIOR_HOOK
672 SOLIB_REMOVE_INFERIOR_HOOK (pid);
673 #endif
674 child_resume (pid_to_ptid (pid), 0, TARGET_SIGNAL_0);
675 ourstatus->kind = TARGET_WAITKIND_IGNORE;
676 return pid_to_ptid (related_pid);
677 }
678 else if (saved_vfork_state == STATE_FAKE_EXEC)
679 {
680 ourstatus->kind = TARGET_WAITKIND_VFORKED;
681 ourstatus->value.related_pid = related_pid;
682 return pid_to_ptid (pid);
683 }
684 else
685 {
686 /* We saw the parent's vfork, but we haven't seen the exec yet.
687 Wait for it, for simplicity's sake. It should be pending. */
688 saved_vfork_pid = related_pid;
689 ourstatus->kind = TARGET_WAITKIND_IGNORE;
690 return pid_to_ptid (pid);
691 }
692 }
693
694 if (hpux_has_execd (pid, &execd_pathname))
695 {
696 /* On HP-UX, events associated with a vforking inferior come in
697 threes: a vfork event for the child (always first), followed
698 a vfork event for the parent and an exec event for the child.
699 The latter two can come in either order. Make sure we get
700 both. */
701 if (saved_vfork_state != STATE_NONE)
702 {
703 if (saved_vfork_state == STATE_GOT_CHILD)
704 {
705 saved_vfork_state = STATE_GOT_EXEC;
706 /* On HP/UX with ptrace, the child must be resumed before
707 the parent vfork event is delivered. A single-step
708 suffices. */
709 if (RESUME_EXECD_VFORKING_CHILD_TO_GET_PARENT_VFORK ())
710 target_resume (pid_to_ptid (pid), 1, TARGET_SIGNAL_0);
711 ourstatus->kind = TARGET_WAITKIND_IGNORE;
712 }
713 else if (saved_vfork_state == STATE_GOT_PARENT)
714 {
715 saved_vfork_state = STATE_FAKE_EXEC;
716 ourstatus->kind = TARGET_WAITKIND_VFORKED;
717 ourstatus->value.related_pid = saved_vfork_pid;
718 }
719 else
720 fprintf_unfiltered (gdb_stdout,
721 "hppa: exec: unexpected state\n");
722
723 saved_child_execd_pathname = execd_pathname;
724
725 return inferior_ptid;
726 }
727
728 /* Are we ignoring initial exec events? (This is likely because
729 we're in the process of starting up the inferior, and another
730 (older) mechanism handles those.) If so, we'll report this
731 as a regular stop, not an exec.
732 */
733 if (inferior_ignoring_startup_exec_events)
734 {
735 inferior_ignoring_startup_exec_events--;
736 }
737 else
738 {
739 ourstatus->kind = TARGET_WAITKIND_EXECD;
740 ourstatus->value.execd_pathname = execd_pathname;
741 return pid_to_ptid (pid);
742 }
743 }
744
745 /* All we must do with these is communicate their occurrence
746 to wait_for_inferior...
747 */
748 if (hpux_has_syscall_event (pid, &kind, &syscall_id))
749 {
750 ourstatus->kind = kind;
751 ourstatus->value.syscall_id = syscall_id;
752 return pid_to_ptid (pid);
753 }
754
755 /*## } while (pid != PIDGET (inferior_ptid)); ## *//* Some other child died or stopped */
756 /* hack for thread testing */
757 }
758 while ((pid != PIDGET (inferior_ptid)) && not_same_real_pid);
759 /*## */
760
761 store_waitstatus (ourstatus, status);
762 return pid_to_ptid (pid);
763 }
764
765 #if !defined (GDB_NATIVE_HPUX_11)
766
767 /* The following code is a substitute for the infttrace.c versions used
768 with ttrace() in HPUX 11. */
769
770 /* This value is an arbitrary integer. */
771 #define PT_VERSION 123456
772
773 /* This semaphore is used to coordinate the child and parent processes
774 after a fork(), and before an exec() by the child. See
775 parent_attach_all for details. */
776
777 typedef struct
778 {
779 int parent_channel[2]; /* Parent "talks" to [1], child "listens" to [0] */
780 int child_channel[2]; /* Child "talks" to [1], parent "listens" to [0] */
781 }
782 startup_semaphore_t;
783
784 #define SEM_TALK (1)
785 #define SEM_LISTEN (0)
786
787 static startup_semaphore_t startup_semaphore;
788
789 #ifdef PT_SETTRC
790 /* This function causes the caller's process to be traced by its
791 parent. This is intended to be called after GDB forks itself,
792 and before the child execs the target.
793
794 Note that HP-UX ptrace is rather funky in how this is done.
795 If the parent wants to get the initial exec event of a child,
796 it must set the ptrace event mask of the child to include execs.
797 (The child cannot do this itself.) This must be done after the
798 child is forked, but before it execs.
799
800 To coordinate the parent and child, we implement a semaphore using
801 pipes. After SETTRC'ing itself, the child tells the parent that
802 it is now traceable by the parent, and waits for the parent's
803 acknowledgement. The parent can then set the child's event mask,
804 and notify the child that it can now exec.
805
806 (The acknowledgement by parent happens as a result of a call to
807 child_acknowledge_created_inferior.) */
808
809 int
810 parent_attach_all (int pid, PTRACE_ARG3_TYPE addr, int data)
811 {
812 int pt_status = 0;
813
814 /* We need a memory home for a constant. */
815 int tc_magic_child = PT_VERSION;
816 int tc_magic_parent = 0;
817
818 /* The remainder of this function is only useful for HPUX 10.0 and
819 later, as it depends upon the ability to request notification
820 of specific kinds of events by the kernel. */
821 #if defined(PT_SET_EVENT_MASK)
822
823 /* Notify the parent that we're potentially ready to exec(). */
824 write (startup_semaphore.child_channel[SEM_TALK],
825 &tc_magic_child,
826 sizeof (tc_magic_child));
827
828 /* Wait for acknowledgement from the parent. */
829 read (startup_semaphore.parent_channel[SEM_LISTEN],
830 &tc_magic_parent,
831 sizeof (tc_magic_parent));
832 if (tc_magic_child != tc_magic_parent)
833 warning ("mismatched semaphore magic");
834
835 /* Discard our copy of the semaphore. */
836 (void) close (startup_semaphore.parent_channel[SEM_LISTEN]);
837 (void) close (startup_semaphore.parent_channel[SEM_TALK]);
838 (void) close (startup_semaphore.child_channel[SEM_LISTEN]);
839 (void) close (startup_semaphore.child_channel[SEM_TALK]);
840 #endif
841
842 return 0;
843 }
844 #endif
845
846 int
847 hppa_require_attach (int pid)
848 {
849 int pt_status;
850 CORE_ADDR pc;
851 CORE_ADDR pc_addr;
852 unsigned int regs_offset;
853
854 /* Are we already attached? There appears to be no explicit way to
855 answer this via ptrace, so we try something which should be
856 innocuous if we are attached. If that fails, then we assume
857 we're not attached, and so attempt to make it so. */
858
859 errno = 0;
860 regs_offset = U_REGS_OFFSET;
861 pc_addr = register_addr (PC_REGNUM, regs_offset);
862 pc = call_ptrace (PT_READ_U, pid, (PTRACE_ARG3_TYPE) pc_addr, 0);
863
864 if (errno)
865 {
866 errno = 0;
867 pt_status = call_ptrace (PT_ATTACH, pid, (PTRACE_ARG3_TYPE) 0, 0);
868
869 if (errno)
870 return -1;
871
872 /* Now we really are attached. */
873 errno = 0;
874 }
875 attach_flag = 1;
876 return pid;
877 }
878
879 int
880 hppa_require_detach (int pid, int signal)
881 {
882 errno = 0;
883 call_ptrace (PT_DETACH, pid, (PTRACE_ARG3_TYPE) 1, signal);
884 errno = 0; /* Ignore any errors. */
885 return pid;
886 }
887
888 /* Since ptrace doesn't support memory page-protection events, which
889 are used to implement "hardware" watchpoints on HP-UX, these are
890 dummy versions, which perform no useful work. */
891
892 void
893 hppa_enable_page_protection_events (int pid)
894 {
895 }
896
897 void
898 hppa_disable_page_protection_events (int pid)
899 {
900 }
901
902 int
903 hppa_insert_hw_watchpoint (int pid, CORE_ADDR start, LONGEST len, int type)
904 {
905 error ("Hardware watchpoints not implemented on this platform.");
906 }
907
908 int
909 hppa_remove_hw_watchpoint (int pid, CORE_ADDR start, LONGEST len, int type)
910 {
911 error ("Hardware watchpoints not implemented on this platform.");
912 }
913
914 int
915 hppa_can_use_hw_watchpoint (int type, int cnt, int ot)
916 {
917 return 0;
918 }
919
920 int
921 hppa_range_profitable_for_hw_watchpoint (int pid, CORE_ADDR start, LONGEST len)
922 {
923 error ("Hardware watchpoints not implemented on this platform.");
924 }
925
926 char *
927 hppa_pid_or_tid_to_str (ptid_t id)
928 {
929 /* In the ptrace world, there are only processes. */
930 return child_pid_to_str (id);
931 }
932
933 void
934 hppa_ensure_vforking_parent_remains_stopped (int pid)
935 {
936 /* This assumes that the vforked parent is presently stopped, and
937 that the vforked child has just delivered its first exec event.
938 Calling kill() this way will cause the SIGTRAP to be delivered as
939 soon as the parent is resumed, which happens as soon as the
940 vforked child is resumed. See wait_for_inferior for the use of
941 this function. */
942 kill (pid, SIGTRAP);
943 }
944
945 int
946 hppa_resume_execd_vforking_child_to_get_parent_vfork (void)
947 {
948 return 1; /* Yes, the child must be resumed. */
949 }
950
951 void
952 require_notification_of_events (int pid)
953 {
954 #if defined(PT_SET_EVENT_MASK)
955 int pt_status;
956 ptrace_event_t ptrace_events;
957 int nsigs;
958 int signum;
959
960 /* Instruct the kernel as to the set of events we wish to be
961 informed of. (This support does not exist before HPUX 10.0.
962 We'll assume if PT_SET_EVENT_MASK has not been defined by
963 <sys/ptrace.h>, then we're being built on pre-10.0.) */
964 memset (&ptrace_events, 0, sizeof (ptrace_events));
965
966 /* Note: By default, all signals are visible to us. If we wish
967 the kernel to keep certain signals hidden from us, we do it
968 by calling sigdelset (ptrace_events.pe_signals, signal) for
969 each such signal here, before doing PT_SET_EVENT_MASK. */
970 /* RM: The above comment is no longer true. We start with ignoring
971 all signals, and then add the ones we are interested in. We could
972 do it the other way: start by looking at all signals and then
973 deleting the ones that we aren't interested in, except that
974 multiple gdb signals may be mapped to the same host signal
975 (eg. TARGET_SIGNAL_IO and TARGET_SIGNAL_POLL both get mapped to
976 signal 22 on HPUX 10.20) We want to be notified if we are
977 interested in either signal. */
978 sigfillset (&ptrace_events.pe_signals);
979
980 /* RM: Let's not bother with signals we don't care about */
981 nsigs = (int) TARGET_SIGNAL_LAST;
982 for (signum = nsigs; signum > 0; signum--)
983 {
984 if ((signal_stop_state (signum)) ||
985 (signal_print_state (signum)) ||
986 (!signal_pass_state (signum)))
987 {
988 if (target_signal_to_host_p (signum))
989 sigdelset (&ptrace_events.pe_signals,
990 target_signal_to_host (signum));
991 }
992 }
993
994 ptrace_events.pe_set_event = 0;
995
996 ptrace_events.pe_set_event |= PTRACE_SIGNAL;
997 ptrace_events.pe_set_event |= PTRACE_EXEC;
998 ptrace_events.pe_set_event |= PTRACE_FORK;
999 ptrace_events.pe_set_event |= PTRACE_VFORK;
1000 /* ??rehrauer: Add this one when we're prepared to catch it...
1001 ptrace_events.pe_set_event |= PTRACE_EXIT;
1002 */
1003
1004 errno = 0;
1005 pt_status = call_ptrace (PT_SET_EVENT_MASK,
1006 pid,
1007 (PTRACE_ARG3_TYPE) & ptrace_events,
1008 sizeof (ptrace_events));
1009 if (errno)
1010 perror_with_name ("ptrace");
1011 if (pt_status < 0)
1012 return;
1013 #endif
1014 }
1015
1016 void
1017 require_notification_of_exec_events (int pid)
1018 {
1019 #if defined(PT_SET_EVENT_MASK)
1020 int pt_status;
1021 ptrace_event_t ptrace_events;
1022
1023 /* Instruct the kernel as to the set of events we wish to be
1024 informed of. (This support does not exist before HPUX 10.0.
1025 We'll assume if PT_SET_EVENT_MASK has not been defined by
1026 <sys/ptrace.h>, then we're being built on pre-10.0.) */
1027 memset (&ptrace_events, 0, sizeof (ptrace_events));
1028
1029 /* Note: By default, all signals are visible to us. If we wish
1030 the kernel to keep certain signals hidden from us, we do it
1031 by calling sigdelset (ptrace_events.pe_signals, signal) for
1032 each such signal here, before doing PT_SET_EVENT_MASK. */
1033 sigemptyset (&ptrace_events.pe_signals);
1034
1035 ptrace_events.pe_set_event = 0;
1036
1037 ptrace_events.pe_set_event |= PTRACE_EXEC;
1038 /* ??rehrauer: Add this one when we're prepared to catch it...
1039 ptrace_events.pe_set_event |= PTRACE_EXIT;
1040 */
1041
1042 errno = 0;
1043 pt_status = call_ptrace (PT_SET_EVENT_MASK,
1044 pid,
1045 (PTRACE_ARG3_TYPE) & ptrace_events,
1046 sizeof (ptrace_events));
1047 if (errno)
1048 perror_with_name ("ptrace");
1049 if (pt_status < 0)
1050 return;
1051 #endif
1052 }
1053
1054 /* This function is called by the parent process, with pid being the
1055 ID of the child process, after the debugger has forked. */
1056
1057 void
1058 child_acknowledge_created_inferior (int pid)
1059 {
1060 /* We need a memory home for a constant. */
1061 int tc_magic_parent = PT_VERSION;
1062 int tc_magic_child = 0;
1063
1064 /* The remainder of this function is only useful for HPUX 10.0 and
1065 later, as it depends upon the ability to request notification
1066 of specific kinds of events by the kernel. */
1067 #if defined(PT_SET_EVENT_MASK)
1068 /* Wait for the child to tell us that it has forked. */
1069 read (startup_semaphore.child_channel[SEM_LISTEN],
1070 &tc_magic_child,
1071 sizeof (tc_magic_child));
1072
1073 /* Notify the child that it can exec.
1074
1075 In the infttrace.c variant of this function, we set the child's
1076 event mask after the fork but before the exec. In the ptrace
1077 world, it seems we can't set the event mask until after the exec. */
1078 write (startup_semaphore.parent_channel[SEM_TALK],
1079 &tc_magic_parent,
1080 sizeof (tc_magic_parent));
1081
1082 /* We'd better pause a bit before trying to set the event mask,
1083 though, to ensure that the exec has happened. We don't want to
1084 wait() on the child, because that'll screw up the upper layers
1085 of gdb's execution control that expect to see the exec event.
1086
1087 After an exec, the child is no longer executing gdb code. Hence,
1088 we can't have yet another synchronization via the pipes. We'll
1089 just sleep for a second, and hope that's enough delay... */
1090 sleep (1);
1091
1092 /* Instruct the kernel as to the set of events we wish to be
1093 informed of. */
1094 require_notification_of_exec_events (pid);
1095
1096 /* Discard our copy of the semaphore. */
1097 (void) close (startup_semaphore.parent_channel[SEM_LISTEN]);
1098 (void) close (startup_semaphore.parent_channel[SEM_TALK]);
1099 (void) close (startup_semaphore.child_channel[SEM_LISTEN]);
1100 (void) close (startup_semaphore.child_channel[SEM_TALK]);
1101 #endif
1102 }
1103
1104 void
1105 child_post_startup_inferior (ptid_t ptid)
1106 {
1107 require_notification_of_events (PIDGET (ptid));
1108 }
1109
1110 void
1111 child_post_attach (int pid)
1112 {
1113 require_notification_of_events (pid);
1114 }
1115
1116 int
1117 child_insert_fork_catchpoint (int pid)
1118 {
1119 /* This request is only available on HPUX 10.0 and later. */
1120 #if !defined(PT_SET_EVENT_MASK)
1121 error ("Unable to catch forks prior to HPUX 10.0");
1122 #else
1123 /* Enable reporting of fork events from the kernel. */
1124 /* ??rehrauer: For the moment, we're always enabling these events,
1125 and just ignoring them if there's no catchpoint to catch them. */
1126 return 0;
1127 #endif
1128 }
1129
1130 int
1131 child_remove_fork_catchpoint (int pid)
1132 {
1133 /* This request is only available on HPUX 10.0 and later. */
1134 #if !defined(PT_SET_EVENT_MASK)
1135 error ("Unable to catch forks prior to HPUX 10.0");
1136 #else
1137 /* Disable reporting of fork events from the kernel. */
1138 /* ??rehrauer: For the moment, we're always enabling these events,
1139 and just ignoring them if there's no catchpoint to catch them. */
1140 return 0;
1141 #endif
1142 }
1143
1144 int
1145 child_insert_vfork_catchpoint (int pid)
1146 {
1147 /* This request is only available on HPUX 10.0 and later. */
1148 #if !defined(PT_SET_EVENT_MASK)
1149 error ("Unable to catch vforks prior to HPUX 10.0");
1150 #else
1151 /* Enable reporting of vfork events from the kernel. */
1152 /* ??rehrauer: For the moment, we're always enabling these events,
1153 and just ignoring them if there's no catchpoint to catch them. */
1154 return 0;
1155 #endif
1156 }
1157
1158 int
1159 child_remove_vfork_catchpoint (int pid)
1160 {
1161 /* This request is only available on HPUX 10.0 and later. */
1162 #if !defined(PT_SET_EVENT_MASK)
1163 error ("Unable to catch vforks prior to HPUX 10.0");
1164 #else
1165 /* Disable reporting of vfork events from the kernel. */
1166 /* ??rehrauer: For the moment, we're always enabling these events,
1167 and just ignoring them if there's no catchpoint to catch them. */
1168 return 0;
1169 #endif
1170 }
1171
1172 int
1173 hpux_has_forked (int pid, int *childpid)
1174 {
1175 /* This request is only available on HPUX 10.0 and later. */
1176 #if !defined(PT_GET_PROCESS_STATE)
1177 *childpid = 0;
1178 return 0;
1179 #else
1180 int pt_status;
1181 ptrace_state_t ptrace_state;
1182
1183 errno = 0;
1184 pt_status = call_ptrace (PT_GET_PROCESS_STATE,
1185 pid,
1186 (PTRACE_ARG3_TYPE) & ptrace_state,
1187 sizeof (ptrace_state));
1188 if (errno)
1189 perror_with_name ("ptrace");
1190 if (pt_status < 0)
1191 return 0;
1192
1193 if (ptrace_state.pe_report_event & PTRACE_FORK)
1194 {
1195 *childpid = ptrace_state.pe_other_pid;
1196 return 1;
1197 }
1198
1199 return 0;
1200 #endif
1201 }
1202
1203 int
1204 hpux_has_vforked (int pid, int *childpid)
1205 {
1206 /* This request is only available on HPUX 10.0 and later. */
1207 #if !defined(PT_GET_PROCESS_STATE)
1208 *childpid = 0;
1209 return 0;
1210
1211 #else
1212 int pt_status;
1213 ptrace_state_t ptrace_state;
1214
1215 errno = 0;
1216 pt_status = call_ptrace (PT_GET_PROCESS_STATE,
1217 pid,
1218 (PTRACE_ARG3_TYPE) & ptrace_state,
1219 sizeof (ptrace_state));
1220 if (errno)
1221 perror_with_name ("ptrace");
1222 if (pt_status < 0)
1223 return 0;
1224
1225 if (ptrace_state.pe_report_event & PTRACE_VFORK)
1226 {
1227 *childpid = ptrace_state.pe_other_pid;
1228 return 1;
1229 }
1230
1231 return 0;
1232 #endif
1233 }
1234
1235 int
1236 child_insert_exec_catchpoint (int pid)
1237 {
1238 /* This request is only available on HPUX 10.0 and later. */
1239 #if !defined(PT_SET_EVENT_MASK)
1240 error ("Unable to catch execs prior to HPUX 10.0");
1241
1242 #else
1243 /* Enable reporting of exec events from the kernel. */
1244 /* ??rehrauer: For the moment, we're always enabling these events,
1245 and just ignoring them if there's no catchpoint to catch them. */
1246 return 0;
1247 #endif
1248 }
1249
1250 int
1251 child_remove_exec_catchpoint (int pid)
1252 {
1253 /* This request is only available on HPUX 10.0 and later. */
1254 #if !defined(PT_SET_EVENT_MASK)
1255 error ("Unable to catch execs prior to HPUX 10.0");
1256
1257 #else
1258 /* Disable reporting of exec events from the kernel. */
1259 /* ??rehrauer: For the moment, we're always enabling these events,
1260 and just ignoring them if there's no catchpoint to catch them. */
1261 return 0;
1262 #endif
1263 }
1264
1265 int
1266 hpux_has_execd (int pid, char **execd_pathname)
1267 {
1268 /* This request is only available on HPUX 10.0 and later. */
1269 #if !defined(PT_GET_PROCESS_STATE)
1270 *execd_pathname = NULL;
1271 return 0;
1272
1273 #else
1274 int pt_status;
1275 ptrace_state_t ptrace_state;
1276
1277 errno = 0;
1278 pt_status = call_ptrace (PT_GET_PROCESS_STATE,
1279 pid,
1280 (PTRACE_ARG3_TYPE) & ptrace_state,
1281 sizeof (ptrace_state));
1282 if (errno)
1283 perror_with_name ("ptrace");
1284 if (pt_status < 0)
1285 return 0;
1286
1287 if (ptrace_state.pe_report_event & PTRACE_EXEC)
1288 {
1289 char *exec_file = target_pid_to_exec_file (pid);
1290 *execd_pathname = savestring (exec_file, strlen (exec_file));
1291 return 1;
1292 }
1293
1294 return 0;
1295 #endif
1296 }
1297
1298 int
1299 child_reported_exec_events_per_exec_call (void)
1300 {
1301 return 2; /* ptrace reports the event twice per call. */
1302 }
1303
1304 int
1305 hpux_has_syscall_event (int pid, enum target_waitkind *kind, int *syscall_id)
1306 {
1307 /* This request is only available on HPUX 10.30 and later, via
1308 the ttrace interface. */
1309
1310 *kind = TARGET_WAITKIND_SPURIOUS;
1311 *syscall_id = -1;
1312 return 0;
1313 }
1314
1315 char *
1316 child_pid_to_exec_file (int pid)
1317 {
1318 static char exec_file_buffer[1024];
1319 int pt_status;
1320 CORE_ADDR top_of_stack;
1321 char four_chars[4];
1322 int name_index;
1323 int i;
1324 ptid_t saved_inferior_ptid;
1325 int done;
1326
1327 #ifdef PT_GET_PROCESS_PATHNAME
1328 /* As of 10.x HP-UX, there's an explicit request to get the pathname. */
1329 pt_status = call_ptrace (PT_GET_PROCESS_PATHNAME,
1330 pid,
1331 (PTRACE_ARG3_TYPE) exec_file_buffer,
1332 sizeof (exec_file_buffer) - 1);
1333 if (pt_status == 0)
1334 return exec_file_buffer;
1335 #endif
1336
1337 /* It appears that this request is broken prior to 10.30.
1338 If it fails, try a really, truly amazingly gross hack
1339 that DDE uses, of pawing through the process' data
1340 segment to find the pathname. */
1341
1342 top_of_stack = 0x7b03a000;
1343 name_index = 0;
1344 done = 0;
1345
1346 /* On the chance that pid != inferior_ptid, set inferior_ptid
1347 to pid, so that (grrrr!) implicit uses of inferior_ptid get
1348 the right id. */
1349
1350 saved_inferior_ptid = inferior_ptid;
1351 inferior_ptid = pid_to_ptid (pid);
1352
1353 /* Try to grab a null-terminated string. */
1354 while (!done)
1355 {
1356 if (target_read_memory (top_of_stack, four_chars, 4) != 0)
1357 {
1358 inferior_ptid = saved_inferior_ptid;
1359 return NULL;
1360 }
1361 for (i = 0; i < 4; i++)
1362 {
1363 exec_file_buffer[name_index++] = four_chars[i];
1364 done = (four_chars[i] == '\0');
1365 if (done)
1366 break;
1367 }
1368 top_of_stack += 4;
1369 }
1370
1371 if (exec_file_buffer[0] == '\0')
1372 {
1373 inferior_ptid = saved_inferior_ptid;
1374 return NULL;
1375 }
1376
1377 inferior_ptid = saved_inferior_ptid;
1378 return exec_file_buffer;
1379 }
1380
1381 void
1382 pre_fork_inferior (void)
1383 {
1384 int status;
1385
1386 status = pipe (startup_semaphore.parent_channel);
1387 if (status < 0)
1388 {
1389 warning ("error getting parent pipe for startup semaphore");
1390 return;
1391 }
1392
1393 status = pipe (startup_semaphore.child_channel);
1394 if (status < 0)
1395 {
1396 warning ("error getting child pipe for startup semaphore");
1397 return;
1398 }
1399 }
1400 \f
1401
1402 /* Check to see if the given thread is alive.
1403
1404 This is a no-op, as ptrace doesn't support threads, so we just
1405 return "TRUE". */
1406
1407 int
1408 child_thread_alive (ptid_t ptid)
1409 {
1410 return 1;
1411 }
1412
1413 #endif /* ! GDB_NATIVE_HPUX_11 */
This page took 0.059739 seconds and 4 git commands to generate.