1 /* Start and stop the inferior process, for GDB.
2 Copyright (C) 1986, 1987, 1988 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"
35 #include <sys/param.h>
36 #include <sys/ptrace.h>
39 extern char *sys_siglist
[];
42 /* Tables of how to react to signals; the user sets them. */
44 static char signal_stop
[NSIG
];
45 static char signal_print
[NSIG
];
46 static char signal_program
[NSIG
];
48 /* Nonzero if breakpoints are now inserted in the inferior. */
50 static int breakpoints_inserted
;
52 /* Function inferior was in as of last step command. */
54 static struct symbol
*step_start_function
;
56 /* This is the sequence of bytes we insert for a breakpoint. */
58 static char break_insn
[] = BREAKPOINT
;
60 /* Nonzero => address for special breakpoint for resuming stepping. */
62 static CORE_ADDR step_resume_break_address
;
64 /* Original contents of the byte where the special breakpoint is. */
66 static char step_resume_break_shadow
[sizeof break_insn
];
68 /* Nonzero means the special breakpoint is a duplicate
69 so it has not itself been inserted. */
71 static int step_resume_break_duplicate
;
73 /* Nonzero if we are expecting a trace trap and should proceed from it.
74 2 means expecting 2 trace traps and should continue both times.
75 That occurs when we tell sh to exec the program: we will get
76 a trap after the exec of sh and a second when the program is exec'd. */
78 static int trap_expected
;
80 /* Nonzero if the next time we try to continue the inferior, it will
81 step one instruction and generate a spurious trace trap.
82 This is used to compensate for a bug in HP-UX. */
84 static int trap_expected_after_continue
;
86 /* Nonzero means expecting a trace trap
87 and should stop the inferior and return silently when it happens. */
89 static int stop_after_trap
;
91 /* Nonzero means expecting a trace trap due to attaching to a process. */
93 static int stop_after_attach
;
95 /* Nonzero if pc has been changed by the debugger
96 since the inferior stopped. */
100 /* Nonzero if debugging a remote machine via a serial link or ethernet. */
102 int remote_debugging
;
104 /* Save register contents here when about to pop a stack dummy frame. */
106 char stop_registers
[REGISTER_BYTES
];
108 /* Nonzero if program stopped due to error trying to insert breakpoints. */
110 static int breakpoints_failed
;
112 /* Nonzero if inferior is in sh before our program got exec'd. */
114 static int running_in_shell
;
116 /* Nonzero after stop if current stack frame should be printed. */
118 static int stop_print_frame
;
120 static void insert_step_breakpoint ();
121 static void remove_step_breakpoint ();
122 static void wait_for_inferior ();
123 static void normal_stop ();
127 /* Clear out all variables saying what to do when inferior is continued.
128 First do this, then set the ones you want, then call `proceed'. */
131 clear_proceed_status ()
134 step_range_start
= 0;
137 step_over_calls
= -1;
138 step_resume_break_address
= 0;
140 stop_after_attach
= 0;
142 /* Discard any remaining commands left by breakpoint we had stopped at. */
143 clear_breakpoint_commands ();
146 /* Basic routine for continuing the program in various fashions.
148 ADDR is the address to resume at, or -1 for resume where stopped.
149 SIGNAL is the signal to give it, or 0 for none,
150 or -1 for act according to how it stopped.
151 STEP is nonzero if should trap after one instruction.
152 -1 means return after that and print nothing.
153 You should probably set various step_... variables
154 before calling here, if you are stepping.
156 You should call clear_proceed_status before calling proceed. */
159 proceed (addr
, signal
, step
)
167 step_start_function
= find_pc_function (read_pc ());
173 /* If there is a breakpoint at the address we will resume at,
174 step one instruction before inserting breakpoints
175 so that we do not stop right away. */
177 if (!pc_changed
&& breakpoint_here_p (read_pc ()))
181 write_register (PC_REGNUM
, addr
);
183 if (trap_expected_after_continue
)
185 /* If (step == 0), a trap will be automatically generated after
186 the first instruction is executed. Force step one
187 instruction to clear this condition. This should not occur
188 if step is nonzero, but it is harmless in that case. */
190 trap_expected_after_continue
= 0;
194 /* We will get a trace trap after one instruction.
195 Continue it automatically and insert breakpoints then. */
199 int temp
= insert_breakpoints ();
202 print_sys_errmsg ("ptrace", temp
);
203 error ("Cannot insert breakpoints.\n\
204 The same program may be running in another process.");
206 breakpoints_inserted
= 1;
209 /* Install inferior's terminal modes. */
210 terminal_inferior ();
213 stop_signal
= signal
;
214 /* If this signal should not be seen by program,
215 give it zero. Used for debugging signals. */
216 else if (stop_signal
< NSIG
&& !signal_program
[stop_signal
])
219 /* Resume inferior. */
220 resume (oneproc
|| step
, stop_signal
);
222 /* Wait for it to stop (if not standalone)
223 and in any case decode why it stopped, and act accordingly. */
225 wait_for_inferior ();
229 /* Writing the inferior pc as a register calls this function
230 to inform infrun that the pc has been set in the debugger. */
239 /* Start an inferior process for the first time.
240 Actually it was started by the fork that created it,
241 but it will have stopped one instruction after execing sh.
242 Here we must get it up to actual execution of the real program. */
246 /* We will get a trace trap after one instruction.
247 Continue it automatically. Eventually (after shell does an exec)
248 it will get another trace trap. Then insert breakpoints and continue. */
250 running_in_shell
= 0; /* Set to 1 at first SIGTRAP, 0 at second. */
251 trap_expected_after_continue
= 0;
252 breakpoints_inserted
= 0;
253 mark_breakpoints_out ();
255 /* Set up the "saved terminal modes" of the inferior
256 based on what modes we are starting it with. */
257 terminal_init_inferior ();
259 /* Install inferior's terminal modes. */
260 terminal_inferior ();
262 if (remote_debugging
)
265 fetch_inferior_registers();
266 set_current_frame (read_register(FP_REGNUM
));
267 stop_frame
= get_current_frame();
269 if (insert_breakpoints())
270 fatal("Can't insert breakpoints");
271 breakpoints_inserted
= 1;
276 wait_for_inferior ();
281 /* Start remote-debugging of a machine over a serial link. */
286 clear_proceed_status ();
287 running_in_shell
= 0;
290 breakpoints_inserted
= 0;
291 mark_breakpoints_out ();
292 wait_for_inferior ();
298 /* Attach to process PID, then initialize for debugging it
299 and wait for the trace-trap that results from attaching. */
308 mark_breakpoints_out ();
309 terminal_init_inferior ();
310 clear_proceed_status ();
311 stop_after_attach
= 1;
312 /*proceed (-1, 0, -2);*/
313 wait_for_inferior ();
316 #endif /* ATTACH_DETACH */
318 /* Wait for control to return from inferior to debugger.
319 If inferior gets a signal, we may decide to start it up again
320 instead of returning. That is why there is a loop in this function.
321 When this function actually returns it means the inferior
322 should be left stopped and GDB should read more commands. */
334 int stop_step_resume_break
;
337 struct symbol
*newfun
;
338 struct symtab_and_line sal
;
341 prev_pc
= read_pc ();
345 if (remote_debugging
)
350 if (pid
!= inferior_pid
)
355 fetch_inferior_registers ();
356 stop_pc
= read_pc ();
357 set_current_frame (read_register (FP_REGNUM
));
358 stop_frame
= get_current_frame ();
359 stop_sp
= read_register (SP_REGNUM
);
363 stop_stack_dummy
= 0;
364 stop_print_frame
= 1;
365 stop_step_resume_break
= 0;
367 breakpoints_failed
= 0;
369 /* Look at the cause of the stop, and decide what to do.
370 The alternatives are:
371 1) break; to really stop and return to the debugger,
372 2) drop through to start up again
373 (set another_trap to 1 to single step once)
374 3) set random_signal to 1, and the decision between 1 and 2
375 will be made according to the signal handling tables. */
379 terminal_ours_for_output ();
381 printf ("\nProgram exited with code 0%o.\n", WRETCODE (w
));
383 printf ("\nProgram exited normally.\n");
386 stop_print_frame
= 0;
389 else if (!WIFSTOPPED (w
))
392 stop_print_frame
= 0;
393 stop_signal
= WTERMSIG (w
);
394 terminal_ours_for_output ();
395 printf ("\nProgram terminated with signal %d, %s\n",
398 ? sys_siglist
[stop_signal
]
400 printf ("The inferior process no longer exists.\n");
406 stop_signal
= WSTOPSIG (w
);
408 /* First, distinguish signals caused by the debugger from signals
409 that have to do with the program's own actions.
410 Note that breakpoint insns may cause SIGTRAP or SIGILL
411 or SIGEMT, depending on the operating system version.
412 Here we detect when a SIGILL or SIGEMT is really a breakpoint
413 and change it to SIGTRAP. */
415 if (stop_signal
== SIGTRAP
416 || (breakpoints_inserted
&&
417 (stop_signal
== SIGILL
418 || stop_signal
== SIGEMT
))
419 || stop_after_attach
)
421 if (stop_signal
== SIGTRAP
&& stop_after_trap
)
423 stop_print_frame
= 0;
426 if (stop_after_attach
)
428 /* Don't even think about breakpoints
429 if still running the shell that will exec the program
430 or if just proceeded over a breakpoint. */
431 if (stop_signal
== SIGTRAP
&& trap_expected
)
434 /* See if there is a breakpoint at the current PC. */
435 #if DECR_PC_AFTER_BREAK
436 /* Notice the case of stepping through a jump
437 that leads just after a breakpoint.
438 Don't confuse that with hitting the breakpoint.
439 What we check for is that 1) stepping is going on
440 and 2) the pc before the last insn does not match
441 the address of the breakpoint before the current pc. */
442 if (!(prev_pc
!= stop_pc
- DECR_PC_AFTER_BREAK
443 && step_range_end
&& !step_resume_break_address
))
444 #endif /* DECR_PC_AFTER_BREAK not zero */
446 select_frame (stop_frame
, 0); /* For condition exprs. */
447 stop_breakpoint
= breakpoint_stop_status (stop_pc
, stop_frame
);
448 /* Following in case break condition called a function. */
449 stop_print_frame
= 1;
450 if (stop_breakpoint
&& DECR_PC_AFTER_BREAK
)
452 stop_pc
-= DECR_PC_AFTER_BREAK
;
453 write_register (PC_REGNUM
, stop_pc
);
457 /* See if we stopped at the special breakpoint for
458 stepping over a subroutine call. */
459 if (stop_pc
- DECR_PC_AFTER_BREAK
== step_resume_break_address
)
461 stop_step_resume_break
= 1;
462 if (DECR_PC_AFTER_BREAK
)
464 stop_pc
-= DECR_PC_AFTER_BREAK
;
465 write_register (PC_REGNUM
, stop_pc
);
470 if (stop_signal
== SIGTRAP
)
472 = !(stop_breakpoint
|| trap_expected
473 || stop_step_resume_break
474 || (stop_sp INNER_THAN stop_pc
&& stop_pc INNER_THAN stop_frame
)
475 || (step_range_end
&& !step_resume_break_address
));
479 = !(stop_breakpoint
|| stop_step_resume_break
);
481 stop_signal
= SIGTRAP
;
487 /* For the program's own signals, act according to
488 the signal handling tables. */
491 && !(running_in_shell
&& stop_signal
== SIGSEGV
))
493 /* Signal not for debugging purposes. */
496 if (stop_signal
>= NSIG
497 || signal_print
[stop_signal
])
500 terminal_ours_for_output ();
501 printf ("\nProgram received signal %d, %s\n",
504 ? sys_siglist
[stop_signal
]
508 if (stop_signal
>= NSIG
509 || signal_stop
[stop_signal
])
511 /* If not going to stop, give terminal back
512 if we took it away. */
514 terminal_inferior ();
517 /* Handle cases caused by hitting a breakpoint. */
520 && (stop_breakpoint
|| stop_step_resume_break
))
522 /* Does a breakpoint want us to stop? */
523 if (stop_breakpoint
&& stop_breakpoint
!= -1)
525 /* 0x1000000 is set in stop_breakpoint as returned by
526 breakpoint_status_p to indicate a silent breakpoint. */
527 if (stop_breakpoint
> 0 && stop_breakpoint
& 0x1000000)
529 stop_breakpoint
&= ~0x1000000;
530 stop_print_frame
= 0;
534 /* But if we have hit the step-resumption breakpoint,
535 remove it. It has done its job getting us here. */
536 if (stop_step_resume_break
537 && (step_frame
== 0 || stop_frame
== step_frame
))
539 remove_step_breakpoint ();
540 step_resume_break_address
= 0;
542 /* Otherwise, must remove breakpoints and single-step
543 to get us past the one we hit. */
546 remove_breakpoints ();
547 remove_step_breakpoint ();
548 breakpoints_inserted
= 0;
552 /* We come here if we hit a breakpoint but should not
553 stop for it. Possibly we also were stepping
554 and should stop for that. So fall through and
555 test for stepping. But, if not stepping,
559 /* If this is the breakpoint at the end of a stack dummy,
560 just stop silently. */
561 if (stop_sp INNER_THAN stop_pc
&& stop_pc INNER_THAN stop_frame
)
563 stop_print_frame
= 0;
564 stop_stack_dummy
= 1;
566 trap_expected_after_continue
= 1;
571 if (step_resume_break_address
)
572 /* Having a step-resume breakpoint overrides anything
573 else having to do with stepping commands until
574 that breakpoint is reached. */
576 /* If stepping through a line, keep going if still within it. */
577 else if (!random_signal
579 && stop_pc
>= step_range_start
580 && stop_pc
< step_range_end
)
582 /* Don't step through the return from a function
583 unless that is the first instruction stepped through. */
584 if (ABOUT_TO_RETURN (stop_pc
))
591 /* We stepped out of the stepping range. See if that was due
592 to a subroutine call that we should proceed to the end of. */
593 else if (!random_signal
&& step_range_end
)
595 newfun
= find_pc_function (stop_pc
);
599 newfun_pc
= BLOCK_START (SYMBOL_BLOCK_VALUE (newfun
))
600 + FUNCTION_START_OFFSET
;
604 newmisc
= find_pc_misc_function (stop_pc
);
606 newfun_pc
= misc_function_vector
[newmisc
].address
607 + FUNCTION_START_OFFSET
;
610 if (stop_pc
== newfun_pc
611 && (step_over_calls
> 0 || (step_over_calls
&& newfun
== 0)))
613 /* A subroutine call has happened. */
614 /* Set a special breakpoint after the return */
615 step_resume_break_address
= SAVED_PC_AFTER_CALL (stop_frame
);
616 step_resume_break_duplicate
617 = breakpoint_here_p (step_resume_break_address
);
618 if (breakpoints_inserted
)
619 insert_step_breakpoint ();
621 /* Subroutine call with source code we should not step over.
622 Do step to the first line of code in it. */
623 else if (stop_pc
== newfun_pc
&& step_over_calls
)
625 SKIP_PROLOGUE (newfun_pc
);
626 sal
= find_pc_line (newfun_pc
, 0);
627 /* Use the step_resume_break to step until
628 the end of the prologue, even if that involves jumps
629 (as it seems to on the vax under 4.2). */
630 /* If the prologue ends in the middle of a source line,
631 continue to the end of that source line.
632 Otherwise, just go to end of prologue. */
633 if (sal
.end
&& sal
.pc
!= newfun_pc
)
636 if (newfun_pc
== stop_pc
)
637 /* We are already there: stop now. */
640 /* Put the step-breakpoint there and go until there. */
642 step_resume_break_address
= newfun_pc
;
644 step_resume_break_duplicate
645 = breakpoint_here_p (step_resume_break_address
);
646 if (breakpoints_inserted
)
647 insert_step_breakpoint ();
648 /* Do not specify what the fp should be when we stop
649 since on some machines the prologue
650 is where the new fp value is established. */
652 /* And make sure stepping stops right away then. */
653 step_range_end
= step_range_start
;
656 /* No subroutince call; stop now. */
665 /* Save the pc before execution, to compare with pc after stop. */
666 prev_pc
= read_pc ();
668 /* If we did not do break;, it means we should keep
669 running the inferior and not return to debugger. */
671 /* If trap_expected is 2, it means continue once more
672 and insert breakpoints at the next trap.
673 If trap_expected is 1 and the signal was SIGSEGV, it means
674 the shell is doing some memory allocation--just resume it
676 Otherwise insert breakpoints now, and possibly single step. */
678 if (trap_expected
> 1)
681 running_in_shell
= 1;
684 else if (running_in_shell
&& stop_signal
== SIGSEGV
)
690 /* Here, we are not awaiting another exec to get
691 the program we really want to debug.
692 Insert breakpoints now, unless we are trying
693 to one-proceed past a breakpoint. */
694 running_in_shell
= 0;
695 if (!breakpoints_inserted
&& !another_trap
)
697 insert_step_breakpoint ();
698 breakpoints_failed
= insert_breakpoints ();
699 if (breakpoints_failed
)
701 breakpoints_inserted
= 1;
704 trap_expected
= another_trap
;
706 if (stop_signal
== SIGTRAP
)
709 resume ((step_range_end
&& !step_resume_break_address
)
716 /* Here to return control to GDB when the inferior stops for real.
717 Print appropriate messages, remove breakpoints, give terminal our modes.
719 RUNNING_IN_SHELL nonzero means the shell got a signal before
720 exec'ing the program we wanted to run.
721 STOP_PRINT_FRAME nonzero means print the executing frame
722 (pc, function, args, file, line number and line text).
723 BREAKPOINTS_FAILED nonzero means stop was due to error
724 attempting to insert breakpoints. */
729 if (breakpoints_failed
)
731 terminal_ours_for_output ();
732 print_sys_errmsg ("ptrace", breakpoints_failed
);
733 printf ("Stopped; cannot insert breakpoints.\n\
734 The same program may be running in another process.\n");
738 remove_step_breakpoint ();
740 if (inferior_pid
&& breakpoints_inserted
)
741 if (remove_breakpoints ())
743 terminal_ours_for_output ();
744 printf ("Cannot remove breakpoints because program is no longer writable.\n\
745 It must be running in another process.\n\
746 Further execution is probably impossible.\n");
749 breakpoints_inserted
= 0;
751 /* Delete the breakpoint we stopped at, if it wants to be deleted.
752 Delete any breakpoint that is to be deleted at the next stop. */
754 breakpoint_auto_delete (stop_breakpoint
);
756 /* If an auto-display called a function and that got a signal,
757 delete that auto-display to avoid an infinite recursion. */
759 delete_current_display ();
761 if (step_multi
&& stop_step
)
766 if (running_in_shell
)
768 if (stop_signal
== SIGSEGV
)
770 char *exec_file
= (char *) get_exec_file (1);
772 if (access (exec_file
, X_OK
) != 0)
773 printf ("The file \"%s\" is not executable.\n", exec_file
);
776 You have just encountered a bug in \"sh\". GDB starts your program\n\
777 by running \"sh\" with a command to exec your program.\n\
778 This is so that \"sh\" will process wildcards and I/O redirection.\n\
779 This time, \"sh\" crashed.\n\
781 One known bug in \"sh\" bites when the environment takes up a lot of space.\n\
782 Try \"info env\" to see the environment; then use \"unset-env\" to kill\n\
783 some variables whose values are large; then do \"run\" again.\n\
785 If that works, you might want to put those \"unset-env\" commands\n\
786 into a \".gdbinit\" file in this directory so they will happen every time.\n");
788 /* Don't confuse user with his program's symbols on sh's data. */
789 stop_print_frame
= 0;
792 if (inferior_pid
== 0)
795 /* Select innermost stack frame except on return from a stack dummy routine,
796 or if the program has exited. */
797 if (!stop_stack_dummy
)
799 select_frame (stop_frame
, 0);
801 if (stop_print_frame
)
803 if (stop_breakpoint
> 0)
804 printf ("\nBpt %d, ", stop_breakpoint
);
805 print_sel_frame (stop_step
806 && step_frame
== stop_frame
807 && step_start_function
== find_pc_function (stop_pc
));
808 /* Display the auto-display expressions. */
813 /* Save the function value return registers
814 We might be about to restore their previous contents. */
815 read_register_bytes (0, stop_registers
, REGISTER_BYTES
);
817 if (stop_stack_dummy
)
819 /* Pop the empty frame that contains the stack dummy. */
821 select_frame (read_register (FP_REGNUM
), 0);
826 insert_step_breakpoint ()
828 if (step_resume_break_address
&& !step_resume_break_duplicate
)
830 read_memory (step_resume_break_address
,
831 step_resume_break_shadow
, sizeof break_insn
);
832 write_memory (step_resume_break_address
,
833 break_insn
, sizeof break_insn
);
838 remove_step_breakpoint ()
840 if (step_resume_break_address
&& !step_resume_break_duplicate
)
841 write_memory (step_resume_break_address
, step_resume_break_shadow
,
845 /* Specify how various signals in the inferior should be handled. */
848 handle_command (args
, from_tty
)
852 register char *p
= args
;
854 register int digits
, wordlen
;
857 error_no_arg ("signal to handle");
861 /* Find the end of the next word in the args. */
862 for (wordlen
= 0; p
[wordlen
] && p
[wordlen
] != ' ' && p
[wordlen
] != '\t';
864 for (digits
= 0; p
[digits
] >= '0' && p
[digits
] <= '9'; digits
++);
866 /* If it is all digits, it is signal number to operate on. */
867 if (digits
== wordlen
)
870 if (signum
== SIGTRAP
|| signum
== SIGINT
)
872 if (!query ("Signal %d is used by the debugger.\nAre you sure you want to change it? ", signum
))
873 error ("Not confirmed.");
876 else if (signum
== 0)
877 error ("First argument is not a signal number.");
879 /* Else, if already got a signal number, look for flag words
880 saying what to do for it. */
881 else if (!strncmp (p
, "stop", wordlen
))
883 signal_stop
[signum
] = 1;
884 signal_print
[signum
] = 1;
886 else if (wordlen
>= 2 && !strncmp (p
, "print", wordlen
))
887 signal_print
[signum
] = 1;
888 else if (wordlen
>= 2 && !strncmp (p
, "pass", wordlen
))
889 signal_program
[signum
] = 1;
890 else if (!strncmp (p
, "ignore", wordlen
))
891 signal_program
[signum
] = 0;
892 else if (wordlen
>= 3 && !strncmp (p
, "nostop", wordlen
))
893 signal_stop
[signum
] = 0;
894 else if (wordlen
>= 4 && !strncmp (p
, "noprint", wordlen
))
896 signal_print
[signum
] = 0;
897 signal_stop
[signum
] = 0;
899 else if (wordlen
>= 4 && !strncmp (p
, "nopass", wordlen
))
900 signal_program
[signum
] = 0;
901 else if (wordlen
>= 3 && !strncmp (p
, "noignore", wordlen
))
902 signal_program
[signum
] = 1;
903 /* Not a number and not a recognized flag word => complain. */
907 error ("Unrecognized flag word: \"%s\".", p
);
910 /* Find start of next word. */
912 while (*p
== ' ' || *p
== '\t') p
++;
917 /* Show the results. */
918 printf ("Number\tStop\tPrint\tPass to program\tDescription\n");
919 printf ("%d\t", signum
);
920 printf ("%s\t", signal_stop
[signum
] ? "Yes" : "No");
921 printf ("%s\t", signal_print
[signum
] ? "Yes" : "No");
922 printf ("%s\t\t", signal_program
[signum
] ? "Yes" : "No");
923 printf ("%s\n", sys_siglist
[signum
]);
927 /* Print current contents of the tables set by the handle command. */
930 signals_info (signum_exp
)
934 printf ("Number\tStop\tPrint\tPass to program\tDescription\n");
938 i
= parse_and_eval_address (signum_exp
);
940 printf ("%s\t", signal_stop
[i
] ? "Yes" : "No");
941 printf ("%s\t", signal_print
[i
] ? "Yes" : "No");
942 printf ("%s\t\t", signal_program
[i
] ? "Yes" : "No");
943 printf ("%s\n", sys_siglist
[i
]);
948 for (i
= 0; i
< NSIG
; i
++)
951 if (i
> 0 && i
% 16 == 0)
953 printf ("[Type Return to see more]");
958 printf ("%s\t", signal_stop
[i
] ? "Yes" : "No");
959 printf ("%s\t", signal_print
[i
] ? "Yes" : "No");
960 printf ("%s\t\t", signal_program
[i
] ? "Yes" : "No");
961 printf ("%s\n", sys_siglist
[i
]);
964 printf ("\nUse the \"handle\" command to change these tables.\n");
972 add_info ("signals", signals_info
,
973 "What debugger does when program gets various signals.\n\
974 Specify a signal number as argument to print info on that signal only.");
976 add_com ("handle", class_run
, handle_command
,
977 "Specify how to handle a signal.\n\
978 Args are signal number followed by flags.\n\
979 Flags allowed are \"stop\", \"print\", \"pass\",\n\
980 \"nostop\", \"noprint\" or \"nopass\".\n\
981 Print means print a message if this signal happens.\n\
982 Stop means reenter debugger if this signal happens (implies print).\n\
983 Pass means let program see this signal; otherwise program doesn't know.\n\
984 Pass and Stop may be combined.");
986 for (i
= 0; i
< NSIG
; i
++)
990 signal_program
[i
] = 1;
993 /* Signals caused by debugger's own actions
994 should not be given to the program afterwards. */
995 signal_program
[SIGTRAP
] = 0;
996 signal_program
[SIGINT
] = 0;
998 /* Signals that are not errors should not normally enter the debugger. */
1000 signal_stop
[SIGALRM
] = 0;
1001 signal_print
[SIGALRM
] = 0;
1002 #endif /* SIGALRM */
1004 signal_stop
[SIGVTALRM
] = 0;
1005 signal_print
[SIGVTALRM
] = 0;
1006 #endif /* SIGVTALRM */
1008 signal_stop
[SIGPROF
] = 0;
1009 signal_print
[SIGPROF
] = 0;
1010 #endif /* SIGPROF */
1012 signal_stop
[SIGCHLD
] = 0;
1013 signal_print
[SIGCHLD
] = 0;
1014 #endif /* SIGCHLD */
1016 signal_stop
[SIGCLD
] = 0;
1017 signal_print
[SIGCLD
] = 0;
1020 signal_stop
[SIGIO
] = 0;
1021 signal_print
[SIGIO
] = 0;
1024 signal_stop
[SIGURG
] = 0;
1025 signal_print
[SIGURG
] = 0;