1 // OBSOLETE /* Sequent Symmetry host interface, for GDB when running under Unix.
3 // OBSOLETE Copyright 1986, 1987, 1989, 1991, 1992, 1993, 1994, 1995, 1999,
4 // OBSOLETE 2000, 2001, 2003 Free Software Foundation, Inc.
6 // OBSOLETE This file is part of GDB.
8 // OBSOLETE This program is free software; you can redistribute it and/or modify
9 // OBSOLETE it under the terms of the GNU General Public License as published by
10 // OBSOLETE the Free Software Foundation; either version 2 of the License, or
11 // OBSOLETE (at your option) any later version.
13 // OBSOLETE This program is distributed in the hope that it will be useful,
14 // OBSOLETE but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // OBSOLETE MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // OBSOLETE GNU General Public License for more details.
18 // OBSOLETE You should have received a copy of the GNU General Public License
19 // OBSOLETE along with this program; if not, write to the Free Software
20 // OBSOLETE Foundation, Inc., 59 Temple Place - Suite 330,
21 // OBSOLETE Boston, MA 02111-1307, USA. */
23 // OBSOLETE /* FIXME, some 387-specific items of use taken from i387-tdep.c -- ought to be
24 // OBSOLETE merged back in. */
26 // OBSOLETE #include "defs.h"
27 // OBSOLETE #include "frame.h"
28 // OBSOLETE #include "inferior.h"
29 // OBSOLETE #include "symtab.h"
30 // OBSOLETE #include "target.h"
31 // OBSOLETE #include "regcache.h"
33 // OBSOLETE /* FIXME: What is the _INKERNEL define for? */
34 // OBSOLETE #define _INKERNEL
35 // OBSOLETE #include <signal.h>
36 // OBSOLETE #undef _INKERNEL
37 // OBSOLETE #include "gdb_wait.h"
38 // OBSOLETE #include <sys/param.h>
39 // OBSOLETE #include <sys/user.h>
40 // OBSOLETE #include <sys/proc.h>
41 // OBSOLETE #include <sys/dir.h>
42 // OBSOLETE #include <sys/ioctl.h>
43 // OBSOLETE #include "gdb_stat.h"
44 // OBSOLETE #ifdef _SEQUENT_
45 // OBSOLETE #include <sys/ptrace.h>
47 // OBSOLETE /* Dynix has only machine/ptrace.h, which is already included by sys/user.h */
48 // OBSOLETE /* Dynix has no mptrace call */
49 // OBSOLETE #define mptrace ptrace
51 // OBSOLETE #include "gdbcore.h"
52 // OBSOLETE #include <fcntl.h>
53 // OBSOLETE #include <sgtty.h>
54 // OBSOLETE #define TERMINAL struct sgttyb
56 // OBSOLETE #include "gdbcore.h"
59 // OBSOLETE store_inferior_registers (int regno)
61 // OBSOLETE struct pt_regset regs;
64 // OBSOLETE /* FIXME: Fetching the registers is a kludge to initialize all elements
65 // OBSOLETE in the fpu and fpa status. This works for normal debugging, but
66 // OBSOLETE might cause problems when calling functions in the inferior.
67 // OBSOLETE At least fpu_control and fpa_pcr (probably more) should be added
68 // OBSOLETE to the registers array to solve this properly. */
69 // OBSOLETE mptrace (XPT_RREGS, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) & regs, 0);
71 // OBSOLETE regs.pr_eax = *(int *) &deprecated_registers[REGISTER_BYTE (0)];
72 // OBSOLETE regs.pr_ebx = *(int *) &deprecated_registers[REGISTER_BYTE (5)];
73 // OBSOLETE regs.pr_ecx = *(int *) &deprecated_registers[REGISTER_BYTE (2)];
74 // OBSOLETE regs.pr_edx = *(int *) &deprecated_registers[REGISTER_BYTE (1)];
75 // OBSOLETE regs.pr_esi = *(int *) &deprecated_registers[REGISTER_BYTE (6)];
76 // OBSOLETE regs.pr_edi = *(int *) &deprecated_registers[REGISTER_BYTE (7)];
77 // OBSOLETE regs.pr_esp = *(int *) &deprecated_registers[REGISTER_BYTE (14)];
78 // OBSOLETE regs.pr_ebp = *(int *) &deprecated_registers[REGISTER_BYTE (15)];
79 // OBSOLETE regs.pr_eip = *(int *) &deprecated_registers[REGISTER_BYTE (16)];
80 // OBSOLETE regs.pr_flags = *(int *) &deprecated_registers[REGISTER_BYTE (17)];
81 // OBSOLETE for (i = 0; i < 31; i++)
83 // OBSOLETE regs.pr_fpa.fpa_regs[i] =
84 // OBSOLETE *(int *) &deprecated_registers[REGISTER_BYTE (FP1_REGNUM + i)];
86 // OBSOLETE memcpy (regs.pr_fpu.fpu_stack[0], &deprecated_registers[REGISTER_BYTE (ST0_REGNUM)], 10);
87 // OBSOLETE memcpy (regs.pr_fpu.fpu_stack[1], &deprecated_registers[REGISTER_BYTE (ST1_REGNUM)], 10);
88 // OBSOLETE memcpy (regs.pr_fpu.fpu_stack[2], &deprecated_registers[REGISTER_BYTE (ST2_REGNUM)], 10);
89 // OBSOLETE memcpy (regs.pr_fpu.fpu_stack[3], &deprecated_registers[REGISTER_BYTE (ST3_REGNUM)], 10);
90 // OBSOLETE memcpy (regs.pr_fpu.fpu_stack[4], &deprecated_registers[REGISTER_BYTE (ST4_REGNUM)], 10);
91 // OBSOLETE memcpy (regs.pr_fpu.fpu_stack[5], &deprecated_registers[REGISTER_BYTE (ST5_REGNUM)], 10);
92 // OBSOLETE memcpy (regs.pr_fpu.fpu_stack[6], &deprecated_registers[REGISTER_BYTE (ST6_REGNUM)], 10);
93 // OBSOLETE memcpy (regs.pr_fpu.fpu_stack[7], &deprecated_registers[REGISTER_BYTE (ST7_REGNUM)], 10);
94 // OBSOLETE mptrace (XPT_WREGS, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) & regs, 0);
98 // OBSOLETE fetch_inferior_registers (int regno)
101 // OBSOLETE struct pt_regset regs;
103 // OBSOLETE deprecated_registers_fetched ();
105 // OBSOLETE mptrace (XPT_RREGS, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) & regs, 0);
106 // OBSOLETE *(int *) &deprecated_registers[REGISTER_BYTE (EAX_REGNUM)] = regs.pr_eax;
107 // OBSOLETE *(int *) &rdeprecated_egisters[REGISTER_BYTE (EBX_REGNUM)] = regs.pr_ebx;
108 // OBSOLETE *(int *) &deprecated_registers[REGISTER_BYTE (ECX_REGNUM)] = regs.pr_ecx;
109 // OBSOLETE *(int *) &deprecated_registers[REGISTER_BYTE (EDX_REGNUM)] = regs.pr_edx;
110 // OBSOLETE *(int *) &deprecated_registers[REGISTER_BYTE (ESI_REGNUM)] = regs.pr_esi;
111 // OBSOLETE *(int *) &deprecated_registers[REGISTER_BYTE (EDI_REGNUM)] = regs.pr_edi;
112 // OBSOLETE *(int *) &deprecated_registers[REGISTER_BYTE (EBP_REGNUM)] = regs.pr_ebp;
113 // OBSOLETE *(int *) &deprecated_registers[REGISTER_BYTE (ESP_REGNUM)] = regs.pr_esp;
114 // OBSOLETE *(int *) &deprecated_registers[REGISTER_BYTE (EIP_REGNUM)] = regs.pr_eip;
115 // OBSOLETE *(int *) &deprecated_registers[REGISTER_BYTE (EFLAGS_REGNUM)] = regs.pr_flags;
116 // OBSOLETE for (i = 0; i < FPA_NREGS; i++)
118 // OBSOLETE *(int *) &deprecated_registers[REGISTER_BYTE (FP1_REGNUM + i)] =
119 // OBSOLETE regs.pr_fpa.fpa_regs[i];
121 // OBSOLETE memcpy (&deprecated_registers[REGISTER_BYTE (ST0_REGNUM)], regs.pr_fpu.fpu_stack[0], 10);
122 // OBSOLETE memcpy (&deprecated_registers[REGISTER_BYTE (ST1_REGNUM)], regs.pr_fpu.fpu_stack[1], 10);
123 // OBSOLETE memcpy (&deprecated_registers[REGISTER_BYTE (ST2_REGNUM)], regs.pr_fpu.fpu_stack[2], 10);
124 // OBSOLETE memcpy (&deprecated_registers[REGISTER_BYTE (ST3_REGNUM)], regs.pr_fpu.fpu_stack[3], 10);
125 // OBSOLETE memcpy (&deprecated_registers[REGISTER_BYTE (ST4_REGNUM)], regs.pr_fpu.fpu_stack[4], 10);
126 // OBSOLETE memcpy (&deprecated_registers[REGISTER_BYTE (ST5_REGNUM)], regs.pr_fpu.fpu_stack[5], 10);
127 // OBSOLETE memcpy (&deprecated_registers[REGISTER_BYTE (ST6_REGNUM)], regs.pr_fpu.fpu_stack[6], 10);
128 // OBSOLETE memcpy (&deprecated_registers[REGISTER_BYTE (ST7_REGNUM)], regs.pr_fpu.fpu_stack[7], 10);
131 // OBSOLETE /* FIXME: This should be merged with i387-tdep.c as well. */
133 // OBSOLETE print_fpu_status (struct pt_regset ep)
136 // OBSOLETE int bothstatus;
138 // OBSOLETE int fpreg;
139 // OBSOLETE unsigned char *p;
141 // OBSOLETE printf_unfiltered ("80387:");
142 // OBSOLETE if (ep.pr_fpu.fpu_ip == 0)
144 // OBSOLETE printf_unfiltered (" not in use.\n");
149 // OBSOLETE printf_unfiltered ("\n");
151 // OBSOLETE if (ep.pr_fpu.fpu_status != 0)
153 // OBSOLETE print_387_status_word (ep.pr_fpu.fpu_status);
155 // OBSOLETE print_387_control_word (ep.pr_fpu.fpu_control);
156 // OBSOLETE printf_unfiltered ("last exception: ");
157 // OBSOLETE printf_unfiltered ("opcode 0x%x; ", ep.pr_fpu.fpu_rsvd4);
158 // OBSOLETE printf_unfiltered ("pc 0x%x:0x%x; ", ep.pr_fpu.fpu_cs, ep.pr_fpu.fpu_ip);
159 // OBSOLETE printf_unfiltered ("operand 0x%x:0x%x\n", ep.pr_fpu.fpu_data_offset, ep.pr_fpu.fpu_op_sel);
161 // OBSOLETE top = (ep.pr_fpu.fpu_status >> 11) & 7;
163 // OBSOLETE printf_unfiltered ("regno tag msb lsb value\n");
164 // OBSOLETE for (fpreg = 7; fpreg >= 0; fpreg--)
166 // OBSOLETE double val;
168 // OBSOLETE printf_unfiltered ("%s %d: ", fpreg == top ? "=>" : " ", fpreg);
170 // OBSOLETE switch ((ep.pr_fpu.fpu_tag >> (fpreg * 2)) & 3)
173 // OBSOLETE printf_unfiltered ("valid ");
176 // OBSOLETE printf_unfiltered ("zero ");
179 // OBSOLETE printf_unfiltered ("trap ");
182 // OBSOLETE printf_unfiltered ("empty ");
185 // OBSOLETE for (i = 9; i >= 0; i--)
186 // OBSOLETE printf_unfiltered ("%02x", ep.pr_fpu.fpu_stack[fpreg][i]);
188 // OBSOLETE i387_to_double ((char *) ep.pr_fpu.fpu_stack[fpreg], (char *) &val);
189 // OBSOLETE printf_unfiltered (" %g\n", val);
191 // OBSOLETE if (ep.pr_fpu.fpu_rsvd1)
192 // OBSOLETE warning ("rsvd1 is 0x%x\n", ep.pr_fpu.fpu_rsvd1);
193 // OBSOLETE if (ep.pr_fpu.fpu_rsvd2)
194 // OBSOLETE warning ("rsvd2 is 0x%x\n", ep.pr_fpu.fpu_rsvd2);
195 // OBSOLETE if (ep.pr_fpu.fpu_rsvd3)
196 // OBSOLETE warning ("rsvd3 is 0x%x\n", ep.pr_fpu.fpu_rsvd3);
197 // OBSOLETE if (ep.pr_fpu.fpu_rsvd5)
198 // OBSOLETE warning ("rsvd5 is 0x%x\n", ep.pr_fpu.fpu_rsvd5);
202 // OBSOLETE print_1167_control_word (unsigned int pcr)
204 // OBSOLETE int pcr_tmp;
206 // OBSOLETE pcr_tmp = pcr & FPA_PCR_MODE;
207 // OBSOLETE printf_unfiltered ("\tMODE= %#x; RND= %#x ", pcr_tmp, pcr_tmp & 12);
208 // OBSOLETE switch (pcr_tmp & 12)
211 // OBSOLETE printf_unfiltered ("RN (Nearest Value)");
214 // OBSOLETE printf_unfiltered ("RZ (Zero)");
217 // OBSOLETE printf_unfiltered ("RP (Positive Infinity)");
220 // OBSOLETE printf_unfiltered ("RM (Negative Infinity)");
223 // OBSOLETE printf_unfiltered ("; IRND= %d ", pcr_tmp & 2);
224 // OBSOLETE if (0 == pcr_tmp & 2)
226 // OBSOLETE printf_unfiltered ("(same as RND)\n");
230 // OBSOLETE printf_unfiltered ("(toward zero)\n");
232 // OBSOLETE pcr_tmp = pcr & FPA_PCR_EM;
233 // OBSOLETE printf_unfiltered ("\tEM= %#x", pcr_tmp);
234 // OBSOLETE if (pcr_tmp & FPA_PCR_EM_DM)
235 // OBSOLETE printf_unfiltered (" DM");
236 // OBSOLETE if (pcr_tmp & FPA_PCR_EM_UOM)
237 // OBSOLETE printf_unfiltered (" UOM");
238 // OBSOLETE if (pcr_tmp & FPA_PCR_EM_PM)
239 // OBSOLETE printf_unfiltered (" PM");
240 // OBSOLETE if (pcr_tmp & FPA_PCR_EM_UM)
241 // OBSOLETE printf_unfiltered (" UM");
242 // OBSOLETE if (pcr_tmp & FPA_PCR_EM_OM)
243 // OBSOLETE printf_unfiltered (" OM");
244 // OBSOLETE if (pcr_tmp & FPA_PCR_EM_ZM)
245 // OBSOLETE printf_unfiltered (" ZM");
246 // OBSOLETE if (pcr_tmp & FPA_PCR_EM_IM)
247 // OBSOLETE printf_unfiltered (" IM");
248 // OBSOLETE printf_unfiltered ("\n");
249 // OBSOLETE pcr_tmp = FPA_PCR_CC;
250 // OBSOLETE printf_unfiltered ("\tCC= %#x", pcr_tmp);
251 // OBSOLETE if (pcr_tmp & FPA_PCR_20MHZ)
252 // OBSOLETE printf_unfiltered (" 20MHZ");
253 // OBSOLETE if (pcr_tmp & FPA_PCR_CC_Z)
254 // OBSOLETE printf_unfiltered (" Z");
255 // OBSOLETE if (pcr_tmp & FPA_PCR_CC_C2)
256 // OBSOLETE printf_unfiltered (" C2");
258 // OBSOLETE /* Dynix defines FPA_PCR_CC_C0 to 0x100 and ptx defines
259 // OBSOLETE FPA_PCR_CC_C1 to 0x100. Use whichever is defined and assume
260 // OBSOLETE the OS knows what it is doing. */
261 // OBSOLETE #ifdef FPA_PCR_CC_C1
262 // OBSOLETE if (pcr_tmp & FPA_PCR_CC_C1)
263 // OBSOLETE printf_unfiltered (" C1");
265 // OBSOLETE if (pcr_tmp & FPA_PCR_CC_C0)
266 // OBSOLETE printf_unfiltered (" C0");
269 // OBSOLETE switch (pcr_tmp)
271 // OBSOLETE case FPA_PCR_CC_Z:
272 // OBSOLETE printf_unfiltered (" (Equal)");
274 // OBSOLETE #ifdef FPA_PCR_CC_C1
275 // OBSOLETE case FPA_PCR_CC_C1:
277 // OBSOLETE case FPA_PCR_CC_C0:
279 // OBSOLETE printf_unfiltered (" (Less than)");
282 // OBSOLETE printf_unfiltered (" (Greater than)");
284 // OBSOLETE case FPA_PCR_CC_Z |
285 // OBSOLETE #ifdef FPA_PCR_CC_C1
286 // OBSOLETE FPA_PCR_CC_C1
288 // OBSOLETE FPA_PCR_CC_C0
290 // OBSOLETE | FPA_PCR_CC_C2:
291 // OBSOLETE printf_unfiltered (" (Unordered)");
294 // OBSOLETE printf_unfiltered (" (Undefined)");
297 // OBSOLETE printf_unfiltered ("\n");
298 // OBSOLETE pcr_tmp = pcr & FPA_PCR_AE;
299 // OBSOLETE printf_unfiltered ("\tAE= %#x", pcr_tmp);
300 // OBSOLETE if (pcr_tmp & FPA_PCR_AE_DE)
301 // OBSOLETE printf_unfiltered (" DE");
302 // OBSOLETE if (pcr_tmp & FPA_PCR_AE_UOE)
303 // OBSOLETE printf_unfiltered (" UOE");
304 // OBSOLETE if (pcr_tmp & FPA_PCR_AE_PE)
305 // OBSOLETE printf_unfiltered (" PE");
306 // OBSOLETE if (pcr_tmp & FPA_PCR_AE_UE)
307 // OBSOLETE printf_unfiltered (" UE");
308 // OBSOLETE if (pcr_tmp & FPA_PCR_AE_OE)
309 // OBSOLETE printf_unfiltered (" OE");
310 // OBSOLETE if (pcr_tmp & FPA_PCR_AE_ZE)
311 // OBSOLETE printf_unfiltered (" ZE");
312 // OBSOLETE if (pcr_tmp & FPA_PCR_AE_EE)
313 // OBSOLETE printf_unfiltered (" EE");
314 // OBSOLETE if (pcr_tmp & FPA_PCR_AE_IE)
315 // OBSOLETE printf_unfiltered (" IE");
316 // OBSOLETE printf_unfiltered ("\n");
319 // OBSOLETE print_1167_regs (long regs[FPA_NREGS])
325 // OBSOLETE double d;
326 // OBSOLETE long l[2];
337 // OBSOLETE for (i = 0; i < FPA_NREGS; i++)
339 // OBSOLETE xf.l = regs[i];
340 // OBSOLETE printf_unfiltered ("%%fp%d: raw= %#x, single= %f", i + 1, regs[i], xf.f);
341 // OBSOLETE if (!(i & 1))
343 // OBSOLETE printf_unfiltered ("\n");
347 // OBSOLETE xd.l[1] = regs[i];
348 // OBSOLETE xd.l[0] = regs[i + 1];
349 // OBSOLETE printf_unfiltered (", double= %f\n", xd.d);
354 // OBSOLETE print_fpa_status (struct pt_regset ep)
357 // OBSOLETE printf_unfiltered ("WTL 1167:");
358 // OBSOLETE if (ep.pr_fpa.fpa_pcr != 0)
360 // OBSOLETE printf_unfiltered ("\n");
361 // OBSOLETE print_1167_control_word (ep.pr_fpa.fpa_pcr);
362 // OBSOLETE print_1167_regs (ep.pr_fpa.fpa_regs);
366 // OBSOLETE printf_unfiltered (" not in use.\n");
370 // OBSOLETE #if 0 /* disabled because it doesn't go through the target vector. */
371 // OBSOLETE i386_float_info (void)
373 // OBSOLETE char ubuf[UPAGES * NBPG];
374 // OBSOLETE struct pt_regset regset;
376 // OBSOLETE if (have_inferior_p ())
378 // OBSOLETE PTRACE_READ_REGS (PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) & regset);
382 // OBSOLETE int corechan = bfd_cache_lookup (core_bfd);
383 // OBSOLETE if (lseek (corechan, 0, 0) < 0)
385 // OBSOLETE perror ("seek on core file");
387 // OBSOLETE if (myread (corechan, ubuf, UPAGES * NBPG) < 0)
389 // OBSOLETE perror ("read on core file");
391 // OBSOLETE /* only interested in the floating point registers */
392 // OBSOLETE regset.pr_fpu = ((struct user *) ubuf)->u_fpusave;
393 // OBSOLETE regset.pr_fpa = ((struct user *) ubuf)->u_fpasave;
395 // OBSOLETE print_fpu_status (regset);
396 // OBSOLETE print_fpa_status (regset);
400 // OBSOLETE static volatile int got_sigchld;
402 // OBSOLETE /*ARGSUSED */
403 // OBSOLETE /* This will eventually be more interesting. */
405 // OBSOLETE sigchld_handler (int signo)
407 // OBSOLETE got_sigchld++;
411 // OBSOLETE * Signals for which the default action does not cause the process
412 // OBSOLETE * to die. See <sys/signal.h> for where this came from (alas, we
413 // OBSOLETE * can't use those macros directly)
415 // OBSOLETE #ifndef sigmask
416 // OBSOLETE #define sigmask(s) (1 << ((s) - 1))
418 // OBSOLETE #define SIGNALS_DFL_SAFE sigmask(SIGSTOP) | sigmask(SIGTSTP) | \
419 // OBSOLETE sigmask(SIGTTIN) | sigmask(SIGTTOU) | sigmask(SIGCHLD) | \
420 // OBSOLETE sigmask(SIGCONT) | sigmask(SIGWINCH) | sigmask(SIGPWR) | \
421 // OBSOLETE sigmask(SIGURG) | sigmask(SIGPOLL)
423 // OBSOLETE #ifdef ATTACH_DETACH
425 // OBSOLETE * Thanks to XPT_MPDEBUGGER, we have to mange child_wait().
428 // OBSOLETE child_wait (ptid_t ptid, struct target_waitstatus *status)
430 // OBSOLETE int save_errno, rv, xvaloff, saoff, sa_hand;
431 // OBSOLETE struct pt_stop pt;
432 // OBSOLETE struct user u;
433 // OBSOLETE sigset_t set;
434 // OBSOLETE /* Host signal number for a signal which the inferior terminates with, or
435 // OBSOLETE 0 if it hasn't terminated due to a signal. */
436 // OBSOLETE static int death_by_signal = 0;
437 // OBSOLETE #ifdef SVR4_SHARED_LIBS /* use this to distinguish ptx 2 vs ptx 4 */
438 // OBSOLETE prstatus_t pstatus;
440 // OBSOLETE int pid = PIDGET (ptid);
444 // OBSOLETE set_sigint_trap (); /* Causes SIGINT to be passed on to the
445 // OBSOLETE attached process. */
446 // OBSOLETE save_errno = errno;
448 // OBSOLETE got_sigchld = 0;
450 // OBSOLETE sigemptyset (&set);
452 // OBSOLETE while (got_sigchld == 0)
454 // OBSOLETE sigsuspend (&set);
457 // OBSOLETE clear_sigint_trap ();
459 // OBSOLETE rv = mptrace (XPT_STOPSTAT, 0, (char *) &pt, 0);
460 // OBSOLETE if (-1 == rv)
462 // OBSOLETE printf ("XPT_STOPSTAT: errno %d\n", errno); /* DEBUG */
463 // OBSOLETE continue;
466 // OBSOLETE pid = pt.ps_pid;
468 // OBSOLETE if (pid != PIDGET (inferior_ptid))
470 // OBSOLETE /* NOTE: the mystery fork in csh/tcsh needs to be ignored.
471 // OBSOLETE * We should not return new children for the initial run
472 // OBSOLETE * of a process until it has done the exec.
474 // OBSOLETE /* inferior probably forked; send it on its way */
475 // OBSOLETE rv = mptrace (XPT_UNDEBUG, pid, 0, 0);
476 // OBSOLETE if (-1 == rv)
478 // OBSOLETE printf ("child_wait: XPT_UNDEBUG: pid %d: %s\n", pid,
479 // OBSOLETE safe_strerror (errno));
481 // OBSOLETE continue;
483 // OBSOLETE /* FIXME: Do we deal with fork notification correctly? */
484 // OBSOLETE switch (pt.ps_reason)
486 // OBSOLETE case PTS_FORK:
487 // OBSOLETE /* multi proc: treat like PTS_EXEC */
489 // OBSOLETE * Pretend this didn't happen, since gdb isn't set up
490 // OBSOLETE * to deal with stops on fork.
492 // OBSOLETE rv = ptrace (PT_CONTSIG, pid, 1, 0);
493 // OBSOLETE if (-1 == rv)
495 // OBSOLETE printf ("PTS_FORK: PT_CONTSIG: error %d\n", errno);
497 // OBSOLETE continue;
498 // OBSOLETE case PTS_EXEC:
500 // OBSOLETE * Pretend this is a SIGTRAP.
502 // OBSOLETE status->kind = TARGET_WAITKIND_STOPPED;
503 // OBSOLETE status->value.sig = TARGET_SIGNAL_TRAP;
505 // OBSOLETE case PTS_EXIT:
507 // OBSOLETE * Note: we stop before the exit actually occurs. Extract
508 // OBSOLETE * the exit code from the uarea. If we're stopped in the
509 // OBSOLETE * exit() system call, the exit code will be in
510 // OBSOLETE * u.u_ap[0]. An exit due to an uncaught signal will have
511 // OBSOLETE * something else in here, see the comment in the default:
512 // OBSOLETE * case, below. Finally,let the process exit.
514 // OBSOLETE if (death_by_signal)
516 // OBSOLETE status->kind = TARGET_WAITKIND_SIGNALED;
517 // OBSOLETE status->value.sig = target_signal_from_host (death_by_signal);
518 // OBSOLETE death_by_signal = 0;
521 // OBSOLETE xvaloff = (unsigned long) &u.u_ap[0] - (unsigned long) &u;
522 // OBSOLETE errno = 0;
523 // OBSOLETE rv = ptrace (PT_RUSER, pid, (char *) xvaloff, 0);
524 // OBSOLETE status->kind = TARGET_WAITKIND_EXITED;
525 // OBSOLETE status->value.integer = rv;
527 // OBSOLETE * addr & data to mptrace() don't matter here, since
528 // OBSOLETE * the process is already dead.
530 // OBSOLETE rv = mptrace (XPT_UNDEBUG, pid, 0, 0);
531 // OBSOLETE if (-1 == rv)
533 // OBSOLETE printf ("child_wait: PTS_EXIT: XPT_UNDEBUG: pid %d error %d\n", pid,
537 // OBSOLETE case PTS_WATCHPT_HIT:
538 // OBSOLETE internal_error (__FILE__, __LINE__,
539 // OBSOLETE "PTS_WATCHPT_HIT\n");
542 // OBSOLETE /* stopped by signal */
543 // OBSOLETE status->kind = TARGET_WAITKIND_STOPPED;
544 // OBSOLETE status->value.sig = target_signal_from_host (pt.ps_reason);
545 // OBSOLETE death_by_signal = 0;
547 // OBSOLETE if (0 == (SIGNALS_DFL_SAFE & sigmask (pt.ps_reason)))
551 // OBSOLETE /* else default action of signal is to die */
552 // OBSOLETE #ifdef SVR4_SHARED_LIBS
553 // OBSOLETE rv = ptrace (PT_GET_PRSTATUS, pid, (char *) &pstatus, 0);
554 // OBSOLETE if (-1 == rv)
555 // OBSOLETE error ("child_wait: signal %d PT_GET_PRSTATUS: %s\n",
556 // OBSOLETE pt.ps_reason, safe_strerror (errno));
557 // OBSOLETE if (pstatus.pr_cursig != pt.ps_reason)
559 // OBSOLETE printf ("pstatus signal %d, pt signal %d\n",
560 // OBSOLETE pstatus.pr_cursig, pt.ps_reason);
562 // OBSOLETE sa_hand = (int) pstatus.pr_action.sa_handler;
564 // OBSOLETE saoff = (unsigned long) &u.u_sa[0] - (unsigned long) &u;
565 // OBSOLETE saoff += sizeof (struct sigaction) * (pt.ps_reason - 1);
566 // OBSOLETE errno = 0;
567 // OBSOLETE sa_hand = ptrace (PT_RUSER, pid, (char *) saoff, 0);
568 // OBSOLETE if (errno)
569 // OBSOLETE error ("child_wait: signal %d: RUSER: %s\n",
570 // OBSOLETE pt.ps_reason, safe_strerror (errno));
572 // OBSOLETE if ((int) SIG_DFL == sa_hand)
574 // OBSOLETE /* we will be dying */
575 // OBSOLETE death_by_signal = pt.ps_reason;
581 // OBSOLETE while (pid != PIDGET (inferior_ptid)); /* Some other child died or stopped */
583 // OBSOLETE return pid_to_ptid (pid);
585 // OBSOLETE #else /* !ATTACH_DETACH */
587 // OBSOLETE * Simple child_wait() based on inftarg.c child_wait() for use until
588 // OBSOLETE * the MPDEBUGGER child_wait() works properly. This will go away when
589 // OBSOLETE * that is fixed.
592 // OBSOLETE child_wait (ptid_t ptid, struct target_waitstatus *ourstatus)
594 // OBSOLETE int save_errno;
595 // OBSOLETE int status;
596 // OBSOLETE int pid = PIDGET (ptid);
600 // OBSOLETE pid = wait (&status);
601 // OBSOLETE save_errno = errno;
603 // OBSOLETE if (pid == -1)
605 // OBSOLETE if (save_errno == EINTR)
606 // OBSOLETE continue;
607 // OBSOLETE fprintf (stderr, "Child process unexpectedly missing: %s.\n",
608 // OBSOLETE safe_strerror (save_errno));
609 // OBSOLETE ourstatus->kind = TARGET_WAITKIND_SIGNALLED;
610 // OBSOLETE ourstatus->value.sig = TARGET_SIGNAL_UNKNOWN;
611 // OBSOLETE return pid_to_ptid (-1);
614 // OBSOLETE while (pid != PIDGET (inferior_ptid)); /* Some other child died or stopped */
615 // OBSOLETE store_waitstatus (ourstatus, status);
616 // OBSOLETE return pid_to_ptid (pid);
618 // OBSOLETE #endif /* ATTACH_DETACH */
622 // OBSOLETE /* This function simply calls ptrace with the given arguments.
623 // OBSOLETE It exists so that all calls to ptrace are isolated in this
624 // OBSOLETE machine-dependent file. */
626 // OBSOLETE call_ptrace (int request, int pid, PTRACE_ARG3_TYPE addr, int data)
628 // OBSOLETE return ptrace (request, pid, addr, data);
632 // OBSOLETE call_mptrace (int request, int pid, PTRACE_ARG3_TYPE addr, int data)
634 // OBSOLETE return mptrace (request, pid, addr, data);
637 // OBSOLETE #if defined (DEBUG_PTRACE)
638 // OBSOLETE /* For the rest of the file, use an extra level of indirection */
639 // OBSOLETE /* This lets us breakpoint usefully on call_ptrace. */
640 // OBSOLETE #define ptrace call_ptrace
641 // OBSOLETE #define mptrace call_mptrace
645 // OBSOLETE kill_inferior (void)
647 // OBSOLETE if (ptid_equal (inferior_ptid, null_ptid))
650 // OBSOLETE /* For MPDEBUGGER, don't use PT_KILL, since the child will stop
651 // OBSOLETE again with a PTS_EXIT. Just hit him with SIGKILL (so he stops)
652 // OBSOLETE and detach. */
654 // OBSOLETE kill (PIDGET (inferior_ptid), SIGKILL);
655 // OBSOLETE #ifdef ATTACH_DETACH
656 // OBSOLETE detach (SIGKILL);
657 // OBSOLETE #else /* ATTACH_DETACH */
658 // OBSOLETE ptrace (PT_KILL, PIDGET (inferior_ptid), 0, 0);
659 // OBSOLETE wait ((int *) NULL);
660 // OBSOLETE #endif /* ATTACH_DETACH */
661 // OBSOLETE target_mourn_inferior ();
664 // OBSOLETE /* Resume execution of the inferior process.
665 // OBSOLETE If STEP is nonzero, single-step it.
666 // OBSOLETE If SIGNAL is nonzero, give it that signal. */
669 // OBSOLETE child_resume (ptid_t ptid, int step, enum target_signal signal)
671 // OBSOLETE int pid = PIDGET (ptid);
673 // OBSOLETE errno = 0;
675 // OBSOLETE if (pid == -1)
676 // OBSOLETE pid = PIDGET (inferior_ptid);
678 // OBSOLETE /* An address of (PTRACE_ARG3_TYPE)1 tells ptrace to continue from where
679 // OBSOLETE it was. (If GDB wanted it to start some other way, we have already
680 // OBSOLETE written a new PC value to the child.)
682 // OBSOLETE If this system does not support PT_SSTEP, a higher level function will
683 // OBSOLETE have called single_step() to transmute the step request into a
684 // OBSOLETE continue request (by setting breakpoints on all possible successor
685 // OBSOLETE instructions), so we don't have to worry about that here. */
687 // OBSOLETE if (step)
688 // OBSOLETE ptrace (PT_SSTEP, pid, (PTRACE_ARG3_TYPE) 1, signal);
690 // OBSOLETE ptrace (PT_CONTSIG, pid, (PTRACE_ARG3_TYPE) 1, signal);
692 // OBSOLETE if (errno)
693 // OBSOLETE perror_with_name ("ptrace");
696 // OBSOLETE #ifdef ATTACH_DETACH
697 // OBSOLETE /* Start debugging the process whose number is PID. */
699 // OBSOLETE attach (int pid)
701 // OBSOLETE sigset_t set;
704 // OBSOLETE rv = mptrace (XPT_DEBUG, pid, 0, 0);
705 // OBSOLETE if (-1 == rv)
707 // OBSOLETE error ("mptrace(XPT_DEBUG): %s", safe_strerror (errno));
709 // OBSOLETE rv = mptrace (XPT_SIGNAL, pid, 0, SIGSTOP);
710 // OBSOLETE if (-1 == rv)
712 // OBSOLETE error ("mptrace(XPT_SIGNAL): %s", safe_strerror (errno));
714 // OBSOLETE attach_flag = 1;
715 // OBSOLETE return pid;
719 // OBSOLETE detach (int signo)
723 // OBSOLETE rv = mptrace (XPT_UNDEBUG, PIDGET (inferior_ptid), 1, signo);
724 // OBSOLETE if (-1 == rv)
726 // OBSOLETE error ("mptrace(XPT_UNDEBUG): %s", safe_strerror (errno));
728 // OBSOLETE attach_flag = 0;
731 // OBSOLETE #endif /* ATTACH_DETACH */
733 // OBSOLETE /* Default the type of the ptrace transfer to int. */
734 // OBSOLETE #ifndef PTRACE_XFER_TYPE
735 // OBSOLETE #define PTRACE_XFER_TYPE int
739 // OBSOLETE /* NOTE! I tried using PTRACE_READDATA, etc., to read and write memory
740 // OBSOLETE in the NEW_SUN_PTRACE case.
741 // OBSOLETE It ought to be straightforward. But it appears that writing did
742 // OBSOLETE not write the data that I specified. I cannot understand where
743 // OBSOLETE it got the data that it actually did write. */
745 // OBSOLETE /* Copy LEN bytes to or from inferior's memory starting at MEMADDR
746 // OBSOLETE to debugger memory starting at MYADDR. Copy to inferior if
747 // OBSOLETE WRITE is nonzero. TARGET is ignored.
749 // OBSOLETE Returns the length copied, which is either the LEN argument or zero.
750 // OBSOLETE This xfer function does not do partial moves, since child_ops
751 // OBSOLETE doesn't allow memory operations to cross below us in the target stack
752 // OBSOLETE anyway. */
755 // OBSOLETE child_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
756 // OBSOLETE struct mem_attrib *attrib,
757 // OBSOLETE struct target_ops *target)
759 // OBSOLETE register int i;
760 // OBSOLETE /* Round starting address down to longword boundary. */
761 // OBSOLETE register CORE_ADDR addr = memaddr & -(CORE_ADDR) sizeof (PTRACE_XFER_TYPE);
762 // OBSOLETE /* Round ending address up; get number of longwords that makes. */
763 // OBSOLETE register int count
764 // OBSOLETE = (((memaddr + len) - addr) + sizeof (PTRACE_XFER_TYPE) - 1)
765 // OBSOLETE / sizeof (PTRACE_XFER_TYPE);
766 // OBSOLETE /* Allocate buffer of that many longwords. */
767 // OBSOLETE /* FIXME (alloca): This code, cloned from infptrace.c, is unsafe
768 // OBSOLETE because it uses alloca to allocate a buffer of arbitrary size.
769 // OBSOLETE For very large xfers, this could crash GDB's stack. */
770 // OBSOLETE register PTRACE_XFER_TYPE *buffer
771 // OBSOLETE = (PTRACE_XFER_TYPE *) alloca (count * sizeof (PTRACE_XFER_TYPE));
773 // OBSOLETE if (write)
775 // OBSOLETE /* Fill start and end extra bytes of buffer with existing memory data. */
777 // OBSOLETE if (addr != memaddr || len < (int) sizeof (PTRACE_XFER_TYPE))
779 // OBSOLETE /* Need part of initial word -- fetch it. */
780 // OBSOLETE buffer[0] = ptrace (PT_RTEXT, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) addr,
784 // OBSOLETE if (count > 1) /* FIXME, avoid if even boundary */
786 // OBSOLETE buffer[count - 1]
787 // OBSOLETE = ptrace (PT_RTEXT, PIDGET (inferior_ptid),
788 // OBSOLETE ((PTRACE_ARG3_TYPE)
789 // OBSOLETE (addr + (count - 1) * sizeof (PTRACE_XFER_TYPE))),
793 // OBSOLETE /* Copy data to be written over corresponding part of buffer */
795 // OBSOLETE memcpy ((char *) buffer + (memaddr & (sizeof (PTRACE_XFER_TYPE) - 1)),
799 // OBSOLETE /* Write the entire buffer. */
801 // OBSOLETE for (i = 0; i < count; i++, addr += sizeof (PTRACE_XFER_TYPE))
803 // OBSOLETE errno = 0;
804 // OBSOLETE ptrace (PT_WDATA, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) addr,
805 // OBSOLETE buffer[i]);
806 // OBSOLETE if (errno)
808 // OBSOLETE /* Using the appropriate one (I or D) is necessary for
809 // OBSOLETE Gould NP1, at least. */
810 // OBSOLETE errno = 0;
811 // OBSOLETE ptrace (PT_WTEXT, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) addr,
812 // OBSOLETE buffer[i]);
814 // OBSOLETE if (errno)
815 // OBSOLETE return 0;
820 // OBSOLETE /* Read all the longwords */
821 // OBSOLETE for (i = 0; i < count; i++, addr += sizeof (PTRACE_XFER_TYPE))
823 // OBSOLETE errno = 0;
824 // OBSOLETE buffer[i] = ptrace (PT_RTEXT, PIDGET (inferior_ptid),
825 // OBSOLETE (PTRACE_ARG3_TYPE) addr, 0);
826 // OBSOLETE if (errno)
827 // OBSOLETE return 0;
831 // OBSOLETE /* Copy appropriate bytes out of the buffer. */
832 // OBSOLETE memcpy (myaddr,
833 // OBSOLETE (char *) buffer + (memaddr & (sizeof (PTRACE_XFER_TYPE) - 1)),
836 // OBSOLETE return len;
841 // OBSOLETE _initialize_symm_nat (void)
843 // OBSOLETE #ifdef ATTACH_DETACH
845 // OBSOLETE * the MPDEBUGGER is necessary for process tree debugging and attach
846 // OBSOLETE * to work, but it alters the behavior of debugged processes, so other
847 // OBSOLETE * things (at least child_wait()) will have to change to accomodate
850 // OBSOLETE * Note that attach is not implemented in dynix 3, and not in ptx
851 // OBSOLETE * until version 2.1 of the OS.
854 // OBSOLETE sigset_t set;
855 // OBSOLETE struct sigaction sact;
857 // OBSOLETE rv = mptrace (XPT_MPDEBUGGER, 0, 0, 0);
858 // OBSOLETE if (-1 == rv)
860 // OBSOLETE internal_error (__FILE__, __LINE__,
861 // OBSOLETE "_initialize_symm_nat(): mptrace(XPT_MPDEBUGGER): %s",
862 // OBSOLETE safe_strerror (errno));
866 // OBSOLETE * Under MPDEBUGGER, we get SIGCLHD when a traced process does
867 // OBSOLETE * anything of interest.
871 // OBSOLETE * Block SIGCHLD. We leave it blocked all the time, and then
872 // OBSOLETE * call sigsuspend() in child_wait() to wait for the child
873 // OBSOLETE * to do something. None of these ought to fail, but check anyway.
875 // OBSOLETE sigemptyset (&set);
876 // OBSOLETE rv = sigaddset (&set, SIGCHLD);
877 // OBSOLETE if (-1 == rv)
879 // OBSOLETE internal_error (__FILE__, __LINE__,
880 // OBSOLETE "_initialize_symm_nat(): sigaddset(SIGCHLD): %s",
881 // OBSOLETE safe_strerror (errno));
883 // OBSOLETE rv = sigprocmask (SIG_BLOCK, &set, (sigset_t *) NULL);
884 // OBSOLETE if (-1 == rv)
886 // OBSOLETE internal_error (__FILE__, __LINE__,
887 // OBSOLETE "_initialize_symm_nat(): sigprocmask(SIG_BLOCK): %s",
888 // OBSOLETE safe_strerror (errno));
891 // OBSOLETE sact.sa_handler = sigchld_handler;
892 // OBSOLETE sigemptyset (&sact.sa_mask);
893 // OBSOLETE sact.sa_flags = SA_NOCLDWAIT; /* keep the zombies away */
894 // OBSOLETE rv = sigaction (SIGCHLD, &sact, (struct sigaction *) NULL);
895 // OBSOLETE if (-1 == rv)
897 // OBSOLETE internal_error (__FILE__, __LINE__,
898 // OBSOLETE "_initialize_symm_nat(): sigaction(SIGCHLD): %s",
899 // OBSOLETE safe_strerror (errno));
This page took 0.048639 seconds and 4 git commands to generate.