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