]> Git Repo - binutils.git/blame - gdb/infrun.c
* app.c (do_scrub_next_char): Another attempt to fix bugs
[binutils.git] / gdb / infrun.c
CommitLineData
3aa6856a 1/* Target-struct-independent code to start (run) and stop an inferior process.
fcbc95a7 2 Copyright 1986, 1987, 1988, 1989, 1991, 1992, 1993, 1994
101b7f9c 3 Free Software Foundation, Inc.
bd5635a1
RP
4
5This file is part of GDB.
6
3b271cf4 7This program is free software; you can redistribute it and/or modify
bd5635a1 8it under the terms of the GNU General Public License as published by
3b271cf4
JG
9the Free Software Foundation; either version 2 of the License, or
10(at your option) any later version.
bd5635a1 11
3b271cf4 12This program is distributed in the hope that it will be useful,
bd5635a1
RP
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
3b271cf4
JG
18along with this program; if not, write to the Free Software
19Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
bd5635a1 20
bd5635a1 21#include "defs.h"
d747e0af 22#include <string.h>
a6b98cb9 23#include <ctype.h>
bd5635a1
RP
24#include "symtab.h"
25#include "frame.h"
26#include "inferior.h"
27#include "breakpoint.h"
28#include "wait.h"
29#include "gdbcore.h"
3950a34e 30#include "gdbcmd.h"
bd5635a1 31#include "target.h"
100f92e2 32#include "thread.h"
bd5635a1
RP
33
34#include <signal.h>
35
36/* unistd.h is needed to #define X_OK */
37#ifdef USG
38#include <unistd.h>
39#else
40#include <sys/file.h>
41#endif
42
30875e1c 43/* Prototypes for local functions */
bd5635a1 44
30875e1c 45static void
e37a6e9c 46signals_info PARAMS ((char *, int));
619fd145 47
30875e1c
SG
48static void
49handle_command PARAMS ((char *, int));
50
67ac9759 51static void sig_print_info PARAMS ((enum target_signal));
30875e1c
SG
52
53static void
54sig_print_header PARAMS ((void));
55
30875e1c
SG
56static void
57resume_cleanups PARAMS ((int));
58
3950a34e
RP
59static int
60hook_stop_stub PARAMS ((char *));
61
30875e1c
SG
62/* GET_LONGJMP_TARGET returns the PC at which longjmp() will resume the
63 program. It needs to examine the jmp_buf argument and extract the PC
64 from it. The return value is non-zero on success, zero otherwise. */
65#ifndef GET_LONGJMP_TARGET
66#define GET_LONGJMP_TARGET(PC_ADDR) 0
67#endif
68
d747e0af
MT
69
70/* Some machines have trampoline code that sits between function callers
71 and the actual functions themselves. If this machine doesn't have
72 such things, disable their processing. */
73#ifndef SKIP_TRAMPOLINE_CODE
74#define SKIP_TRAMPOLINE_CODE(pc) 0
75#endif
76
b2f03c30
JK
77/* On Irix 5, some function calls automatically skip the first few
78 instructions, so we need a more complicated test to see if we are
79 the start of a function. */
80#ifndef AT_FUNCTION_START
81#define AT_FUNCTION_START(pc,func_name,func_addr) 0
82#endif
83
1eeba686
PB
84/* For SVR4 shared libraries, each call goes through a small piece of
85 trampoline code in the ".init" section. IN_SOLIB_TRAMPOLINE evaluates
86 to nonzero if we are current stopped in one of these. */
87#ifndef IN_SOLIB_TRAMPOLINE
88#define IN_SOLIB_TRAMPOLINE(pc,name) 0
89#endif
d747e0af 90
9f739abd
SG
91/* On some systems, the PC may be left pointing at an instruction that won't
92 actually be executed. This is usually indicated by a bit in the PSW. If
93 we find ourselves in such a state, then we step the target beyond the
94 nullified instruction before returning control to the user so as to avoid
95 confusion. */
96
97#ifndef INSTRUCTION_NULLIFIED
98#define INSTRUCTION_NULLIFIED 0
99#endif
100
bd5635a1
RP
101/* Tables of how to react to signals; the user sets them. */
102
072b552a
JG
103static unsigned char *signal_stop;
104static unsigned char *signal_print;
105static unsigned char *signal_program;
106
107#define SET_SIGS(nsigs,sigs,flags) \
108 do { \
109 int signum = (nsigs); \
110 while (signum-- > 0) \
111 if ((sigs)[signum]) \
112 (flags)[signum] = 1; \
113 } while (0)
114
115#define UNSET_SIGS(nsigs,sigs,flags) \
116 do { \
117 int signum = (nsigs); \
118 while (signum-- > 0) \
119 if ((sigs)[signum]) \
120 (flags)[signum] = 0; \
121 } while (0)
bd5635a1 122
3950a34e
RP
123
124/* Command list pointer for the "stop" placeholder. */
125
126static struct cmd_list_element *stop_command;
127
bd5635a1 128/* Nonzero if breakpoints are now inserted in the inferior. */
bd5635a1 129
3950a34e 130static int breakpoints_inserted;
bd5635a1
RP
131
132/* Function inferior was in as of last step command. */
133
134static struct symbol *step_start_function;
135
bd5635a1
RP
136/* Nonzero if we are expecting a trace trap and should proceed from it. */
137
138static int trap_expected;
139
140/* Nonzero if the next time we try to continue the inferior, it will
141 step one instruction and generate a spurious trace trap.
142 This is used to compensate for a bug in HP-UX. */
143
144static int trap_expected_after_continue;
145
146/* Nonzero means expecting a trace trap
147 and should stop the inferior and return silently when it happens. */
148
149int stop_after_trap;
150
151/* Nonzero means expecting a trap and caller will handle it themselves.
152 It is used after attach, due to attaching to a process;
153 when running in the shell before the child program has been exec'd;
154 and when running some kinds of remote stuff (FIXME?). */
155
156int stop_soon_quietly;
157
bd5635a1
RP
158/* Nonzero if proceed is being used for a "finish" command or a similar
159 situation when stop_registers should be saved. */
160
161int proceed_to_finish;
162
163/* Save register contents here when about to pop a stack dummy frame,
164 if-and-only-if proceed_to_finish is set.
165 Thus this contains the return value from the called function (assuming
166 values are returned in a register). */
167
168char stop_registers[REGISTER_BYTES];
169
170/* Nonzero if program stopped due to error trying to insert breakpoints. */
171
172static int breakpoints_failed;
173
174/* Nonzero after stop if current stack frame should be printed. */
175
176static int stop_print_frame;
177
178#ifdef NO_SINGLE_STEP
179extern int one_stepped; /* From machine dependent code */
180extern void single_step (); /* Same. */
181#endif /* NO_SINGLE_STEP */
182
a71d17b1
JK
183\f
184/* Things to clean up if we QUIT out of resume (). */
e1ce8aa5 185/* ARGSUSED */
a71d17b1
JK
186static void
187resume_cleanups (arg)
188 int arg;
189{
190 normal_stop ();
191}
192
193/* Resume the inferior, but allow a QUIT. This is useful if the user
194 wants to interrupt some lengthy single-stepping operation
195 (for child processes, the SIGINT goes to the inferior, and so
196 we get a SIGINT random_signal, but for remote debugging and perhaps
197 other targets, that's not true).
198
199 STEP nonzero if we should step (zero to continue instead).
200 SIG is the signal to give the inferior (zero for none). */
310cc570 201void
a71d17b1
JK
202resume (step, sig)
203 int step;
67ac9759 204 enum target_signal sig;
a71d17b1
JK
205{
206 struct cleanup *old_cleanups = make_cleanup (resume_cleanups, 0);
207 QUIT;
d11c44f1 208
cef4c2e7
PS
209#ifdef CANNOT_STEP_BREAKPOINT
210 /* Most targets can step a breakpoint instruction, thus executing it
211 normally. But if this one cannot, just continue and we will hit
212 it anyway. */
213 if (step && breakpoints_inserted && breakpoint_here_p (read_pc ()))
214 step = 0;
215#endif
216
d11c44f1
JG
217#ifdef NO_SINGLE_STEP
218 if (step) {
818de002 219 single_step(sig); /* Do it the hard way, w/temp breakpoints */
d11c44f1
JG
220 step = 0; /* ...and don't ask hardware to do it. */
221 }
222#endif
223
bdbd5f50
JG
224 /* Handle any optimized stores to the inferior NOW... */
225#ifdef DO_DEFERRED_STORES
226 DO_DEFERRED_STORES;
227#endif
228
2f1c7c3f
JK
229 /* Install inferior's terminal modes. */
230 target_terminal_inferior ();
231
de43d7d0 232 target_resume (-1, step, sig);
a71d17b1
JK
233 discard_cleanups (old_cleanups);
234}
235
bd5635a1
RP
236\f
237/* Clear out all variables saying what to do when inferior is continued.
238 First do this, then set the ones you want, then call `proceed'. */
239
240void
241clear_proceed_status ()
242{
243 trap_expected = 0;
244 step_range_start = 0;
245 step_range_end = 0;
246 step_frame_address = 0;
247 step_over_calls = -1;
bd5635a1
RP
248 stop_after_trap = 0;
249 stop_soon_quietly = 0;
250 proceed_to_finish = 0;
251 breakpoint_proceeded = 1; /* We're about to proceed... */
252
253 /* Discard any remaining commands or status from previous stop. */
254 bpstat_clear (&stop_bpstat);
255}
256
257/* Basic routine for continuing the program in various fashions.
258
259 ADDR is the address to resume at, or -1 for resume where stopped.
260 SIGGNAL is the signal to give it, or 0 for none,
261 or -1 for act according to how it stopped.
262 STEP is nonzero if should trap after one instruction.
263 -1 means return after that and print nothing.
264 You should probably set various step_... variables
265 before calling here, if you are stepping.
266
267 You should call clear_proceed_status before calling proceed. */
268
269void
270proceed (addr, siggnal, step)
271 CORE_ADDR addr;
67ac9759 272 enum target_signal siggnal;
bd5635a1
RP
273 int step;
274{
275 int oneproc = 0;
276
277 if (step > 0)
278 step_start_function = find_pc_function (read_pc ());
279 if (step < 0)
280 stop_after_trap = 1;
281
bdbd5f50 282 if (addr == (CORE_ADDR)-1)
bd5635a1
RP
283 {
284 /* If there is a breakpoint at the address we will resume at,
285 step one instruction before inserting breakpoints
286 so that we do not stop right away. */
287
37c99ddb 288 if (breakpoint_here_p (read_pc ()))
bd5635a1
RP
289 oneproc = 1;
290 }
291 else
101b7f9c 292 write_pc (addr);
bd5635a1
RP
293
294 if (trap_expected_after_continue)
295 {
296 /* If (step == 0), a trap will be automatically generated after
297 the first instruction is executed. Force step one
298 instruction to clear this condition. This should not occur
299 if step is nonzero, but it is harmless in that case. */
300 oneproc = 1;
301 trap_expected_after_continue = 0;
302 }
303
304 if (oneproc)
305 /* We will get a trace trap after one instruction.
306 Continue it automatically and insert breakpoints then. */
307 trap_expected = 1;
308 else
309 {
310 int temp = insert_breakpoints ();
311 if (temp)
312 {
313 print_sys_errmsg ("ptrace", temp);
314 error ("Cannot insert breakpoints.\n\
315The same program may be running in another process.");
316 }
317 breakpoints_inserted = 1;
318 }
319
fcbc95a7 320 if (siggnal != TARGET_SIGNAL_DEFAULT)
bd5635a1
RP
321 stop_signal = siggnal;
322 /* If this signal should not be seen by program,
323 give it zero. Used for debugging signals. */
67ac9759 324 else if (!signal_program[stop_signal])
fcbc95a7 325 stop_signal = TARGET_SIGNAL_0;
bd5635a1 326
bd5635a1 327 /* Resume inferior. */
a71d17b1 328 resume (oneproc || step || bpstat_should_step (), stop_signal);
bd5635a1
RP
329
330 /* Wait for it to stop (if not standalone)
331 and in any case decode why it stopped, and act accordingly. */
332
333 wait_for_inferior ();
334 normal_stop ();
335}
336
bd5635a1
RP
337/* Record the pc and sp of the program the last time it stopped.
338 These are just used internally by wait_for_inferior, but need
339 to be preserved over calls to it and cleared when the inferior
340 is started. */
341static CORE_ADDR prev_pc;
342static CORE_ADDR prev_sp;
343static CORE_ADDR prev_func_start;
344static char *prev_func_name;
345
a71d17b1 346\f
bd5635a1
RP
347/* Start remote-debugging of a machine over a serial link. */
348
349void
350start_remote ()
351{
352 init_wait_for_inferior ();
353 clear_proceed_status ();
354 stop_soon_quietly = 1;
355 trap_expected = 0;
98885d76
JK
356 wait_for_inferior ();
357 normal_stop ();
bd5635a1
RP
358}
359
360/* Initialize static vars when a new inferior begins. */
361
362void
363init_wait_for_inferior ()
364{
365 /* These are meaningless until the first time through wait_for_inferior. */
366 prev_pc = 0;
367 prev_sp = 0;
368 prev_func_start = 0;
369 prev_func_name = NULL;
370
371 trap_expected_after_continue = 0;
372 breakpoints_inserted = 0;
cf3e377e 373 breakpoint_init_inferior ();
67ac9759
JK
374
375 /* Don't confuse first call to proceed(). */
376 stop_signal = TARGET_SIGNAL_0;
bd5635a1
RP
377}
378
fe675038
JK
379static void
380delete_breakpoint_current_contents (arg)
381 PTR arg;
382{
383 struct breakpoint **breakpointp = (struct breakpoint **)arg;
384 if (*breakpointp != NULL)
385 delete_breakpoint (*breakpointp);
386}
bd5635a1
RP
387\f
388/* Wait for control to return from inferior to debugger.
389 If inferior gets a signal, we may decide to start it up again
390 instead of returning. That is why there is a loop in this function.
391 When this function actually returns it means the inferior
392 should be left stopped and GDB should read more commands. */
393
394void
395wait_for_inferior ()
396{
fe675038 397 struct cleanup *old_cleanups;
67ac9759 398 struct target_waitstatus w;
bd5635a1
RP
399 int another_trap;
400 int random_signal;
37c99ddb 401 CORE_ADDR stop_sp = 0;
bd5635a1 402 CORE_ADDR stop_func_start;
67ac9759 403 CORE_ADDR stop_func_end;
bd5635a1 404 char *stop_func_name;
37c99ddb 405 CORE_ADDR prologue_pc = 0, tmp;
bd5635a1
RP
406 struct symtab_and_line sal;
407 int remove_breakpoints_on_following_step = 0;
b3b39c0c 408 int current_line;
b2f03c30 409 struct symtab *current_symtab;
30875e1c 410 int handling_longjmp = 0; /* FIXME */
fe675038 411 struct breakpoint *step_resume_breakpoint = NULL;
37c99ddb 412 int pid;
bd5635a1 413
fe675038
JK
414 old_cleanups = make_cleanup (delete_breakpoint_current_contents,
415 &step_resume_breakpoint);
b3b39c0c
SG
416 sal = find_pc_line(prev_pc, 0);
417 current_line = sal.line;
b2f03c30 418 current_symtab = sal.symtab;
b3b39c0c 419
cb6b0202
JK
420 /* Are we stepping? */
421#define CURRENTLY_STEPPING() ((step_resume_breakpoint == NULL \
422 && !handling_longjmp \
423 && (step_range_end \
424 || trap_expected)) \
425 || bpstat_should_step ())
426
bd5635a1
RP
427 while (1)
428 {
429 /* Clean up saved state that will become invalid. */
bd5635a1
RP
430 flush_cached_frames ();
431 registers_changed ();
432
de43d7d0 433 pid = target_wait (-1, &w);
bd5635a1 434
fcbc95a7
JK
435 switch (w.kind)
436 {
437 case TARGET_WAITKIND_LOADED:
438 /* Ignore it gracefully. */
439 if (breakpoints_inserted)
440 {
441 mark_breakpoints_out ();
442 insert_breakpoints ();
443 }
444 resume (0, TARGET_SIGNAL_0);
445 continue;
1eeba686 446
fcbc95a7
JK
447 case TARGET_WAITKIND_SPURIOUS:
448 resume (0, TARGET_SIGNAL_0);
449 continue;
1eeba686 450
fcbc95a7 451 case TARGET_WAITKIND_EXITED:
bd5635a1 452 target_terminal_ours (); /* Must do this before mourn anyway */
67ac9759 453 if (w.value.integer)
e37a6e9c 454 printf_filtered ("\nProgram exited with code 0%o.\n",
67ac9759 455 (unsigned int)w.value.integer);
bd5635a1
RP
456 else
457 if (!batch_mode())
e37a6e9c 458 printf_filtered ("\nProgram exited normally.\n");
199b2450 459 gdb_flush (gdb_stdout);
bd5635a1
RP
460 target_mourn_inferior ();
461#ifdef NO_SINGLE_STEP
462 one_stepped = 0;
463#endif
464 stop_print_frame = 0;
fcbc95a7 465 goto stop_stepping;
67ac9759 466
fcbc95a7 467 case TARGET_WAITKIND_SIGNALLED:
bd5635a1 468 stop_print_frame = 0;
67ac9759 469 stop_signal = w.value.sig;
bd5635a1 470 target_terminal_ours (); /* Must do this before mourn anyway */
30875e1c 471 target_kill (); /* kill mourns as well */
67ac9759
JK
472 printf_filtered ("\nProgram terminated with signal %s, %s.\n",
473 target_signal_to_name (stop_signal),
474 target_signal_to_string (stop_signal));
475
fee44494 476 printf_filtered ("The program no longer exists.\n");
199b2450 477 gdb_flush (gdb_stdout);
bd5635a1
RP
478#ifdef NO_SINGLE_STEP
479 one_stepped = 0;
480#endif
fcbc95a7
JK
481 goto stop_stepping;
482
483 case TARGET_WAITKIND_STOPPED:
484 /* This is the only case in which we keep going; the above cases
485 end in a continue or goto. */
bd5635a1
RP
486 break;
487 }
de43d7d0 488
67ac9759 489 stop_signal = w.value.sig;
de43d7d0
SG
490
491 if (pid != inferior_pid)
492 {
493 int save_pid = inferior_pid;
494
495 inferior_pid = pid; /* Setup for target memory/regs */
496 registers_changed ();
497 stop_pc = read_pc ();
498 inferior_pid = save_pid;
499 registers_changed ();
500 }
501 else
502 stop_pc = read_pc ();
503
67ac9759 504 if (stop_signal == TARGET_SIGNAL_TRAP
de43d7d0 505 && breakpoint_here_p (stop_pc - DECR_PC_AFTER_BREAK))
b2f03c30
JK
506 {
507 if (!breakpoint_thread_match (stop_pc - DECR_PC_AFTER_BREAK, pid))
508 {
509 /* Saw a breakpoint, but it was hit by the wrong thread. Just continue. */
510 if (breakpoints_inserted)
511 {
512 if (pid != inferior_pid)
513 {
514 int save_pid = inferior_pid;
515
516 inferior_pid = pid;
517 registers_changed ();
518 write_pc (stop_pc - DECR_PC_AFTER_BREAK);
519 inferior_pid = save_pid;
520 registers_changed ();
521 }
522 else
523 write_pc (stop_pc - DECR_PC_AFTER_BREAK);
524
525 remove_breakpoints ();
67ac9759 526 target_resume (pid, 1, TARGET_SIGNAL_0); /* Single step */
b2f03c30
JK
527 /* FIXME: What if a signal arrives instead of the single-step
528 happening? */
529 target_wait (pid, &w);
530 insert_breakpoints ();
531 }
67ac9759 532 target_resume (-1, 0, TARGET_SIGNAL_0);
b2f03c30
JK
533 continue;
534 }
535 else
536 if (pid != inferior_pid)
537 goto switch_thread;
538 }
de43d7d0 539
37c99ddb
JK
540 if (pid != inferior_pid)
541 {
542 int printed = 0;
543
544 if (!in_thread_list (pid))
545 {
199b2450 546 fprintf_unfiltered (gdb_stderr, "[New %s]\n", target_pid_to_str (pid));
37c99ddb
JK
547 add_thread (pid);
548
67ac9759 549 target_resume (-1, 0, TARGET_SIGNAL_0);
37c99ddb
JK
550 continue;
551 }
552 else
553 {
67ac9759 554 if (signal_print[stop_signal])
37c99ddb
JK
555 {
556 char *signame;
557
558 printed = 1;
559 target_terminal_ours_for_output ();
67ac9759
JK
560 printf_filtered ("\nProgram received signal %s, %s.\n",
561 target_signal_to_name (stop_signal),
562 target_signal_to_string (stop_signal));
199b2450 563 gdb_flush (gdb_stdout);
37c99ddb
JK
564 }
565
67ac9759 566 if (stop_signal == TARGET_SIGNAL_TRAP
de43d7d0 567 || signal_stop[stop_signal])
37c99ddb 568 {
de43d7d0 569switch_thread:
37c99ddb
JK
570 inferior_pid = pid;
571 printf_filtered ("[Switching to %s]\n", target_pid_to_str (pid));
572
573 flush_cached_frames ();
574 registers_changed ();
575 trap_expected = 0;
576 if (step_resume_breakpoint)
577 {
578 delete_breakpoint (step_resume_breakpoint);
579 step_resume_breakpoint = NULL;
580 }
581 prev_pc = 0;
582 prev_sp = 0;
583 prev_func_name = NULL;
584 step_range_start = 0;
585 step_range_end = 0;
586 step_frame_address = 0;
587 handling_longjmp = 0;
588 another_trap = 0;
589 }
590 else
591 {
592 if (printed)
593 target_terminal_inferior ();
594
595 /* Clear the signal if it should not be passed. */
596 if (signal_program[stop_signal] == 0)
67ac9759 597 stop_signal = TARGET_SIGNAL_0;
37c99ddb 598
b2f03c30 599 target_resume (pid, 0, stop_signal);
37c99ddb
JK
600 continue;
601 }
602 }
603 }
604
bd5635a1
RP
605#ifdef NO_SINGLE_STEP
606 if (one_stepped)
607 single_step (0); /* This actually cleans up the ss */
608#endif /* NO_SINGLE_STEP */
609
9f739abd
SG
610/* If PC is pointing at a nullified instruction, then step beyond it so that
611 the user won't be confused when GDB appears to be ready to execute it. */
612
613 if (INSTRUCTION_NULLIFIED)
614 {
615 resume (1, 0);
616 continue;
617 }
618
37c99ddb 619 set_current_frame ( create_new_frame (read_fp (), stop_pc));
fe675038 620
bd5635a1 621 stop_frame_address = FRAME_FP (get_current_frame ());
fee44494 622 stop_sp = read_sp ();
bd5635a1
RP
623 stop_func_start = 0;
624 stop_func_name = 0;
625 /* Don't care about return value; stop_func_start and stop_func_name
626 will both be 0 if it doesn't work. */
37c99ddb 627 find_pc_partial_function (stop_pc, &stop_func_name, &stop_func_start,
67ac9759 628 &stop_func_end);
bd5635a1
RP
629 stop_func_start += FUNCTION_START_OFFSET;
630 another_trap = 0;
631 bpstat_clear (&stop_bpstat);
632 stop_step = 0;
633 stop_stack_dummy = 0;
634 stop_print_frame = 1;
bd5635a1
RP
635 random_signal = 0;
636 stopped_by_random_signal = 0;
637 breakpoints_failed = 0;
638
639 /* Look at the cause of the stop, and decide what to do.
640 The alternatives are:
641 1) break; to really stop and return to the debugger,
642 2) drop through to start up again
643 (set another_trap to 1 to single step once)
644 3) set random_signal to 1, and the decision between 1 and 2
645 will be made according to the signal handling tables. */
646
bd5635a1
RP
647 /* First, distinguish signals caused by the debugger from signals
648 that have to do with the program's own actions.
649 Note that breakpoint insns may cause SIGTRAP or SIGILL
650 or SIGEMT, depending on the operating system version.
651 Here we detect when a SIGILL or SIGEMT is really a breakpoint
652 and change it to SIGTRAP. */
653
67ac9759 654 if (stop_signal == TARGET_SIGNAL_TRAP
bd5635a1 655 || (breakpoints_inserted &&
67ac9759
JK
656 (stop_signal == TARGET_SIGNAL_ILL
657 || stop_signal == TARGET_SIGNAL_EMT
e37a6e9c 658 ))
bd5635a1
RP
659 || stop_soon_quietly)
660 {
67ac9759 661 if (stop_signal == TARGET_SIGNAL_TRAP && stop_after_trap)
bd5635a1
RP
662 {
663 stop_print_frame = 0;
664 break;
665 }
666 if (stop_soon_quietly)
667 break;
668
669 /* Don't even think about breakpoints
670 if just proceeded over a breakpoint.
671
672 However, if we are trying to proceed over a breakpoint
fe675038 673 and end up in sigtramp, then step_resume_breakpoint
bd5635a1
RP
674 will be set and we should check whether we've hit the
675 step breakpoint. */
67ac9759 676 if (stop_signal == TARGET_SIGNAL_TRAP && trap_expected
fe675038 677 && step_resume_breakpoint == NULL)
bd5635a1
RP
678 bpstat_clear (&stop_bpstat);
679 else
680 {
681 /* See if there is a breakpoint at the current PC. */
cb6b0202
JK
682 stop_bpstat = bpstat_stop_status
683 (&stop_pc, stop_frame_address,
bd5635a1 684#if DECR_PC_AFTER_BREAK
cb6b0202
JK
685 /* Notice the case of stepping through a jump
686 that lands just after a breakpoint.
687 Don't confuse that with hitting the breakpoint.
688 What we check for is that 1) stepping is going on
689 and 2) the pc before the last insn does not match
690 the address of the breakpoint before the current pc. */
691 (prev_pc != stop_pc - DECR_PC_AFTER_BREAK
692 && CURRENTLY_STEPPING ())
693#else /* DECR_PC_AFTER_BREAK zero */
694 0
695#endif /* DECR_PC_AFTER_BREAK zero */
696 );
697 /* Following in case break condition called a
698 function. */
699 stop_print_frame = 1;
bd5635a1 700 }
fe675038 701
67ac9759 702 if (stop_signal == TARGET_SIGNAL_TRAP)
bd5635a1
RP
703 random_signal
704 = !(bpstat_explains_signal (stop_bpstat)
705 || trap_expected
84d59861 706#ifndef CALL_DUMMY_BREAKPOINT_OFFSET
bd5635a1 707 || PC_IN_CALL_DUMMY (stop_pc, stop_sp, stop_frame_address)
84d59861 708#endif /* No CALL_DUMMY_BREAKPOINT_OFFSET. */
fe675038 709 || (step_range_end && step_resume_breakpoint == NULL));
bd5635a1
RP
710 else
711 {
712 random_signal
713 = !(bpstat_explains_signal (stop_bpstat)
bd5635a1
RP
714 /* End of a stack dummy. Some systems (e.g. Sony
715 news) give another signal besides SIGTRAP,
716 so check here as well as above. */
84d59861 717#ifndef CALL_DUMMY_BREAKPOINT_OFFSET
d747e0af 718 || PC_IN_CALL_DUMMY (stop_pc, stop_sp, stop_frame_address)
84d59861 719#endif /* No CALL_DUMMY_BREAKPOINT_OFFSET. */
bd5635a1
RP
720 );
721 if (!random_signal)
67ac9759 722 stop_signal = TARGET_SIGNAL_TRAP;
bd5635a1
RP
723 }
724 }
725 else
726 random_signal = 1;
fe675038 727
bd5635a1
RP
728 /* For the program's own signals, act according to
729 the signal handling tables. */
fe675038 730
bd5635a1
RP
731 if (random_signal)
732 {
733 /* Signal not for debugging purposes. */
734 int printed = 0;
735
736 stopped_by_random_signal = 1;
737
67ac9759 738 if (signal_print[stop_signal])
bd5635a1 739 {
fee44494 740 char *signame;
bd5635a1
RP
741 printed = 1;
742 target_terminal_ours_for_output ();
67ac9759
JK
743 printf_filtered ("\nProgram received signal %s, %s.\n",
744 target_signal_to_name (stop_signal),
745 target_signal_to_string (stop_signal));
199b2450 746 gdb_flush (gdb_stdout);
bd5635a1 747 }
67ac9759 748 if (signal_stop[stop_signal])
bd5635a1
RP
749 break;
750 /* If not going to stop, give terminal back
751 if we took it away. */
752 else if (printed)
753 target_terminal_inferior ();
b7f81b57 754
101b7f9c
PS
755 /* Clear the signal if it should not be passed. */
756 if (signal_program[stop_signal] == 0)
67ac9759 757 stop_signal = TARGET_SIGNAL_0;
101b7f9c 758
fe675038
JK
759 /* I'm not sure whether this needs to be check_sigtramp2 or
760 whether it could/should be keep_going. */
761 goto check_sigtramp2;
bd5635a1 762 }
30875e1c 763
bd5635a1 764 /* Handle cases caused by hitting a breakpoint. */
fe675038
JK
765 {
766 CORE_ADDR jmp_buf_pc;
29c6dce2
JK
767 struct bpstat_what what;
768
769 what = bpstat_what (stop_bpstat);
bd5635a1 770
84d59861
JK
771 if (what.call_dummy)
772 {
773 stop_stack_dummy = 1;
774#ifdef HP_OS_BUG
775 trap_expected_after_continue = 1;
776#endif
777 }
778
fe675038
JK
779 switch (what.main_action)
780 {
781 case BPSTAT_WHAT_SET_LONGJMP_RESUME:
782 /* If we hit the breakpoint at longjmp, disable it for the
783 duration of this command. Then, install a temporary
784 breakpoint at the target of the jmp_buf. */
785 disable_longjmp_breakpoint();
786 remove_breakpoints ();
787 breakpoints_inserted = 0;
788 if (!GET_LONGJMP_TARGET(&jmp_buf_pc)) goto keep_going;
789
790 /* Need to blow away step-resume breakpoint, as it
791 interferes with us */
792 if (step_resume_breakpoint != NULL)
793 {
794 delete_breakpoint (step_resume_breakpoint);
795 step_resume_breakpoint = NULL;
796 what.step_resume = 0;
797 }
30875e1c 798
101b7f9c 799#if 0
fe675038
JK
800 /* FIXME - Need to implement nested temporary breakpoints */
801 if (step_over_calls > 0)
802 set_longjmp_resume_breakpoint(jmp_buf_pc,
803 get_current_frame());
804 else
30875e1c 805#endif /* 0 */
fe675038
JK
806 set_longjmp_resume_breakpoint(jmp_buf_pc, NULL);
807 handling_longjmp = 1; /* FIXME */
808 goto keep_going;
809
810 case BPSTAT_WHAT_CLEAR_LONGJMP_RESUME:
811 case BPSTAT_WHAT_CLEAR_LONGJMP_RESUME_SINGLE:
812 remove_breakpoints ();
813 breakpoints_inserted = 0;
101b7f9c 814#if 0
fe675038
JK
815 /* FIXME - Need to implement nested temporary breakpoints */
816 if (step_over_calls
817 && (stop_frame_address
818 INNER_THAN step_frame_address))
819 {
820 another_trap = 1;
821 goto keep_going;
822 }
30875e1c 823#endif /* 0 */
fe675038
JK
824 disable_longjmp_breakpoint();
825 handling_longjmp = 0; /* FIXME */
826 if (what.main_action == BPSTAT_WHAT_CLEAR_LONGJMP_RESUME)
101b7f9c 827 break;
fe675038
JK
828 /* else fallthrough */
829
830 case BPSTAT_WHAT_SINGLE:
831 if (breakpoints_inserted)
832 remove_breakpoints ();
833 breakpoints_inserted = 0;
834 another_trap = 1;
835 /* Still need to check other stuff, at least the case
836 where we are stepping and step out of the right range. */
837 break;
838
839 case BPSTAT_WHAT_STOP_NOISY:
840 stop_print_frame = 1;
841 /* We are about to nuke the step_resume_breakpoint via the
842 cleanup chain, so no need to worry about it here. */
843 goto stop_stepping;
101b7f9c 844
fe675038
JK
845 case BPSTAT_WHAT_STOP_SILENT:
846 stop_print_frame = 0;
847 /* We are about to nuke the step_resume_breakpoint via the
848 cleanup chain, so no need to worry about it here. */
849 goto stop_stepping;
850
100f92e2
JK
851 case BPSTAT_WHAT_LAST:
852 /* Not a real code, but listed here to shut up gcc -Wall. */
853
fe675038
JK
854 case BPSTAT_WHAT_KEEP_CHECKING:
855 break;
856 }
857
858 if (what.step_resume)
30875e1c 859 {
fe675038
JK
860 delete_breakpoint (step_resume_breakpoint);
861 step_resume_breakpoint = NULL;
30875e1c 862
fe675038
JK
863 /* If were waiting for a trap, hitting the step_resume_break
864 doesn't count as getting it. */
865 if (trap_expected)
866 another_trap = 1;
30875e1c 867 }
fe675038 868 }
30875e1c
SG
869
870 /* We come here if we hit a breakpoint but should not
871 stop for it. Possibly we also were stepping
872 and should stop for that. So fall through and
873 test for stepping. But, if not stepping,
874 do not stop. */
875
84d59861
JK
876#ifndef CALL_DUMMY_BREAKPOINT_OFFSET
877 /* This is the old way of detecting the end of the stack dummy.
878 An architecture which defines CALL_DUMMY_BREAKPOINT_OFFSET gets
879 handled above. As soon as we can test it on all of them, all
880 architectures should define it. */
881
bd5635a1 882 /* If this is the breakpoint at the end of a stack dummy,
c9de302b
SG
883 just stop silently, unless the user was doing an si/ni, in which
884 case she'd better know what she's doing. */
885
886 if (PC_IN_CALL_DUMMY (stop_pc, stop_sp, stop_frame_address)
887 && !step_range_end)
888 {
889 stop_print_frame = 0;
890 stop_stack_dummy = 1;
bd5635a1 891#ifdef HP_OS_BUG
c9de302b 892 trap_expected_after_continue = 1;
bd5635a1 893#endif
c9de302b
SG
894 break;
895 }
84d59861
JK
896#endif /* No CALL_DUMMY_BREAKPOINT_OFFSET. */
897
fe675038 898 if (step_resume_breakpoint)
bd5635a1
RP
899 /* Having a step-resume breakpoint overrides anything
900 else having to do with stepping commands until
901 that breakpoint is reached. */
fe675038
JK
902 /* I suspect this could/should be keep_going, because if the
903 check_sigtramp2 check succeeds, then it will put in another
904 step_resume_breakpoint, and we aren't (yet) prepared to nest
905 them. */
906 goto check_sigtramp2;
907
908 if (step_range_end == 0)
909 /* Likewise if we aren't even stepping. */
910 /* I'm not sure whether this needs to be check_sigtramp2 or
911 whether it could/should be keep_going. */
912 goto check_sigtramp2;
913
bd5635a1 914 /* If stepping through a line, keep going if still within it. */
fe675038
JK
915 if (stop_pc >= step_range_start
916 && stop_pc < step_range_end
917 /* The step range might include the start of the
918 function, so if we are at the start of the
919 step range and either the stack or frame pointers
920 just changed, we've stepped outside */
921 && !(stop_pc == step_range_start
922 && stop_frame_address
923 && (stop_sp INNER_THAN prev_sp
924 || stop_frame_address != step_frame_address)))
bd5635a1 925 {
fe675038
JK
926 /* We might be doing a BPSTAT_WHAT_SINGLE and getting a signal.
927 So definately need to check for sigtramp here. */
928 goto check_sigtramp2;
bd5635a1 929 }
fe675038 930
bd5635a1
RP
931 /* We stepped out of the stepping range. See if that was due
932 to a subroutine call that we should proceed to the end of. */
fe675038
JK
933
934 /* Did we just take a signal? */
935 if (IN_SIGTRAMP (stop_pc, stop_func_name)
936 && !IN_SIGTRAMP (prev_pc, prev_func_name))
bd5635a1 937 {
fe675038
JK
938 /* This code is needed at least in the following case:
939 The user types "next" and then a signal arrives (before
940 the "next" is done). */
941 /* We've just taken a signal; go until we are back to
942 the point where we took it and one more. */
943 {
944 struct symtab_and_line sr_sal;
945
946 sr_sal.pc = prev_pc;
947 sr_sal.symtab = NULL;
948 sr_sal.line = 0;
949 step_resume_breakpoint =
950 set_momentary_breakpoint (sr_sal, get_current_frame (),
951 bp_step_resume);
952 if (breakpoints_inserted)
953 insert_breakpoints ();
954 }
bd5635a1 955
fe675038
JK
956 /* If this is stepi or nexti, make sure that the stepping range
957 gets us past that instruction. */
958 if (step_range_end == 1)
959 /* FIXME: Does this run afoul of the code below which, if
960 we step into the middle of a line, resets the stepping
961 range? */
962 step_range_end = (step_range_start = prev_pc) + 1;
101b7f9c 963
fe675038
JK
964 remove_breakpoints_on_following_step = 1;
965 goto keep_going;
966 }
30875e1c 967
fe675038
JK
968 if (stop_func_start)
969 {
970 /* Do this after the IN_SIGTRAMP check; it might give
971 an error. */
972 prologue_pc = stop_func_start;
973 SKIP_PROLOGUE (prologue_pc);
974 }
30875e1c 975
c0c14c1e
JK
976 if ((/* Might be a non-recursive call. If the symbols are missing
977 enough that stop_func_start == prev_func_start even though
978 they are really two functions, we will treat some calls as
979 jumps. */
980 stop_func_start != prev_func_start
981
982 /* Might be a recursive call if either we have a prologue
983 or the call instruction itself saves the PC on the stack. */
984 || prologue_pc != stop_func_start
985 || stop_sp != prev_sp)
199b2450
TL
986 && (/* PC is completely out of bounds of any known objfiles. Treat
987 like a subroutine call. */
988 ! stop_func_start
c0c14c1e 989
f1619234 990 /* If we do a call, we will be at the start of a function... */
c0c14c1e 991 || stop_pc == stop_func_start
f1619234
JK
992#if 0
993 /* Should be taken care of by the stop_pc < prologue_pc check
994 below. Also, on irix5 where this checks for stop_pc
995 equal to stop_func_start plus 12, it would seem to be
996 wrong for a function with a 4 byte prologue, and an 8 byte
997 call; a "return" could end up at stop_func_start+12. */
998
b2f03c30 999 || AT_FUNCTION_START (stop_pc, stop_func_name, stop_func_start)
f1619234
JK
1000#endif
1001
1002 /* ...except on the Alpha with -O (and also Irix 5 and
1003 perhaps others), in which we might call the address
1004 after the load of gp. Since prologues don't contain
1005 calls, we can't return to within one, and we don't
1006 jump back into them, so this check is OK. */
c0c14c1e 1007
c0c14c1e 1008 || stop_pc < prologue_pc
d747e0af 1009
c0c14c1e
JK
1010 /* If we end up in certain places, it means we did a subroutine
1011 call. I'm not completely sure this is necessary now that we
1012 have the above checks with stop_func_start (and now that
100f92e2 1013 find_pc_partial_function is pickier). */
c0c14c1e
JK
1014 || IN_SOLIB_TRAMPOLINE (stop_pc, stop_func_name)
1015
1016 /* If none of the above apply, it is a jump within a function,
1017 or a return from a subroutine. The other case is longjmp,
1018 which can no longer happen here as long as the
1019 handling_longjmp stuff is working. */
1020 ))
fe675038
JK
1021 {
1022 /* It's a subroutine call. */
fee44494 1023
fe675038
JK
1024 if (step_over_calls == 0)
1025 {
1026 /* I presume that step_over_calls is only 0 when we're
1027 supposed to be stepping at the assembly language level
1028 ("stepi"). Just stop. */
1029 stop_step = 1;
1030 break;
1031 }
fee44494 1032
fe675038
JK
1033 if (step_over_calls > 0)
1034 /* We're doing a "next". */
1035 goto step_over_function;
1036
1037 /* If we are in a function call trampoline (a stub between
1038 the calling routine and the real function), locate the real
1039 function. That's what tells us (a) whether we want to step
1040 into it at all, and (b) what prologue we want to run to
1041 the end of, if we do step into it. */
1042 tmp = SKIP_TRAMPOLINE_CODE (stop_pc);
1043 if (tmp != 0)
1044 stop_func_start = tmp;
1045
1046 /* If we have line number information for the function we
1047 are thinking of stepping into, step into it.
1048
1049 If there are several symtabs at that PC (e.g. with include
1050 files), just want to know whether *any* of them have line
1051 numbers. find_pc_line handles this. */
1052 {
1053 struct symtab_and_line tmp_sal;
1054
1055 tmp_sal = find_pc_line (stop_func_start, 0);
1056 if (tmp_sal.line != 0)
1057 goto step_into_function;
1058 }
d747e0af
MT
1059
1060step_over_function:
fe675038
JK
1061 /* A subroutine call has happened. */
1062 {
1063 /* Set a special breakpoint after the return */
1064 struct symtab_and_line sr_sal;
1065 sr_sal.pc =
1066 ADDR_BITS_REMOVE
1067 (SAVED_PC_AFTER_CALL (get_current_frame ()));
1068 sr_sal.symtab = NULL;
1069 sr_sal.line = 0;
1070 step_resume_breakpoint =
1071 set_momentary_breakpoint (sr_sal, get_current_frame (),
1072 bp_step_resume);
1073 if (breakpoints_inserted)
1074 insert_breakpoints ();
1075 }
1076 goto keep_going;
d747e0af
MT
1077
1078step_into_function:
fe675038
JK
1079 /* Subroutine call with source code we should not step over.
1080 Do step to the first line of code in it. */
1081 SKIP_PROLOGUE (stop_func_start);
1082 sal = find_pc_line (stop_func_start, 0);
1083 /* Use the step_resume_break to step until
1084 the end of the prologue, even if that involves jumps
1085 (as it seems to on the vax under 4.2). */
1086 /* If the prologue ends in the middle of a source line,
67ac9759
JK
1087 continue to the end of that source line (if it is still
1088 within the function). Otherwise, just go to end of prologue. */
bd5635a1 1089#ifdef PROLOGUE_FIRSTLINE_OVERLAP
fe675038
JK
1090 /* no, don't either. It skips any code that's
1091 legitimately on the first line. */
bd5635a1 1092#else
67ac9759 1093 if (sal.end && sal.pc != stop_func_start && sal.end < stop_func_end)
fe675038 1094 stop_func_start = sal.end;
bd5635a1 1095#endif
d747e0af 1096
fe675038
JK
1097 if (stop_func_start == stop_pc)
1098 {
1099 /* We are already there: stop now. */
1100 stop_step = 1;
1101 break;
1102 }
1103 else
1104 /* Put the step-breakpoint there and go until there. */
1105 {
1106 struct symtab_and_line sr_sal;
1107
1108 sr_sal.pc = stop_func_start;
1109 sr_sal.symtab = NULL;
1110 sr_sal.line = 0;
1111 /* Do not specify what the fp should be when we stop
1112 since on some machines the prologue
1113 is where the new fp value is established. */
1114 step_resume_breakpoint =
84d59861 1115 set_momentary_breakpoint (sr_sal, NULL, bp_step_resume);
fe675038
JK
1116 if (breakpoints_inserted)
1117 insert_breakpoints ();
1118
1119 /* And make sure stepping stops right away then. */
1120 step_range_end = step_range_start;
bd5635a1 1121 }
fe675038
JK
1122 goto keep_going;
1123 }
d747e0af 1124
b2f03c30 1125 /* We've wandered out of the step range. */
d747e0af 1126
fe675038
JK
1127 sal = find_pc_line(stop_pc, 0);
1128
1129 if (step_range_end == 1)
1130 {
1131 /* It is stepi or nexti. We always want to stop stepping after
1132 one instruction. */
1133 stop_step = 1;
1134 break;
1135 }
1136
1137 if (sal.line == 0)
1138 {
1139 /* We have no line number information. That means to stop
1140 stepping (does this always happen right after one instruction,
1141 when we do "s" in a function with no line numbers,
1142 or can this happen as a result of a return or longjmp?). */
1143 stop_step = 1;
1144 break;
1145 }
1146
b2f03c30
JK
1147 if (stop_pc == sal.pc
1148 && (current_line != sal.line || current_symtab != sal.symtab))
fe675038
JK
1149 {
1150 /* We are at the start of a different line. So stop. Note that
1151 we don't stop if we step into the middle of a different line.
1152 That is said to make things like for (;;) statements work
1153 better. */
1154 stop_step = 1;
1155 break;
bd5635a1
RP
1156 }
1157
fe675038
JK
1158 /* We aren't done stepping.
1159
1160 Optimize by setting the stepping range to the line.
1161 (We might not be in the original line, but if we entered a
1162 new line in mid-statement, we continue stepping. This makes
1163 things like for(;;) statements work better.) */
67ac9759
JK
1164
1165 if (stop_func_end && sal.end >= stop_func_end)
1166 {
1167 /* If this is the last line of the function, don't keep stepping
1168 (it would probably step us out of the function).
1169 This is particularly necessary for a one-line function,
1170 in which after skipping the prologue we better stop even though
1171 we will be in mid-line. */
1172 stop_step = 1;
1173 break;
1174 }
fe675038
JK
1175 step_range_start = sal.pc;
1176 step_range_end = sal.end;
1177 goto keep_going;
1178
1179 check_sigtramp2:
d747e0af
MT
1180 if (trap_expected
1181 && IN_SIGTRAMP (stop_pc, stop_func_name)
1182 && !IN_SIGTRAMP (prev_pc, prev_func_name))
bd5635a1
RP
1183 {
1184 /* What has happened here is that we have just stepped the inferior
1185 with a signal (because it is a signal which shouldn't make
1186 us stop), thus stepping into sigtramp.
1187
1188 So we need to set a step_resume_break_address breakpoint
fe675038
JK
1189 and continue until we hit it, and then step. FIXME: This should
1190 be more enduring than a step_resume breakpoint; we should know
1191 that we will later need to keep going rather than re-hitting
1192 the breakpoint here (see testsuite/gdb.t06/signals.exp where
1193 it says "exceedingly difficult"). */
1194 struct symtab_and_line sr_sal;
1195
1196 sr_sal.pc = prev_pc;
1197 sr_sal.symtab = NULL;
1198 sr_sal.line = 0;
1199 step_resume_breakpoint =
1200 set_momentary_breakpoint (sr_sal, get_current_frame (),
1201 bp_step_resume);
bd5635a1 1202 if (breakpoints_inserted)
fe675038
JK
1203 insert_breakpoints ();
1204
bd5635a1
RP
1205 remove_breakpoints_on_following_step = 1;
1206 another_trap = 1;
1207 }
1208
30875e1c 1209 keep_going:
fe675038
JK
1210 /* Come to this label when you need to resume the inferior.
1211 It's really much cleaner to do a goto than a maze of if-else
1212 conditions. */
30875e1c 1213
bd5635a1
RP
1214 /* Save the pc before execution, to compare with pc after stop. */
1215 prev_pc = read_pc (); /* Might have been DECR_AFTER_BREAK */
1216 prev_func_start = stop_func_start; /* Ok, since if DECR_PC_AFTER
1217 BREAK is defined, the
1218 original pc would not have
1219 been at the start of a
1220 function. */
1221 prev_func_name = stop_func_name;
1222 prev_sp = stop_sp;
1223
1224 /* If we did not do break;, it means we should keep
1225 running the inferior and not return to debugger. */
1226
67ac9759 1227 if (trap_expected && stop_signal != TARGET_SIGNAL_TRAP)
bd5635a1
RP
1228 {
1229 /* We took a signal (which we are supposed to pass through to
1230 the inferior, else we'd have done a break above) and we
1231 haven't yet gotten our trap. Simply continue. */
cb6b0202 1232 resume (CURRENTLY_STEPPING (), stop_signal);
bd5635a1
RP
1233 }
1234 else
1235 {
1236 /* Either the trap was not expected, but we are continuing
1237 anyway (the user asked that this signal be passed to the
1238 child)
1239 -- or --
1240 The signal was SIGTRAP, e.g. it was our signal, but we
1241 decided we should resume from it.
1242
1243 We're going to run this baby now!
1244
1245 Insert breakpoints now, unless we are trying
1246 to one-proceed past a breakpoint. */
1247 /* If we've just finished a special step resume and we don't
1248 want to hit a breakpoint, pull em out. */
fe675038 1249 if (step_resume_breakpoint == NULL &&
bd5635a1
RP
1250 remove_breakpoints_on_following_step)
1251 {
1252 remove_breakpoints_on_following_step = 0;
1253 remove_breakpoints ();
1254 breakpoints_inserted = 0;
1255 }
1256 else if (!breakpoints_inserted &&
fe675038 1257 (step_resume_breakpoint != NULL || !another_trap))
bd5635a1 1258 {
bd5635a1
RP
1259 breakpoints_failed = insert_breakpoints ();
1260 if (breakpoints_failed)
1261 break;
1262 breakpoints_inserted = 1;
1263 }
1264
1265 trap_expected = another_trap;
1266
67ac9759
JK
1267 if (stop_signal == TARGET_SIGNAL_TRAP)
1268 stop_signal = TARGET_SIGNAL_0;
bd5635a1
RP
1269
1270#ifdef SHIFT_INST_REGS
1271 /* I'm not sure when this following segment applies. I do know, now,
1272 that we shouldn't rewrite the regs when we were stopped by a
1273 random signal from the inferior process. */
cef4c2e7
PS
1274 /* FIXME: Shouldn't this be based on the valid bit of the SXIP?
1275 (this is only used on the 88k). */
bd5635a1 1276
d11c44f1 1277 if (!bpstat_explains_signal (stop_bpstat)
67ac9759 1278 && (stop_signal != TARGET_SIGNAL_CHLD)
bd5635a1 1279 && !stopped_by_random_signal)
07a5991a 1280 SHIFT_INST_REGS();
bd5635a1
RP
1281#endif /* SHIFT_INST_REGS */
1282
cb6b0202 1283 resume (CURRENTLY_STEPPING (), stop_signal);
bd5635a1
RP
1284 }
1285 }
30875e1c
SG
1286
1287 stop_stepping:
bd5635a1
RP
1288 if (target_has_execution)
1289 {
1290 /* Assuming the inferior still exists, set these up for next
1291 time, just like we did above if we didn't break out of the
1292 loop. */
1293 prev_pc = read_pc ();
1294 prev_func_start = stop_func_start;
1295 prev_func_name = stop_func_name;
1296 prev_sp = stop_sp;
1297 }
fe675038 1298 do_cleanups (old_cleanups);
bd5635a1
RP
1299}
1300\f
1301/* Here to return control to GDB when the inferior stops for real.
1302 Print appropriate messages, remove breakpoints, give terminal our modes.
1303
1304 STOP_PRINT_FRAME nonzero means print the executing frame
1305 (pc, function, args, file, line number and line text).
1306 BREAKPOINTS_FAILED nonzero means stop was due to error
1307 attempting to insert breakpoints. */
1308
1309void
1310normal_stop ()
1311{
1312 /* Make sure that the current_frame's pc is correct. This
1313 is a correction for setting up the frame info before doing
1314 DECR_PC_AFTER_BREAK */
3f0184ac 1315 if (target_has_execution && get_current_frame())
bd5635a1
RP
1316 (get_current_frame ())->pc = read_pc ();
1317
1318 if (breakpoints_failed)
1319 {
1320 target_terminal_ours_for_output ();
1321 print_sys_errmsg ("ptrace", breakpoints_failed);
e37a6e9c 1322 printf_filtered ("Stopped; cannot insert breakpoints.\n\
bd5635a1
RP
1323The same program may be running in another process.\n");
1324 }
1325
bd5635a1
RP
1326 if (target_has_execution && breakpoints_inserted)
1327 if (remove_breakpoints ())
1328 {
1329 target_terminal_ours_for_output ();
e37a6e9c 1330 printf_filtered ("Cannot remove breakpoints because program is no longer writable.\n\
bd5635a1
RP
1331It might be running in another process.\n\
1332Further execution is probably impossible.\n");
1333 }
1334
1335 breakpoints_inserted = 0;
1336
1337 /* Delete the breakpoint we stopped at, if it wants to be deleted.
1338 Delete any breakpoint that is to be deleted at the next stop. */
1339
1340 breakpoint_auto_delete (stop_bpstat);
1341
1342 /* If an auto-display called a function and that got a signal,
1343 delete that auto-display to avoid an infinite recursion. */
1344
1345 if (stopped_by_random_signal)
1346 disable_current_display ();
1347
1348 if (step_multi && stop_step)
1349 return;
1350
1351 target_terminal_ours ();
1352
3950a34e
RP
1353 /* Look up the hook_stop and run it if it exists. */
1354
1355 if (stop_command->hook)
1356 {
1357 catch_errors (hook_stop_stub, (char *)stop_command->hook,
fee44494 1358 "Error while running hook_stop:\n", RETURN_MASK_ALL);
3950a34e
RP
1359 }
1360
bd5635a1
RP
1361 if (!target_has_stack)
1362 return;
1363
1364 /* Select innermost stack frame except on return from a stack dummy routine,
1515ff18
JG
1365 or if the program has exited. Print it without a level number if
1366 we have changed functions or hit a breakpoint. Print source line
1367 if we have one. */
bd5635a1
RP
1368 if (!stop_stack_dummy)
1369 {
1370 select_frame (get_current_frame (), 0);
1371
1372 if (stop_print_frame)
1373 {
1515ff18
JG
1374 int source_only;
1375
1376 source_only = bpstat_print (stop_bpstat);
1377 source_only = source_only ||
1378 ( stop_step
bd5635a1 1379 && step_frame_address == stop_frame_address
1515ff18
JG
1380 && step_start_function == find_pc_function (stop_pc));
1381
1382 print_stack_frame (selected_frame, -1, source_only? -1: 1);
bd5635a1
RP
1383
1384 /* Display the auto-display expressions. */
1385 do_displays ();
1386 }
1387 }
1388
1389 /* Save the function value return registers, if we care.
1390 We might be about to restore their previous contents. */
1391 if (proceed_to_finish)
1392 read_register_bytes (0, stop_registers, REGISTER_BYTES);
1393
1394 if (stop_stack_dummy)
1395 {
1396 /* Pop the empty frame that contains the stack dummy.
1397 POP_FRAME ends with a setting of the current frame, so we
1398 can use that next. */
1399 POP_FRAME;
1400 select_frame (get_current_frame (), 0);
1401 }
1402}
3950a34e
RP
1403
1404static int
1405hook_stop_stub (cmd)
1406 char *cmd;
1407{
1408 execute_user_command ((struct cmd_list_element *)cmd, 0);
a8a69e63 1409 return (0);
3950a34e 1410}
bd5635a1 1411\f
cc221e76
FF
1412int signal_stop_state (signo)
1413 int signo;
1414{
67ac9759 1415 return signal_stop[signo];
cc221e76
FF
1416}
1417
1418int signal_print_state (signo)
1419 int signo;
1420{
67ac9759 1421 return signal_print[signo];
cc221e76
FF
1422}
1423
1424int signal_pass_state (signo)
1425 int signo;
1426{
67ac9759 1427 return signal_program[signo];
cc221e76
FF
1428}
1429
bd5635a1
RP
1430static void
1431sig_print_header ()
1432{
67ac9759
JK
1433 printf_filtered ("\
1434Signal Stop\tPrint\tPass to program\tDescription\n");
bd5635a1
RP
1435}
1436
1437static void
67ac9759
JK
1438sig_print_info (oursig)
1439 enum target_signal oursig;
bd5635a1 1440{
67ac9759
JK
1441 char *name = target_signal_to_name (oursig);
1442 printf_filtered ("%s", name);
1443 printf_filtered ("%*.*s ", 13 - strlen (name), 13 - strlen (name),
1444 " ");
1445 printf_filtered ("%s\t", signal_stop[oursig] ? "Yes" : "No");
1446 printf_filtered ("%s\t", signal_print[oursig] ? "Yes" : "No");
1447 printf_filtered ("%s\t\t", signal_program[oursig] ? "Yes" : "No");
1448 printf_filtered ("%s\n", target_signal_to_string (oursig));
bd5635a1
RP
1449}
1450
1451/* Specify how various signals in the inferior should be handled. */
1452
1453static void
1454handle_command (args, from_tty)
1455 char *args;
1456 int from_tty;
1457{
072b552a
JG
1458 char **argv;
1459 int digits, wordlen;
1460 int sigfirst, signum, siglast;
67ac9759 1461 enum target_signal oursig;
072b552a
JG
1462 int allsigs;
1463 int nsigs;
1464 unsigned char *sigs;
1465 struct cleanup *old_chain;
1466
1467 if (args == NULL)
1468 {
1469 error_no_arg ("signal to handle");
1470 }
bd5635a1 1471
072b552a
JG
1472 /* Allocate and zero an array of flags for which signals to handle. */
1473
67ac9759 1474 nsigs = (int)TARGET_SIGNAL_LAST;
072b552a
JG
1475 sigs = (unsigned char *) alloca (nsigs);
1476 memset (sigs, 0, nsigs);
bd5635a1 1477
072b552a
JG
1478 /* Break the command line up into args. */
1479
1480 argv = buildargv (args);
1481 if (argv == NULL)
bd5635a1 1482 {
072b552a
JG
1483 nomem (0);
1484 }
1485 old_chain = make_cleanup (freeargv, (char *) argv);
bd5635a1 1486
67ac9759 1487 /* Walk through the args, looking for signal oursigs, signal names, and
072b552a
JG
1488 actions. Signal numbers and signal names may be interspersed with
1489 actions, with the actions being performed for all signals cumulatively
1490 specified. Signal ranges can be specified as <LOW>-<HIGH>. */
bd5635a1 1491
072b552a
JG
1492 while (*argv != NULL)
1493 {
1494 wordlen = strlen (*argv);
1495 for (digits = 0; isdigit ((*argv)[digits]); digits++) {;}
1496 allsigs = 0;
1497 sigfirst = siglast = -1;
1498
1499 if (wordlen >= 1 && !strncmp (*argv, "all", wordlen))
1500 {
1501 /* Apply action to all signals except those used by the
1502 debugger. Silently skip those. */
1503 allsigs = 1;
1504 sigfirst = 0;
1505 siglast = nsigs - 1;
1506 }
1507 else if (wordlen >= 1 && !strncmp (*argv, "stop", wordlen))
1508 {
1509 SET_SIGS (nsigs, sigs, signal_stop);
1510 SET_SIGS (nsigs, sigs, signal_print);
1511 }
1512 else if (wordlen >= 1 && !strncmp (*argv, "ignore", wordlen))
1513 {
1514 UNSET_SIGS (nsigs, sigs, signal_program);
1515 }
1516 else if (wordlen >= 2 && !strncmp (*argv, "print", wordlen))
1517 {
1518 SET_SIGS (nsigs, sigs, signal_print);
1519 }
1520 else if (wordlen >= 2 && !strncmp (*argv, "pass", wordlen))
1521 {
1522 SET_SIGS (nsigs, sigs, signal_program);
1523 }
1524 else if (wordlen >= 3 && !strncmp (*argv, "nostop", wordlen))
1525 {
1526 UNSET_SIGS (nsigs, sigs, signal_stop);
1527 }
1528 else if (wordlen >= 3 && !strncmp (*argv, "noignore", wordlen))
1529 {
1530 SET_SIGS (nsigs, sigs, signal_program);
1531 }
1532 else if (wordlen >= 4 && !strncmp (*argv, "noprint", wordlen))
1533 {
1534 UNSET_SIGS (nsigs, sigs, signal_print);
1535 UNSET_SIGS (nsigs, sigs, signal_stop);
1536 }
1537 else if (wordlen >= 4 && !strncmp (*argv, "nopass", wordlen))
1538 {
1539 UNSET_SIGS (nsigs, sigs, signal_program);
1540 }
1541 else if (digits > 0)
bd5635a1 1542 {
67ac9759
JK
1543 /* It is numeric. The numeric signal refers to our own internal
1544 signal numbering from target.h, not to host/target signal number.
1545 This is a feature; users really should be using symbolic names
1546 anyway, and the common ones like SIGHUP, SIGINT, SIGALRM, etc.
1547 will work right anyway. */
1548
072b552a
JG
1549 sigfirst = siglast = atoi (*argv);
1550 if ((*argv)[digits] == '-')
bd5635a1 1551 {
072b552a 1552 siglast = atoi ((*argv) + digits + 1);
bd5635a1 1553 }
072b552a 1554 if (sigfirst > siglast)
bd5635a1 1555 {
072b552a
JG
1556 /* Bet he didn't figure we'd think of this case... */
1557 signum = sigfirst;
1558 sigfirst = siglast;
1559 siglast = signum;
bd5635a1 1560 }
072b552a
JG
1561 if (sigfirst < 0 || sigfirst >= nsigs)
1562 {
1563 error ("Signal %d not in range 0-%d", sigfirst, nsigs - 1);
1564 }
1565 if (siglast < 0 || siglast >= nsigs)
bd5635a1 1566 {
072b552a 1567 error ("Signal %d not in range 0-%d", siglast, nsigs - 1);
bd5635a1
RP
1568 }
1569 }
072b552a 1570 else
bd5635a1 1571 {
fcbc95a7
JK
1572 oursig = target_signal_from_name (*argv);
1573 if (oursig != TARGET_SIGNAL_UNKNOWN)
1574 {
1575 sigfirst = siglast = (int)oursig;
1576 }
1577 else
1578 {
1579 /* Not a number and not a recognized flag word => complain. */
1580 error ("Unrecognized or ambiguous flag word: \"%s\".", *argv);
1581 }
bd5635a1 1582 }
072b552a
JG
1583
1584 /* If any signal numbers or symbol names were found, set flags for
1585 which signals to apply actions to. */
1586
1587 for (signum = sigfirst; signum >= 0 && signum <= siglast; signum++)
bd5635a1 1588 {
67ac9759 1589 switch ((enum target_signal)signum)
072b552a 1590 {
67ac9759
JK
1591 case TARGET_SIGNAL_TRAP:
1592 case TARGET_SIGNAL_INT:
072b552a
JG
1593 if (!allsigs && !sigs[signum])
1594 {
67ac9759
JK
1595 if (query ("%s is used by the debugger.\n\
1596Are you sure you want to change it? ",
1597 target_signal_to_name
1598 ((enum target_signal)signum)))
072b552a
JG
1599 {
1600 sigs[signum] = 1;
1601 }
1602 else
1603 {
199b2450
TL
1604 printf_unfiltered ("Not confirmed, unchanged.\n");
1605 gdb_flush (gdb_stdout);
072b552a
JG
1606 }
1607 }
1608 break;
1609 default:
1610 sigs[signum] = 1;
1611 break;
1612 }
bd5635a1
RP
1613 }
1614
072b552a 1615 argv++;
bd5635a1
RP
1616 }
1617
de43d7d0 1618 target_notice_signals(inferior_pid);
cc221e76 1619
bd5635a1
RP
1620 if (from_tty)
1621 {
1622 /* Show the results. */
1623 sig_print_header ();
072b552a
JG
1624 for (signum = 0; signum < nsigs; signum++)
1625 {
1626 if (sigs[signum])
1627 {
1628 sig_print_info (signum);
1629 }
1630 }
bd5635a1 1631 }
072b552a
JG
1632
1633 do_cleanups (old_chain);
bd5635a1
RP
1634}
1635
67ac9759
JK
1636/* Print current contents of the tables set by the handle command.
1637 It is possible we should just be printing signals actually used
1638 by the current target (but for things to work right when switching
1639 targets, all signals should be in the signal tables). */
bd5635a1
RP
1640
1641static void
e37a6e9c 1642signals_info (signum_exp, from_tty)
bd5635a1 1643 char *signum_exp;
e37a6e9c 1644 int from_tty;
bd5635a1 1645{
67ac9759 1646 enum target_signal oursig;
bd5635a1
RP
1647 sig_print_header ();
1648
1649 if (signum_exp)
1650 {
1651 /* First see if this is a symbol name. */
67ac9759
JK
1652 oursig = target_signal_from_name (signum_exp);
1653 if (oursig == TARGET_SIGNAL_UNKNOWN)
bd5635a1
RP
1654 {
1655 /* Nope, maybe it's an address which evaluates to a signal
1656 number. */
67ac9759
JK
1657 /* The numeric signal refers to our own internal
1658 signal numbering from target.h, not to host/target signal number.
1659 This is a feature; users really should be using symbolic names
1660 anyway, and the common ones like SIGHUP, SIGINT, SIGALRM, etc.
1661 will work right anyway. */
1662 int i = parse_and_eval_address (signum_exp);
1663 if (i >= (int)TARGET_SIGNAL_LAST
1664 || i < 0
fcbc95a7
JK
1665 || i == (int)TARGET_SIGNAL_UNKNOWN
1666 || i == (int)TARGET_SIGNAL_DEFAULT)
bd5635a1 1667 error ("Signal number out of bounds.");
67ac9759 1668 oursig = (enum target_signal)i;
bd5635a1 1669 }
67ac9759 1670 sig_print_info (oursig);
bd5635a1
RP
1671 return;
1672 }
1673
1674 printf_filtered ("\n");
67ac9759 1675 for (oursig = 0; oursig < TARGET_SIGNAL_LAST; ++oursig)
bd5635a1
RP
1676 {
1677 QUIT;
1678
fcbc95a7
JK
1679 if (oursig != TARGET_SIGNAL_UNKNOWN
1680 && oursig != TARGET_SIGNAL_DEFAULT
1681 && oursig != TARGET_SIGNAL_0)
67ac9759 1682 sig_print_info (oursig);
bd5635a1
RP
1683 }
1684
1685 printf_filtered ("\nUse the \"handle\" command to change these tables.\n");
1686}
1687\f
1688/* Save all of the information associated with the inferior<==>gdb
1689 connection. INF_STATUS is a pointer to a "struct inferior_status"
1690 (defined in inferior.h). */
1691
1692void
1693save_inferior_status (inf_status, restore_stack_info)
1694 struct inferior_status *inf_status;
1695 int restore_stack_info;
1696{
bd5635a1
RP
1697 inf_status->stop_signal = stop_signal;
1698 inf_status->stop_pc = stop_pc;
1699 inf_status->stop_frame_address = stop_frame_address;
1700 inf_status->stop_step = stop_step;
1701 inf_status->stop_stack_dummy = stop_stack_dummy;
1702 inf_status->stopped_by_random_signal = stopped_by_random_signal;
1703 inf_status->trap_expected = trap_expected;
1704 inf_status->step_range_start = step_range_start;
1705 inf_status->step_range_end = step_range_end;
1706 inf_status->step_frame_address = step_frame_address;
1707 inf_status->step_over_calls = step_over_calls;
bd5635a1
RP
1708 inf_status->stop_after_trap = stop_after_trap;
1709 inf_status->stop_soon_quietly = stop_soon_quietly;
1710 /* Save original bpstat chain here; replace it with copy of chain.
1711 If caller's caller is walking the chain, they'll be happier if we
1712 hand them back the original chain when restore_i_s is called. */
1713 inf_status->stop_bpstat = stop_bpstat;
1714 stop_bpstat = bpstat_copy (stop_bpstat);
1715 inf_status->breakpoint_proceeded = breakpoint_proceeded;
1716 inf_status->restore_stack_info = restore_stack_info;
1717 inf_status->proceed_to_finish = proceed_to_finish;
1718
072b552a 1719 memcpy (inf_status->stop_registers, stop_registers, REGISTER_BYTES);
37c99ddb
JK
1720
1721 read_register_bytes (0, inf_status->registers, REGISTER_BYTES);
1722
bd5635a1
RP
1723 record_selected_frame (&(inf_status->selected_frame_address),
1724 &(inf_status->selected_level));
1725 return;
1726}
1727
37c99ddb
JK
1728struct restore_selected_frame_args {
1729 FRAME_ADDR frame_address;
1730 int level;
1731};
1732
1733static int restore_selected_frame PARAMS ((char *));
1734
1735/* Restore the selected frame. args is really a struct
1736 restore_selected_frame_args * (declared as char * for catch_errors)
1737 telling us what frame to restore. Returns 1 for success, or 0 for
1738 failure. An error message will have been printed on error. */
1739static int
1740restore_selected_frame (args)
1741 char *args;
1742{
1743 struct restore_selected_frame_args *fr =
1744 (struct restore_selected_frame_args *) args;
1745 FRAME fid;
1746 int level = fr->level;
1747
1748 fid = find_relative_frame (get_current_frame (), &level);
1749
1750 /* If inf_status->selected_frame_address is NULL, there was no
1751 previously selected frame. */
1752 if (fid == 0 ||
1753 FRAME_FP (fid) != fr->frame_address ||
1754 level != 0)
1755 {
1756 warning ("Unable to restore previously selected frame.\n");
1757 return 0;
1758 }
1759 select_frame (fid, fr->level);
1760 return(1);
1761}
1762
bd5635a1
RP
1763void
1764restore_inferior_status (inf_status)
1765 struct inferior_status *inf_status;
1766{
bd5635a1
RP
1767 stop_signal = inf_status->stop_signal;
1768 stop_pc = inf_status->stop_pc;
1769 stop_frame_address = inf_status->stop_frame_address;
1770 stop_step = inf_status->stop_step;
1771 stop_stack_dummy = inf_status->stop_stack_dummy;
1772 stopped_by_random_signal = inf_status->stopped_by_random_signal;
1773 trap_expected = inf_status->trap_expected;
1774 step_range_start = inf_status->step_range_start;
1775 step_range_end = inf_status->step_range_end;
1776 step_frame_address = inf_status->step_frame_address;
1777 step_over_calls = inf_status->step_over_calls;
bd5635a1
RP
1778 stop_after_trap = inf_status->stop_after_trap;
1779 stop_soon_quietly = inf_status->stop_soon_quietly;
1780 bpstat_clear (&stop_bpstat);
1781 stop_bpstat = inf_status->stop_bpstat;
1782 breakpoint_proceeded = inf_status->breakpoint_proceeded;
1783 proceed_to_finish = inf_status->proceed_to_finish;
1784
072b552a 1785 memcpy (stop_registers, inf_status->stop_registers, REGISTER_BYTES);
bd5635a1
RP
1786
1787 /* The inferior can be gone if the user types "print exit(0)"
1788 (and perhaps other times). */
37c99ddb
JK
1789 if (target_has_execution)
1790 write_register_bytes (0, inf_status->registers, REGISTER_BYTES);
1791
1792 /* The inferior can be gone if the user types "print exit(0)"
1793 (and perhaps other times). */
1794
1795 /* FIXME: If we are being called after stopping in a function which
1796 is called from gdb, we should not be trying to restore the
1797 selected frame; it just prints a spurious error message (The
1798 message is useful, however, in detecting bugs in gdb (like if gdb
1799 clobbers the stack)). In fact, should we be restoring the
1800 inferior status at all in that case? . */
1801
bd5635a1
RP
1802 if (target_has_stack && inf_status->restore_stack_info)
1803 {
37c99ddb
JK
1804 struct restore_selected_frame_args fr;
1805 fr.level = inf_status->selected_level;
1806 fr.frame_address = inf_status->selected_frame_address;
1807 /* The point of catch_errors is that if the stack is clobbered,
1808 walking the stack might encounter a garbage pointer and error()
1809 trying to dereference it. */
1810 if (catch_errors (restore_selected_frame, &fr,
1811 "Unable to restore previously selected frame:\n",
1812 RETURN_MASK_ERROR) == 0)
1813 /* Error in restoring the selected frame. Select the innermost
1814 frame. */
1815 select_frame (get_current_frame (), 0);
bd5635a1
RP
1816 }
1817}
1818
1819\f
1820void
1821_initialize_infrun ()
1822{
1823 register int i;
e37a6e9c 1824 register int numsigs;
bd5635a1
RP
1825
1826 add_info ("signals", signals_info,
1827 "What debugger does when program gets various signals.\n\
1828Specify a signal number as argument to print info on that signal only.");
6b50c5c2 1829 add_info_alias ("handle", "signals", 0);
bd5635a1
RP
1830
1831 add_com ("handle", class_run, handle_command,
1832 "Specify how to handle a signal.\n\
072b552a
JG
1833Args are signal numbers and actions to apply to those signals.\n\
1834Signal numbers may be numeric (ex. 11) or symbolic (ex. SIGSEGV).\n\
1835Numeric ranges may be specified with the form LOW-HIGH (ex. 14-21).\n\
1836The special arg \"all\" is recognized to mean all signals except those\n\
1837used by the debugger, typically SIGTRAP and SIGINT.\n\
1838Recognized actions include \"stop\", \"nostop\", \"print\", \"noprint\",\n\
1839\"pass\", \"nopass\", \"ignore\", or \"noignore\".\n\
bd5635a1 1840Stop means reenter debugger if this signal happens (implies print).\n\
072b552a 1841Print means print a message if this signal happens.\n\
bd5635a1 1842Pass means let program see this signal; otherwise program doesn't know.\n\
072b552a 1843Ignore is a synonym for nopass and noignore is a synonym for pass.\n\
bd5635a1
RP
1844Pass and Stop may be combined.");
1845
a8a69e63 1846 stop_command = add_cmd ("stop", class_obscure, not_just_help_class_command,
3950a34e
RP
1847 "There is no `stop' command, but you can set a hook on `stop'.\n\
1848This allows you to set a list of commands to be run each time execution\n\
fee44494 1849of the program stops.", &cmdlist);
3950a34e 1850
67ac9759
JK
1851 numsigs = (int)TARGET_SIGNAL_LAST;
1852 signal_stop = (unsigned char *)
1853 xmalloc (sizeof (signal_stop[0]) * numsigs);
1854 signal_print = (unsigned char *)
1855 xmalloc (sizeof (signal_print[0]) * numsigs);
072b552a 1856 signal_program = (unsigned char *)
67ac9759 1857 xmalloc (sizeof (signal_program[0]) * numsigs);
e37a6e9c 1858 for (i = 0; i < numsigs; i++)
bd5635a1
RP
1859 {
1860 signal_stop[i] = 1;
1861 signal_print[i] = 1;
1862 signal_program[i] = 1;
1863 }
1864
1865 /* Signals caused by debugger's own actions
1866 should not be given to the program afterwards. */
67ac9759
JK
1867 signal_program[TARGET_SIGNAL_TRAP] = 0;
1868 signal_program[TARGET_SIGNAL_INT] = 0;
bd5635a1
RP
1869
1870 /* Signals that are not errors should not normally enter the debugger. */
67ac9759
JK
1871 signal_stop[TARGET_SIGNAL_ALRM] = 0;
1872 signal_print[TARGET_SIGNAL_ALRM] = 0;
1873 signal_stop[TARGET_SIGNAL_VTALRM] = 0;
1874 signal_print[TARGET_SIGNAL_VTALRM] = 0;
1875 signal_stop[TARGET_SIGNAL_PROF] = 0;
1876 signal_print[TARGET_SIGNAL_PROF] = 0;
1877 signal_stop[TARGET_SIGNAL_CHLD] = 0;
1878 signal_print[TARGET_SIGNAL_CHLD] = 0;
1879 signal_stop[TARGET_SIGNAL_IO] = 0;
1880 signal_print[TARGET_SIGNAL_IO] = 0;
1881 signal_stop[TARGET_SIGNAL_URG] = 0;
1882 signal_print[TARGET_SIGNAL_URG] = 0;
bd5635a1 1883}
This page took 0.53146 seconds and 4 git commands to generate.