* alpha-tdep.c (alpha_supply_int_regs, alpha_fill_int_regs): New.
[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 register unsigned int regaddr;
68 char buf[80];
69 register 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 + (REGISTER_BYTE (regno) - 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 + 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 + (REGISTER_BYTE (regno) - 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[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[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[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 + (REGISTER_BYTE (regno) - 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 + 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 + (REGISTER_BYTE (regno) - 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 register int i;
286 /* Round starting address down to longword boundary. */
287 register CORE_ADDR addr = memaddr & - (CORE_ADDR)(sizeof (int));
288 /* Round ending address up; get number of longwords that makes. */
289 register 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 register 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 /* This function has no meaning in a non-threaded world. Thus, we
934 return 0 (FALSE). See the use of "hppa_prepare_to_proceed" in
935 hppa-tdep.c. */
936
937 pid_t
938 hppa_switched_threads (pid_t pid)
939 {
940 return (pid_t) 0;
941 }
942
943 void
944 hppa_ensure_vforking_parent_remains_stopped (int pid)
945 {
946 /* This assumes that the vforked parent is presently stopped, and
947 that the vforked child has just delivered its first exec event.
948 Calling kill() this way will cause the SIGTRAP to be delivered as
949 soon as the parent is resumed, which happens as soon as the
950 vforked child is resumed. See wait_for_inferior for the use of
951 this function. */
952 kill (pid, SIGTRAP);
953 }
954
955 int
956 hppa_resume_execd_vforking_child_to_get_parent_vfork (void)
957 {
958 return 1; /* Yes, the child must be resumed. */
959 }
960
961 void
962 require_notification_of_events (int pid)
963 {
964 #if defined(PT_SET_EVENT_MASK)
965 int pt_status;
966 ptrace_event_t ptrace_events;
967 int nsigs;
968 int signum;
969
970 /* Instruct the kernel as to the set of events we wish to be
971 informed of. (This support does not exist before HPUX 10.0.
972 We'll assume if PT_SET_EVENT_MASK has not been defined by
973 <sys/ptrace.h>, then we're being built on pre-10.0.) */
974 memset (&ptrace_events, 0, sizeof (ptrace_events));
975
976 /* Note: By default, all signals are visible to us. If we wish
977 the kernel to keep certain signals hidden from us, we do it
978 by calling sigdelset (ptrace_events.pe_signals, signal) for
979 each such signal here, before doing PT_SET_EVENT_MASK. */
980 /* RM: The above comment is no longer true. We start with ignoring
981 all signals, and then add the ones we are interested in. We could
982 do it the other way: start by looking at all signals and then
983 deleting the ones that we aren't interested in, except that
984 multiple gdb signals may be mapped to the same host signal
985 (eg. TARGET_SIGNAL_IO and TARGET_SIGNAL_POLL both get mapped to
986 signal 22 on HPUX 10.20) We want to be notified if we are
987 interested in either signal. */
988 sigfillset (&ptrace_events.pe_signals);
989
990 /* RM: Let's not bother with signals we don't care about */
991 nsigs = (int) TARGET_SIGNAL_LAST;
992 for (signum = nsigs; signum > 0; signum--)
993 {
994 if ((signal_stop_state (signum)) ||
995 (signal_print_state (signum)) ||
996 (!signal_pass_state (signum)))
997 {
998 if (target_signal_to_host_p (signum))
999 sigdelset (&ptrace_events.pe_signals,
1000 target_signal_to_host (signum));
1001 }
1002 }
1003
1004 ptrace_events.pe_set_event = 0;
1005
1006 ptrace_events.pe_set_event |= PTRACE_SIGNAL;
1007 ptrace_events.pe_set_event |= PTRACE_EXEC;
1008 ptrace_events.pe_set_event |= PTRACE_FORK;
1009 ptrace_events.pe_set_event |= PTRACE_VFORK;
1010 /* ??rehrauer: Add this one when we're prepared to catch it...
1011 ptrace_events.pe_set_event |= PTRACE_EXIT;
1012 */
1013
1014 errno = 0;
1015 pt_status = call_ptrace (PT_SET_EVENT_MASK,
1016 pid,
1017 (PTRACE_ARG3_TYPE) & ptrace_events,
1018 sizeof (ptrace_events));
1019 if (errno)
1020 perror_with_name ("ptrace");
1021 if (pt_status < 0)
1022 return;
1023 #endif
1024 }
1025
1026 void
1027 require_notification_of_exec_events (int pid)
1028 {
1029 #if defined(PT_SET_EVENT_MASK)
1030 int pt_status;
1031 ptrace_event_t ptrace_events;
1032
1033 /* Instruct the kernel as to the set of events we wish to be
1034 informed of. (This support does not exist before HPUX 10.0.
1035 We'll assume if PT_SET_EVENT_MASK has not been defined by
1036 <sys/ptrace.h>, then we're being built on pre-10.0.) */
1037 memset (&ptrace_events, 0, sizeof (ptrace_events));
1038
1039 /* Note: By default, all signals are visible to us. If we wish
1040 the kernel to keep certain signals hidden from us, we do it
1041 by calling sigdelset (ptrace_events.pe_signals, signal) for
1042 each such signal here, before doing PT_SET_EVENT_MASK. */
1043 sigemptyset (&ptrace_events.pe_signals);
1044
1045 ptrace_events.pe_set_event = 0;
1046
1047 ptrace_events.pe_set_event |= PTRACE_EXEC;
1048 /* ??rehrauer: Add this one when we're prepared to catch it...
1049 ptrace_events.pe_set_event |= PTRACE_EXIT;
1050 */
1051
1052 errno = 0;
1053 pt_status = call_ptrace (PT_SET_EVENT_MASK,
1054 pid,
1055 (PTRACE_ARG3_TYPE) & ptrace_events,
1056 sizeof (ptrace_events));
1057 if (errno)
1058 perror_with_name ("ptrace");
1059 if (pt_status < 0)
1060 return;
1061 #endif
1062 }
1063
1064 /* This function is called by the parent process, with pid being the
1065 ID of the child process, after the debugger has forked. */
1066
1067 void
1068 child_acknowledge_created_inferior (int pid)
1069 {
1070 /* We need a memory home for a constant. */
1071 int tc_magic_parent = PT_VERSION;
1072 int tc_magic_child = 0;
1073
1074 /* The remainder of this function is only useful for HPUX 10.0 and
1075 later, as it depends upon the ability to request notification
1076 of specific kinds of events by the kernel. */
1077 #if defined(PT_SET_EVENT_MASK)
1078 /* Wait for the child to tell us that it has forked. */
1079 read (startup_semaphore.child_channel[SEM_LISTEN],
1080 &tc_magic_child,
1081 sizeof (tc_magic_child));
1082
1083 /* Notify the child that it can exec.
1084
1085 In the infttrace.c variant of this function, we set the child's
1086 event mask after the fork but before the exec. In the ptrace
1087 world, it seems we can't set the event mask until after the exec. */
1088 write (startup_semaphore.parent_channel[SEM_TALK],
1089 &tc_magic_parent,
1090 sizeof (tc_magic_parent));
1091
1092 /* We'd better pause a bit before trying to set the event mask,
1093 though, to ensure that the exec has happened. We don't want to
1094 wait() on the child, because that'll screw up the upper layers
1095 of gdb's execution control that expect to see the exec event.
1096
1097 After an exec, the child is no longer executing gdb code. Hence,
1098 we can't have yet another synchronization via the pipes. We'll
1099 just sleep for a second, and hope that's enough delay... */
1100 sleep (1);
1101
1102 /* Instruct the kernel as to the set of events we wish to be
1103 informed of. */
1104 require_notification_of_exec_events (pid);
1105
1106 /* Discard our copy of the semaphore. */
1107 (void) close (startup_semaphore.parent_channel[SEM_LISTEN]);
1108 (void) close (startup_semaphore.parent_channel[SEM_TALK]);
1109 (void) close (startup_semaphore.child_channel[SEM_LISTEN]);
1110 (void) close (startup_semaphore.child_channel[SEM_TALK]);
1111 #endif
1112 }
1113
1114 void
1115 child_post_startup_inferior (ptid_t ptid)
1116 {
1117 require_notification_of_events (PIDGET (ptid));
1118 }
1119
1120 void
1121 child_post_attach (int pid)
1122 {
1123 require_notification_of_events (pid);
1124 }
1125
1126 int
1127 child_insert_fork_catchpoint (int pid)
1128 {
1129 /* This request is only available on HPUX 10.0 and later. */
1130 #if !defined(PT_SET_EVENT_MASK)
1131 error ("Unable to catch forks prior to HPUX 10.0");
1132 #else
1133 /* Enable reporting of fork events from the kernel. */
1134 /* ??rehrauer: For the moment, we're always enabling these events,
1135 and just ignoring them if there's no catchpoint to catch them. */
1136 return 0;
1137 #endif
1138 }
1139
1140 int
1141 child_remove_fork_catchpoint (int pid)
1142 {
1143 /* This request is only available on HPUX 10.0 and later. */
1144 #if !defined(PT_SET_EVENT_MASK)
1145 error ("Unable to catch forks prior to HPUX 10.0");
1146 #else
1147 /* Disable reporting of fork events from the kernel. */
1148 /* ??rehrauer: For the moment, we're always enabling these events,
1149 and just ignoring them if there's no catchpoint to catch them. */
1150 return 0;
1151 #endif
1152 }
1153
1154 int
1155 child_insert_vfork_catchpoint (int pid)
1156 {
1157 /* This request is only available on HPUX 10.0 and later. */
1158 #if !defined(PT_SET_EVENT_MASK)
1159 error ("Unable to catch vforks prior to HPUX 10.0");
1160 #else
1161 /* Enable reporting of vfork events from the kernel. */
1162 /* ??rehrauer: For the moment, we're always enabling these events,
1163 and just ignoring them if there's no catchpoint to catch them. */
1164 return 0;
1165 #endif
1166 }
1167
1168 int
1169 child_remove_vfork_catchpoint (int pid)
1170 {
1171 /* This request is only available on HPUX 10.0 and later. */
1172 #if !defined(PT_SET_EVENT_MASK)
1173 error ("Unable to catch vforks prior to HPUX 10.0");
1174 #else
1175 /* Disable reporting of vfork events from the kernel. */
1176 /* ??rehrauer: For the moment, we're always enabling these events,
1177 and just ignoring them if there's no catchpoint to catch them. */
1178 return 0;
1179 #endif
1180 }
1181
1182 int
1183 hpux_has_forked (int pid, int *childpid)
1184 {
1185 /* This request is only available on HPUX 10.0 and later. */
1186 #if !defined(PT_GET_PROCESS_STATE)
1187 *childpid = 0;
1188 return 0;
1189 #else
1190 int pt_status;
1191 ptrace_state_t ptrace_state;
1192
1193 errno = 0;
1194 pt_status = call_ptrace (PT_GET_PROCESS_STATE,
1195 pid,
1196 (PTRACE_ARG3_TYPE) & ptrace_state,
1197 sizeof (ptrace_state));
1198 if (errno)
1199 perror_with_name ("ptrace");
1200 if (pt_status < 0)
1201 return 0;
1202
1203 if (ptrace_state.pe_report_event & PTRACE_FORK)
1204 {
1205 *childpid = ptrace_state.pe_other_pid;
1206 return 1;
1207 }
1208
1209 return 0;
1210 #endif
1211 }
1212
1213 int
1214 hpux_has_vforked (int pid, int *childpid)
1215 {
1216 /* This request is only available on HPUX 10.0 and later. */
1217 #if !defined(PT_GET_PROCESS_STATE)
1218 *childpid = 0;
1219 return 0;
1220
1221 #else
1222 int pt_status;
1223 ptrace_state_t ptrace_state;
1224
1225 errno = 0;
1226 pt_status = call_ptrace (PT_GET_PROCESS_STATE,
1227 pid,
1228 (PTRACE_ARG3_TYPE) & ptrace_state,
1229 sizeof (ptrace_state));
1230 if (errno)
1231 perror_with_name ("ptrace");
1232 if (pt_status < 0)
1233 return 0;
1234
1235 if (ptrace_state.pe_report_event & PTRACE_VFORK)
1236 {
1237 *childpid = ptrace_state.pe_other_pid;
1238 return 1;
1239 }
1240
1241 return 0;
1242 #endif
1243 }
1244
1245 int
1246 child_insert_exec_catchpoint (int pid)
1247 {
1248 /* This request is only available on HPUX 10.0 and later. */
1249 #if !defined(PT_SET_EVENT_MASK)
1250 error ("Unable to catch execs prior to HPUX 10.0");
1251
1252 #else
1253 /* Enable reporting of exec events from the kernel. */
1254 /* ??rehrauer: For the moment, we're always enabling these events,
1255 and just ignoring them if there's no catchpoint to catch them. */
1256 return 0;
1257 #endif
1258 }
1259
1260 int
1261 child_remove_exec_catchpoint (int pid)
1262 {
1263 /* This request is only available on HPUX 10.0 and later. */
1264 #if !defined(PT_SET_EVENT_MASK)
1265 error ("Unable to catch execs prior to HPUX 10.0");
1266
1267 #else
1268 /* Disable reporting of exec events from the kernel. */
1269 /* ??rehrauer: For the moment, we're always enabling these events,
1270 and just ignoring them if there's no catchpoint to catch them. */
1271 return 0;
1272 #endif
1273 }
1274
1275 int
1276 hpux_has_execd (int pid, char **execd_pathname)
1277 {
1278 /* This request is only available on HPUX 10.0 and later. */
1279 #if !defined(PT_GET_PROCESS_STATE)
1280 *execd_pathname = NULL;
1281 return 0;
1282
1283 #else
1284 int pt_status;
1285 ptrace_state_t ptrace_state;
1286
1287 errno = 0;
1288 pt_status = call_ptrace (PT_GET_PROCESS_STATE,
1289 pid,
1290 (PTRACE_ARG3_TYPE) & ptrace_state,
1291 sizeof (ptrace_state));
1292 if (errno)
1293 perror_with_name ("ptrace");
1294 if (pt_status < 0)
1295 return 0;
1296
1297 if (ptrace_state.pe_report_event & PTRACE_EXEC)
1298 {
1299 char *exec_file = target_pid_to_exec_file (pid);
1300 *execd_pathname = savestring (exec_file, strlen (exec_file));
1301 return 1;
1302 }
1303
1304 return 0;
1305 #endif
1306 }
1307
1308 int
1309 child_reported_exec_events_per_exec_call (void)
1310 {
1311 return 2; /* ptrace reports the event twice per call. */
1312 }
1313
1314 int
1315 hpux_has_syscall_event (int pid, enum target_waitkind *kind, int *syscall_id)
1316 {
1317 /* This request is only available on HPUX 10.30 and later, via
1318 the ttrace interface. */
1319
1320 *kind = TARGET_WAITKIND_SPURIOUS;
1321 *syscall_id = -1;
1322 return 0;
1323 }
1324
1325 char *
1326 child_pid_to_exec_file (int pid)
1327 {
1328 static char exec_file_buffer[1024];
1329 int pt_status;
1330 CORE_ADDR top_of_stack;
1331 char four_chars[4];
1332 int name_index;
1333 int i;
1334 ptid_t saved_inferior_ptid;
1335 int done;
1336
1337 #ifdef PT_GET_PROCESS_PATHNAME
1338 /* As of 10.x HP-UX, there's an explicit request to get the pathname. */
1339 pt_status = call_ptrace (PT_GET_PROCESS_PATHNAME,
1340 pid,
1341 (PTRACE_ARG3_TYPE) exec_file_buffer,
1342 sizeof (exec_file_buffer) - 1);
1343 if (pt_status == 0)
1344 return exec_file_buffer;
1345 #endif
1346
1347 /* It appears that this request is broken prior to 10.30.
1348 If it fails, try a really, truly amazingly gross hack
1349 that DDE uses, of pawing through the process' data
1350 segment to find the pathname. */
1351
1352 top_of_stack = 0x7b03a000;
1353 name_index = 0;
1354 done = 0;
1355
1356 /* On the chance that pid != inferior_ptid, set inferior_ptid
1357 to pid, so that (grrrr!) implicit uses of inferior_ptid get
1358 the right id. */
1359
1360 saved_inferior_ptid = inferior_ptid;
1361 inferior_ptid = pid_to_ptid (pid);
1362
1363 /* Try to grab a null-terminated string. */
1364 while (!done)
1365 {
1366 if (target_read_memory (top_of_stack, four_chars, 4) != 0)
1367 {
1368 inferior_ptid = saved_inferior_ptid;
1369 return NULL;
1370 }
1371 for (i = 0; i < 4; i++)
1372 {
1373 exec_file_buffer[name_index++] = four_chars[i];
1374 done = (four_chars[i] == '\0');
1375 if (done)
1376 break;
1377 }
1378 top_of_stack += 4;
1379 }
1380
1381 if (exec_file_buffer[0] == '\0')
1382 {
1383 inferior_ptid = saved_inferior_ptid;
1384 return NULL;
1385 }
1386
1387 inferior_ptid = saved_inferior_ptid;
1388 return exec_file_buffer;
1389 }
1390
1391 void
1392 pre_fork_inferior (void)
1393 {
1394 int status;
1395
1396 status = pipe (startup_semaphore.parent_channel);
1397 if (status < 0)
1398 {
1399 warning ("error getting parent pipe for startup semaphore");
1400 return;
1401 }
1402
1403 status = pipe (startup_semaphore.child_channel);
1404 if (status < 0)
1405 {
1406 warning ("error getting child pipe for startup semaphore");
1407 return;
1408 }
1409 }
1410 \f
1411
1412 /* Check to see if the given thread is alive.
1413
1414 This is a no-op, as ptrace doesn't support threads, so we just
1415 return "TRUE". */
1416
1417 int
1418 child_thread_alive (ptid_t ptid)
1419 {
1420 return 1;
1421 }
1422
1423 #endif /* ! GDB_NATIVE_HPUX_11 */
This page took 0.058122 seconds and 4 git commands to generate.