1 /* Target-struct-independent code to start (run) and stop an inferior process.
2 Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
3 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
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.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
23 #include "gdb_string.h"
28 #include "breakpoint.h"
33 #include "gdbthread.h"
41 /* Prototypes for local functions */
43 static void signals_info (char *, int);
45 static void handle_command (char *, int);
47 static void sig_print_info (enum target_signal
);
49 static void sig_print_header (void);
51 static void resume_cleanups (void *);
53 static int hook_stop_stub (void *);
55 static void delete_breakpoint_current_contents (void *);
57 static void set_follow_fork_mode_command (char *arg
, int from_tty
,
58 struct cmd_list_element
* c
);
60 static struct inferior_status
*xmalloc_inferior_status (void);
62 static void free_inferior_status (struct inferior_status
*);
64 static int restore_selected_frame (void *);
66 static void build_infrun (void);
68 static void follow_inferior_fork (int parent_pid
, int child_pid
,
69 int has_forked
, int has_vforked
);
71 static void follow_fork (int parent_pid
, int child_pid
);
73 static void follow_vfork (int parent_pid
, int child_pid
);
75 static void set_schedlock_func (char *args
, int from_tty
,
76 struct cmd_list_element
* c
);
78 struct execution_control_state
;
80 static int currently_stepping (struct execution_control_state
*ecs
);
82 static void xdb_handle_command (char *args
, int from_tty
);
84 void _initialize_infrun (void);
86 int inferior_ignoring_startup_exec_events
= 0;
87 int inferior_ignoring_leading_exec_events
= 0;
89 /* When set, stop the 'step' command if we enter a function which has
90 no line number information. The normal behavior is that we step
91 over such function. */
92 int step_stop_if_no_debug
= 0;
94 /* In asynchronous mode, but simulating synchronous execution. */
96 int sync_execution
= 0;
98 /* wait_for_inferior and normal_stop use this to notify the user
99 when the inferior stopped in a different thread than it had been
102 static ptid_t previous_inferior_ptid
;
104 /* This is true for configurations that may follow through execl() and
105 similar functions. At present this is only true for HP-UX native. */
107 #ifndef MAY_FOLLOW_EXEC
108 #define MAY_FOLLOW_EXEC (0)
111 static int may_follow_exec
= MAY_FOLLOW_EXEC
;
113 /* GET_LONGJMP_TARGET returns the PC at which longjmp() will resume the
114 program. It needs to examine the jmp_buf argument and extract the PC
115 from it. The return value is non-zero on success, zero otherwise. */
117 #ifndef GET_LONGJMP_TARGET
118 #define GET_LONGJMP_TARGET(PC_ADDR) 0
122 /* Some machines have trampoline code that sits between function callers
123 and the actual functions themselves. If this machine doesn't have
124 such things, disable their processing. */
126 #ifndef SKIP_TRAMPOLINE_CODE
127 #define SKIP_TRAMPOLINE_CODE(pc) 0
130 /* Dynamic function trampolines are similar to solib trampolines in that they
131 are between the caller and the callee. The difference is that when you
132 enter a dynamic trampoline, you can't determine the callee's address. Some
133 (usually complex) code needs to run in the dynamic trampoline to figure out
134 the callee's address. This macro is usually called twice. First, when we
135 enter the trampoline (looks like a normal function call at that point). It
136 should return the PC of a point within the trampoline where the callee's
137 address is known. Second, when we hit the breakpoint, this routine returns
138 the callee's address. At that point, things proceed as per a step resume
141 #ifndef DYNAMIC_TRAMPOLINE_NEXTPC
142 #define DYNAMIC_TRAMPOLINE_NEXTPC(pc) 0
145 /* If the program uses ELF-style shared libraries, then calls to
146 functions in shared libraries go through stubs, which live in a
147 table called the PLT (Procedure Linkage Table). The first time the
148 function is called, the stub sends control to the dynamic linker,
149 which looks up the function's real address, patches the stub so
150 that future calls will go directly to the function, and then passes
151 control to the function.
153 If we are stepping at the source level, we don't want to see any of
154 this --- we just want to skip over the stub and the dynamic linker.
155 The simple approach is to single-step until control leaves the
158 However, on some systems (e.g., Red Hat Linux 5.2) the dynamic
159 linker calls functions in the shared C library, so you can't tell
160 from the PC alone whether the dynamic linker is still running. In
161 this case, we use a step-resume breakpoint to get us past the
162 dynamic linker, as if we were using "next" to step over a function
165 IN_SOLIB_DYNSYM_RESOLVE_CODE says whether we're in the dynamic
166 linker code or not. Normally, this means we single-step. However,
167 if SKIP_SOLIB_RESOLVER then returns non-zero, then its value is an
168 address where we can place a step-resume breakpoint to get past the
169 linker's symbol resolution function.
171 IN_SOLIB_DYNSYM_RESOLVE_CODE can generally be implemented in a
172 pretty portable way, by comparing the PC against the address ranges
173 of the dynamic linker's sections.
175 SKIP_SOLIB_RESOLVER is generally going to be system-specific, since
176 it depends on internal details of the dynamic linker. It's usually
177 not too hard to figure out where to put a breakpoint, but it
178 certainly isn't portable. SKIP_SOLIB_RESOLVER should do plenty of
179 sanity checking. If it can't figure things out, returning zero and
180 getting the (possibly confusing) stepping behavior is better than
181 signalling an error, which will obscure the change in the
184 #ifndef IN_SOLIB_DYNSYM_RESOLVE_CODE
185 #define IN_SOLIB_DYNSYM_RESOLVE_CODE(pc) 0
188 #ifndef SKIP_SOLIB_RESOLVER
189 #define SKIP_SOLIB_RESOLVER(pc) 0
192 /* For SVR4 shared libraries, each call goes through a small piece of
193 trampoline code in the ".plt" section. IN_SOLIB_CALL_TRAMPOLINE evaluates
194 to nonzero if we are current stopped in one of these. */
196 #ifndef IN_SOLIB_CALL_TRAMPOLINE
197 #define IN_SOLIB_CALL_TRAMPOLINE(pc,name) 0
200 /* In some shared library schemes, the return path from a shared library
201 call may need to go through a trampoline too. */
203 #ifndef IN_SOLIB_RETURN_TRAMPOLINE
204 #define IN_SOLIB_RETURN_TRAMPOLINE(pc,name) 0
207 /* This function returns TRUE if pc is the address of an instruction
208 that lies within the dynamic linker (such as the event hook, or the
211 This function must be used only when a dynamic linker event has
212 been caught, and the inferior is being stepped out of the hook, or
213 undefined results are guaranteed. */
215 #ifndef SOLIB_IN_DYNAMIC_LINKER
216 #define SOLIB_IN_DYNAMIC_LINKER(pid,pc) 0
219 /* On MIPS16, a function that returns a floating point value may call
220 a library helper function to copy the return value to a floating point
221 register. The IGNORE_HELPER_CALL macro returns non-zero if we
222 should ignore (i.e. step over) this function call. */
223 #ifndef IGNORE_HELPER_CALL
224 #define IGNORE_HELPER_CALL(pc) 0
227 /* On some systems, the PC may be left pointing at an instruction that won't
228 actually be executed. This is usually indicated by a bit in the PSW. If
229 we find ourselves in such a state, then we step the target beyond the
230 nullified instruction before returning control to the user so as to avoid
233 #ifndef INSTRUCTION_NULLIFIED
234 #define INSTRUCTION_NULLIFIED 0
237 /* We can't step off a permanent breakpoint in the ordinary way, because we
238 can't remove it. Instead, we have to advance the PC to the next
239 instruction. This macro should expand to a pointer to a function that
240 does that, or zero if we have no such function. If we don't have a
241 definition for it, we have to report an error. */
242 #ifndef SKIP_PERMANENT_BREAKPOINT
243 #define SKIP_PERMANENT_BREAKPOINT (default_skip_permanent_breakpoint)
245 default_skip_permanent_breakpoint (void)
248 fprintf_filtered (gdb_stderr
, "\
249 The program is stopped at a permanent breakpoint, but GDB does not know\n\
250 how to step past a permanent breakpoint on this architecture. Try using\n\
251 a command like `return' or `jump' to continue execution.\n");
252 return_to_top_level (RETURN_ERROR
);
257 /* Convert the #defines into values. This is temporary until wfi control
258 flow is completely sorted out. */
260 #ifndef HAVE_STEPPABLE_WATCHPOINT
261 #define HAVE_STEPPABLE_WATCHPOINT 0
263 #undef HAVE_STEPPABLE_WATCHPOINT
264 #define HAVE_STEPPABLE_WATCHPOINT 1
267 #ifndef HAVE_NONSTEPPABLE_WATCHPOINT
268 #define HAVE_NONSTEPPABLE_WATCHPOINT 0
270 #undef HAVE_NONSTEPPABLE_WATCHPOINT
271 #define HAVE_NONSTEPPABLE_WATCHPOINT 1
274 #ifndef HAVE_CONTINUABLE_WATCHPOINT
275 #define HAVE_CONTINUABLE_WATCHPOINT 0
277 #undef HAVE_CONTINUABLE_WATCHPOINT
278 #define HAVE_CONTINUABLE_WATCHPOINT 1
281 #ifndef CANNOT_STEP_HW_WATCHPOINTS
282 #define CANNOT_STEP_HW_WATCHPOINTS 0
284 #undef CANNOT_STEP_HW_WATCHPOINTS
285 #define CANNOT_STEP_HW_WATCHPOINTS 1
288 /* Tables of how to react to signals; the user sets them. */
290 static unsigned char *signal_stop
;
291 static unsigned char *signal_print
;
292 static unsigned char *signal_program
;
294 #define SET_SIGS(nsigs,sigs,flags) \
296 int signum = (nsigs); \
297 while (signum-- > 0) \
298 if ((sigs)[signum]) \
299 (flags)[signum] = 1; \
302 #define UNSET_SIGS(nsigs,sigs,flags) \
304 int signum = (nsigs); \
305 while (signum-- > 0) \
306 if ((sigs)[signum]) \
307 (flags)[signum] = 0; \
310 /* Value to pass to target_resume() to cause all threads to resume */
312 #define RESUME_ALL (pid_to_ptid (-1))
314 /* Command list pointer for the "stop" placeholder. */
316 static struct cmd_list_element
*stop_command
;
318 /* Nonzero if breakpoints are now inserted in the inferior. */
320 static int breakpoints_inserted
;
322 /* Function inferior was in as of last step command. */
324 static struct symbol
*step_start_function
;
326 /* Nonzero if we are expecting a trace trap and should proceed from it. */
328 static int trap_expected
;
331 /* Nonzero if we want to give control to the user when we're notified
332 of shared library events by the dynamic linker. */
333 static int stop_on_solib_events
;
337 /* Nonzero if the next time we try to continue the inferior, it will
338 step one instruction and generate a spurious trace trap.
339 This is used to compensate for a bug in HP-UX. */
341 static int trap_expected_after_continue
;
344 /* Nonzero means expecting a trace trap
345 and should stop the inferior and return silently when it happens. */
349 /* Nonzero means expecting a trap and caller will handle it themselves.
350 It is used after attach, due to attaching to a process;
351 when running in the shell before the child program has been exec'd;
352 and when running some kinds of remote stuff (FIXME?). */
354 int stop_soon_quietly
;
356 /* Nonzero if proceed is being used for a "finish" command or a similar
357 situation when stop_registers should be saved. */
359 int proceed_to_finish
;
361 /* Save register contents here when about to pop a stack dummy frame,
362 if-and-only-if proceed_to_finish is set.
363 Thus this contains the return value from the called function (assuming
364 values are returned in a register). */
366 char *stop_registers
;
368 /* Nonzero if program stopped due to error trying to insert breakpoints. */
370 static int breakpoints_failed
;
372 /* Nonzero after stop if current stack frame should be printed. */
374 static int stop_print_frame
;
376 static struct breakpoint
*step_resume_breakpoint
= NULL
;
377 static struct breakpoint
*through_sigtramp_breakpoint
= NULL
;
379 /* On some platforms (e.g., HP-UX), hardware watchpoints have bad
380 interactions with an inferior that is running a kernel function
381 (aka, a system call or "syscall"). wait_for_inferior therefore
382 may have a need to know when the inferior is in a syscall. This
383 is a count of the number of inferior threads which are known to
384 currently be running in a syscall. */
385 static int number_of_threads_in_syscalls
;
387 /* This is a cached copy of the pid/waitstatus of the last event
388 returned by target_wait()/target_wait_hook(). This information is
389 returned by get_last_target_status(). */
390 static ptid_t target_last_wait_ptid
;
391 static struct target_waitstatus target_last_waitstatus
;
393 /* This is used to remember when a fork, vfork or exec event
394 was caught by a catchpoint, and thus the event is to be
395 followed at the next resume of the inferior, and not
399 enum target_waitkind kind
;
409 char *execd_pathname
;
413 /* Some platforms don't allow us to do anything meaningful with a
414 vforked child until it has exec'd. Vforked processes on such
415 platforms can only be followed after they've exec'd.
417 When this is set to 0, a vfork can be immediately followed,
418 and an exec can be followed merely as an exec. When this is
419 set to 1, a vfork event has been seen, but cannot be followed
420 until the exec is seen.
422 (In the latter case, inferior_ptid is still the parent of the
423 vfork, and pending_follow.fork_event.child_pid is the child. The
424 appropriate process is followed, according to the setting of
425 follow-fork-mode.) */
426 static int follow_vfork_when_exec
;
428 static const char follow_fork_mode_ask
[] = "ask";
429 static const char follow_fork_mode_both
[] = "both";
430 static const char follow_fork_mode_child
[] = "child";
431 static const char follow_fork_mode_parent
[] = "parent";
433 static const char *follow_fork_mode_kind_names
[] =
435 follow_fork_mode_ask
,
436 /* ??rehrauer: The "both" option is broken, by what may be a 10.20
437 kernel problem. It's also not terribly useful without a GUI to
438 help the user drive two debuggers. So for now, I'm disabling the
440 /* follow_fork_mode_both, */
441 follow_fork_mode_child
,
442 follow_fork_mode_parent
,
446 static const char *follow_fork_mode_string
= follow_fork_mode_parent
;
450 follow_inferior_fork (int parent_pid
, int child_pid
, int has_forked
,
453 int followed_parent
= 0;
454 int followed_child
= 0;
456 /* Which process did the user want us to follow? */
457 const char *follow_mode
= follow_fork_mode_string
;
459 /* Or, did the user not know, and want us to ask? */
460 if (follow_fork_mode_string
== follow_fork_mode_ask
)
462 internal_error (__FILE__
, __LINE__
,
463 "follow_inferior_fork: \"ask\" mode not implemented");
464 /* follow_mode = follow_fork_mode_...; */
467 /* If we're to be following the parent, then detach from child_pid.
468 We're already following the parent, so need do nothing explicit
470 if (follow_mode
== follow_fork_mode_parent
)
474 /* We're already attached to the parent, by default. */
476 /* Before detaching from the child, remove all breakpoints from
477 it. (This won't actually modify the breakpoint list, but will
478 physically remove the breakpoints from the child.) */
479 if (!has_vforked
|| !follow_vfork_when_exec
)
481 detach_breakpoints (child_pid
);
482 #ifdef SOLIB_REMOVE_INFERIOR_HOOK
483 SOLIB_REMOVE_INFERIOR_HOOK (child_pid
);
487 /* Detach from the child. */
490 target_require_detach (child_pid
, "", 1);
493 /* If we're to be following the child, then attach to it, detach
494 from inferior_ptid, and set inferior_ptid to child_pid. */
495 else if (follow_mode
== follow_fork_mode_child
)
497 char child_pid_spelling
[100]; /* Arbitrary length. */
501 /* Before detaching from the parent, detach all breakpoints from
502 the child. But only if we're forking, or if we follow vforks
503 as soon as they happen. (If we're following vforks only when
504 the child has exec'd, then it's very wrong to try to write
505 back the "shadow contents" of inserted breakpoints now -- they
506 belong to the child's pre-exec'd a.out.) */
507 if (!has_vforked
|| !follow_vfork_when_exec
)
509 detach_breakpoints (child_pid
);
512 /* Before detaching from the parent, remove all breakpoints from it. */
513 remove_breakpoints ();
515 /* Also reset the solib inferior hook from the parent. */
516 #ifdef SOLIB_REMOVE_INFERIOR_HOOK
517 SOLIB_REMOVE_INFERIOR_HOOK (PIDGET (inferior_ptid
));
520 /* Detach from the parent. */
522 target_detach (NULL
, 1);
524 /* Attach to the child. */
525 inferior_ptid
= pid_to_ptid (child_pid
);
526 sprintf (child_pid_spelling
, "%d", child_pid
);
529 target_require_attach (child_pid_spelling
, 1);
531 /* Was there a step_resume breakpoint? (There was if the user
532 did a "next" at the fork() call.) If so, explicitly reset its
535 step_resumes are a form of bp that are made to be per-thread.
536 Since we created the step_resume bp when the parent process
537 was being debugged, and now are switching to the child process,
538 from the breakpoint package's viewpoint, that's a switch of
539 "threads". We must update the bp's notion of which thread
540 it is for, or it'll be ignored when it triggers... */
541 if (step_resume_breakpoint
&&
542 (!has_vforked
|| !follow_vfork_when_exec
))
543 breakpoint_re_set_thread (step_resume_breakpoint
);
545 /* Reinsert all breakpoints in the child. (The user may've set
546 breakpoints after catching the fork, in which case those
547 actually didn't get set in the child, but only in the parent.) */
548 if (!has_vforked
|| !follow_vfork_when_exec
)
550 breakpoint_re_set ();
551 insert_breakpoints ();
555 /* If we're to be following both parent and child, then fork ourselves,
556 and attach the debugger clone to the child. */
557 else if (follow_mode
== follow_fork_mode_both
)
559 char pid_suffix
[100]; /* Arbitrary length. */
561 /* Clone ourselves to follow the child. This is the end of our
562 involvement with child_pid; our clone will take it from here... */
564 target_clone_and_follow_inferior (child_pid
, &followed_child
);
565 followed_parent
= !followed_child
;
567 /* We continue to follow the parent. To help distinguish the two
568 debuggers, though, both we and our clone will reset our prompts. */
569 sprintf (pid_suffix
, "[%d] ", PIDGET (inferior_ptid
));
570 set_prompt (strcat (get_prompt (), pid_suffix
));
573 /* The parent and child of a vfork share the same address space.
574 Also, on some targets the order in which vfork and exec events
575 are received for parent in child requires some delicate handling
578 For instance, on ptrace-based HPUX we receive the child's vfork
579 event first, at which time the parent has been suspended by the
580 OS and is essentially untouchable until the child's exit or second
581 exec event arrives. At that time, the parent's vfork event is
582 delivered to us, and that's when we see and decide how to follow
583 the vfork. But to get to that point, we must continue the child
584 until it execs or exits. To do that smoothly, all breakpoints
585 must be removed from the child, in case there are any set between
586 the vfork() and exec() calls. But removing them from the child
587 also removes them from the parent, due to the shared-address-space
588 nature of a vfork'd parent and child. On HPUX, therefore, we must
589 take care to restore the bp's to the parent before we continue it.
590 Else, it's likely that we may not stop in the expected place. (The
591 worst scenario is when the user tries to step over a vfork() call;
592 the step-resume bp must be restored for the step to properly stop
593 in the parent after the call completes!)
595 Sequence of events, as reported to gdb from HPUX:
597 Parent Child Action for gdb to take
598 -------------------------------------------------------
599 1 VFORK Continue child
605 target_post_follow_vfork (parent_pid
,
611 pending_follow
.fork_event
.saw_parent_fork
= 0;
612 pending_follow
.fork_event
.saw_child_fork
= 0;
616 follow_fork (int parent_pid
, int child_pid
)
618 follow_inferior_fork (parent_pid
, child_pid
, 1, 0);
622 /* Forward declaration. */
623 static void follow_exec (int, char *);
626 follow_vfork (int parent_pid
, int child_pid
)
628 follow_inferior_fork (parent_pid
, child_pid
, 0, 1);
630 /* Did we follow the child? Had it exec'd before we saw the parent vfork? */
631 if (pending_follow
.fork_event
.saw_child_exec
632 && (PIDGET (inferior_ptid
) == child_pid
))
634 pending_follow
.fork_event
.saw_child_exec
= 0;
635 pending_follow
.kind
= TARGET_WAITKIND_SPURIOUS
;
636 follow_exec (PIDGET (inferior_ptid
), pending_follow
.execd_pathname
);
637 xfree (pending_follow
.execd_pathname
);
641 /* EXECD_PATHNAME is assumed to be non-NULL. */
644 follow_exec (int pid
, char *execd_pathname
)
647 struct target_ops
*tgt
;
649 if (!may_follow_exec
)
652 /* Did this exec() follow a vfork()? If so, we must follow the
653 vfork now too. Do it before following the exec. */
654 if (follow_vfork_when_exec
&&
655 (pending_follow
.kind
== TARGET_WAITKIND_VFORKED
))
657 pending_follow
.kind
= TARGET_WAITKIND_SPURIOUS
;
658 follow_vfork (PIDGET (inferior_ptid
),
659 pending_follow
.fork_event
.child_pid
);
660 follow_vfork_when_exec
= 0;
661 saved_pid
= PIDGET (inferior_ptid
);
663 /* Did we follow the parent? If so, we're done. If we followed
664 the child then we must also follow its exec(). */
665 if (PIDGET (inferior_ptid
) == pending_follow
.fork_event
.parent_pid
)
669 /* This is an exec event that we actually wish to pay attention to.
670 Refresh our symbol table to the newly exec'd program, remove any
673 If there are breakpoints, they aren't really inserted now,
674 since the exec() transformed our inferior into a fresh set
677 We want to preserve symbolic breakpoints on the list, since
678 we have hopes that they can be reset after the new a.out's
679 symbol table is read.
681 However, any "raw" breakpoints must be removed from the list
682 (e.g., the solib bp's), since their address is probably invalid
685 And, we DON'T want to call delete_breakpoints() here, since
686 that may write the bp's "shadow contents" (the instruction
687 value that was overwritten witha TRAP instruction). Since
688 we now have a new a.out, those shadow contents aren't valid. */
689 update_breakpoints_after_exec ();
691 /* If there was one, it's gone now. We cannot truly step-to-next
692 statement through an exec(). */
693 step_resume_breakpoint
= NULL
;
694 step_range_start
= 0;
697 /* If there was one, it's gone now. */
698 through_sigtramp_breakpoint
= NULL
;
700 /* What is this a.out's name? */
701 printf_unfiltered ("Executing new program: %s\n", execd_pathname
);
703 /* We've followed the inferior through an exec. Therefore, the
704 inferior has essentially been killed & reborn. */
706 /* First collect the run target in effect. */
707 tgt
= find_run_target ();
708 /* If we can't find one, things are in a very strange state... */
710 error ("Could find run target to save before following exec");
712 gdb_flush (gdb_stdout
);
713 target_mourn_inferior ();
714 inferior_ptid
= pid_to_ptid (saved_pid
);
715 /* Because mourn_inferior resets inferior_ptid. */
718 /* That a.out is now the one to use. */
719 exec_file_attach (execd_pathname
, 0);
721 /* And also is where symbols can be found. */
722 symbol_file_add_main (execd_pathname
, 0);
724 /* Reset the shared library package. This ensures that we get
725 a shlib event when the child reaches "_start", at which point
726 the dld will have had a chance to initialize the child. */
727 #if defined(SOLIB_RESTART)
730 #ifdef SOLIB_CREATE_INFERIOR_HOOK
731 SOLIB_CREATE_INFERIOR_HOOK (PIDGET (inferior_ptid
));
734 /* Reinsert all breakpoints. (Those which were symbolic have
735 been reset to the proper address in the new a.out, thanks
736 to symbol_file_command...) */
737 insert_breakpoints ();
739 /* The next resume of this inferior should bring it to the shlib
740 startup breakpoints. (If the user had also set bp's on
741 "main" from the old (parent) process, then they'll auto-
742 matically get reset there in the new process.) */
745 /* Non-zero if we just simulating a single-step. This is needed
746 because we cannot remove the breakpoints in the inferior process
747 until after the `wait' in `wait_for_inferior'. */
748 static int singlestep_breakpoints_inserted_p
= 0;
751 /* Things to clean up if we QUIT out of resume (). */
754 resume_cleanups (void *ignore
)
759 static const char schedlock_off
[] = "off";
760 static const char schedlock_on
[] = "on";
761 static const char schedlock_step
[] = "step";
762 static const char *scheduler_mode
= schedlock_off
;
763 static const char *scheduler_enums
[] =
772 set_schedlock_func (char *args
, int from_tty
, struct cmd_list_element
*c
)
774 if (c
->type
== set_cmd
)
775 if (!target_can_lock_scheduler
)
777 scheduler_mode
= schedlock_off
;
778 error ("Target '%s' cannot support this command.",
784 /* Resume the inferior, but allow a QUIT. This is useful if the user
785 wants to interrupt some lengthy single-stepping operation
786 (for child processes, the SIGINT goes to the inferior, and so
787 we get a SIGINT random_signal, but for remote debugging and perhaps
788 other targets, that's not true).
790 STEP nonzero if we should step (zero to continue instead).
791 SIG is the signal to give the inferior (zero for none). */
793 resume (int step
, enum target_signal sig
)
795 int should_resume
= 1;
796 struct cleanup
*old_cleanups
= make_cleanup (resume_cleanups
, 0);
799 /* FIXME: calling breakpoint_here_p (read_pc ()) three times! */
802 /* Some targets (e.g. Solaris x86) have a kernel bug when stepping
803 over an instruction that causes a page fault without triggering
804 a hardware watchpoint. The kernel properly notices that it shouldn't
805 stop, because the hardware watchpoint is not triggered, but it forgets
806 the step request and continues the program normally.
807 Work around the problem by removing hardware watchpoints if a step is
808 requested, GDB will check for a hardware watchpoint trigger after the
810 if (CANNOT_STEP_HW_WATCHPOINTS
&& step
&& breakpoints_inserted
)
811 remove_hw_watchpoints ();
814 /* Normally, by the time we reach `resume', the breakpoints are either
815 removed or inserted, as appropriate. The exception is if we're sitting
816 at a permanent breakpoint; we need to step over it, but permanent
817 breakpoints can't be removed. So we have to test for it here. */
818 if (breakpoint_here_p (read_pc ()) == permanent_breakpoint_here
)
819 SKIP_PERMANENT_BREAKPOINT ();
821 if (SOFTWARE_SINGLE_STEP_P () && step
)
823 /* Do it the hard way, w/temp breakpoints */
824 SOFTWARE_SINGLE_STEP (sig
, 1 /*insert-breakpoints */ );
825 /* ...and don't ask hardware to do it. */
827 /* and do not pull these breakpoints until after a `wait' in
828 `wait_for_inferior' */
829 singlestep_breakpoints_inserted_p
= 1;
832 /* Handle any optimized stores to the inferior NOW... */
833 #ifdef DO_DEFERRED_STORES
837 /* If there were any forks/vforks/execs that were caught and are
838 now to be followed, then do so. */
839 switch (pending_follow
.kind
)
841 case (TARGET_WAITKIND_FORKED
):
842 pending_follow
.kind
= TARGET_WAITKIND_SPURIOUS
;
843 follow_fork (PIDGET (inferior_ptid
),
844 pending_follow
.fork_event
.child_pid
);
847 case (TARGET_WAITKIND_VFORKED
):
849 int saw_child_exec
= pending_follow
.fork_event
.saw_child_exec
;
851 pending_follow
.kind
= TARGET_WAITKIND_SPURIOUS
;
852 follow_vfork (PIDGET (inferior_ptid
),
853 pending_follow
.fork_event
.child_pid
);
855 /* Did we follow the child, but not yet see the child's exec event?
856 If so, then it actually ought to be waiting for us; we respond to
857 parent vfork events. We don't actually want to resume the child
858 in this situation; we want to just get its exec event. */
859 if (!saw_child_exec
&&
860 (PIDGET (inferior_ptid
) == pending_follow
.fork_event
.child_pid
))
865 case (TARGET_WAITKIND_EXECD
):
866 /* If we saw a vfork event but couldn't follow it until we saw
867 an exec, then now might be the time! */
868 pending_follow
.kind
= TARGET_WAITKIND_SPURIOUS
;
869 /* follow_exec is called as soon as the exec event is seen. */
876 /* Install inferior's terminal modes. */
877 target_terminal_inferior ();
883 resume_ptid
= RESUME_ALL
; /* Default */
885 if ((step
|| singlestep_breakpoints_inserted_p
) &&
886 !breakpoints_inserted
&& breakpoint_here_p (read_pc ()))
888 /* Stepping past a breakpoint without inserting breakpoints.
889 Make sure only the current thread gets to step, so that
890 other threads don't sneak past breakpoints while they are
893 resume_ptid
= inferior_ptid
;
896 if ((scheduler_mode
== schedlock_on
) ||
897 (scheduler_mode
== schedlock_step
&&
898 (step
|| singlestep_breakpoints_inserted_p
)))
900 /* User-settable 'scheduler' mode requires solo thread resume. */
901 resume_ptid
= inferior_ptid
;
904 #ifdef CANNOT_STEP_BREAKPOINT
905 /* Most targets can step a breakpoint instruction, thus executing it
906 normally. But if this one cannot, just continue and we will hit
908 if (step
&& breakpoints_inserted
&& breakpoint_here_p (read_pc ()))
911 target_resume (resume_ptid
, step
, sig
);
914 discard_cleanups (old_cleanups
);
918 /* Clear out all variables saying what to do when inferior is continued.
919 First do this, then set the ones you want, then call `proceed'. */
922 clear_proceed_status (void)
925 step_range_start
= 0;
927 step_frame_address
= 0;
928 step_over_calls
= STEP_OVER_UNDEBUGGABLE
;
930 stop_soon_quietly
= 0;
931 proceed_to_finish
= 0;
932 breakpoint_proceeded
= 1; /* We're about to proceed... */
934 /* Discard any remaining commands or status from previous stop. */
935 bpstat_clear (&stop_bpstat
);
938 /* Basic routine for continuing the program in various fashions.
940 ADDR is the address to resume at, or -1 for resume where stopped.
941 SIGGNAL is the signal to give it, or 0 for none,
942 or -1 for act according to how it stopped.
943 STEP is nonzero if should trap after one instruction.
944 -1 means return after that and print nothing.
945 You should probably set various step_... variables
946 before calling here, if you are stepping.
948 You should call clear_proceed_status before calling proceed. */
951 proceed (CORE_ADDR addr
, enum target_signal siggnal
, int step
)
956 step_start_function
= find_pc_function (read_pc ());
960 if (addr
== (CORE_ADDR
) -1)
962 /* If there is a breakpoint at the address we will resume at,
963 step one instruction before inserting breakpoints
964 so that we do not stop right away (and report a second
965 hit at this breakpoint). */
967 if (read_pc () == stop_pc
&& breakpoint_here_p (read_pc ()))
970 #ifndef STEP_SKIPS_DELAY
971 #define STEP_SKIPS_DELAY(pc) (0)
972 #define STEP_SKIPS_DELAY_P (0)
974 /* Check breakpoint_here_p first, because breakpoint_here_p is fast
975 (it just checks internal GDB data structures) and STEP_SKIPS_DELAY
976 is slow (it needs to read memory from the target). */
977 if (STEP_SKIPS_DELAY_P
978 && breakpoint_here_p (read_pc () + 4)
979 && STEP_SKIPS_DELAY (read_pc ()))
987 #ifdef PREPARE_TO_PROCEED
988 /* In a multi-threaded task we may select another thread
989 and then continue or step.
991 But if the old thread was stopped at a breakpoint, it
992 will immediately cause another breakpoint stop without
993 any execution (i.e. it will report a breakpoint hit
994 incorrectly). So we must step over it first.
996 PREPARE_TO_PROCEED checks the current thread against the thread
997 that reported the most recent event. If a step-over is required
998 it returns TRUE and sets the current thread to the old thread. */
999 if (PREPARE_TO_PROCEED (1) && breakpoint_here_p (read_pc ()))
1004 #endif /* PREPARE_TO_PROCEED */
1007 if (trap_expected_after_continue
)
1009 /* If (step == 0), a trap will be automatically generated after
1010 the first instruction is executed. Force step one
1011 instruction to clear this condition. This should not occur
1012 if step is nonzero, but it is harmless in that case. */
1014 trap_expected_after_continue
= 0;
1016 #endif /* HP_OS_BUG */
1019 /* We will get a trace trap after one instruction.
1020 Continue it automatically and insert breakpoints then. */
1024 int temp
= insert_breakpoints ();
1027 print_sys_errmsg ("insert_breakpoints", temp
);
1028 error ("Cannot insert breakpoints.\n\
1029 The same program may be running in another process,\n\
1030 or you may have requested too many hardware\n\
1031 breakpoints and/or watchpoints.\n");
1034 breakpoints_inserted
= 1;
1037 if (siggnal
!= TARGET_SIGNAL_DEFAULT
)
1038 stop_signal
= siggnal
;
1039 /* If this signal should not be seen by program,
1040 give it zero. Used for debugging signals. */
1041 else if (!signal_program
[stop_signal
])
1042 stop_signal
= TARGET_SIGNAL_0
;
1044 annotate_starting ();
1046 /* Make sure that output from GDB appears before output from the
1048 gdb_flush (gdb_stdout
);
1050 /* Resume inferior. */
1051 resume (oneproc
|| step
|| bpstat_should_step (), stop_signal
);
1053 /* Wait for it to stop (if not standalone)
1054 and in any case decode why it stopped, and act accordingly. */
1055 /* Do this only if we are not using the event loop, or if the target
1056 does not support asynchronous execution. */
1057 if (!event_loop_p
|| !target_can_async_p ())
1059 wait_for_inferior ();
1064 /* Record the pc and sp of the program the last time it stopped.
1065 These are just used internally by wait_for_inferior, but need
1066 to be preserved over calls to it and cleared when the inferior
1068 static CORE_ADDR prev_pc
;
1069 static CORE_ADDR prev_func_start
;
1070 static char *prev_func_name
;
1073 /* Start remote-debugging of a machine over a serial link. */
1078 init_thread_list ();
1079 init_wait_for_inferior ();
1080 stop_soon_quietly
= 1;
1083 /* Always go on waiting for the target, regardless of the mode. */
1084 /* FIXME: cagney/1999-09-23: At present it isn't possible to
1085 indicate to wait_for_inferior that a target should timeout if
1086 nothing is returned (instead of just blocking). Because of this,
1087 targets expecting an immediate response need to, internally, set
1088 things up so that the target_wait() is forced to eventually
1090 /* FIXME: cagney/1999-09-24: It isn't possible for target_open() to
1091 differentiate to its caller what the state of the target is after
1092 the initial open has been performed. Here we're assuming that
1093 the target has stopped. It should be possible to eventually have
1094 target_open() return to the caller an indication that the target
1095 is currently running and GDB state should be set to the same as
1096 for an async run. */
1097 wait_for_inferior ();
1101 /* Initialize static vars when a new inferior begins. */
1104 init_wait_for_inferior (void)
1106 /* These are meaningless until the first time through wait_for_inferior. */
1108 prev_func_start
= 0;
1109 prev_func_name
= NULL
;
1112 trap_expected_after_continue
= 0;
1114 breakpoints_inserted
= 0;
1115 breakpoint_init_inferior (inf_starting
);
1117 /* Don't confuse first call to proceed(). */
1118 stop_signal
= TARGET_SIGNAL_0
;
1120 /* The first resume is not following a fork/vfork/exec. */
1121 pending_follow
.kind
= TARGET_WAITKIND_SPURIOUS
; /* I.e., none. */
1122 pending_follow
.fork_event
.saw_parent_fork
= 0;
1123 pending_follow
.fork_event
.saw_child_fork
= 0;
1124 pending_follow
.fork_event
.saw_child_exec
= 0;
1126 /* See wait_for_inferior's handling of SYSCALL_ENTRY/RETURN events. */
1127 number_of_threads_in_syscalls
= 0;
1129 clear_proceed_status ();
1133 delete_breakpoint_current_contents (void *arg
)
1135 struct breakpoint
**breakpointp
= (struct breakpoint
**) arg
;
1136 if (*breakpointp
!= NULL
)
1138 delete_breakpoint (*breakpointp
);
1139 *breakpointp
= NULL
;
1143 /* This enum encodes possible reasons for doing a target_wait, so that
1144 wfi can call target_wait in one place. (Ultimately the call will be
1145 moved out of the infinite loop entirely.) */
1149 infwait_normal_state
,
1150 infwait_thread_hop_state
,
1151 infwait_nullified_state
,
1152 infwait_nonstep_watch_state
1155 /* Why did the inferior stop? Used to print the appropriate messages
1156 to the interface from within handle_inferior_event(). */
1157 enum inferior_stop_reason
1159 /* We don't know why. */
1161 /* Step, next, nexti, stepi finished. */
1163 /* Found breakpoint. */
1165 /* Inferior terminated by signal. */
1167 /* Inferior exited. */
1169 /* Inferior received signal, and user asked to be notified. */
1173 /* This structure contains what used to be local variables in
1174 wait_for_inferior. Probably many of them can return to being
1175 locals in handle_inferior_event. */
1177 struct execution_control_state
1179 struct target_waitstatus ws
;
1180 struct target_waitstatus
*wp
;
1183 CORE_ADDR stop_func_start
;
1184 CORE_ADDR stop_func_end
;
1185 char *stop_func_name
;
1186 struct symtab_and_line sal
;
1187 int remove_breakpoints_on_following_step
;
1189 struct symtab
*current_symtab
;
1190 int handling_longjmp
; /* FIXME */
1192 ptid_t saved_inferior_ptid
;
1194 int stepping_through_solib_after_catch
;
1195 bpstat stepping_through_solib_catchpoints
;
1196 int enable_hw_watchpoints_after_wait
;
1197 int stepping_through_sigtramp
;
1198 int new_thread_event
;
1199 struct target_waitstatus tmpstatus
;
1200 enum infwait_states infwait_state
;
1205 void init_execution_control_state (struct execution_control_state
* ecs
);
1207 void handle_inferior_event (struct execution_control_state
* ecs
);
1209 static void check_sigtramp2 (struct execution_control_state
*ecs
);
1210 static void step_into_function (struct execution_control_state
*ecs
);
1211 static void step_over_function (struct execution_control_state
*ecs
);
1212 static void stop_stepping (struct execution_control_state
*ecs
);
1213 static void prepare_to_wait (struct execution_control_state
*ecs
);
1214 static void keep_going (struct execution_control_state
*ecs
);
1215 static void print_stop_reason (enum inferior_stop_reason stop_reason
, int stop_info
);
1217 /* Wait for control to return from inferior to debugger.
1218 If inferior gets a signal, we may decide to start it up again
1219 instead of returning. That is why there is a loop in this function.
1220 When this function actually returns it means the inferior
1221 should be left stopped and GDB should read more commands. */
1224 wait_for_inferior (void)
1226 struct cleanup
*old_cleanups
;
1227 struct execution_control_state ecss
;
1228 struct execution_control_state
*ecs
;
1230 old_cleanups
= make_cleanup (delete_step_resume_breakpoint
,
1231 &step_resume_breakpoint
);
1232 make_cleanup (delete_breakpoint_current_contents
,
1233 &through_sigtramp_breakpoint
);
1235 /* wfi still stays in a loop, so it's OK just to take the address of
1236 a local to get the ecs pointer. */
1239 /* Fill in with reasonable starting values. */
1240 init_execution_control_state (ecs
);
1242 /* We'll update this if & when we switch to a new thread. */
1243 previous_inferior_ptid
= inferior_ptid
;
1245 overlay_cache_invalid
= 1;
1247 /* We have to invalidate the registers BEFORE calling target_wait
1248 because they can be loaded from the target while in target_wait.
1249 This makes remote debugging a bit more efficient for those
1250 targets that provide critical registers as part of their normal
1251 status mechanism. */
1253 registers_changed ();
1257 if (target_wait_hook
)
1258 ecs
->ptid
= target_wait_hook (ecs
->waiton_ptid
, ecs
->wp
);
1260 ecs
->ptid
= target_wait (ecs
->waiton_ptid
, ecs
->wp
);
1262 /* Now figure out what to do with the result of the result. */
1263 handle_inferior_event (ecs
);
1265 if (!ecs
->wait_some_more
)
1268 do_cleanups (old_cleanups
);
1271 /* Asynchronous version of wait_for_inferior. It is called by the
1272 event loop whenever a change of state is detected on the file
1273 descriptor corresponding to the target. It can be called more than
1274 once to complete a single execution command. In such cases we need
1275 to keep the state in a global variable ASYNC_ECSS. If it is the
1276 last time that this function is called for a single execution
1277 command, then report to the user that the inferior has stopped, and
1278 do the necessary cleanups. */
1280 struct execution_control_state async_ecss
;
1281 struct execution_control_state
*async_ecs
;
1284 fetch_inferior_event (void *client_data
)
1286 static struct cleanup
*old_cleanups
;
1288 async_ecs
= &async_ecss
;
1290 if (!async_ecs
->wait_some_more
)
1292 old_cleanups
= make_exec_cleanup (delete_step_resume_breakpoint
,
1293 &step_resume_breakpoint
);
1294 make_exec_cleanup (delete_breakpoint_current_contents
,
1295 &through_sigtramp_breakpoint
);
1297 /* Fill in with reasonable starting values. */
1298 init_execution_control_state (async_ecs
);
1300 /* We'll update this if & when we switch to a new thread. */
1301 previous_inferior_ptid
= inferior_ptid
;
1303 overlay_cache_invalid
= 1;
1305 /* We have to invalidate the registers BEFORE calling target_wait
1306 because they can be loaded from the target while in target_wait.
1307 This makes remote debugging a bit more efficient for those
1308 targets that provide critical registers as part of their normal
1309 status mechanism. */
1311 registers_changed ();
1314 if (target_wait_hook
)
1315 async_ecs
->ptid
= target_wait_hook (async_ecs
->waiton_ptid
, async_ecs
->wp
);
1317 async_ecs
->ptid
= target_wait (async_ecs
->waiton_ptid
, async_ecs
->wp
);
1319 /* Now figure out what to do with the result of the result. */
1320 handle_inferior_event (async_ecs
);
1322 if (!async_ecs
->wait_some_more
)
1324 /* Do only the cleanups that have been added by this
1325 function. Let the continuations for the commands do the rest,
1326 if there are any. */
1327 do_exec_cleanups (old_cleanups
);
1329 if (step_multi
&& stop_step
)
1330 inferior_event_handler (INF_EXEC_CONTINUE
, NULL
);
1332 inferior_event_handler (INF_EXEC_COMPLETE
, NULL
);
1336 /* Prepare an execution control state for looping through a
1337 wait_for_inferior-type loop. */
1340 init_execution_control_state (struct execution_control_state
*ecs
)
1342 /* ecs->another_trap? */
1343 ecs
->random_signal
= 0;
1344 ecs
->remove_breakpoints_on_following_step
= 0;
1345 ecs
->handling_longjmp
= 0; /* FIXME */
1346 ecs
->update_step_sp
= 0;
1347 ecs
->stepping_through_solib_after_catch
= 0;
1348 ecs
->stepping_through_solib_catchpoints
= NULL
;
1349 ecs
->enable_hw_watchpoints_after_wait
= 0;
1350 ecs
->stepping_through_sigtramp
= 0;
1351 ecs
->sal
= find_pc_line (prev_pc
, 0);
1352 ecs
->current_line
= ecs
->sal
.line
;
1353 ecs
->current_symtab
= ecs
->sal
.symtab
;
1354 ecs
->infwait_state
= infwait_normal_state
;
1355 ecs
->waiton_ptid
= pid_to_ptid (-1);
1356 ecs
->wp
= &(ecs
->ws
);
1359 /* Call this function before setting step_resume_breakpoint, as a
1360 sanity check. There should never be more than one step-resume
1361 breakpoint per thread, so we should never be setting a new
1362 step_resume_breakpoint when one is already active. */
1364 check_for_old_step_resume_breakpoint (void)
1366 if (step_resume_breakpoint
)
1367 warning ("GDB bug: infrun.c (wait_for_inferior): dropping old step_resume breakpoint");
1370 /* Return the cached copy of the last pid/waitstatus returned by
1371 target_wait()/target_wait_hook(). The data is actually cached by
1372 handle_inferior_event(), which gets called immediately after
1373 target_wait()/target_wait_hook(). */
1376 get_last_target_status(ptid_t
*ptidp
, struct target_waitstatus
*status
)
1378 *ptidp
= target_last_wait_ptid
;
1379 *status
= target_last_waitstatus
;
1382 /* Switch thread contexts, maintaining "infrun state". */
1385 context_switch (struct execution_control_state
*ecs
)
1387 /* Caution: it may happen that the new thread (or the old one!)
1388 is not in the thread list. In this case we must not attempt
1389 to "switch context", or we run the risk that our context may
1390 be lost. This may happen as a result of the target module
1391 mishandling thread creation. */
1393 if (in_thread_list (inferior_ptid
) && in_thread_list (ecs
->ptid
))
1394 { /* Perform infrun state context switch: */
1395 /* Save infrun state for the old thread. */
1396 save_infrun_state (inferior_ptid
, prev_pc
,
1397 prev_func_start
, prev_func_name
,
1398 trap_expected
, step_resume_breakpoint
,
1399 through_sigtramp_breakpoint
, step_range_start
,
1400 step_range_end
, step_frame_address
,
1401 ecs
->handling_longjmp
, ecs
->another_trap
,
1402 ecs
->stepping_through_solib_after_catch
,
1403 ecs
->stepping_through_solib_catchpoints
,
1404 ecs
->stepping_through_sigtramp
,
1405 ecs
->current_line
, ecs
->current_symtab
,
1408 /* Load infrun state for the new thread. */
1409 load_infrun_state (ecs
->ptid
, &prev_pc
,
1410 &prev_func_start
, &prev_func_name
,
1411 &trap_expected
, &step_resume_breakpoint
,
1412 &through_sigtramp_breakpoint
, &step_range_start
,
1413 &step_range_end
, &step_frame_address
,
1414 &ecs
->handling_longjmp
, &ecs
->another_trap
,
1415 &ecs
->stepping_through_solib_after_catch
,
1416 &ecs
->stepping_through_solib_catchpoints
,
1417 &ecs
->stepping_through_sigtramp
,
1418 &ecs
->current_line
, &ecs
->current_symtab
,
1421 inferior_ptid
= ecs
->ptid
;
1425 /* Given an execution control state that has been freshly filled in
1426 by an event from the inferior, figure out what it means and take
1427 appropriate action. */
1430 handle_inferior_event (struct execution_control_state
*ecs
)
1433 int stepped_after_stopped_by_watchpoint
;
1435 /* Cache the last pid/waitstatus. */
1436 target_last_wait_ptid
= ecs
->ptid
;
1437 target_last_waitstatus
= *ecs
->wp
;
1439 /* Keep this extra brace for now, minimizes diffs. */
1441 switch (ecs
->infwait_state
)
1443 case infwait_thread_hop_state
:
1444 /* Cancel the waiton_ptid. */
1445 ecs
->waiton_ptid
= pid_to_ptid (-1);
1446 /* Fall thru to the normal_state case. */
1448 case infwait_normal_state
:
1449 /* See comments where a TARGET_WAITKIND_SYSCALL_RETURN event
1450 is serviced in this loop, below. */
1451 if (ecs
->enable_hw_watchpoints_after_wait
)
1453 TARGET_ENABLE_HW_WATCHPOINTS (PIDGET (inferior_ptid
));
1454 ecs
->enable_hw_watchpoints_after_wait
= 0;
1456 stepped_after_stopped_by_watchpoint
= 0;
1459 case infwait_nullified_state
:
1462 case infwait_nonstep_watch_state
:
1463 insert_breakpoints ();
1465 /* FIXME-maybe: is this cleaner than setting a flag? Does it
1466 handle things like signals arriving and other things happening
1467 in combination correctly? */
1468 stepped_after_stopped_by_watchpoint
= 1;
1471 ecs
->infwait_state
= infwait_normal_state
;
1473 flush_cached_frames ();
1475 /* If it's a new process, add it to the thread database */
1477 ecs
->new_thread_event
= (! ptid_equal (ecs
->ptid
, inferior_ptid
)
1478 && ! in_thread_list (ecs
->ptid
));
1480 if (ecs
->ws
.kind
!= TARGET_WAITKIND_EXITED
1481 && ecs
->ws
.kind
!= TARGET_WAITKIND_SIGNALLED
1482 && ecs
->new_thread_event
)
1484 add_thread (ecs
->ptid
);
1487 ui_out_text (uiout
, "[New ");
1488 ui_out_text (uiout
, target_pid_or_tid_to_str (ecs
->ptid
));
1489 ui_out_text (uiout
, "]\n");
1491 printf_filtered ("[New %s]\n", target_pid_or_tid_to_str (ecs
->ptid
));
1495 /* NOTE: This block is ONLY meant to be invoked in case of a
1496 "thread creation event"! If it is invoked for any other
1497 sort of event (such as a new thread landing on a breakpoint),
1498 the event will be discarded, which is almost certainly
1501 To avoid this, the low-level module (eg. target_wait)
1502 should call in_thread_list and add_thread, so that the
1503 new thread is known by the time we get here. */
1505 /* We may want to consider not doing a resume here in order
1506 to give the user a chance to play with the new thread.
1507 It might be good to make that a user-settable option. */
1509 /* At this point, all threads are stopped (happens
1510 automatically in either the OS or the native code).
1511 Therefore we need to continue all threads in order to
1514 target_resume (RESUME_ALL
, 0, TARGET_SIGNAL_0
);
1515 prepare_to_wait (ecs
);
1520 switch (ecs
->ws
.kind
)
1522 case TARGET_WAITKIND_LOADED
:
1523 /* Ignore gracefully during startup of the inferior, as it
1524 might be the shell which has just loaded some objects,
1525 otherwise add the symbols for the newly loaded objects. */
1527 if (!stop_soon_quietly
)
1529 /* Remove breakpoints, SOLIB_ADD might adjust
1530 breakpoint addresses via breakpoint_re_set. */
1531 if (breakpoints_inserted
)
1532 remove_breakpoints ();
1534 /* Check for any newly added shared libraries if we're
1535 supposed to be adding them automatically. */
1538 /* Switch terminal for any messages produced by
1539 breakpoint_re_set. */
1540 target_terminal_ours_for_output ();
1541 SOLIB_ADD (NULL
, 0, NULL
);
1542 target_terminal_inferior ();
1545 /* Reinsert breakpoints and continue. */
1546 if (breakpoints_inserted
)
1547 insert_breakpoints ();
1550 resume (0, TARGET_SIGNAL_0
);
1551 prepare_to_wait (ecs
);
1554 case TARGET_WAITKIND_SPURIOUS
:
1555 resume (0, TARGET_SIGNAL_0
);
1556 prepare_to_wait (ecs
);
1559 case TARGET_WAITKIND_EXITED
:
1560 target_terminal_ours (); /* Must do this before mourn anyway */
1561 print_stop_reason (EXITED
, ecs
->ws
.value
.integer
);
1563 /* Record the exit code in the convenience variable $_exitcode, so
1564 that the user can inspect this again later. */
1565 set_internalvar (lookup_internalvar ("_exitcode"),
1566 value_from_longest (builtin_type_int
,
1567 (LONGEST
) ecs
->ws
.value
.integer
));
1568 gdb_flush (gdb_stdout
);
1569 target_mourn_inferior ();
1570 singlestep_breakpoints_inserted_p
= 0; /*SOFTWARE_SINGLE_STEP_P() */
1571 stop_print_frame
= 0;
1572 stop_stepping (ecs
);
1575 case TARGET_WAITKIND_SIGNALLED
:
1576 stop_print_frame
= 0;
1577 stop_signal
= ecs
->ws
.value
.sig
;
1578 target_terminal_ours (); /* Must do this before mourn anyway */
1580 /* Note: By definition of TARGET_WAITKIND_SIGNALLED, we shouldn't
1581 reach here unless the inferior is dead. However, for years
1582 target_kill() was called here, which hints that fatal signals aren't
1583 really fatal on some systems. If that's true, then some changes
1585 target_mourn_inferior ();
1587 print_stop_reason (SIGNAL_EXITED
, stop_signal
);
1588 singlestep_breakpoints_inserted_p
= 0; /*SOFTWARE_SINGLE_STEP_P() */
1589 stop_stepping (ecs
);
1592 /* The following are the only cases in which we keep going;
1593 the above cases end in a continue or goto. */
1594 case TARGET_WAITKIND_FORKED
:
1595 stop_signal
= TARGET_SIGNAL_TRAP
;
1596 pending_follow
.kind
= ecs
->ws
.kind
;
1598 /* Ignore fork events reported for the parent; we're only
1599 interested in reacting to forks of the child. Note that
1600 we expect the child's fork event to be available if we
1601 waited for it now. */
1602 if (ptid_equal (inferior_ptid
, ecs
->ptid
))
1604 pending_follow
.fork_event
.saw_parent_fork
= 1;
1605 pending_follow
.fork_event
.parent_pid
= PIDGET (ecs
->ptid
);
1606 pending_follow
.fork_event
.child_pid
= ecs
->ws
.value
.related_pid
;
1607 prepare_to_wait (ecs
);
1612 pending_follow
.fork_event
.saw_child_fork
= 1;
1613 pending_follow
.fork_event
.child_pid
= PIDGET (ecs
->ptid
);
1614 pending_follow
.fork_event
.parent_pid
= ecs
->ws
.value
.related_pid
;
1617 stop_pc
= read_pc_pid (ecs
->ptid
);
1618 ecs
->saved_inferior_ptid
= inferior_ptid
;
1619 inferior_ptid
= ecs
->ptid
;
1620 /* The second argument of bpstat_stop_status is meant to help
1621 distinguish between a breakpoint trap and a singlestep trap.
1622 This is only important on targets where DECR_PC_AFTER_BREAK
1623 is non-zero. The prev_pc test is meant to distinguish between
1624 singlestepping a trap instruction, and singlestepping thru a
1625 jump to the instruction following a trap instruction. */
1627 stop_bpstat
= bpstat_stop_status (&stop_pc
,
1628 currently_stepping (ecs
) &&
1630 stop_pc
- DECR_PC_AFTER_BREAK
);
1631 ecs
->random_signal
= !bpstat_explains_signal (stop_bpstat
);
1632 inferior_ptid
= ecs
->saved_inferior_ptid
;
1633 goto process_event_stop_test
;
1635 /* If this a platform which doesn't allow a debugger to touch a
1636 vfork'd inferior until after it exec's, then we'd best keep
1637 our fingers entirely off the inferior, other than continuing
1638 it. This has the unfortunate side-effect that catchpoints
1639 of vforks will be ignored. But since the platform doesn't
1640 allow the inferior be touched at vfork time, there's really
1642 case TARGET_WAITKIND_VFORKED
:
1643 stop_signal
= TARGET_SIGNAL_TRAP
;
1644 pending_follow
.kind
= ecs
->ws
.kind
;
1646 /* Is this a vfork of the parent? If so, then give any
1647 vfork catchpoints a chance to trigger now. (It's
1648 dangerous to do so if the child canot be touched until
1649 it execs, and the child has not yet exec'd. We probably
1650 should warn the user to that effect when the catchpoint
1652 if (ptid_equal (ecs
->ptid
, inferior_ptid
))
1654 pending_follow
.fork_event
.saw_parent_fork
= 1;
1655 pending_follow
.fork_event
.parent_pid
= PIDGET (ecs
->ptid
);
1656 pending_follow
.fork_event
.child_pid
= ecs
->ws
.value
.related_pid
;
1659 /* If we've seen the child's vfork event but cannot really touch
1660 the child until it execs, then we must continue the child now.
1661 Else, give any vfork catchpoints a chance to trigger now. */
1664 pending_follow
.fork_event
.saw_child_fork
= 1;
1665 pending_follow
.fork_event
.child_pid
= PIDGET (ecs
->ptid
);
1666 pending_follow
.fork_event
.parent_pid
= ecs
->ws
.value
.related_pid
;
1667 target_post_startup_inferior (
1668 pid_to_ptid (pending_follow
.fork_event
.child_pid
));
1669 follow_vfork_when_exec
= !target_can_follow_vfork_prior_to_exec ();
1670 if (follow_vfork_when_exec
)
1672 target_resume (ecs
->ptid
, 0, TARGET_SIGNAL_0
);
1673 prepare_to_wait (ecs
);
1678 stop_pc
= read_pc ();
1679 /* The second argument of bpstat_stop_status is meant to help
1680 distinguish between a breakpoint trap and a singlestep trap.
1681 This is only important on targets where DECR_PC_AFTER_BREAK
1682 is non-zero. The prev_pc test is meant to distinguish between
1683 singlestepping a trap instruction, and singlestepping thru a
1684 jump to the instruction following a trap instruction. */
1686 stop_bpstat
= bpstat_stop_status (&stop_pc
,
1687 currently_stepping (ecs
) &&
1689 stop_pc
- DECR_PC_AFTER_BREAK
);
1690 ecs
->random_signal
= !bpstat_explains_signal (stop_bpstat
);
1691 goto process_event_stop_test
;
1693 case TARGET_WAITKIND_EXECD
:
1694 stop_signal
= TARGET_SIGNAL_TRAP
;
1696 /* Is this a target which reports multiple exec events per actual
1697 call to exec()? (HP-UX using ptrace does, for example.) If so,
1698 ignore all but the last one. Just resume the exec'r, and wait
1699 for the next exec event. */
1700 if (inferior_ignoring_leading_exec_events
)
1702 inferior_ignoring_leading_exec_events
--;
1703 if (pending_follow
.kind
== TARGET_WAITKIND_VFORKED
)
1704 ENSURE_VFORKING_PARENT_REMAINS_STOPPED (pending_follow
.fork_event
.parent_pid
);
1705 target_resume (ecs
->ptid
, 0, TARGET_SIGNAL_0
);
1706 prepare_to_wait (ecs
);
1709 inferior_ignoring_leading_exec_events
=
1710 target_reported_exec_events_per_exec_call () - 1;
1712 pending_follow
.execd_pathname
=
1713 savestring (ecs
->ws
.value
.execd_pathname
,
1714 strlen (ecs
->ws
.value
.execd_pathname
));
1716 /* Did inferior_ptid exec, or did a (possibly not-yet-followed)
1717 child of a vfork exec?
1719 ??rehrauer: This is unabashedly an HP-UX specific thing. On
1720 HP-UX, events associated with a vforking inferior come in
1721 threes: a vfork event for the child (always first), followed
1722 a vfork event for the parent and an exec event for the child.
1723 The latter two can come in either order.
1725 If we get the parent vfork event first, life's good: We follow
1726 either the parent or child, and then the child's exec event is
1729 But if we get the child's exec event first, then we delay
1730 responding to it until we handle the parent's vfork. Because,
1731 otherwise we can't satisfy a "catch vfork". */
1732 if (pending_follow
.kind
== TARGET_WAITKIND_VFORKED
)
1734 pending_follow
.fork_event
.saw_child_exec
= 1;
1736 /* On some targets, the child must be resumed before
1737 the parent vfork event is delivered. A single-step
1739 if (RESUME_EXECD_VFORKING_CHILD_TO_GET_PARENT_VFORK ())
1740 target_resume (ecs
->ptid
, 1, TARGET_SIGNAL_0
);
1741 /* We expect the parent vfork event to be available now. */
1742 prepare_to_wait (ecs
);
1746 /* This causes the eventpoints and symbol table to be reset. Must
1747 do this now, before trying to determine whether to stop. */
1748 follow_exec (PIDGET (inferior_ptid
), pending_follow
.execd_pathname
);
1749 xfree (pending_follow
.execd_pathname
);
1751 stop_pc
= read_pc_pid (ecs
->ptid
);
1752 ecs
->saved_inferior_ptid
= inferior_ptid
;
1753 inferior_ptid
= ecs
->ptid
;
1754 /* The second argument of bpstat_stop_status is meant to help
1755 distinguish between a breakpoint trap and a singlestep trap.
1756 This is only important on targets where DECR_PC_AFTER_BREAK
1757 is non-zero. The prev_pc test is meant to distinguish between
1758 singlestepping a trap instruction, and singlestepping thru a
1759 jump to the instruction following a trap instruction. */
1761 stop_bpstat
= bpstat_stop_status (&stop_pc
,
1762 currently_stepping (ecs
) &&
1764 stop_pc
- DECR_PC_AFTER_BREAK
);
1765 ecs
->random_signal
= !bpstat_explains_signal (stop_bpstat
);
1766 inferior_ptid
= ecs
->saved_inferior_ptid
;
1767 goto process_event_stop_test
;
1769 /* These syscall events are returned on HP-UX, as part of its
1770 implementation of page-protection-based "hardware" watchpoints.
1771 HP-UX has unfortunate interactions between page-protections and
1772 some system calls. Our solution is to disable hardware watches
1773 when a system call is entered, and reenable them when the syscall
1774 completes. The downside of this is that we may miss the precise
1775 point at which a watched piece of memory is modified. "Oh well."
1777 Note that we may have multiple threads running, which may each
1778 enter syscalls at roughly the same time. Since we don't have a
1779 good notion currently of whether a watched piece of memory is
1780 thread-private, we'd best not have any page-protections active
1781 when any thread is in a syscall. Thus, we only want to reenable
1782 hardware watches when no threads are in a syscall.
1784 Also, be careful not to try to gather much state about a thread
1785 that's in a syscall. It's frequently a losing proposition. */
1786 case TARGET_WAITKIND_SYSCALL_ENTRY
:
1787 number_of_threads_in_syscalls
++;
1788 if (number_of_threads_in_syscalls
== 1)
1790 TARGET_DISABLE_HW_WATCHPOINTS (PIDGET (inferior_ptid
));
1792 resume (0, TARGET_SIGNAL_0
);
1793 prepare_to_wait (ecs
);
1796 /* Before examining the threads further, step this thread to
1797 get it entirely out of the syscall. (We get notice of the
1798 event when the thread is just on the verge of exiting a
1799 syscall. Stepping one instruction seems to get it back
1802 Note that although the logical place to reenable h/w watches
1803 is here, we cannot. We cannot reenable them before stepping
1804 the thread (this causes the next wait on the thread to hang).
1806 Nor can we enable them after stepping until we've done a wait.
1807 Thus, we simply set the flag ecs->enable_hw_watchpoints_after_wait
1808 here, which will be serviced immediately after the target
1810 case TARGET_WAITKIND_SYSCALL_RETURN
:
1811 target_resume (ecs
->ptid
, 1, TARGET_SIGNAL_0
);
1813 if (number_of_threads_in_syscalls
> 0)
1815 number_of_threads_in_syscalls
--;
1816 ecs
->enable_hw_watchpoints_after_wait
=
1817 (number_of_threads_in_syscalls
== 0);
1819 prepare_to_wait (ecs
);
1822 case TARGET_WAITKIND_STOPPED
:
1823 stop_signal
= ecs
->ws
.value
.sig
;
1826 /* We had an event in the inferior, but we are not interested
1827 in handling it at this level. The lower layers have already
1828 done what needs to be done, if anything. This case can
1829 occur only when the target is async or extended-async. One
1830 of the circumstamces for this to happen is when the
1831 inferior produces output for the console. The inferior has
1832 not stopped, and we are ignoring the event. */
1833 case TARGET_WAITKIND_IGNORE
:
1834 ecs
->wait_some_more
= 1;
1838 /* We may want to consider not doing a resume here in order to give
1839 the user a chance to play with the new thread. It might be good
1840 to make that a user-settable option. */
1842 /* At this point, all threads are stopped (happens automatically in
1843 either the OS or the native code). Therefore we need to continue
1844 all threads in order to make progress. */
1845 if (ecs
->new_thread_event
)
1847 target_resume (RESUME_ALL
, 0, TARGET_SIGNAL_0
);
1848 prepare_to_wait (ecs
);
1852 stop_pc
= read_pc_pid (ecs
->ptid
);
1854 /* See if a thread hit a thread-specific breakpoint that was meant for
1855 another thread. If so, then step that thread past the breakpoint,
1858 if (stop_signal
== TARGET_SIGNAL_TRAP
)
1860 if (SOFTWARE_SINGLE_STEP_P () && singlestep_breakpoints_inserted_p
)
1861 ecs
->random_signal
= 0;
1862 else if (breakpoints_inserted
1863 && breakpoint_here_p (stop_pc
- DECR_PC_AFTER_BREAK
))
1865 ecs
->random_signal
= 0;
1866 if (!breakpoint_thread_match (stop_pc
- DECR_PC_AFTER_BREAK
,
1871 /* Saw a breakpoint, but it was hit by the wrong thread.
1873 if (DECR_PC_AFTER_BREAK
)
1874 write_pc_pid (stop_pc
- DECR_PC_AFTER_BREAK
, ecs
->ptid
);
1876 remove_status
= remove_breakpoints ();
1877 /* Did we fail to remove breakpoints? If so, try
1878 to set the PC past the bp. (There's at least
1879 one situation in which we can fail to remove
1880 the bp's: On HP-UX's that use ttrace, we can't
1881 change the address space of a vforking child
1882 process until the child exits (well, okay, not
1883 then either :-) or execs. */
1884 if (remove_status
!= 0)
1886 /* FIXME! This is obviously non-portable! */
1887 write_pc_pid (stop_pc
- DECR_PC_AFTER_BREAK
+ 4,
1889 /* We need to restart all the threads now,
1890 * unles we're running in scheduler-locked mode.
1891 * Use currently_stepping to determine whether to
1894 /* FIXME MVS: is there any reason not to call resume()? */
1895 if (scheduler_mode
== schedlock_on
)
1896 target_resume (ecs
->ptid
,
1897 currently_stepping (ecs
),
1900 target_resume (RESUME_ALL
,
1901 currently_stepping (ecs
),
1903 prepare_to_wait (ecs
);
1908 breakpoints_inserted
= 0;
1909 if (!ptid_equal (inferior_ptid
, ecs
->ptid
))
1910 context_switch (ecs
);
1911 ecs
->waiton_ptid
= ecs
->ptid
;
1912 ecs
->wp
= &(ecs
->ws
);
1913 ecs
->another_trap
= 1;
1915 ecs
->infwait_state
= infwait_thread_hop_state
;
1917 registers_changed ();
1924 ecs
->random_signal
= 1;
1926 /* See if something interesting happened to the non-current thread. If
1927 so, then switch to that thread, and eventually give control back to
1930 Note that if there's any kind of pending follow (i.e., of a fork,
1931 vfork or exec), we don't want to do this now. Rather, we'll let
1932 the next resume handle it. */
1933 if (! ptid_equal (ecs
->ptid
, inferior_ptid
) &&
1934 (pending_follow
.kind
== TARGET_WAITKIND_SPURIOUS
))
1938 /* If it's a random signal for a non-current thread, notify user
1939 if he's expressed an interest. */
1940 if (ecs
->random_signal
1941 && signal_print
[stop_signal
])
1943 /* ??rehrauer: I don't understand the rationale for this code. If the
1944 inferior will stop as a result of this signal, then the act of handling
1945 the stop ought to print a message that's couches the stoppage in user
1946 terms, e.g., "Stopped for breakpoint/watchpoint". If the inferior
1947 won't stop as a result of the signal -- i.e., if the signal is merely
1948 a side-effect of something GDB's doing "under the covers" for the
1949 user, such as stepping threads over a breakpoint they shouldn't stop
1950 for -- then the message seems to be a serious annoyance at best.
1952 For now, remove the message altogether. */
1955 target_terminal_ours_for_output ();
1956 printf_filtered ("\nProgram received signal %s, %s.\n",
1957 target_signal_to_name (stop_signal
),
1958 target_signal_to_string (stop_signal
));
1959 gdb_flush (gdb_stdout
);
1963 /* If it's not SIGTRAP and not a signal we want to stop for, then
1964 continue the thread. */
1966 if (stop_signal
!= TARGET_SIGNAL_TRAP
1967 && !signal_stop
[stop_signal
])
1970 target_terminal_inferior ();
1972 /* Clear the signal if it should not be passed. */
1973 if (signal_program
[stop_signal
] == 0)
1974 stop_signal
= TARGET_SIGNAL_0
;
1976 target_resume (ecs
->ptid
, 0, stop_signal
);
1977 prepare_to_wait (ecs
);
1981 /* It's a SIGTRAP or a signal we're interested in. Switch threads,
1982 and fall into the rest of wait_for_inferior(). */
1984 context_switch (ecs
);
1987 context_hook (pid_to_thread_id (ecs
->ptid
));
1989 flush_cached_frames ();
1992 if (SOFTWARE_SINGLE_STEP_P () && singlestep_breakpoints_inserted_p
)
1994 /* Pull the single step breakpoints out of the target. */
1995 SOFTWARE_SINGLE_STEP (0, 0);
1996 singlestep_breakpoints_inserted_p
= 0;
1999 /* If PC is pointing at a nullified instruction, then step beyond
2000 it so that the user won't be confused when GDB appears to be ready
2003 /* if (INSTRUCTION_NULLIFIED && currently_stepping (ecs)) */
2004 if (INSTRUCTION_NULLIFIED
)
2006 registers_changed ();
2007 target_resume (ecs
->ptid
, 1, TARGET_SIGNAL_0
);
2009 /* We may have received a signal that we want to pass to
2010 the inferior; therefore, we must not clobber the waitstatus
2013 ecs
->infwait_state
= infwait_nullified_state
;
2014 ecs
->waiton_ptid
= ecs
->ptid
;
2015 ecs
->wp
= &(ecs
->tmpstatus
);
2016 prepare_to_wait (ecs
);
2020 /* It may not be necessary to disable the watchpoint to stop over
2021 it. For example, the PA can (with some kernel cooperation)
2022 single step over a watchpoint without disabling the watchpoint. */
2023 if (HAVE_STEPPABLE_WATCHPOINT
&& STOPPED_BY_WATCHPOINT (ecs
->ws
))
2026 prepare_to_wait (ecs
);
2030 /* It is far more common to need to disable a watchpoint to step
2031 the inferior over it. FIXME. What else might a debug
2032 register or page protection watchpoint scheme need here? */
2033 if (HAVE_NONSTEPPABLE_WATCHPOINT
&& STOPPED_BY_WATCHPOINT (ecs
->ws
))
2035 /* At this point, we are stopped at an instruction which has
2036 attempted to write to a piece of memory under control of
2037 a watchpoint. The instruction hasn't actually executed
2038 yet. If we were to evaluate the watchpoint expression
2039 now, we would get the old value, and therefore no change
2040 would seem to have occurred.
2042 In order to make watchpoints work `right', we really need
2043 to complete the memory write, and then evaluate the
2044 watchpoint expression. The following code does that by
2045 removing the watchpoint (actually, all watchpoints and
2046 breakpoints), single-stepping the target, re-inserting
2047 watchpoints, and then falling through to let normal
2048 single-step processing handle proceed. Since this
2049 includes evaluating watchpoints, things will come to a
2050 stop in the correct manner. */
2052 if (DECR_PC_AFTER_BREAK
)
2053 write_pc (stop_pc
- DECR_PC_AFTER_BREAK
);
2055 remove_breakpoints ();
2056 registers_changed ();
2057 target_resume (ecs
->ptid
, 1, TARGET_SIGNAL_0
); /* Single step */
2059 ecs
->waiton_ptid
= ecs
->ptid
;
2060 ecs
->wp
= &(ecs
->ws
);
2061 ecs
->infwait_state
= infwait_nonstep_watch_state
;
2062 prepare_to_wait (ecs
);
2066 /* It may be possible to simply continue after a watchpoint. */
2067 if (HAVE_CONTINUABLE_WATCHPOINT
)
2068 STOPPED_BY_WATCHPOINT (ecs
->ws
);
2070 ecs
->stop_func_start
= 0;
2071 ecs
->stop_func_end
= 0;
2072 ecs
->stop_func_name
= 0;
2073 /* Don't care about return value; stop_func_start and stop_func_name
2074 will both be 0 if it doesn't work. */
2075 find_pc_partial_function (stop_pc
, &ecs
->stop_func_name
,
2076 &ecs
->stop_func_start
, &ecs
->stop_func_end
);
2077 ecs
->stop_func_start
+= FUNCTION_START_OFFSET
;
2078 ecs
->another_trap
= 0;
2079 bpstat_clear (&stop_bpstat
);
2081 stop_stack_dummy
= 0;
2082 stop_print_frame
= 1;
2083 ecs
->random_signal
= 0;
2084 stopped_by_random_signal
= 0;
2085 breakpoints_failed
= 0;
2087 /* Look at the cause of the stop, and decide what to do.
2088 The alternatives are:
2089 1) break; to really stop and return to the debugger,
2090 2) drop through to start up again
2091 (set ecs->another_trap to 1 to single step once)
2092 3) set ecs->random_signal to 1, and the decision between 1 and 2
2093 will be made according to the signal handling tables. */
2095 /* First, distinguish signals caused by the debugger from signals
2096 that have to do with the program's own actions.
2097 Note that breakpoint insns may cause SIGTRAP or SIGILL
2098 or SIGEMT, depending on the operating system version.
2099 Here we detect when a SIGILL or SIGEMT is really a breakpoint
2100 and change it to SIGTRAP. */
2102 if (stop_signal
== TARGET_SIGNAL_TRAP
2103 || (breakpoints_inserted
&&
2104 (stop_signal
== TARGET_SIGNAL_ILL
2105 || stop_signal
== TARGET_SIGNAL_EMT
2107 || stop_soon_quietly
)
2109 if (stop_signal
== TARGET_SIGNAL_TRAP
&& stop_after_trap
)
2111 stop_print_frame
= 0;
2112 stop_stepping (ecs
);
2115 if (stop_soon_quietly
)
2117 stop_stepping (ecs
);
2121 /* Don't even think about breakpoints
2122 if just proceeded over a breakpoint.
2124 However, if we are trying to proceed over a breakpoint
2125 and end up in sigtramp, then through_sigtramp_breakpoint
2126 will be set and we should check whether we've hit the
2128 if (stop_signal
== TARGET_SIGNAL_TRAP
&& trap_expected
2129 && through_sigtramp_breakpoint
== NULL
)
2130 bpstat_clear (&stop_bpstat
);
2133 /* See if there is a breakpoint at the current PC. */
2135 /* The second argument of bpstat_stop_status is meant to help
2136 distinguish between a breakpoint trap and a singlestep trap.
2137 This is only important on targets where DECR_PC_AFTER_BREAK
2138 is non-zero. The prev_pc test is meant to distinguish between
2139 singlestepping a trap instruction, and singlestepping thru a
2140 jump to the instruction following a trap instruction. */
2142 stop_bpstat
= bpstat_stop_status
2144 /* Pass TRUE if our reason for stopping is something other
2145 than hitting a breakpoint. We do this by checking that
2146 1) stepping is going on and 2) we didn't hit a breakpoint
2147 in a signal handler without an intervening stop in
2148 sigtramp, which is detected by a new stack pointer value
2149 below any usual function calling stack adjustments. */
2150 (currently_stepping (ecs
)
2151 && prev_pc
!= stop_pc
- DECR_PC_AFTER_BREAK
2153 && INNER_THAN (read_sp (), (step_sp
- 16))))
2155 /* Following in case break condition called a
2157 stop_print_frame
= 1;
2160 if (stop_signal
== TARGET_SIGNAL_TRAP
)
2162 = !(bpstat_explains_signal (stop_bpstat
)
2164 || (!CALL_DUMMY_BREAKPOINT_OFFSET_P
2165 && PC_IN_CALL_DUMMY (stop_pc
, read_sp (),
2166 FRAME_FP (get_current_frame ())))
2167 || (step_range_end
&& step_resume_breakpoint
== NULL
));
2172 = !(bpstat_explains_signal (stop_bpstat
)
2173 /* End of a stack dummy. Some systems (e.g. Sony
2174 news) give another signal besides SIGTRAP, so
2175 check here as well as above. */
2176 || (!CALL_DUMMY_BREAKPOINT_OFFSET_P
2177 && PC_IN_CALL_DUMMY (stop_pc
, read_sp (),
2178 FRAME_FP (get_current_frame ())))
2180 if (!ecs
->random_signal
)
2181 stop_signal
= TARGET_SIGNAL_TRAP
;
2185 /* When we reach this point, we've pretty much decided
2186 that the reason for stopping must've been a random
2187 (unexpected) signal. */
2190 ecs
->random_signal
= 1;
2191 /* If a fork, vfork or exec event was seen, then there are two
2192 possible responses we can make:
2194 1. If a catchpoint triggers for the event (ecs->random_signal == 0),
2195 then we must stop now and issue a prompt. We will resume
2196 the inferior when the user tells us to.
2197 2. If no catchpoint triggers for the event (ecs->random_signal == 1),
2198 then we must resume the inferior now and keep checking.
2200 In either case, we must take appropriate steps to "follow" the
2201 the fork/vfork/exec when the inferior is resumed. For example,
2202 if follow-fork-mode is "child", then we must detach from the
2203 parent inferior and follow the new child inferior.
2205 In either case, setting pending_follow causes the next resume()
2206 to take the appropriate following action. */
2207 process_event_stop_test
:
2208 if (ecs
->ws
.kind
== TARGET_WAITKIND_FORKED
)
2210 if (ecs
->random_signal
) /* I.e., no catchpoint triggered for this. */
2213 stop_signal
= TARGET_SIGNAL_0
;
2218 else if (ecs
->ws
.kind
== TARGET_WAITKIND_VFORKED
)
2220 if (ecs
->random_signal
) /* I.e., no catchpoint triggered for this. */
2222 stop_signal
= TARGET_SIGNAL_0
;
2227 else if (ecs
->ws
.kind
== TARGET_WAITKIND_EXECD
)
2229 pending_follow
.kind
= ecs
->ws
.kind
;
2230 if (ecs
->random_signal
) /* I.e., no catchpoint triggered for this. */
2233 stop_signal
= TARGET_SIGNAL_0
;
2239 /* For the program's own signals, act according to
2240 the signal handling tables. */
2242 if (ecs
->random_signal
)
2244 /* Signal not for debugging purposes. */
2247 stopped_by_random_signal
= 1;
2249 if (signal_print
[stop_signal
])
2252 target_terminal_ours_for_output ();
2253 print_stop_reason (SIGNAL_RECEIVED
, stop_signal
);
2255 if (signal_stop
[stop_signal
])
2257 stop_stepping (ecs
);
2260 /* If not going to stop, give terminal back
2261 if we took it away. */
2263 target_terminal_inferior ();
2265 /* Clear the signal if it should not be passed. */
2266 if (signal_program
[stop_signal
] == 0)
2267 stop_signal
= TARGET_SIGNAL_0
;
2269 /* I'm not sure whether this needs to be check_sigtramp2 or
2270 whether it could/should be keep_going.
2272 This used to jump to step_over_function if we are stepping,
2275 Suppose the user does a `next' over a function call, and while
2276 that call is in progress, the inferior receives a signal for
2277 which GDB does not stop (i.e., signal_stop[SIG] is false). In
2278 that case, when we reach this point, there is already a
2279 step-resume breakpoint established, right where it should be:
2280 immediately after the function call the user is "next"-ing
2281 over. If we call step_over_function now, two bad things
2284 - we'll create a new breakpoint, at wherever the current
2285 frame's return address happens to be. That could be
2286 anywhere, depending on what function call happens to be on
2287 the top of the stack at that point. Point is, it's probably
2288 not where we need it.
2290 - the existing step-resume breakpoint (which is at the correct
2291 address) will get orphaned: step_resume_breakpoint will point
2292 to the new breakpoint, and the old step-resume breakpoint
2293 will never be cleaned up.
2295 The old behavior was meant to help HP-UX single-step out of
2296 sigtramps. It would place the new breakpoint at prev_pc, which
2297 was certainly wrong. I don't know the details there, so fixing
2298 this probably breaks that. As with anything else, it's up to
2299 the HP-UX maintainer to furnish a fix that doesn't break other
2300 platforms. --JimB, 20 May 1999 */
2301 check_sigtramp2 (ecs
);
2306 /* Handle cases caused by hitting a breakpoint. */
2308 CORE_ADDR jmp_buf_pc
;
2309 struct bpstat_what what
;
2311 what
= bpstat_what (stop_bpstat
);
2313 if (what
.call_dummy
)
2315 stop_stack_dummy
= 1;
2317 trap_expected_after_continue
= 1;
2321 switch (what
.main_action
)
2323 case BPSTAT_WHAT_SET_LONGJMP_RESUME
:
2324 /* If we hit the breakpoint at longjmp, disable it for the
2325 duration of this command. Then, install a temporary
2326 breakpoint at the target of the jmp_buf. */
2327 disable_longjmp_breakpoint ();
2328 remove_breakpoints ();
2329 breakpoints_inserted
= 0;
2330 if (!GET_LONGJMP_TARGET (&jmp_buf_pc
))
2336 /* Need to blow away step-resume breakpoint, as it
2337 interferes with us */
2338 if (step_resume_breakpoint
!= NULL
)
2340 delete_step_resume_breakpoint (&step_resume_breakpoint
);
2342 /* Not sure whether we need to blow this away too, but probably
2343 it is like the step-resume breakpoint. */
2344 if (through_sigtramp_breakpoint
!= NULL
)
2346 delete_breakpoint (through_sigtramp_breakpoint
);
2347 through_sigtramp_breakpoint
= NULL
;
2351 /* FIXME - Need to implement nested temporary breakpoints */
2352 if (step_over_calls
> 0)
2353 set_longjmp_resume_breakpoint (jmp_buf_pc
,
2354 get_current_frame ());
2357 set_longjmp_resume_breakpoint (jmp_buf_pc
, NULL
);
2358 ecs
->handling_longjmp
= 1; /* FIXME */
2362 case BPSTAT_WHAT_CLEAR_LONGJMP_RESUME
:
2363 case BPSTAT_WHAT_CLEAR_LONGJMP_RESUME_SINGLE
:
2364 remove_breakpoints ();
2365 breakpoints_inserted
= 0;
2367 /* FIXME - Need to implement nested temporary breakpoints */
2369 && (INNER_THAN (FRAME_FP (get_current_frame ()),
2370 step_frame_address
)))
2372 ecs
->another_trap
= 1;
2377 disable_longjmp_breakpoint ();
2378 ecs
->handling_longjmp
= 0; /* FIXME */
2379 if (what
.main_action
== BPSTAT_WHAT_CLEAR_LONGJMP_RESUME
)
2381 /* else fallthrough */
2383 case BPSTAT_WHAT_SINGLE
:
2384 if (breakpoints_inserted
)
2386 remove_breakpoints ();
2388 breakpoints_inserted
= 0;
2389 ecs
->another_trap
= 1;
2390 /* Still need to check other stuff, at least the case
2391 where we are stepping and step out of the right range. */
2394 case BPSTAT_WHAT_STOP_NOISY
:
2395 stop_print_frame
= 1;
2397 /* We are about to nuke the step_resume_breakpoint and
2398 through_sigtramp_breakpoint via the cleanup chain, so
2399 no need to worry about it here. */
2401 stop_stepping (ecs
);
2404 case BPSTAT_WHAT_STOP_SILENT
:
2405 stop_print_frame
= 0;
2407 /* We are about to nuke the step_resume_breakpoint and
2408 through_sigtramp_breakpoint via the cleanup chain, so
2409 no need to worry about it here. */
2411 stop_stepping (ecs
);
2414 case BPSTAT_WHAT_STEP_RESUME
:
2415 /* This proably demands a more elegant solution, but, yeah
2418 This function's use of the simple variable
2419 step_resume_breakpoint doesn't seem to accomodate
2420 simultaneously active step-resume bp's, although the
2421 breakpoint list certainly can.
2423 If we reach here and step_resume_breakpoint is already
2424 NULL, then apparently we have multiple active
2425 step-resume bp's. We'll just delete the breakpoint we
2426 stopped at, and carry on.
2428 Correction: what the code currently does is delete a
2429 step-resume bp, but it makes no effort to ensure that
2430 the one deleted is the one currently stopped at. MVS */
2432 if (step_resume_breakpoint
== NULL
)
2434 step_resume_breakpoint
=
2435 bpstat_find_step_resume_breakpoint (stop_bpstat
);
2437 delete_step_resume_breakpoint (&step_resume_breakpoint
);
2440 case BPSTAT_WHAT_THROUGH_SIGTRAMP
:
2441 if (through_sigtramp_breakpoint
)
2442 delete_breakpoint (through_sigtramp_breakpoint
);
2443 through_sigtramp_breakpoint
= NULL
;
2445 /* If were waiting for a trap, hitting the step_resume_break
2446 doesn't count as getting it. */
2448 ecs
->another_trap
= 1;
2451 case BPSTAT_WHAT_CHECK_SHLIBS
:
2452 case BPSTAT_WHAT_CHECK_SHLIBS_RESUME_FROM_HOOK
:
2455 /* Remove breakpoints, we eventually want to step over the
2456 shlib event breakpoint, and SOLIB_ADD might adjust
2457 breakpoint addresses via breakpoint_re_set. */
2458 if (breakpoints_inserted
)
2459 remove_breakpoints ();
2460 breakpoints_inserted
= 0;
2462 /* Check for any newly added shared libraries if we're
2463 supposed to be adding them automatically. */
2466 /* Switch terminal for any messages produced by
2467 breakpoint_re_set. */
2468 target_terminal_ours_for_output ();
2469 SOLIB_ADD (NULL
, 0, NULL
);
2470 target_terminal_inferior ();
2473 /* Try to reenable shared library breakpoints, additional
2474 code segments in shared libraries might be mapped in now. */
2475 re_enable_breakpoints_in_shlibs ();
2477 /* If requested, stop when the dynamic linker notifies
2478 gdb of events. This allows the user to get control
2479 and place breakpoints in initializer routines for
2480 dynamically loaded objects (among other things). */
2481 if (stop_on_solib_events
)
2483 stop_stepping (ecs
);
2487 /* If we stopped due to an explicit catchpoint, then the
2488 (see above) call to SOLIB_ADD pulled in any symbols
2489 from a newly-loaded library, if appropriate.
2491 We do want the inferior to stop, but not where it is
2492 now, which is in the dynamic linker callback. Rather,
2493 we would like it stop in the user's program, just after
2494 the call that caused this catchpoint to trigger. That
2495 gives the user a more useful vantage from which to
2496 examine their program's state. */
2497 else if (what
.main_action
== BPSTAT_WHAT_CHECK_SHLIBS_RESUME_FROM_HOOK
)
2499 /* ??rehrauer: If I could figure out how to get the
2500 right return PC from here, we could just set a temp
2501 breakpoint and resume. I'm not sure we can without
2502 cracking open the dld's shared libraries and sniffing
2503 their unwind tables and text/data ranges, and that's
2504 not a terribly portable notion.
2506 Until that time, we must step the inferior out of the
2507 dld callback, and also out of the dld itself (and any
2508 code or stubs in libdld.sl, such as "shl_load" and
2509 friends) until we reach non-dld code. At that point,
2510 we can stop stepping. */
2511 bpstat_get_triggered_catchpoints (stop_bpstat
,
2512 &ecs
->stepping_through_solib_catchpoints
);
2513 ecs
->stepping_through_solib_after_catch
= 1;
2515 /* Be sure to lift all breakpoints, so the inferior does
2516 actually step past this point... */
2517 ecs
->another_trap
= 1;
2522 /* We want to step over this breakpoint, then keep going. */
2523 ecs
->another_trap
= 1;
2530 case BPSTAT_WHAT_LAST
:
2531 /* Not a real code, but listed here to shut up gcc -Wall. */
2533 case BPSTAT_WHAT_KEEP_CHECKING
:
2538 /* We come here if we hit a breakpoint but should not
2539 stop for it. Possibly we also were stepping
2540 and should stop for that. So fall through and
2541 test for stepping. But, if not stepping,
2544 /* Are we stepping to get the inferior out of the dynamic
2545 linker's hook (and possibly the dld itself) after catching
2547 if (ecs
->stepping_through_solib_after_catch
)
2549 #if defined(SOLIB_ADD)
2550 /* Have we reached our destination? If not, keep going. */
2551 if (SOLIB_IN_DYNAMIC_LINKER (PIDGET (ecs
->ptid
), stop_pc
))
2553 ecs
->another_trap
= 1;
2558 /* Else, stop and report the catchpoint(s) whose triggering
2559 caused us to begin stepping. */
2560 ecs
->stepping_through_solib_after_catch
= 0;
2561 bpstat_clear (&stop_bpstat
);
2562 stop_bpstat
= bpstat_copy (ecs
->stepping_through_solib_catchpoints
);
2563 bpstat_clear (&ecs
->stepping_through_solib_catchpoints
);
2564 stop_print_frame
= 1;
2565 stop_stepping (ecs
);
2569 if (!CALL_DUMMY_BREAKPOINT_OFFSET_P
)
2571 /* This is the old way of detecting the end of the stack dummy.
2572 An architecture which defines CALL_DUMMY_BREAKPOINT_OFFSET gets
2573 handled above. As soon as we can test it on all of them, all
2574 architectures should define it. */
2576 /* If this is the breakpoint at the end of a stack dummy,
2577 just stop silently, unless the user was doing an si/ni, in which
2578 case she'd better know what she's doing. */
2580 if (CALL_DUMMY_HAS_COMPLETED (stop_pc
, read_sp (),
2581 FRAME_FP (get_current_frame ()))
2584 stop_print_frame
= 0;
2585 stop_stack_dummy
= 1;
2587 trap_expected_after_continue
= 1;
2589 stop_stepping (ecs
);
2594 if (step_resume_breakpoint
)
2596 /* Having a step-resume breakpoint overrides anything
2597 else having to do with stepping commands until
2598 that breakpoint is reached. */
2599 /* I'm not sure whether this needs to be check_sigtramp2 or
2600 whether it could/should be keep_going. */
2601 check_sigtramp2 (ecs
);
2606 if (step_range_end
== 0)
2608 /* Likewise if we aren't even stepping. */
2609 /* I'm not sure whether this needs to be check_sigtramp2 or
2610 whether it could/should be keep_going. */
2611 check_sigtramp2 (ecs
);
2616 /* If stepping through a line, keep going if still within it.
2618 Note that step_range_end is the address of the first instruction
2619 beyond the step range, and NOT the address of the last instruction
2621 if (stop_pc
>= step_range_start
2622 && stop_pc
< step_range_end
)
2624 /* We might be doing a BPSTAT_WHAT_SINGLE and getting a signal.
2625 So definately need to check for sigtramp here. */
2626 check_sigtramp2 (ecs
);
2631 /* We stepped out of the stepping range. */
2633 /* If we are stepping at the source level and entered the runtime
2634 loader dynamic symbol resolution code, we keep on single stepping
2635 until we exit the run time loader code and reach the callee's
2637 if (step_over_calls
== STEP_OVER_UNDEBUGGABLE
&& IN_SOLIB_DYNSYM_RESOLVE_CODE (stop_pc
))
2639 CORE_ADDR pc_after_resolver
= SKIP_SOLIB_RESOLVER (stop_pc
);
2641 if (pc_after_resolver
)
2643 /* Set up a step-resume breakpoint at the address
2644 indicated by SKIP_SOLIB_RESOLVER. */
2645 struct symtab_and_line sr_sal
;
2647 sr_sal
.pc
= pc_after_resolver
;
2649 check_for_old_step_resume_breakpoint ();
2650 step_resume_breakpoint
=
2651 set_momentary_breakpoint (sr_sal
, NULL
, bp_step_resume
);
2652 if (breakpoints_inserted
)
2653 insert_breakpoints ();
2660 /* We can't update step_sp every time through the loop, because
2661 reading the stack pointer would slow down stepping too much.
2662 But we can update it every time we leave the step range. */
2663 ecs
->update_step_sp
= 1;
2665 /* Did we just take a signal? */
2666 if (IN_SIGTRAMP (stop_pc
, ecs
->stop_func_name
)
2667 && !IN_SIGTRAMP (prev_pc
, prev_func_name
)
2668 && INNER_THAN (read_sp (), step_sp
))
2670 /* We've just taken a signal; go until we are back to
2671 the point where we took it and one more. */
2673 /* Note: The test above succeeds not only when we stepped
2674 into a signal handler, but also when we step past the last
2675 statement of a signal handler and end up in the return stub
2676 of the signal handler trampoline. To distinguish between
2677 these two cases, check that the frame is INNER_THAN the
2678 previous one below. pai/1997-09-11 */
2682 CORE_ADDR current_frame
= FRAME_FP (get_current_frame ());
2684 if (INNER_THAN (current_frame
, step_frame_address
))
2686 /* We have just taken a signal; go until we are back to
2687 the point where we took it and one more. */
2689 /* This code is needed at least in the following case:
2690 The user types "next" and then a signal arrives (before
2691 the "next" is done). */
2693 /* Note that if we are stopped at a breakpoint, then we need
2694 the step_resume breakpoint to override any breakpoints at
2695 the same location, so that we will still step over the
2696 breakpoint even though the signal happened. */
2697 struct symtab_and_line sr_sal
;
2700 sr_sal
.symtab
= NULL
;
2702 sr_sal
.pc
= prev_pc
;
2703 /* We could probably be setting the frame to
2704 step_frame_address; I don't think anyone thought to
2706 check_for_old_step_resume_breakpoint ();
2707 step_resume_breakpoint
=
2708 set_momentary_breakpoint (sr_sal
, NULL
, bp_step_resume
);
2709 if (breakpoints_inserted
)
2710 insert_breakpoints ();
2714 /* We just stepped out of a signal handler and into
2715 its calling trampoline.
2717 Normally, we'd call step_over_function from
2718 here, but for some reason GDB can't unwind the
2719 stack correctly to find the real PC for the point
2720 user code where the signal trampoline will return
2721 -- FRAME_SAVED_PC fails, at least on HP-UX 10.20.
2722 But signal trampolines are pretty small stubs of
2723 code, anyway, so it's OK instead to just
2724 single-step out. Note: assuming such trampolines
2725 don't exhibit recursion on any platform... */
2726 find_pc_partial_function (stop_pc
, &ecs
->stop_func_name
,
2727 &ecs
->stop_func_start
,
2728 &ecs
->stop_func_end
);
2729 /* Readjust stepping range */
2730 step_range_start
= ecs
->stop_func_start
;
2731 step_range_end
= ecs
->stop_func_end
;
2732 ecs
->stepping_through_sigtramp
= 1;
2737 /* If this is stepi or nexti, make sure that the stepping range
2738 gets us past that instruction. */
2739 if (step_range_end
== 1)
2740 /* FIXME: Does this run afoul of the code below which, if
2741 we step into the middle of a line, resets the stepping
2743 step_range_end
= (step_range_start
= prev_pc
) + 1;
2745 ecs
->remove_breakpoints_on_following_step
= 1;
2750 if (stop_pc
== ecs
->stop_func_start
/* Quick test */
2751 || (in_prologue (stop_pc
, ecs
->stop_func_start
) &&
2752 !IN_SOLIB_RETURN_TRAMPOLINE (stop_pc
, ecs
->stop_func_name
))
2753 || IN_SOLIB_CALL_TRAMPOLINE (stop_pc
, ecs
->stop_func_name
)
2754 || ecs
->stop_func_name
== 0)
2756 /* It's a subroutine call. */
2758 if ((step_over_calls
== STEP_OVER_NONE
)
2759 || ((step_range_end
== 1)
2760 && in_prologue (prev_pc
, ecs
->stop_func_start
)))
2762 /* I presume that step_over_calls is only 0 when we're
2763 supposed to be stepping at the assembly language level
2764 ("stepi"). Just stop. */
2765 /* Also, maybe we just did a "nexti" inside a prolog,
2766 so we thought it was a subroutine call but it was not.
2767 Stop as well. FENN */
2769 print_stop_reason (END_STEPPING_RANGE
, 0);
2770 stop_stepping (ecs
);
2774 if (step_over_calls
== STEP_OVER_ALL
|| IGNORE_HELPER_CALL (stop_pc
))
2776 /* We're doing a "next". */
2778 if (IN_SIGTRAMP (stop_pc
, ecs
->stop_func_name
)
2779 && INNER_THAN (step_frame_address
, read_sp()))
2780 /* We stepped out of a signal handler, and into its
2781 calling trampoline. This is misdetected as a
2782 subroutine call, but stepping over the signal
2783 trampoline isn't such a bad idea. In order to do
2784 that, we have to ignore the value in
2785 step_frame_address, since that doesn't represent the
2786 frame that'll reach when we return from the signal
2787 trampoline. Otherwise we'll probably continue to the
2788 end of the program. */
2789 step_frame_address
= 0;
2791 step_over_function (ecs
);
2796 /* If we are in a function call trampoline (a stub between
2797 the calling routine and the real function), locate the real
2798 function. That's what tells us (a) whether we want to step
2799 into it at all, and (b) what prologue we want to run to
2800 the end of, if we do step into it. */
2801 tmp
= SKIP_TRAMPOLINE_CODE (stop_pc
);
2803 ecs
->stop_func_start
= tmp
;
2806 tmp
= DYNAMIC_TRAMPOLINE_NEXTPC (stop_pc
);
2809 struct symtab_and_line xxx
;
2810 /* Why isn't this s_a_l called "sr_sal", like all of the
2811 other s_a_l's where this code is duplicated? */
2812 INIT_SAL (&xxx
); /* initialize to zeroes */
2814 xxx
.section
= find_pc_overlay (xxx
.pc
);
2815 check_for_old_step_resume_breakpoint ();
2816 step_resume_breakpoint
=
2817 set_momentary_breakpoint (xxx
, NULL
, bp_step_resume
);
2818 insert_breakpoints ();
2824 /* If we have line number information for the function we
2825 are thinking of stepping into, step into it.
2827 If there are several symtabs at that PC (e.g. with include
2828 files), just want to know whether *any* of them have line
2829 numbers. find_pc_line handles this. */
2831 struct symtab_and_line tmp_sal
;
2833 tmp_sal
= find_pc_line (ecs
->stop_func_start
, 0);
2834 if (tmp_sal
.line
!= 0)
2836 step_into_function (ecs
);
2841 /* If we have no line number and the step-stop-if-no-debug
2842 is set, we stop the step so that the user has a chance to
2843 switch in assembly mode. */
2844 if (step_over_calls
== STEP_OVER_UNDEBUGGABLE
&& step_stop_if_no_debug
)
2847 print_stop_reason (END_STEPPING_RANGE
, 0);
2848 stop_stepping (ecs
);
2852 step_over_function (ecs
);
2858 /* We've wandered out of the step range. */
2860 ecs
->sal
= find_pc_line (stop_pc
, 0);
2862 if (step_range_end
== 1)
2864 /* It is stepi or nexti. We always want to stop stepping after
2867 print_stop_reason (END_STEPPING_RANGE
, 0);
2868 stop_stepping (ecs
);
2872 /* If we're in the return path from a shared library trampoline,
2873 we want to proceed through the trampoline when stepping. */
2874 if (IN_SOLIB_RETURN_TRAMPOLINE (stop_pc
, ecs
->stop_func_name
))
2878 /* Determine where this trampoline returns. */
2879 tmp
= SKIP_TRAMPOLINE_CODE (stop_pc
);
2881 /* Only proceed through if we know where it's going. */
2884 /* And put the step-breakpoint there and go until there. */
2885 struct symtab_and_line sr_sal
;
2887 INIT_SAL (&sr_sal
); /* initialize to zeroes */
2889 sr_sal
.section
= find_pc_overlay (sr_sal
.pc
);
2890 /* Do not specify what the fp should be when we stop
2891 since on some machines the prologue
2892 is where the new fp value is established. */
2893 check_for_old_step_resume_breakpoint ();
2894 step_resume_breakpoint
=
2895 set_momentary_breakpoint (sr_sal
, NULL
, bp_step_resume
);
2896 if (breakpoints_inserted
)
2897 insert_breakpoints ();
2899 /* Restart without fiddling with the step ranges or
2906 if (ecs
->sal
.line
== 0)
2908 /* We have no line number information. That means to stop
2909 stepping (does this always happen right after one instruction,
2910 when we do "s" in a function with no line numbers,
2911 or can this happen as a result of a return or longjmp?). */
2913 print_stop_reason (END_STEPPING_RANGE
, 0);
2914 stop_stepping (ecs
);
2918 if ((stop_pc
== ecs
->sal
.pc
)
2919 && (ecs
->current_line
!= ecs
->sal
.line
|| ecs
->current_symtab
!= ecs
->sal
.symtab
))
2921 /* We are at the start of a different line. So stop. Note that
2922 we don't stop if we step into the middle of a different line.
2923 That is said to make things like for (;;) statements work
2926 print_stop_reason (END_STEPPING_RANGE
, 0);
2927 stop_stepping (ecs
);
2931 /* We aren't done stepping.
2933 Optimize by setting the stepping range to the line.
2934 (We might not be in the original line, but if we entered a
2935 new line in mid-statement, we continue stepping. This makes
2936 things like for(;;) statements work better.) */
2938 if (ecs
->stop_func_end
&& ecs
->sal
.end
>= ecs
->stop_func_end
)
2940 /* If this is the last line of the function, don't keep stepping
2941 (it would probably step us out of the function).
2942 This is particularly necessary for a one-line function,
2943 in which after skipping the prologue we better stop even though
2944 we will be in mid-line. */
2946 print_stop_reason (END_STEPPING_RANGE
, 0);
2947 stop_stepping (ecs
);
2950 step_range_start
= ecs
->sal
.pc
;
2951 step_range_end
= ecs
->sal
.end
;
2952 step_frame_address
= FRAME_FP (get_current_frame ());
2953 ecs
->current_line
= ecs
->sal
.line
;
2954 ecs
->current_symtab
= ecs
->sal
.symtab
;
2956 /* In the case where we just stepped out of a function into the middle
2957 of a line of the caller, continue stepping, but step_frame_address
2958 must be modified to current frame */
2960 CORE_ADDR current_frame
= FRAME_FP (get_current_frame ());
2961 if (!(INNER_THAN (current_frame
, step_frame_address
)))
2962 step_frame_address
= current_frame
;
2967 } /* extra brace, to preserve old indentation */
2970 /* Are we in the middle of stepping? */
2973 currently_stepping (struct execution_control_state
*ecs
)
2975 return ((through_sigtramp_breakpoint
== NULL
2976 && !ecs
->handling_longjmp
2977 && ((step_range_end
&& step_resume_breakpoint
== NULL
)
2979 || ecs
->stepping_through_solib_after_catch
2980 || bpstat_should_step ());
2984 check_sigtramp2 (struct execution_control_state
*ecs
)
2987 && IN_SIGTRAMP (stop_pc
, ecs
->stop_func_name
)
2988 && !IN_SIGTRAMP (prev_pc
, prev_func_name
)
2989 && INNER_THAN (read_sp (), step_sp
))
2991 /* What has happened here is that we have just stepped the
2992 inferior with a signal (because it is a signal which
2993 shouldn't make us stop), thus stepping into sigtramp.
2995 So we need to set a step_resume_break_address breakpoint and
2996 continue until we hit it, and then step. FIXME: This should
2997 be more enduring than a step_resume breakpoint; we should
2998 know that we will later need to keep going rather than
2999 re-hitting the breakpoint here (see the testsuite,
3000 gdb.base/signals.exp where it says "exceedingly difficult"). */
3002 struct symtab_and_line sr_sal
;
3004 INIT_SAL (&sr_sal
); /* initialize to zeroes */
3005 sr_sal
.pc
= prev_pc
;
3006 sr_sal
.section
= find_pc_overlay (sr_sal
.pc
);
3007 /* We perhaps could set the frame if we kept track of what the
3008 frame corresponding to prev_pc was. But we don't, so don't. */
3009 through_sigtramp_breakpoint
=
3010 set_momentary_breakpoint (sr_sal
, NULL
, bp_through_sigtramp
);
3011 if (breakpoints_inserted
)
3012 insert_breakpoints ();
3014 ecs
->remove_breakpoints_on_following_step
= 1;
3015 ecs
->another_trap
= 1;
3019 /* Subroutine call with source code we should not step over. Do step
3020 to the first line of code in it. */
3023 step_into_function (struct execution_control_state
*ecs
)
3026 struct symtab_and_line sr_sal
;
3028 s
= find_pc_symtab (stop_pc
);
3029 if (s
&& s
->language
!= language_asm
)
3030 ecs
->stop_func_start
= SKIP_PROLOGUE (ecs
->stop_func_start
);
3032 ecs
->sal
= find_pc_line (ecs
->stop_func_start
, 0);
3033 /* Use the step_resume_break to step until the end of the prologue,
3034 even if that involves jumps (as it seems to on the vax under
3036 /* If the prologue ends in the middle of a source line, continue to
3037 the end of that source line (if it is still within the function).
3038 Otherwise, just go to end of prologue. */
3039 #ifdef PROLOGUE_FIRSTLINE_OVERLAP
3040 /* no, don't either. It skips any code that's legitimately on the
3044 && ecs
->sal
.pc
!= ecs
->stop_func_start
3045 && ecs
->sal
.end
< ecs
->stop_func_end
)
3046 ecs
->stop_func_start
= ecs
->sal
.end
;
3049 if (ecs
->stop_func_start
== stop_pc
)
3051 /* We are already there: stop now. */
3053 print_stop_reason (END_STEPPING_RANGE
, 0);
3054 stop_stepping (ecs
);
3059 /* Put the step-breakpoint there and go until there. */
3060 INIT_SAL (&sr_sal
); /* initialize to zeroes */
3061 sr_sal
.pc
= ecs
->stop_func_start
;
3062 sr_sal
.section
= find_pc_overlay (ecs
->stop_func_start
);
3063 /* Do not specify what the fp should be when we stop since on
3064 some machines the prologue is where the new fp value is
3066 check_for_old_step_resume_breakpoint ();
3067 step_resume_breakpoint
=
3068 set_momentary_breakpoint (sr_sal
, NULL
, bp_step_resume
);
3069 if (breakpoints_inserted
)
3070 insert_breakpoints ();
3072 /* And make sure stepping stops right away then. */
3073 step_range_end
= step_range_start
;
3078 /* We've just entered a callee, and we wish to resume until it returns
3079 to the caller. Setting a step_resume breakpoint on the return
3080 address will catch a return from the callee.
3082 However, if the callee is recursing, we want to be careful not to
3083 catch returns of those recursive calls, but only of THIS instance
3086 To do this, we set the step_resume bp's frame to our current
3087 caller's frame (step_frame_address, which is set by the "next" or
3088 "until" command, before execution begins). */
3091 step_over_function (struct execution_control_state
*ecs
)
3093 struct symtab_and_line sr_sal
;
3095 INIT_SAL (&sr_sal
); /* initialize to zeros */
3096 sr_sal
.pc
= ADDR_BITS_REMOVE (SAVED_PC_AFTER_CALL (get_current_frame ()));
3097 sr_sal
.section
= find_pc_overlay (sr_sal
.pc
);
3099 check_for_old_step_resume_breakpoint ();
3100 step_resume_breakpoint
=
3101 set_momentary_breakpoint (sr_sal
, get_current_frame (), bp_step_resume
);
3103 if (step_frame_address
&& !IN_SOLIB_DYNSYM_RESOLVE_CODE (sr_sal
.pc
))
3104 step_resume_breakpoint
->frame
= step_frame_address
;
3106 if (breakpoints_inserted
)
3107 insert_breakpoints ();
3111 stop_stepping (struct execution_control_state
*ecs
)
3113 if (target_has_execution
)
3115 /* Are we stopping for a vfork event? We only stop when we see
3116 the child's event. However, we may not yet have seen the
3117 parent's event. And, inferior_ptid is still set to the
3118 parent's pid, until we resume again and follow either the
3121 To ensure that we can really touch inferior_ptid (aka, the
3122 parent process) -- which calls to functions like read_pc
3123 implicitly do -- wait on the parent if necessary. */
3124 if ((pending_follow
.kind
== TARGET_WAITKIND_VFORKED
)
3125 && !pending_follow
.fork_event
.saw_parent_fork
)
3131 if (target_wait_hook
)
3132 parent_ptid
= target_wait_hook (pid_to_ptid (-1), &(ecs
->ws
));
3134 parent_ptid
= target_wait (pid_to_ptid (-1), &(ecs
->ws
));
3136 while (! ptid_equal (parent_ptid
, inferior_ptid
));
3139 /* Assuming the inferior still exists, set these up for next
3140 time, just like we did above if we didn't break out of the
3142 prev_pc
= read_pc ();
3143 prev_func_start
= ecs
->stop_func_start
;
3144 prev_func_name
= ecs
->stop_func_name
;
3147 /* Let callers know we don't want to wait for the inferior anymore. */
3148 ecs
->wait_some_more
= 0;
3151 /* This function handles various cases where we need to continue
3152 waiting for the inferior. */
3153 /* (Used to be the keep_going: label in the old wait_for_inferior) */
3156 keep_going (struct execution_control_state
*ecs
)
3158 /* ??rehrauer: ttrace on HP-UX theoretically allows one to debug a
3159 vforked child between its creation and subsequent exit or call to
3160 exec(). However, I had big problems in this rather creaky exec
3161 engine, getting that to work. The fundamental problem is that
3162 I'm trying to debug two processes via an engine that only
3163 understands a single process with possibly multiple threads.
3165 Hence, this spot is known to have problems when
3166 target_can_follow_vfork_prior_to_exec returns 1. */
3168 /* Save the pc before execution, to compare with pc after stop. */
3169 prev_pc
= read_pc (); /* Might have been DECR_AFTER_BREAK */
3170 prev_func_start
= ecs
->stop_func_start
; /* Ok, since if DECR_PC_AFTER
3171 BREAK is defined, the
3172 original pc would not have
3173 been at the start of a
3175 prev_func_name
= ecs
->stop_func_name
;
3177 if (ecs
->update_step_sp
)
3178 step_sp
= read_sp ();
3179 ecs
->update_step_sp
= 0;
3181 /* If we did not do break;, it means we should keep running the
3182 inferior and not return to debugger. */
3184 if (trap_expected
&& stop_signal
!= TARGET_SIGNAL_TRAP
)
3186 /* We took a signal (which we are supposed to pass through to
3187 the inferior, else we'd have done a break above) and we
3188 haven't yet gotten our trap. Simply continue. */
3189 resume (currently_stepping (ecs
), stop_signal
);
3193 /* Either the trap was not expected, but we are continuing
3194 anyway (the user asked that this signal be passed to the
3197 The signal was SIGTRAP, e.g. it was our signal, but we
3198 decided we should resume from it.
3200 We're going to run this baby now!
3202 Insert breakpoints now, unless we are trying to one-proceed
3203 past a breakpoint. */
3204 /* If we've just finished a special step resume and we don't
3205 want to hit a breakpoint, pull em out. */
3206 if (step_resume_breakpoint
== NULL
3207 && through_sigtramp_breakpoint
== NULL
3208 && ecs
->remove_breakpoints_on_following_step
)
3210 ecs
->remove_breakpoints_on_following_step
= 0;
3211 remove_breakpoints ();
3212 breakpoints_inserted
= 0;
3214 else if (!breakpoints_inserted
&&
3215 (through_sigtramp_breakpoint
!= NULL
|| !ecs
->another_trap
))
3217 breakpoints_failed
= insert_breakpoints ();
3218 if (breakpoints_failed
)
3220 stop_stepping (ecs
);
3223 breakpoints_inserted
= 1;
3226 trap_expected
= ecs
->another_trap
;
3228 /* Do not deliver SIGNAL_TRAP (except when the user explicitly
3229 specifies that such a signal should be delivered to the
3232 Typically, this would occure when a user is debugging a
3233 target monitor on a simulator: the target monitor sets a
3234 breakpoint; the simulator encounters this break-point and
3235 halts the simulation handing control to GDB; GDB, noteing
3236 that the break-point isn't valid, returns control back to the
3237 simulator; the simulator then delivers the hardware
3238 equivalent of a SIGNAL_TRAP to the program being debugged. */
3240 if (stop_signal
== TARGET_SIGNAL_TRAP
3241 && !signal_program
[stop_signal
])
3242 stop_signal
= TARGET_SIGNAL_0
;
3244 #ifdef SHIFT_INST_REGS
3245 /* I'm not sure when this following segment applies. I do know,
3246 now, that we shouldn't rewrite the regs when we were stopped
3247 by a random signal from the inferior process. */
3248 /* FIXME: Shouldn't this be based on the valid bit of the SXIP?
3249 (this is only used on the 88k). */
3251 if (!bpstat_explains_signal (stop_bpstat
)
3252 && (stop_signal
!= TARGET_SIGNAL_CHLD
)
3253 && !stopped_by_random_signal
)
3255 #endif /* SHIFT_INST_REGS */
3257 resume (currently_stepping (ecs
), stop_signal
);
3260 prepare_to_wait (ecs
);
3263 /* This function normally comes after a resume, before
3264 handle_inferior_event exits. It takes care of any last bits of
3265 housekeeping, and sets the all-important wait_some_more flag. */
3268 prepare_to_wait (struct execution_control_state
*ecs
)
3270 if (ecs
->infwait_state
== infwait_normal_state
)
3272 overlay_cache_invalid
= 1;
3274 /* We have to invalidate the registers BEFORE calling
3275 target_wait because they can be loaded from the target while
3276 in target_wait. This makes remote debugging a bit more
3277 efficient for those targets that provide critical registers
3278 as part of their normal status mechanism. */
3280 registers_changed ();
3281 ecs
->waiton_ptid
= pid_to_ptid (-1);
3282 ecs
->wp
= &(ecs
->ws
);
3284 /* This is the old end of the while loop. Let everybody know we
3285 want to wait for the inferior some more and get called again
3287 ecs
->wait_some_more
= 1;
3290 /* Print why the inferior has stopped. We always print something when
3291 the inferior exits, or receives a signal. The rest of the cases are
3292 dealt with later on in normal_stop() and print_it_typical(). Ideally
3293 there should be a call to this function from handle_inferior_event()
3294 each time stop_stepping() is called.*/
3296 print_stop_reason (enum inferior_stop_reason stop_reason
, int stop_info
)
3298 switch (stop_reason
)
3301 /* We don't deal with these cases from handle_inferior_event()
3304 case END_STEPPING_RANGE
:
3305 /* We are done with a step/next/si/ni command. */
3306 /* For now print nothing. */
3308 /* Print a message only if not in the middle of doing a "step n"
3309 operation for n > 1 */
3310 if (!step_multi
|| !stop_step
)
3311 if (ui_out_is_mi_like_p (uiout
))
3312 ui_out_field_string (uiout
, "reason", "end-stepping-range");
3315 case BREAKPOINT_HIT
:
3316 /* We found a breakpoint. */
3317 /* For now print nothing. */
3320 /* The inferior was terminated by a signal. */
3322 annotate_signalled ();
3323 if (ui_out_is_mi_like_p (uiout
))
3324 ui_out_field_string (uiout
, "reason", "exited-signalled");
3325 ui_out_text (uiout
, "\nProgram terminated with signal ");
3326 annotate_signal_name ();
3327 ui_out_field_string (uiout
, "signal-name", target_signal_to_name (stop_info
));
3328 annotate_signal_name_end ();
3329 ui_out_text (uiout
, ", ");
3330 annotate_signal_string ();
3331 ui_out_field_string (uiout
, "signal-meaning", target_signal_to_string (stop_info
));
3332 annotate_signal_string_end ();
3333 ui_out_text (uiout
, ".\n");
3334 ui_out_text (uiout
, "The program no longer exists.\n");
3336 annotate_signalled ();
3337 printf_filtered ("\nProgram terminated with signal ");
3338 annotate_signal_name ();
3339 printf_filtered ("%s", target_signal_to_name (stop_info
));
3340 annotate_signal_name_end ();
3341 printf_filtered (", ");
3342 annotate_signal_string ();
3343 printf_filtered ("%s", target_signal_to_string (stop_info
));
3344 annotate_signal_string_end ();
3345 printf_filtered (".\n");
3347 printf_filtered ("The program no longer exists.\n");
3348 gdb_flush (gdb_stdout
);
3352 /* The inferior program is finished. */
3354 annotate_exited (stop_info
);
3357 if (ui_out_is_mi_like_p (uiout
))
3358 ui_out_field_string (uiout
, "reason", "exited");
3359 ui_out_text (uiout
, "\nProgram exited with code ");
3360 ui_out_field_fmt (uiout
, "exit-code", "0%o", (unsigned int) stop_info
);
3361 ui_out_text (uiout
, ".\n");
3365 if (ui_out_is_mi_like_p (uiout
))
3366 ui_out_field_string (uiout
, "reason", "exited-normally");
3367 ui_out_text (uiout
, "\nProgram exited normally.\n");
3370 annotate_exited (stop_info
);
3372 printf_filtered ("\nProgram exited with code 0%o.\n",
3373 (unsigned int) stop_info
);
3375 printf_filtered ("\nProgram exited normally.\n");
3378 case SIGNAL_RECEIVED
:
3379 /* Signal received. The signal table tells us to print about
3383 ui_out_text (uiout
, "\nProgram received signal ");
3384 annotate_signal_name ();
3385 ui_out_field_string (uiout
, "signal-name", target_signal_to_name (stop_info
));
3386 annotate_signal_name_end ();
3387 ui_out_text (uiout
, ", ");
3388 annotate_signal_string ();
3389 ui_out_field_string (uiout
, "signal-meaning", target_signal_to_string (stop_info
));
3390 annotate_signal_string_end ();
3391 ui_out_text (uiout
, ".\n");
3394 printf_filtered ("\nProgram received signal ");
3395 annotate_signal_name ();
3396 printf_filtered ("%s", target_signal_to_name (stop_info
));
3397 annotate_signal_name_end ();
3398 printf_filtered (", ");
3399 annotate_signal_string ();
3400 printf_filtered ("%s", target_signal_to_string (stop_info
));
3401 annotate_signal_string_end ();
3402 printf_filtered (".\n");
3403 gdb_flush (gdb_stdout
);
3407 internal_error (__FILE__
, __LINE__
,
3408 "print_stop_reason: unrecognized enum value");
3414 /* Here to return control to GDB when the inferior stops for real.
3415 Print appropriate messages, remove breakpoints, give terminal our modes.
3417 STOP_PRINT_FRAME nonzero means print the executing frame
3418 (pc, function, args, file, line number and line text).
3419 BREAKPOINTS_FAILED nonzero means stop was due to error
3420 attempting to insert breakpoints. */
3425 /* As with the notification of thread events, we want to delay
3426 notifying the user that we've switched thread context until
3427 the inferior actually stops.
3429 (Note that there's no point in saying anything if the inferior
3431 if (! ptid_equal (previous_inferior_ptid
, inferior_ptid
)
3432 && target_has_execution
)
3434 target_terminal_ours_for_output ();
3435 printf_filtered ("[Switching to %s]\n",
3436 target_pid_or_tid_to_str (inferior_ptid
));
3437 previous_inferior_ptid
= inferior_ptid
;
3440 /* Make sure that the current_frame's pc is correct. This
3441 is a correction for setting up the frame info before doing
3442 DECR_PC_AFTER_BREAK */
3443 if (target_has_execution
&& get_current_frame ())
3444 (get_current_frame ())->pc
= read_pc ();
3446 if (breakpoints_failed
)
3448 target_terminal_ours_for_output ();
3449 print_sys_errmsg ("While inserting breakpoints", breakpoints_failed
);
3450 printf_filtered ("Stopped; cannot insert breakpoints.\n\
3451 The same program may be running in another process,\n\
3452 or you may have requested too many hardware breakpoints\n\
3453 and/or watchpoints.\n");
3456 if (target_has_execution
&& breakpoints_inserted
)
3458 if (remove_breakpoints ())
3460 target_terminal_ours_for_output ();
3461 printf_filtered ("Cannot remove breakpoints because ");
3462 printf_filtered ("program is no longer writable.\n");
3463 printf_filtered ("It might be running in another process.\n");
3464 printf_filtered ("Further execution is probably impossible.\n");
3467 breakpoints_inserted
= 0;
3469 /* Delete the breakpoint we stopped at, if it wants to be deleted.
3470 Delete any breakpoint that is to be deleted at the next stop. */
3472 breakpoint_auto_delete (stop_bpstat
);
3474 /* If an auto-display called a function and that got a signal,
3475 delete that auto-display to avoid an infinite recursion. */
3477 if (stopped_by_random_signal
)
3478 disable_current_display ();
3480 /* Don't print a message if in the middle of doing a "step n"
3481 operation for n > 1 */
3482 if (step_multi
&& stop_step
)
3485 target_terminal_ours ();
3487 /* Look up the hook_stop and run it if it exists. */
3489 if (stop_command
&& stop_command
->hook_pre
)
3491 catch_errors (hook_stop_stub
, stop_command
->hook_pre
,
3492 "Error while running hook_stop:\n", RETURN_MASK_ALL
);
3495 if (!target_has_stack
)
3501 /* Select innermost stack frame - i.e., current frame is frame 0,
3502 and current location is based on that.
3503 Don't do this on return from a stack dummy routine,
3504 or if the program has exited. */
3506 if (!stop_stack_dummy
)
3508 select_frame (get_current_frame (), 0);
3510 /* Print current location without a level number, if
3511 we have changed functions or hit a breakpoint.
3512 Print source line if we have one.
3513 bpstat_print() contains the logic deciding in detail
3514 what to print, based on the event(s) that just occurred. */
3516 if (stop_print_frame
3521 int do_frame_printing
= 1;
3523 bpstat_ret
= bpstat_print (stop_bpstat
);
3528 && step_frame_address
== FRAME_FP (get_current_frame ())
3529 && step_start_function
== find_pc_function (stop_pc
))
3530 source_flag
= SRC_LINE
; /* finished step, just print source line */
3532 source_flag
= SRC_AND_LOC
; /* print location and source line */
3534 case PRINT_SRC_AND_LOC
:
3535 source_flag
= SRC_AND_LOC
; /* print location and source line */
3537 case PRINT_SRC_ONLY
:
3538 source_flag
= SRC_LINE
;
3541 source_flag
= SRC_LINE
; /* something bogus */
3542 do_frame_printing
= 0;
3545 internal_error (__FILE__
, __LINE__
,
3549 /* For mi, have the same behavior every time we stop:
3550 print everything but the source line. */
3551 if (ui_out_is_mi_like_p (uiout
))
3552 source_flag
= LOC_AND_ADDRESS
;
3556 if (ui_out_is_mi_like_p (uiout
))
3557 ui_out_field_int (uiout
, "thread-id",
3558 pid_to_thread_id (inferior_ptid
));
3560 /* The behavior of this routine with respect to the source
3562 SRC_LINE: Print only source line
3563 LOCATION: Print only location
3564 SRC_AND_LOC: Print location and source line */
3565 if (do_frame_printing
)
3566 show_and_print_stack_frame (selected_frame
, -1, source_flag
);
3568 /* Display the auto-display expressions. */
3573 /* Save the function value return registers, if we care.
3574 We might be about to restore their previous contents. */
3575 if (proceed_to_finish
)
3576 read_register_bytes (0, stop_registers
, REGISTER_BYTES
);
3578 if (stop_stack_dummy
)
3580 /* Pop the empty frame that contains the stack dummy.
3581 POP_FRAME ends with a setting of the current frame, so we
3582 can use that next. */
3584 /* Set stop_pc to what it was before we called the function.
3585 Can't rely on restore_inferior_status because that only gets
3586 called if we don't stop in the called function. */
3587 stop_pc
= read_pc ();
3588 select_frame (get_current_frame (), 0);
3592 TUIDO (((TuiOpaqueFuncPtr
) tui_vCheckDataValues
, selected_frame
));
3595 annotate_stopped ();
3599 hook_stop_stub (void *cmd
)
3601 execute_user_command ((struct cmd_list_element
*) cmd
, 0);
3606 signal_stop_state (int signo
)
3608 return signal_stop
[signo
];
3612 signal_print_state (int signo
)
3614 return signal_print
[signo
];
3618 signal_pass_state (int signo
)
3620 return signal_program
[signo
];
3623 int signal_stop_update (signo
, state
)
3627 int ret
= signal_stop
[signo
];
3628 signal_stop
[signo
] = state
;
3632 int signal_print_update (signo
, state
)
3636 int ret
= signal_print
[signo
];
3637 signal_print
[signo
] = state
;
3641 int signal_pass_update (signo
, state
)
3645 int ret
= signal_program
[signo
];
3646 signal_program
[signo
] = state
;
3651 sig_print_header (void)
3654 Signal Stop\tPrint\tPass to program\tDescription\n");
3658 sig_print_info (enum target_signal oursig
)
3660 char *name
= target_signal_to_name (oursig
);
3661 int name_padding
= 13 - strlen (name
);
3663 if (name_padding
<= 0)
3666 printf_filtered ("%s", name
);
3667 printf_filtered ("%*.*s ", name_padding
, name_padding
,
3669 printf_filtered ("%s\t", signal_stop
[oursig
] ? "Yes" : "No");
3670 printf_filtered ("%s\t", signal_print
[oursig
] ? "Yes" : "No");
3671 printf_filtered ("%s\t\t", signal_program
[oursig
] ? "Yes" : "No");
3672 printf_filtered ("%s\n", target_signal_to_string (oursig
));
3675 /* Specify how various signals in the inferior should be handled. */
3678 handle_command (char *args
, int from_tty
)
3681 int digits
, wordlen
;
3682 int sigfirst
, signum
, siglast
;
3683 enum target_signal oursig
;
3686 unsigned char *sigs
;
3687 struct cleanup
*old_chain
;
3691 error_no_arg ("signal to handle");
3694 /* Allocate and zero an array of flags for which signals to handle. */
3696 nsigs
= (int) TARGET_SIGNAL_LAST
;
3697 sigs
= (unsigned char *) alloca (nsigs
);
3698 memset (sigs
, 0, nsigs
);
3700 /* Break the command line up into args. */
3702 argv
= buildargv (args
);
3707 old_chain
= make_cleanup_freeargv (argv
);
3709 /* Walk through the args, looking for signal oursigs, signal names, and
3710 actions. Signal numbers and signal names may be interspersed with
3711 actions, with the actions being performed for all signals cumulatively
3712 specified. Signal ranges can be specified as <LOW>-<HIGH>. */
3714 while (*argv
!= NULL
)
3716 wordlen
= strlen (*argv
);
3717 for (digits
= 0; isdigit ((*argv
)[digits
]); digits
++)
3721 sigfirst
= siglast
= -1;
3723 if (wordlen
>= 1 && !strncmp (*argv
, "all", wordlen
))
3725 /* Apply action to all signals except those used by the
3726 debugger. Silently skip those. */
3729 siglast
= nsigs
- 1;
3731 else if (wordlen
>= 1 && !strncmp (*argv
, "stop", wordlen
))
3733 SET_SIGS (nsigs
, sigs
, signal_stop
);
3734 SET_SIGS (nsigs
, sigs
, signal_print
);
3736 else if (wordlen
>= 1 && !strncmp (*argv
, "ignore", wordlen
))
3738 UNSET_SIGS (nsigs
, sigs
, signal_program
);
3740 else if (wordlen
>= 2 && !strncmp (*argv
, "print", wordlen
))
3742 SET_SIGS (nsigs
, sigs
, signal_print
);
3744 else if (wordlen
>= 2 && !strncmp (*argv
, "pass", wordlen
))
3746 SET_SIGS (nsigs
, sigs
, signal_program
);
3748 else if (wordlen
>= 3 && !strncmp (*argv
, "nostop", wordlen
))
3750 UNSET_SIGS (nsigs
, sigs
, signal_stop
);
3752 else if (wordlen
>= 3 && !strncmp (*argv
, "noignore", wordlen
))
3754 SET_SIGS (nsigs
, sigs
, signal_program
);
3756 else if (wordlen
>= 4 && !strncmp (*argv
, "noprint", wordlen
))
3758 UNSET_SIGS (nsigs
, sigs
, signal_print
);
3759 UNSET_SIGS (nsigs
, sigs
, signal_stop
);
3761 else if (wordlen
>= 4 && !strncmp (*argv
, "nopass", wordlen
))
3763 UNSET_SIGS (nsigs
, sigs
, signal_program
);
3765 else if (digits
> 0)
3767 /* It is numeric. The numeric signal refers to our own
3768 internal signal numbering from target.h, not to host/target
3769 signal number. This is a feature; users really should be
3770 using symbolic names anyway, and the common ones like
3771 SIGHUP, SIGINT, SIGALRM, etc. will work right anyway. */
3773 sigfirst
= siglast
= (int)
3774 target_signal_from_command (atoi (*argv
));
3775 if ((*argv
)[digits
] == '-')
3778 target_signal_from_command (atoi ((*argv
) + digits
+ 1));
3780 if (sigfirst
> siglast
)
3782 /* Bet he didn't figure we'd think of this case... */
3790 oursig
= target_signal_from_name (*argv
);
3791 if (oursig
!= TARGET_SIGNAL_UNKNOWN
)
3793 sigfirst
= siglast
= (int) oursig
;
3797 /* Not a number and not a recognized flag word => complain. */
3798 error ("Unrecognized or ambiguous flag word: \"%s\".", *argv
);
3802 /* If any signal numbers or symbol names were found, set flags for
3803 which signals to apply actions to. */
3805 for (signum
= sigfirst
; signum
>= 0 && signum
<= siglast
; signum
++)
3807 switch ((enum target_signal
) signum
)
3809 case TARGET_SIGNAL_TRAP
:
3810 case TARGET_SIGNAL_INT
:
3811 if (!allsigs
&& !sigs
[signum
])
3813 if (query ("%s is used by the debugger.\n\
3814 Are you sure you want to change it? ",
3815 target_signal_to_name
3816 ((enum target_signal
) signum
)))
3822 printf_unfiltered ("Not confirmed, unchanged.\n");
3823 gdb_flush (gdb_stdout
);
3827 case TARGET_SIGNAL_0
:
3828 case TARGET_SIGNAL_DEFAULT
:
3829 case TARGET_SIGNAL_UNKNOWN
:
3830 /* Make sure that "all" doesn't print these. */
3841 target_notice_signals (inferior_ptid
);
3845 /* Show the results. */
3846 sig_print_header ();
3847 for (signum
= 0; signum
< nsigs
; signum
++)
3851 sig_print_info (signum
);
3856 do_cleanups (old_chain
);
3860 xdb_handle_command (char *args
, int from_tty
)
3863 struct cleanup
*old_chain
;
3865 /* Break the command line up into args. */
3867 argv
= buildargv (args
);
3872 old_chain
= make_cleanup_freeargv (argv
);
3873 if (argv
[1] != (char *) NULL
)
3878 bufLen
= strlen (argv
[0]) + 20;
3879 argBuf
= (char *) xmalloc (bufLen
);
3883 enum target_signal oursig
;
3885 oursig
= target_signal_from_name (argv
[0]);
3886 memset (argBuf
, 0, bufLen
);
3887 if (strcmp (argv
[1], "Q") == 0)
3888 sprintf (argBuf
, "%s %s", argv
[0], "noprint");
3891 if (strcmp (argv
[1], "s") == 0)
3893 if (!signal_stop
[oursig
])
3894 sprintf (argBuf
, "%s %s", argv
[0], "stop");
3896 sprintf (argBuf
, "%s %s", argv
[0], "nostop");
3898 else if (strcmp (argv
[1], "i") == 0)
3900 if (!signal_program
[oursig
])
3901 sprintf (argBuf
, "%s %s", argv
[0], "pass");
3903 sprintf (argBuf
, "%s %s", argv
[0], "nopass");
3905 else if (strcmp (argv
[1], "r") == 0)
3907 if (!signal_print
[oursig
])
3908 sprintf (argBuf
, "%s %s", argv
[0], "print");
3910 sprintf (argBuf
, "%s %s", argv
[0], "noprint");
3916 handle_command (argBuf
, from_tty
);
3918 printf_filtered ("Invalid signal handling flag.\n");
3923 do_cleanups (old_chain
);
3926 /* Print current contents of the tables set by the handle command.
3927 It is possible we should just be printing signals actually used
3928 by the current target (but for things to work right when switching
3929 targets, all signals should be in the signal tables). */
3932 signals_info (char *signum_exp
, int from_tty
)
3934 enum target_signal oursig
;
3935 sig_print_header ();
3939 /* First see if this is a symbol name. */
3940 oursig
= target_signal_from_name (signum_exp
);
3941 if (oursig
== TARGET_SIGNAL_UNKNOWN
)
3943 /* No, try numeric. */
3945 target_signal_from_command (parse_and_eval_long (signum_exp
));
3947 sig_print_info (oursig
);
3951 printf_filtered ("\n");
3952 /* These ugly casts brought to you by the native VAX compiler. */
3953 for (oursig
= TARGET_SIGNAL_FIRST
;
3954 (int) oursig
< (int) TARGET_SIGNAL_LAST
;
3955 oursig
= (enum target_signal
) ((int) oursig
+ 1))
3959 if (oursig
!= TARGET_SIGNAL_UNKNOWN
3960 && oursig
!= TARGET_SIGNAL_DEFAULT
3961 && oursig
!= TARGET_SIGNAL_0
)
3962 sig_print_info (oursig
);
3965 printf_filtered ("\nUse the \"handle\" command to change these tables.\n");
3968 struct inferior_status
3970 enum target_signal stop_signal
;
3974 int stop_stack_dummy
;
3975 int stopped_by_random_signal
;
3977 CORE_ADDR step_range_start
;
3978 CORE_ADDR step_range_end
;
3979 CORE_ADDR step_frame_address
;
3980 enum step_over_calls_kind step_over_calls
;
3981 CORE_ADDR step_resume_break_address
;
3982 int stop_after_trap
;
3983 int stop_soon_quietly
;
3984 CORE_ADDR selected_frame_address
;
3985 char *stop_registers
;
3987 /* These are here because if call_function_by_hand has written some
3988 registers and then decides to call error(), we better not have changed
3993 int breakpoint_proceeded
;
3994 int restore_stack_info
;
3995 int proceed_to_finish
;
3998 static struct inferior_status
*
3999 xmalloc_inferior_status (void)
4001 struct inferior_status
*inf_status
;
4002 inf_status
= xmalloc (sizeof (struct inferior_status
));
4003 inf_status
->stop_registers
= xmalloc (REGISTER_BYTES
);
4004 inf_status
->registers
= xmalloc (REGISTER_BYTES
);
4009 free_inferior_status (struct inferior_status
*inf_status
)
4011 xfree (inf_status
->registers
);
4012 xfree (inf_status
->stop_registers
);
4017 write_inferior_status_register (struct inferior_status
*inf_status
, int regno
,
4020 int size
= REGISTER_RAW_SIZE (regno
);
4021 void *buf
= alloca (size
);
4022 store_signed_integer (buf
, size
, val
);
4023 memcpy (&inf_status
->registers
[REGISTER_BYTE (regno
)], buf
, size
);
4026 /* Save all of the information associated with the inferior<==>gdb
4027 connection. INF_STATUS is a pointer to a "struct inferior_status"
4028 (defined in inferior.h). */
4030 struct inferior_status
*
4031 save_inferior_status (int restore_stack_info
)
4033 struct inferior_status
*inf_status
= xmalloc_inferior_status ();
4035 inf_status
->stop_signal
= stop_signal
;
4036 inf_status
->stop_pc
= stop_pc
;
4037 inf_status
->stop_step
= stop_step
;
4038 inf_status
->stop_stack_dummy
= stop_stack_dummy
;
4039 inf_status
->stopped_by_random_signal
= stopped_by_random_signal
;
4040 inf_status
->trap_expected
= trap_expected
;
4041 inf_status
->step_range_start
= step_range_start
;
4042 inf_status
->step_range_end
= step_range_end
;
4043 inf_status
->step_frame_address
= step_frame_address
;
4044 inf_status
->step_over_calls
= step_over_calls
;
4045 inf_status
->stop_after_trap
= stop_after_trap
;
4046 inf_status
->stop_soon_quietly
= stop_soon_quietly
;
4047 /* Save original bpstat chain here; replace it with copy of chain.
4048 If caller's caller is walking the chain, they'll be happier if we
4049 hand them back the original chain when restore_inferior_status is
4051 inf_status
->stop_bpstat
= stop_bpstat
;
4052 stop_bpstat
= bpstat_copy (stop_bpstat
);
4053 inf_status
->breakpoint_proceeded
= breakpoint_proceeded
;
4054 inf_status
->restore_stack_info
= restore_stack_info
;
4055 inf_status
->proceed_to_finish
= proceed_to_finish
;
4057 memcpy (inf_status
->stop_registers
, stop_registers
, REGISTER_BYTES
);
4059 read_register_bytes (0, inf_status
->registers
, REGISTER_BYTES
);
4061 record_selected_frame (&(inf_status
->selected_frame_address
),
4062 &(inf_status
->selected_level
));
4066 struct restore_selected_frame_args
4068 CORE_ADDR frame_address
;
4073 restore_selected_frame (void *args
)
4075 struct restore_selected_frame_args
*fr
=
4076 (struct restore_selected_frame_args
*) args
;
4077 struct frame_info
*frame
;
4078 int level
= fr
->level
;
4080 frame
= find_relative_frame (get_current_frame (), &level
);
4082 /* If inf_status->selected_frame_address is NULL, there was no
4083 previously selected frame. */
4084 if (frame
== NULL
||
4085 /* FRAME_FP (frame) != fr->frame_address || */
4086 /* elz: deleted this check as a quick fix to the problem that
4087 for function called by hand gdb creates no internal frame
4088 structure and the real stack and gdb's idea of stack are
4089 different if nested calls by hands are made.
4091 mvs: this worries me. */
4094 warning ("Unable to restore previously selected frame.\n");
4098 select_frame (frame
, fr
->level
);
4104 restore_inferior_status (struct inferior_status
*inf_status
)
4106 stop_signal
= inf_status
->stop_signal
;
4107 stop_pc
= inf_status
->stop_pc
;
4108 stop_step
= inf_status
->stop_step
;
4109 stop_stack_dummy
= inf_status
->stop_stack_dummy
;
4110 stopped_by_random_signal
= inf_status
->stopped_by_random_signal
;
4111 trap_expected
= inf_status
->trap_expected
;
4112 step_range_start
= inf_status
->step_range_start
;
4113 step_range_end
= inf_status
->step_range_end
;
4114 step_frame_address
= inf_status
->step_frame_address
;
4115 step_over_calls
= inf_status
->step_over_calls
;
4116 stop_after_trap
= inf_status
->stop_after_trap
;
4117 stop_soon_quietly
= inf_status
->stop_soon_quietly
;
4118 bpstat_clear (&stop_bpstat
);
4119 stop_bpstat
= inf_status
->stop_bpstat
;
4120 breakpoint_proceeded
= inf_status
->breakpoint_proceeded
;
4121 proceed_to_finish
= inf_status
->proceed_to_finish
;
4123 /* FIXME: Is the restore of stop_registers always needed */
4124 memcpy (stop_registers
, inf_status
->stop_registers
, REGISTER_BYTES
);
4126 /* The inferior can be gone if the user types "print exit(0)"
4127 (and perhaps other times). */
4128 if (target_has_execution
)
4129 write_register_bytes (0, inf_status
->registers
, REGISTER_BYTES
);
4131 /* FIXME: If we are being called after stopping in a function which
4132 is called from gdb, we should not be trying to restore the
4133 selected frame; it just prints a spurious error message (The
4134 message is useful, however, in detecting bugs in gdb (like if gdb
4135 clobbers the stack)). In fact, should we be restoring the
4136 inferior status at all in that case? . */
4138 if (target_has_stack
&& inf_status
->restore_stack_info
)
4140 struct restore_selected_frame_args fr
;
4141 fr
.level
= inf_status
->selected_level
;
4142 fr
.frame_address
= inf_status
->selected_frame_address
;
4143 /* The point of catch_errors is that if the stack is clobbered,
4144 walking the stack might encounter a garbage pointer and error()
4145 trying to dereference it. */
4146 if (catch_errors (restore_selected_frame
, &fr
,
4147 "Unable to restore previously selected frame:\n",
4148 RETURN_MASK_ERROR
) == 0)
4149 /* Error in restoring the selected frame. Select the innermost
4153 select_frame (get_current_frame (), 0);
4157 free_inferior_status (inf_status
);
4161 do_restore_inferior_status_cleanup (void *sts
)
4163 restore_inferior_status (sts
);
4167 make_cleanup_restore_inferior_status (struct inferior_status
*inf_status
)
4169 return make_cleanup (do_restore_inferior_status_cleanup
, inf_status
);
4173 discard_inferior_status (struct inferior_status
*inf_status
)
4175 /* See save_inferior_status for info on stop_bpstat. */
4176 bpstat_clear (&inf_status
->stop_bpstat
);
4177 free_inferior_status (inf_status
);
4180 /* Oft used ptids */
4182 ptid_t minus_one_ptid
;
4184 /* Create a ptid given the necessary PID, LWP, and TID components. */
4187 ptid_build (int pid
, long lwp
, long tid
)
4197 /* Create a ptid from just a pid. */
4200 pid_to_ptid (int pid
)
4202 return ptid_build (pid
, 0, 0);
4205 /* Fetch the pid (process id) component from a ptid. */
4208 ptid_get_pid (ptid_t ptid
)
4213 /* Fetch the lwp (lightweight process) component from a ptid. */
4216 ptid_get_lwp (ptid_t ptid
)
4221 /* Fetch the tid (thread id) component from a ptid. */
4224 ptid_get_tid (ptid_t ptid
)
4229 /* ptid_equal() is used to test equality of two ptids. */
4232 ptid_equal (ptid_t ptid1
, ptid_t ptid2
)
4234 return (ptid1
.pid
== ptid2
.pid
&& ptid1
.lwp
== ptid2
.lwp
4235 && ptid1
.tid
== ptid2
.tid
);
4238 /* restore_inferior_ptid() will be used by the cleanup machinery
4239 to restore the inferior_ptid value saved in a call to
4240 save_inferior_ptid(). */
4243 restore_inferior_ptid (void *arg
)
4245 ptid_t
*saved_ptid_ptr
= arg
;
4246 inferior_ptid
= *saved_ptid_ptr
;
4250 /* Save the value of inferior_ptid so that it may be restored by a
4251 later call to do_cleanups(). Returns the struct cleanup pointer
4252 needed for later doing the cleanup. */
4255 save_inferior_ptid (void)
4257 ptid_t
*saved_ptid_ptr
;
4259 saved_ptid_ptr
= xmalloc (sizeof (ptid_t
));
4260 *saved_ptid_ptr
= inferior_ptid
;
4261 return make_cleanup (restore_inferior_ptid
, saved_ptid_ptr
);
4268 stop_registers
= xmalloc (REGISTER_BYTES
);
4272 _initialize_infrun (void)
4275 register int numsigs
;
4276 struct cmd_list_element
*c
;
4280 register_gdbarch_swap (&stop_registers
, sizeof (stop_registers
), NULL
);
4281 register_gdbarch_swap (NULL
, 0, build_infrun
);
4283 add_info ("signals", signals_info
,
4284 "What debugger does when program gets various signals.\n\
4285 Specify a signal as argument to print info on that signal only.");
4286 add_info_alias ("handle", "signals", 0);
4288 add_com ("handle", class_run
, handle_command
,
4289 concat ("Specify how to handle a signal.\n\
4290 Args are signals and actions to apply to those signals.\n\
4291 Symbolic signals (e.g. SIGSEGV) are recommended but numeric signals\n\
4292 from 1-15 are allowed for compatibility with old versions of GDB.\n\
4293 Numeric ranges may be specified with the form LOW-HIGH (e.g. 1-5).\n\
4294 The special arg \"all\" is recognized to mean all signals except those\n\
4295 used by the debugger, typically SIGTRAP and SIGINT.\n",
4296 "Recognized actions include \"stop\", \"nostop\", \"print\", \"noprint\",\n\
4297 \"pass\", \"nopass\", \"ignore\", or \"noignore\".\n\
4298 Stop means reenter debugger if this signal happens (implies print).\n\
4299 Print means print a message if this signal happens.\n\
4300 Pass means let program see this signal; otherwise program doesn't know.\n\
4301 Ignore is a synonym for nopass and noignore is a synonym for pass.\n\
4302 Pass and Stop may be combined.", NULL
));
4305 add_com ("lz", class_info
, signals_info
,
4306 "What debugger does when program gets various signals.\n\
4307 Specify a signal as argument to print info on that signal only.");
4308 add_com ("z", class_run
, xdb_handle_command
,
4309 concat ("Specify how to handle a signal.\n\
4310 Args are signals and actions to apply to those signals.\n\
4311 Symbolic signals (e.g. SIGSEGV) are recommended but numeric signals\n\
4312 from 1-15 are allowed for compatibility with old versions of GDB.\n\
4313 Numeric ranges may be specified with the form LOW-HIGH (e.g. 1-5).\n\
4314 The special arg \"all\" is recognized to mean all signals except those\n\
4315 used by the debugger, typically SIGTRAP and SIGINT.\n",
4316 "Recognized actions include \"s\" (toggles between stop and nostop), \n\
4317 \"r\" (toggles between print and noprint), \"i\" (toggles between pass and \
4318 nopass), \"Q\" (noprint)\n\
4319 Stop means reenter debugger if this signal happens (implies print).\n\
4320 Print means print a message if this signal happens.\n\
4321 Pass means let program see this signal; otherwise program doesn't know.\n\
4322 Ignore is a synonym for nopass and noignore is a synonym for pass.\n\
4323 Pass and Stop may be combined.", NULL
));
4327 stop_command
= add_cmd ("stop", class_obscure
, not_just_help_class_command
,
4328 "There is no `stop' command, but you can set a hook on `stop'.\n\
4329 This allows you to set a list of commands to be run each time execution\n\
4330 of the program stops.", &cmdlist
);
4332 numsigs
= (int) TARGET_SIGNAL_LAST
;
4333 signal_stop
= (unsigned char *)
4334 xmalloc (sizeof (signal_stop
[0]) * numsigs
);
4335 signal_print
= (unsigned char *)
4336 xmalloc (sizeof (signal_print
[0]) * numsigs
);
4337 signal_program
= (unsigned char *)
4338 xmalloc (sizeof (signal_program
[0]) * numsigs
);
4339 for (i
= 0; i
< numsigs
; i
++)
4342 signal_print
[i
] = 1;
4343 signal_program
[i
] = 1;
4346 /* Signals caused by debugger's own actions
4347 should not be given to the program afterwards. */
4348 signal_program
[TARGET_SIGNAL_TRAP
] = 0;
4349 signal_program
[TARGET_SIGNAL_INT
] = 0;
4351 /* Signals that are not errors should not normally enter the debugger. */
4352 signal_stop
[TARGET_SIGNAL_ALRM
] = 0;
4353 signal_print
[TARGET_SIGNAL_ALRM
] = 0;
4354 signal_stop
[TARGET_SIGNAL_VTALRM
] = 0;
4355 signal_print
[TARGET_SIGNAL_VTALRM
] = 0;
4356 signal_stop
[TARGET_SIGNAL_PROF
] = 0;
4357 signal_print
[TARGET_SIGNAL_PROF
] = 0;
4358 signal_stop
[TARGET_SIGNAL_CHLD
] = 0;
4359 signal_print
[TARGET_SIGNAL_CHLD
] = 0;
4360 signal_stop
[TARGET_SIGNAL_IO
] = 0;
4361 signal_print
[TARGET_SIGNAL_IO
] = 0;
4362 signal_stop
[TARGET_SIGNAL_POLL
] = 0;
4363 signal_print
[TARGET_SIGNAL_POLL
] = 0;
4364 signal_stop
[TARGET_SIGNAL_URG
] = 0;
4365 signal_print
[TARGET_SIGNAL_URG
] = 0;
4366 signal_stop
[TARGET_SIGNAL_WINCH
] = 0;
4367 signal_print
[TARGET_SIGNAL_WINCH
] = 0;
4369 /* These signals are used internally by user-level thread
4370 implementations. (See signal(5) on Solaris.) Like the above
4371 signals, a healthy program receives and handles them as part of
4372 its normal operation. */
4373 signal_stop
[TARGET_SIGNAL_LWP
] = 0;
4374 signal_print
[TARGET_SIGNAL_LWP
] = 0;
4375 signal_stop
[TARGET_SIGNAL_WAITING
] = 0;
4376 signal_print
[TARGET_SIGNAL_WAITING
] = 0;
4377 signal_stop
[TARGET_SIGNAL_CANCEL
] = 0;
4378 signal_print
[TARGET_SIGNAL_CANCEL
] = 0;
4382 (add_set_cmd ("stop-on-solib-events", class_support
, var_zinteger
,
4383 (char *) &stop_on_solib_events
,
4384 "Set stopping for shared library events.\n\
4385 If nonzero, gdb will give control to the user when the dynamic linker\n\
4386 notifies gdb of shared library events. The most common event of interest\n\
4387 to the user would be loading/unloading of a new library.\n",
4392 c
= add_set_enum_cmd ("follow-fork-mode",
4394 follow_fork_mode_kind_names
,
4395 &follow_fork_mode_string
,
4396 /* ??rehrauer: The "both" option is broken, by what may be a 10.20
4397 kernel problem. It's also not terribly useful without a GUI to
4398 help the user drive two debuggers. So for now, I'm disabling
4399 the "both" option. */
4400 /* "Set debugger response to a program call of fork \
4402 A fork or vfork creates a new process. follow-fork-mode can be:\n\
4403 parent - the original process is debugged after a fork\n\
4404 child - the new process is debugged after a fork\n\
4405 both - both the parent and child are debugged after a fork\n\
4406 ask - the debugger will ask for one of the above choices\n\
4407 For \"both\", another copy of the debugger will be started to follow\n\
4408 the new child process. The original debugger will continue to follow\n\
4409 the original parent process. To distinguish their prompts, the\n\
4410 debugger copy's prompt will be changed.\n\
4411 For \"parent\" or \"child\", the unfollowed process will run free.\n\
4412 By default, the debugger will follow the parent process.",
4414 "Set debugger response to a program call of fork \
4416 A fork or vfork creates a new process. follow-fork-mode can be:\n\
4417 parent - the original process is debugged after a fork\n\
4418 child - the new process is debugged after a fork\n\
4419 ask - the debugger will ask for one of the above choices\n\
4420 For \"parent\" or \"child\", the unfollowed process will run free.\n\
4421 By default, the debugger will follow the parent process.",
4423 /* c->function.sfunc = ; */
4424 add_show_from_set (c
, &showlist
);
4426 c
= add_set_enum_cmd ("scheduler-locking", class_run
,
4427 scheduler_enums
, /* array of string names */
4428 &scheduler_mode
, /* current mode */
4429 "Set mode for locking scheduler during execution.\n\
4430 off == no locking (threads may preempt at any time)\n\
4431 on == full locking (no thread except the current thread may run)\n\
4432 step == scheduler locked during every single-step operation.\n\
4433 In this mode, no other thread may run during a step command.\n\
4434 Other threads may run while stepping over a function call ('next').",
4437 c
->function
.sfunc
= set_schedlock_func
; /* traps on target vector */
4438 add_show_from_set (c
, &showlist
);
4440 c
= add_set_cmd ("step-mode", class_run
,
4441 var_boolean
, (char*) &step_stop_if_no_debug
,
4442 "Set mode of the step operation. When set, doing a step over a\n\
4443 function without debug line information will stop at the first\n\
4444 instruction of that function. Otherwise, the function is skipped and\n\
4445 the step command stops at a different source line.",
4447 add_show_from_set (c
, &showlist
);
4449 /* ptid initializations */
4450 null_ptid
= ptid_build (0, 0, 0);
4451 minus_one_ptid
= ptid_build (-1, 0, 0);
4452 inferior_ptid
= null_ptid
;
4453 target_last_wait_ptid
= minus_one_ptid
;