1 /* Low level interface to ptrace, for GDB when running under Unix.
2 Copyright (C) 1986, 1987 Free Software Foundation, Inc.
4 GDB is distributed in the hope that it will be useful, but WITHOUT ANY
5 WARRANTY. No author or distributor accepts responsibility to anyone
6 for the consequences of using it or for whether it serves any
7 particular purpose or works at all, unless he says so in writing.
8 Refer to the GDB General Public License for full details.
10 Everyone is granted permission to copy, modify and redistribute GDB,
11 but only under the conditions described in the GDB General Public
12 License. A copy of this license is supposed to have been given to you
13 along with GDB so you can know your rights and responsibilities. It
14 should be in a file named COPYING. Among other things, the copyright
15 notice and this notice must be preserved on all copies.
17 In other words, go ahead and share GDB, but don't try to stop
18 anyone else from sharing it farther. Help stamp out software hoarding!
22 #include "initialize.h"
28 #include <sys/param.h>
34 #include <sys/ioctl.h>
39 #include <sys/ptrace.h>
40 #define PTRACE_ATTACH PT_ATTACH
41 #define PTRACE_DETACH PT_FREEPROC
45 #include <sys/ptrace.h>
46 #include <machine/reg.h>
50 #include <sys/ptrace.h>
58 #define TIOCGETP TCGETA
60 #define TIOCSETN TCSETA
62 #define TIOCSETP TCSETAF
63 #define TERMINAL struct termio
66 #define TERMINAL struct sgttyb
71 /* Nonzero if we are debugging an attached outside process
72 rather than an inferior. */
74 static int attach_flag;
78 /* Record terminal status separately for debugger and inferior. */
80 static TERMINAL sg_inferior;
81 static TERMINAL sg_ours;
82 static int tflags_inferior;
83 static int tflags_ours;
86 static struct tchars tc_inferior;
87 static struct tchars tc_ours;
88 static struct ltchars ltc_inferior;
89 static struct ltchars ltc_ours;
90 static int lmode_inferior;
91 static int lmode_ours;
95 static int pgrp_inferior;
98 static int (*sigint_ours) ();
99 static int (*sigquit_ours) ();
100 #endif /* TIOCGPGRP */
102 /* Copy of inferior_io_terminal when inferior was last started. */
103 static char *inferior_thisrun_terminal;
105 static void terminal_ours_1 ();
107 /* Nonzero if our terminal settings are in effect.
108 Zero if the inferior's settings are in effect. */
109 static int terminal_is_ours;
111 /* Initialize the terminal settings we record for the inferior,
112 before we actually run the inferior. */
115 terminal_init_inferior ()
117 if (remote_debugging)
120 sg_inferior = sg_ours;
121 tflags_inferior = tflags_ours;
124 tc_inferior = tc_ours;
125 ltc_inferior = ltc_ours;
126 lmode_inferior = lmode_ours;
127 #endif /* TIOCGLTC */
130 pgrp_inferior = inferior_pid;
131 #endif /* TIOCGPGRP */
133 terminal_is_ours = 1;
136 /* Put the inferior's terminal settings into effect.
137 This is preparation for starting or resuming the inferior. */
142 if (remote_debugging)
145 if (terminal_is_ours) /* && inferior_thisrun_terminal == 0) */
147 fcntl (0, F_SETFL, tflags_inferior);
148 fcntl (0, F_SETFL, tflags_inferior);
149 ioctl (0, TIOCSETN, &sg_inferior);
152 ioctl (0, TIOCSETC, &tc_inferior);
153 ioctl (0, TIOCSLTC, <c_inferior);
154 ioctl (0, TIOCLSET, &lmode_inferior);
155 #endif /* TIOCGLTC */
158 ioctl (0, TIOCSPGRP, &pgrp_inferior);
160 sigint_ours = (signal (SIGINT, SIG_IGN));
161 sigquit_ours = (signal (SIGQUIT, SIG_IGN));
162 #endif /* TIOCGPGRP */
164 terminal_is_ours = 0;
167 /* Put some of our terminal settings into effect,
168 enough to get proper results from our output,
169 but do not change into or out of RAW mode
170 so that no input is discarded.
172 After doing this, either terminal_ours or terminal_inferior
173 should be called to get back to a normal state of affairs. */
176 terminal_ours_for_output ()
178 if (remote_debugging)
184 /* Put our terminal settings into effect.
185 First record the inferior's terminal settings
186 so they can be restored properly later. */
191 if (remote_debugging)
198 terminal_ours_1 (output_only)
202 /* Ignore this signal since it will happen when we try to set the pgrp. */
204 #endif /* TIOCGPGRP */
206 if (!terminal_is_ours) /* && inferior_thisrun_terminal == 0) */
208 terminal_is_ours = 1;
211 osigttou = signal (SIGTTOU, SIG_IGN);
213 ioctl (0, TIOCGPGRP, &pgrp_inferior);
214 ioctl (0, TIOCSPGRP, &pgrp_ours);
216 signal (SIGTTOU, osigttou);
218 signal (SIGINT, sigint_ours);
219 signal (SIGQUIT, sigquit_ours);
220 #endif /* TIOCGPGRP */
222 tflags_inferior = fcntl (0, F_GETFL, 0);
223 ioctl (0, TIOCGETP, &sg_inferior);
226 ioctl (0, TIOCGETC, &tc_inferior);
227 ioctl (0, TIOCGLTC, <c_inferior);
228 ioctl (0, TIOCLGET, &lmode_inferior);
229 #endif /* TIOCGLTC */
233 sg_ours.c_lflag |= ICANON;
234 if (output_only && !(sg_inferior.c_lflag & ICANON))
235 sg_ours.c_lflag &= ~ICANON;
236 #else /* not HAVE_TERMIO */
237 sg_ours.sg_flags &= ~RAW & ~CBREAK;
239 sg_ours.sg_flags |= (RAW | CBREAK) & sg_inferior.sg_flags;
240 #endif /* not HAVE_TERMIO */
242 fcntl (0, F_SETFL, tflags_ours);
243 fcntl (0, F_SETFL, tflags_ours);
244 ioctl (0, TIOCSETN, &sg_ours);
247 ioctl (0, TIOCSETC, &tc_ours);
248 ioctl (0, TIOCSLTC, <c_ours);
249 ioctl (0, TIOCLSET, &lmode_ours);
250 #endif /* TIOCGLTC */
254 sg_ours.c_lflag |= ICANON;
255 #else /* not HAVE_TERMIO */
256 sg_ours.sg_flags &= ~RAW & ~CBREAK;
257 #endif /* not HAVE_TERMIO */
261 term_status_command ()
265 if (remote_debugging)
267 printf ("No terminal status when remote debugging.\n");
271 printf ("Inferior's terminal status (currently saved by GDB):\n");
275 printf ("fcntl flags = 0x%x, c_iflag = 0x%x, c_oflag = 0x%x,\n",
276 tflags_inferior, sg_inferior.c_iflag, sg_inferior.c_oflag);
277 printf ("c_cflag = 0x%x, c_lflag = 0x%x, c_line = 0x%x.\n",
278 sg_inferior.c_cflag, sg_inferior.c_lflag, sg_inferior.c_line);
280 for (i = 0; (i < NCC); i += 1)
281 printf ("0x%x ", sg_inferior.c_cc[i]);
284 #else /* not HAVE_TERMIO */
286 printf ("fcntl flags = 0x%x, lmode = 0x%x,\nsgttyb.sg_flags = 0x%x, owner pid = %d.\n",
287 tflags_inferior, lmode_inferior,
288 sg_inferior.sg_flags, pgrp_inferior);
290 for (i = 0; i < sizeof (struct tchars); i++)
291 printf ("0x%x ", ((char *)&tc_inferior)[i]);
293 printf ("ltchars: ");
294 for (i = 0; i < sizeof (struct ltchars); i++)
295 printf ("0x%x ", ((char *)<c_inferior)[i]);
297 #endif /* not HAVE_TERMIO */
308 /* I think it is better not to do this. Then C-z on the GDB terminal
309 will still stop the program, while C-z on the data terminal
312 /* Disconnect the child process from our controlling terminal. */
313 tty = open("/dev/tty", O_RDWR);
316 ioctl(tty, TIOCNOTTY, 0);
320 /* Now open the specified new terminal. */
322 tty = open(ttyname, O_RDWR);
332 /* Start an inferior process and returns its pid.
333 ALLARGS is a string containing shell command to run the program.
334 ENV is the environment vector to pass. */
337 #define SHELL_FILE "/bin/sh"
341 create_inferior (allargs, env)
348 extern char *sys_errlist[];
351 /* If desired, concat something onto the front of ALLARGS.
352 SHELL_COMMAND is the result. */
353 #ifdef SHELL_COMMAND_CONCAT
354 shell_command = (char *) alloca (strlen (SHELL_COMMAND_CONCAT) + strlen (allargs) + 1);
355 strcpy (shell_command, SHELL_COMMAND_CONCAT);
356 strcat (shell_command, allargs);
358 shell_command = allargs;
361 /* exec is said to fail if the executable is open. */
366 perror_with_name ("vfork");
373 /* Run inferior in a separate process group. */
374 setpgrp (getpid (), getpid ());
375 #endif /* TIOCGPGRP */
377 inferior_thisrun_terminal = inferior_io_terminal;
378 if (inferior_io_terminal != 0)
379 new_tty (inferior_io_terminal);
381 /* Not needed on Sun, at least, and loses there
382 because it clobbers the superior. */
383 /*??? signal (SIGQUIT, SIG_DFL);
384 signal (SIGINT, SIG_DFL); */
390 args[2] = shell_command;
393 execve (SHELL_FILE, args, env);
395 fprintf (stderr, "Cannot exec %s: %s.\n", SHELL_FILE,
396 errno < sys_nerr ? sys_errlist[errno] : "unknown error");
403 /* Kill the inferior process. Make us have no inferior. */
408 if (remote_debugging)
410 if (inferior_pid == 0)
411 error ("The program is not being run.");
412 if (!query ("Kill the inferior process? "))
413 error ("Not confirmed.");
419 if (remote_debugging)
421 if (inferior_pid == 0)
423 ptrace (8, inferior_pid, 0, 0);
428 /* This is used when GDB is exiting. It gives less chance of error.*/
430 kill_inferior_fast ()
432 if (remote_debugging)
434 if (inferior_pid == 0)
436 ptrace (8, inferior_pid, 0, 0);
444 mark_breakpoints_out ();
446 if (have_core_file_p ())
447 set_current_frame (read_register (FP_REGNUM));
450 /* Resume execution of the inferior process.
451 If STEP is nonzero, single-step it.
452 If SIGNAL is nonzero, give it that signal. */
455 resume (step, signal)
460 if (remote_debugging)
461 remote_resume (step, signal);
464 #ifdef NO_SINGLE_STEP
467 single_step (signal);
469 else ptrace (7, inferior_pid, 1, signal);
471 ptrace (step ? 9 : 7, inferior_pid, 1, signal);
474 perror_with_name ("ptrace");
480 /* Start debugging the process whose number is PID. */
486 ptrace (PTRACE_ATTACH, pid, 0, 0);
488 perror_with_name ("ptrace");
493 /* Stop debugging the process whose number is PID
494 and continue it with signal number SIGNAL.
495 SIGNAL = 0 means just continue it. */
502 ptrace (PTRACE_DETACH, inferior_pid, 1, signal);
504 perror_with_name ("ptrace");
507 #endif /* ATTACH_DETACH */
509 #ifdef NEW_SUN_PTRACE
512 fetch_inferior_registers ()
514 struct regs inferior_registers;
515 struct fp_status inferior_fp_registers;
516 extern char registers[];
518 if (remote_debugging)
519 remote_fetch_registers (registers);
522 ptrace (PTRACE_GETREGS, inferior_pid, &inferior_registers);
523 ptrace (PTRACE_GETFPREGS, inferior_pid, &inferior_fp_registers);
525 #if defined(sun2) || defined(sun3)
526 bcopy (&inferior_registers, registers, 16 * 4);
527 bcopy (&inferior_fp_registers, ®isters[REGISTER_BYTE (FP0_REGNUM)],
528 sizeof inferior_fp_registers.fps_regs);
529 *(int *)®isters[REGISTER_BYTE (PS_REGNUM)] = inferior_registers.r_ps;
530 *(int *)®isters[REGISTER_BYTE (PC_REGNUM)] = inferior_registers.r_pc;
531 bcopy (&inferior_fp_registers.fps_control,
532 ®isters[REGISTER_BYTE (FPC_REGNUM)],
533 sizeof inferior_fp_registers - sizeof inferior_fp_registers.fps_regs);
536 registers[REGISTER_BYTE (0)] = 0;
537 bcopy (&inferior_registers.r_g1, ®isters[REGISTER_BYTE (1)], 15 * 4);
538 bcopy (&inferior_fp_registers, ®isters[REGISTER_BYTE (FP0_REGNUM)],
539 sizeof inferior_fp_registers.fpu_fr);
540 *(int *)®isters[REGISTER_BYTE (PS_REGNUM)] = inferior_registers.r_ps;
541 *(int *)®isters[REGISTER_BYTE (PC_REGNUM)] = inferior_registers.r_pc;
542 *(int *)®isters[REGISTER_BYTE (NPC_REGNUM)] = inferior_registers.r_npc;
543 *(int *)®isters[REGISTER_BYTE (Y_REGNUM)] = inferior_registers.r_y;
544 /* *(int *)®isters[REGISTER_BYTE (RP_REGNUM)] =
545 inferior_registers.r_o7 + 8;
546 bcopy (&inferior_fp_registers.Fpu_fsr,
547 ®isters[REGISTER_BYTE (FPS_REGNUM)],
548 sizeof (FPU_FSR_TYPE)); */
549 read_inferior_memory (inferior_registers.r_sp,
550 ®isters[REGISTER_BYTE (16)],
556 /* Store our register values back into the inferior.
557 If REGNO is -1, do this for all registers.
558 Otherwise, REGNO specifies which register (so we can save time). */
560 store_inferior_registers (regno)
563 struct regs inferior_registers;
564 struct fp_status inferior_fp_registers;
565 extern char registers[];
567 if (remote_debugging)
568 remote_store_registers (registers);
571 int in_regs = 1, in_fpregs = 1, in_fparegs, in_cpregs = 1;
573 #if defined(sun2) || defined(sun3)
576 bcopy (registers, &inferior_registers, 16 * 4);
577 inferior_registers.r_ps = *(int *)®isters[REGISTER_BYTE (PS_REGNUM)];
578 inferior_registers.r_pc = *(int *)®isters[REGISTER_BYTE (PC_REGNUM)];
582 bcopy (®isters[REGISTER_BYTE (FP0_REGNUM)], &inferior_fp_registers,
583 sizeof inferior_fp_registers.fps_regs);
584 bcopy (®isters[REGISTER_BYTE (FPC_REGNUM)],
585 &inferior_fp_registers.fps_control,
586 sizeof inferior_fp_registers - sizeof inferior_fp_registers.fps_regs);
589 ptrace (PTRACE_SETREGS, inferior_pid, &inferior_registers);
591 ptrace (PTRACE_SETFPREGS, inferior_pid, &inferior_fp_registers);
595 if (FP0_REGNUM <= regno && regno <= FP0_REGNUM + 32)
602 bcopy (®isters[REGISTER_BYTE (1)], &inferior_registers.r_g1, 15 * 4);
603 inferior_registers.r_ps = *(int *)®isters[REGISTER_BYTE (PS_REGNUM)];
604 inferior_registers.r_pc = *(int *)®isters[REGISTER_BYTE (PC_REGNUM)];
605 inferior_registers.r_npc = *(int *)®isters[REGISTER_BYTE (NPC_REGNUM)];
606 inferior_registers.r_y = *(int *)®isters[REGISTER_BYTE (Y_REGNUM)];
607 write_inferior_memory (*(int *)®isters[REGISTER_BYTE (SP_REGNUM)],
608 ®isters[REGISTER_BYTE (16)],
613 bcopy (®isters[REGISTER_BYTE (FP0_REGNUM)], &inferior_fp_registers,
614 sizeof inferior_fp_registers.fpu_fr);
615 /* bcopy (®isters[REGISTER_BYTE (FPS_REGNUM)],
616 &inferior_fp_registers.Fpu_fsr,
617 sizeof (FPU_FSR_TYPE));
622 ptrace (PTRACE_SETREGS, inferior_pid, &inferior_registers);
624 ptrace (PTRACE_SETFPREGS, inferior_pid, &inferior_fp_registers);
632 #define FP_REGISTER_ADDR_DIFF(u, regno) \
633 (((char *) (FP_REGISTER_ADDR (u, regno))) - ((char *) &(u)))
635 #define INFERIOR_AR0(u) \
637 (PT_RUAREA, inferior_pid, ((char *) &u.u_ar0 - (char *) &u), 0)) \
641 fetch_inferior_register (regno, regaddr)
643 register unsigned int regaddr;
645 #ifndef HPUX_VERSION_5
646 if (regno == PS_REGNUM)
648 union { int i; short s[2]; } ps_val;
651 ps_val.i = (ptrace (PT_RUAREA, inferior_pid, regaddr, 0));
652 regval = ps_val.s[0];
653 supply_register (regno, ®val);
656 #endif /* not HPUX_VERSION_5 */
658 char buf[MAX_REGISTER_RAW_SIZE];
661 for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (int))
663 *(int *) &buf[i] = ptrace (PT_RUAREA, inferior_pid, regaddr, 0);
664 regaddr += sizeof (int);
666 supply_register (regno, buf);
672 store_inferior_register_1 (regno, regaddr, value)
674 unsigned int regaddr;
678 ptrace (PT_WUAREA, inferior_pid, regaddr, value);
680 /* HP-UX randomly sets errno to non-zero for regno == 25.
681 However, the value is correctly written, so ignore errno. */
686 sprintf (string_buf, "writing register number %d", regno);
687 perror_with_name (string_buf);
694 store_inferior_register (regno, regaddr)
696 register unsigned int regaddr;
698 #ifndef HPUX_VERSION_5
699 if (regno == PS_REGNUM)
701 union { int i; short s[2]; } ps_val;
703 ps_val.i = (ptrace (PT_RUAREA, inferior_pid, regaddr, 0));
704 ps_val.s[0] = (read_register (regno));
705 store_inferior_register_1 (regno, regaddr, ps_val.i);
708 #endif /* not HPUX_VERSION_5 */
710 char buf[MAX_REGISTER_RAW_SIZE];
712 extern char registers[];
714 for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (int))
716 store_inferior_register_1
718 (*(int *) ®isters[(REGISTER_BYTE (regno)) + i]));
719 regaddr += sizeof (int);
726 fetch_inferior_registers ()
730 register unsigned int ar0_offset;
732 ar0_offset = (INFERIOR_AR0 (u));
733 for (regno = 0; (regno < FP0_REGNUM); regno++)
734 fetch_inferior_register (regno, (REGISTER_ADDR (ar0_offset, regno)));
735 for (; (regno < NUM_REGS); regno++)
736 fetch_inferior_register (regno, (FP_REGISTER_ADDR_DIFF (u, regno)));
739 /* Store our register values back into the inferior.
740 If REGNO is -1, do this for all registers.
741 Otherwise, REGNO specifies which register (so we can save time). */
743 store_inferior_registers (regno)
747 register unsigned int ar0_offset;
749 if (regno >= FP0_REGNUM)
751 store_inferior_register (regno, (FP_REGISTER_ADDR_DIFF (u, regno)));
755 ar0_offset = (INFERIOR_AR0 (u));
758 store_inferior_register (regno, (REGISTER_ADDR (ar0_offset, regno)));
762 for (regno = 0; (regno < FP0_REGNUM); regno++)
763 store_inferior_register (regno, (REGISTER_ADDR (ar0_offset, regno)));
764 for (; (regno < NUM_REGS); regno++)
765 store_inferior_register (regno, (FP_REGISTER_ADDR_DIFF (u, regno)));
769 #else /* not HP9K320 */
772 fetch_inferior_registers ()
775 register unsigned int regaddr;
776 char buf[MAX_REGISTER_RAW_SIZE];
780 unsigned int offset = 0;
783 unsigned int offset = (char *) &u.u_ar0 - (char *) &u;
784 offset = ptrace (3, inferior_pid, offset, 0) - KERNEL_U_ADDR;
787 for (regno = 0; regno < NUM_REGS; regno++)
789 regaddr = register_addr (regno, offset);
790 for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (int))
792 *(int *) &buf[i] = ptrace (3, inferior_pid, regaddr, 0);
793 regaddr += sizeof (int);
795 supply_register (regno, buf);
799 /* Store our register values back into the inferior.
800 If REGNO is -1, do this for all registers.
801 Otherwise, REGNO specifies which register (so we can save time). */
803 store_inferior_registers (regno)
806 register unsigned int regaddr;
808 extern char registers[];
812 unsigned int offset = 0;
815 unsigned int offset = (char *) &u.u_ar0 - (char *) &u;
816 offset = ptrace (3, inferior_pid, offset, 0) - KERNEL_U_ADDR;
821 regaddr = register_addr (regno, offset);
822 for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof(int))
825 ptrace (6, inferior_pid, regaddr,
826 *(int *) ®isters[REGISTER_BYTE (regno) + i]);
829 sprintf (buf, "writing register number %d(%d)", regno, i);
830 perror_with_name (buf);
832 regaddr += sizeof(int);
835 else for (regno = 0; regno < NUM_REGS; regno++)
837 regaddr = register_addr (regno, offset);
838 for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof(int))
841 ptrace (6, inferior_pid, regaddr,
842 *(int *) ®isters[REGISTER_BYTE (regno) + i]);
845 sprintf (buf, "writing register number %d(%d)", regno, i);
846 perror_with_name (buf);
848 regaddr += sizeof(int);
853 #endif /* not HP9K320 */
854 #endif /* not NEW_SUN_PTRACE */
856 /* NOTE! I tried using PTRACE_READDATA, etc., to read and write memory
857 in the NEW_SUN_PTRACE case.
858 It ought to be straightforward. But it appears that writing did
859 not write the data that I specified. I cannot understand where
860 it got the data that it actually did write. */
862 /* Copy LEN bytes from inferior's memory starting at MEMADDR
863 to debugger memory starting at MYADDR. */
865 read_inferior_memory (memaddr, myaddr, len)
871 /* Round starting address down to longword boundary. */
872 register CORE_ADDR addr = memaddr & - sizeof (int);
873 /* Round ending address up; get number of longwords that makes. */
875 = (((memaddr + len) - addr) + sizeof (int) - 1) / sizeof (int);
876 /* Allocate buffer of that many longwords. */
877 register int *buffer = (int *) alloca (count * sizeof (int));
879 /* Read all the longwords */
880 for (i = 0; i < count; i++, addr += sizeof (int))
882 if (remote_debugging)
883 buffer[i] = remote_fetch_word (addr);
885 buffer[i] = ptrace (1, inferior_pid, addr, 0);
888 /* Copy appropriate bytes out of the buffer. */
889 bcopy ((char *) buffer + (memaddr & (sizeof (int) - 1)), myaddr, len);
892 /* Copy LEN bytes of data from debugger memory at MYADDR
893 to inferior's memory at MEMADDR.
894 On failure (cannot write the inferior)
895 returns the value of errno. */
898 write_inferior_memory (memaddr, myaddr, len)
904 /* Round starting address down to longword boundary. */
905 register CORE_ADDR addr = memaddr & - sizeof (int);
906 /* Round ending address up; get number of longwords that makes. */
908 = (((memaddr + len) - addr) + sizeof (int) - 1) / sizeof (int);
909 /* Allocate buffer of that many longwords. */
910 register int *buffer = (int *) alloca (count * sizeof (int));
913 /* Fill start and end extra bytes of buffer with existing memory data. */
915 if (remote_debugging)
916 buffer[0] = remote_fetch_word (addr);
918 buffer[0] = ptrace (1, inferior_pid, addr, 0);
922 if (remote_debugging)
924 = remote_fetch_word (addr + (count - 1) * sizeof (int));
927 = ptrace (1, inferior_pid,
928 addr + (count - 1) * sizeof (int), 0);
931 /* Copy data to be written over corresponding part of buffer */
933 bcopy (myaddr, (char *) buffer + (memaddr & (sizeof (int) - 1)), len);
935 /* Write the entire buffer. */
937 for (i = 0; i < count; i++, addr += sizeof (int))
940 if (remote_debugging)
941 remote_store_word (addr, buffer[i]);
943 ptrace (4, inferior_pid, addr, buffer[i]);
952 try_writing_regs_command ()
958 if (inferior_pid == 0)
959 error ("There is no inferior process now.");
961 for (i = 0; ; i += 2)
965 value = ptrace (3, inferior_pid, i, 0);
966 ptrace (6, inferior_pid, i, value);
969 printf (" Succeeded with address 0x%x; value 0x%x (%d).\n",
972 else if ((i & 0377) == 0)
973 printf (" Failed at 0x%x.\n", i);
980 add_com ("term-status", class_obscure, term_status_command,
981 "Print info on inferior's saved terminal status.");
983 add_com ("try-writing-regs", class_obscure, try_writing_regs_command,
984 "Try writing all locations in inferior's system block.\n\
985 Report which ones can be written.");
987 add_com ("kill", class_run, kill_command,
988 "Kill execution of program being debugged.");
992 ioctl (0, TIOCGETP, &sg_ours);
993 fcntl (0, F_GETFL, tflags_ours);
996 ioctl (0, TIOCGETC, &tc_ours);
997 ioctl (0, TIOCGLTC, <c_ours);
998 ioctl (0, TIOCLGET, &lmode_ours);
999 #endif /* TIOCGLTC */
1002 ioctl (0, TIOCGPGRP, &pgrp_ours);
1003 #endif /* TIOCGPGRP */
1005 terminal_is_ours = 1;