1 /* Target-struct-independent code to start (run) and stop an inferior process.
2 Copyright 1986-1989, 1991-1999 Free Software Foundation, Inc.
4 This file is part of GDB.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
21 #include "gdb_string.h"
26 #include "breakpoint.h"
31 #include "gdbthread.h"
33 #include "symfile.h" /* for overlay functions */
38 /* Prototypes for local functions */
40 static void signals_info
PARAMS ((char *, int));
42 static void handle_command
PARAMS ((char *, int));
44 static void sig_print_info
PARAMS ((enum target_signal
));
46 static void sig_print_header
PARAMS ((void));
48 static void resume_cleanups
PARAMS ((int));
50 static int hook_stop_stub
PARAMS ((PTR
));
52 static void delete_breakpoint_current_contents
PARAMS ((PTR
));
54 static void set_follow_fork_mode_command
PARAMS ((char *arg
, int from_tty
, struct cmd_list_element
*c
));
56 int inferior_ignoring_startup_exec_events
= 0;
57 int inferior_ignoring_leading_exec_events
= 0;
59 /* wait_for_inferior and normal_stop use this to notify the user
60 when the inferior stopped in a different thread than it had been
62 static int switched_from_inferior_pid
;
64 /* This will be true for configurations that may actually report an
65 inferior pid different from the original. At present this is only
66 true for HP-UX native. */
68 #ifndef MAY_SWITCH_FROM_INFERIOR_PID
69 #define MAY_SWITCH_FROM_INFERIOR_PID (0)
72 static int may_switch_from_inferior_pid
= MAY_SWITCH_FROM_INFERIOR_PID
;
74 /* This is true for configurations that may follow through execl() and
75 similar functions. At present this is only true for HP-UX native. */
77 #ifndef MAY_FOLLOW_EXEC
78 #define MAY_FOLLOW_EXEC (0)
81 static int may_follow_exec
= MAY_FOLLOW_EXEC
;
83 /* resume and wait_for_inferior use this to ensure that when
84 stepping over a hit breakpoint in a threaded application
85 only the thread that hit the breakpoint is stepped and the
86 other threads don't continue. This prevents having another
87 thread run past the breakpoint while it is temporarily
90 This is not thread-specific, so it isn't saved as part of
93 Versions of gdb which don't use the "step == this thread steps
94 and others continue" model but instead use the "step == this
95 thread steps and others wait" shouldn't do this. */
96 static int thread_step_needed
= 0;
98 /* This is true if thread_step_needed should actually be used. At
99 present this is only true for HP-UX native. */
101 #ifndef USE_THREAD_STEP_NEEDED
102 #define USE_THREAD_STEP_NEEDED (0)
105 static int use_thread_step_needed
= USE_THREAD_STEP_NEEDED
;
107 void _initialize_infrun
PARAMS ((void));
109 /* GET_LONGJMP_TARGET returns the PC at which longjmp() will resume the
110 program. It needs to examine the jmp_buf argument and extract the PC
111 from it. The return value is non-zero on success, zero otherwise. */
113 #ifndef GET_LONGJMP_TARGET
114 #define GET_LONGJMP_TARGET(PC_ADDR) 0
118 /* Some machines have trampoline code that sits between function callers
119 and the actual functions themselves. If this machine doesn't have
120 such things, disable their processing. */
122 #ifndef SKIP_TRAMPOLINE_CODE
123 #define SKIP_TRAMPOLINE_CODE(pc) 0
126 /* Dynamic function trampolines are similar to solib trampolines in that they
127 are between the caller and the callee. The difference is that when you
128 enter a dynamic trampoline, you can't determine the callee's address. Some
129 (usually complex) code needs to run in the dynamic trampoline to figure out
130 the callee's address. This macro is usually called twice. First, when we
131 enter the trampoline (looks like a normal function call at that point). It
132 should return the PC of a point within the trampoline where the callee's
133 address is known. Second, when we hit the breakpoint, this routine returns
134 the callee's address. At that point, things proceed as per a step resume
137 #ifndef DYNAMIC_TRAMPOLINE_NEXTPC
138 #define DYNAMIC_TRAMPOLINE_NEXTPC(pc) 0
141 /* On SVR4 based systems, determining the callee's address is exceedingly
142 difficult and depends on the implementation of the run time loader.
143 If we are stepping at the source level, we single step until we exit
144 the run time loader code and reach the callee's address. */
146 #ifndef IN_SOLIB_DYNSYM_RESOLVE_CODE
147 #define IN_SOLIB_DYNSYM_RESOLVE_CODE(pc) 0
150 /* For SVR4 shared libraries, each call goes through a small piece of
151 trampoline code in the ".plt" section. IN_SOLIB_CALL_TRAMPOLINE evaluates
152 to nonzero if we are current stopped in one of these. */
154 #ifndef IN_SOLIB_CALL_TRAMPOLINE
155 #define IN_SOLIB_CALL_TRAMPOLINE(pc,name) 0
158 /* In some shared library schemes, the return path from a shared library
159 call may need to go through a trampoline too. */
161 #ifndef IN_SOLIB_RETURN_TRAMPOLINE
162 #define IN_SOLIB_RETURN_TRAMPOLINE(pc,name) 0
165 /* This function returns TRUE if pc is the address of an instruction
166 that lies within the dynamic linker (such as the event hook, or the
169 This function must be used only when a dynamic linker event has
170 been caught, and the inferior is being stepped out of the hook, or
171 undefined results are guaranteed. */
173 #ifndef SOLIB_IN_DYNAMIC_LINKER
174 #define SOLIB_IN_DYNAMIC_LINKER(pid,pc) 0
177 /* On MIPS16, a function that returns a floating point value may call
178 a library helper function to copy the return value to a floating point
179 register. The IGNORE_HELPER_CALL macro returns non-zero if we
180 should ignore (i.e. step over) this function call. */
181 #ifndef IGNORE_HELPER_CALL
182 #define IGNORE_HELPER_CALL(pc) 0
185 /* On some systems, the PC may be left pointing at an instruction that won't
186 actually be executed. This is usually indicated by a bit in the PSW. If
187 we find ourselves in such a state, then we step the target beyond the
188 nullified instruction before returning control to the user so as to avoid
191 #ifndef INSTRUCTION_NULLIFIED
192 #define INSTRUCTION_NULLIFIED 0
195 /* Convert the #defines into values. This is temporary until wfi control
196 flow is completely sorted out. */
198 #ifndef HAVE_STEPPABLE_WATCHPOINT
199 #define HAVE_STEPPABLE_WATCHPOINT 0
201 #undef HAVE_STEPPABLE_WATCHPOINT
202 #define HAVE_STEPPABLE_WATCHPOINT 1
205 #ifndef HAVE_NONSTEPPABLE_WATCHPOINT
206 #define HAVE_NONSTEPPABLE_WATCHPOINT 0
208 #undef HAVE_NONSTEPPABLE_WATCHPOINT
209 #define HAVE_NONSTEPPABLE_WATCHPOINT 1
212 #ifndef HAVE_CONTINUABLE_WATCHPOINT
213 #define HAVE_CONTINUABLE_WATCHPOINT 0
215 #undef HAVE_CONTINUABLE_WATCHPOINT
216 #define HAVE_CONTINUABLE_WATCHPOINT 1
219 /* Tables of how to react to signals; the user sets them. */
221 static unsigned char *signal_stop
;
222 static unsigned char *signal_print
;
223 static unsigned char *signal_program
;
225 #define SET_SIGS(nsigs,sigs,flags) \
227 int signum = (nsigs); \
228 while (signum-- > 0) \
229 if ((sigs)[signum]) \
230 (flags)[signum] = 1; \
233 #define UNSET_SIGS(nsigs,sigs,flags) \
235 int signum = (nsigs); \
236 while (signum-- > 0) \
237 if ((sigs)[signum]) \
238 (flags)[signum] = 0; \
242 /* Command list pointer for the "stop" placeholder. */
244 static struct cmd_list_element
*stop_command
;
246 /* Nonzero if breakpoints are now inserted in the inferior. */
248 static int breakpoints_inserted
;
250 /* Function inferior was in as of last step command. */
252 static struct symbol
*step_start_function
;
254 /* Nonzero if we are expecting a trace trap and should proceed from it. */
256 static int trap_expected
;
259 /* Nonzero if we want to give control to the user when we're notified
260 of shared library events by the dynamic linker. */
261 static int stop_on_solib_events
;
265 /* Nonzero if the next time we try to continue the inferior, it will
266 step one instruction and generate a spurious trace trap.
267 This is used to compensate for a bug in HP-UX. */
269 static int trap_expected_after_continue
;
272 /* Nonzero means expecting a trace trap
273 and should stop the inferior and return silently when it happens. */
277 /* Nonzero means expecting a trap and caller will handle it themselves.
278 It is used after attach, due to attaching to a process;
279 when running in the shell before the child program has been exec'd;
280 and when running some kinds of remote stuff (FIXME?). */
282 int stop_soon_quietly
;
284 /* Nonzero if proceed is being used for a "finish" command or a similar
285 situation when stop_registers should be saved. */
287 int proceed_to_finish
;
289 /* Save register contents here when about to pop a stack dummy frame,
290 if-and-only-if proceed_to_finish is set.
291 Thus this contains the return value from the called function (assuming
292 values are returned in a register). */
294 char *stop_registers
;
296 /* Nonzero if program stopped due to error trying to insert breakpoints. */
298 static int breakpoints_failed
;
300 /* Nonzero after stop if current stack frame should be printed. */
302 static int stop_print_frame
;
304 static struct breakpoint
*step_resume_breakpoint
= NULL
;
305 static struct breakpoint
*through_sigtramp_breakpoint
= NULL
;
307 /* On some platforms (e.g., HP-UX), hardware watchpoints have bad
308 interactions with an inferior that is running a kernel function
309 (aka, a system call or "syscall"). wait_for_inferior therefore
310 may have a need to know when the inferior is in a syscall. This
311 is a count of the number of inferior threads which are known to
312 currently be running in a syscall. */
313 static int number_of_threads_in_syscalls
;
315 /* This is used to remember when a fork, vfork or exec event
316 was caught by a catchpoint, and thus the event is to be
317 followed at the next resume of the inferior, and not
321 enum target_waitkind kind
;
331 char *execd_pathname
;
335 /* Some platforms don't allow us to do anything meaningful with a
336 vforked child until it has exec'd. Vforked processes on such
337 platforms can only be followed after they've exec'd.
339 When this is set to 0, a vfork can be immediately followed,
340 and an exec can be followed merely as an exec. When this is
341 set to 1, a vfork event has been seen, but cannot be followed
342 until the exec is seen.
344 (In the latter case, inferior_pid is still the parent of the
345 vfork, and pending_follow.fork_event.child_pid is the child. The
346 appropriate process is followed, according to the setting of
347 follow-fork-mode.) */
348 static int follow_vfork_when_exec
;
350 static char *follow_fork_mode_kind_names
[] =
352 /* ??rehrauer: The "both" option is broken, by what may be a 10.20
353 kernel problem. It's also not terribly useful without a GUI to
354 help the user drive two debuggers. So for now, I'm disabling
356 "parent", "child", "both", "ask" };
358 "parent", "child", "ask"};
360 static char *follow_fork_mode_string
= NULL
;
364 follow_inferior_fork (parent_pid
, child_pid
, has_forked
, has_vforked
)
370 int followed_parent
= 0;
371 int followed_child
= 0;
374 /* Which process did the user want us to follow? */
376 savestring (follow_fork_mode_string
, strlen (follow_fork_mode_string
));
378 /* Or, did the user not know, and want us to ask? */
379 if (STREQ (follow_fork_mode_string
, "ask"))
381 char requested_mode
[100];
384 error ("\"ask\" mode NYI");
385 follow_mode
= savestring (requested_mode
, strlen (requested_mode
));
388 /* If we're to be following the parent, then detach from child_pid.
389 We're already following the parent, so need do nothing explicit
391 if (STREQ (follow_mode
, "parent"))
395 /* We're already attached to the parent, by default. */
397 /* Before detaching from the child, remove all breakpoints from
398 it. (This won't actually modify the breakpoint list, but will
399 physically remove the breakpoints from the child.) */
400 if (!has_vforked
|| !follow_vfork_when_exec
)
402 detach_breakpoints (child_pid
);
403 #ifdef SOLIB_REMOVE_INFERIOR_HOOK
404 SOLIB_REMOVE_INFERIOR_HOOK (child_pid
);
408 /* Detach from the child. */
411 target_require_detach (child_pid
, "", 1);
414 /* If we're to be following the child, then attach to it, detach
415 from inferior_pid, and set inferior_pid to child_pid. */
416 else if (STREQ (follow_mode
, "child"))
418 char child_pid_spelling
[100]; /* Arbitrary length. */
422 /* Before detaching from the parent, detach all breakpoints from
423 the child. But only if we're forking, or if we follow vforks
424 as soon as they happen. (If we're following vforks only when
425 the child has exec'd, then it's very wrong to try to write
426 back the "shadow contents" of inserted breakpoints now -- they
427 belong to the child's pre-exec'd a.out.) */
428 if (!has_vforked
|| !follow_vfork_when_exec
)
430 detach_breakpoints (child_pid
);
433 /* Before detaching from the parent, remove all breakpoints from it. */
434 remove_breakpoints ();
436 /* Also reset the solib inferior hook from the parent. */
437 #ifdef SOLIB_REMOVE_INFERIOR_HOOK
438 SOLIB_REMOVE_INFERIOR_HOOK (inferior_pid
);
441 /* Detach from the parent. */
443 target_detach (NULL
, 1);
445 /* Attach to the child. */
446 inferior_pid
= child_pid
;
447 sprintf (child_pid_spelling
, "%d", child_pid
);
450 target_require_attach (child_pid_spelling
, 1);
452 /* Was there a step_resume breakpoint? (There was if the user
453 did a "next" at the fork() call.) If so, explicitly reset its
456 step_resumes are a form of bp that are made to be per-thread.
457 Since we created the step_resume bp when the parent process
458 was being debugged, and now are switching to the child process,
459 from the breakpoint package's viewpoint, that's a switch of
460 "threads". We must update the bp's notion of which thread
461 it is for, or it'll be ignored when it triggers... */
462 if (step_resume_breakpoint
&&
463 (!has_vforked
|| !follow_vfork_when_exec
))
464 breakpoint_re_set_thread (step_resume_breakpoint
);
466 /* Reinsert all breakpoints in the child. (The user may've set
467 breakpoints after catching the fork, in which case those
468 actually didn't get set in the child, but only in the parent.) */
469 if (!has_vforked
|| !follow_vfork_when_exec
)
471 breakpoint_re_set ();
472 insert_breakpoints ();
476 /* If we're to be following both parent and child, then fork ourselves,
477 and attach the debugger clone to the child. */
478 else if (STREQ (follow_mode
, "both"))
480 char pid_suffix
[100]; /* Arbitrary length. */
482 /* Clone ourselves to follow the child. This is the end of our
483 involvement with child_pid; our clone will take it from here... */
485 target_clone_and_follow_inferior (child_pid
, &followed_child
);
486 followed_parent
= !followed_child
;
488 /* We continue to follow the parent. To help distinguish the two
489 debuggers, though, both we and our clone will reset our prompts. */
490 sprintf (pid_suffix
, "[%d] ", inferior_pid
);
491 set_prompt (strcat (get_prompt (), pid_suffix
));
494 /* The parent and child of a vfork share the same address space.
495 Also, on some targets the order in which vfork and exec events
496 are received for parent in child requires some delicate handling
499 For instance, on ptrace-based HPUX we receive the child's vfork
500 event first, at which time the parent has been suspended by the
501 OS and is essentially untouchable until the child's exit or second
502 exec event arrives. At that time, the parent's vfork event is
503 delivered to us, and that's when we see and decide how to follow
504 the vfork. But to get to that point, we must continue the child
505 until it execs or exits. To do that smoothly, all breakpoints
506 must be removed from the child, in case there are any set between
507 the vfork() and exec() calls. But removing them from the child
508 also removes them from the parent, due to the shared-address-space
509 nature of a vfork'd parent and child. On HPUX, therefore, we must
510 take care to restore the bp's to the parent before we continue it.
511 Else, it's likely that we may not stop in the expected place. (The
512 worst scenario is when the user tries to step over a vfork() call;
513 the step-resume bp must be restored for the step to properly stop
514 in the parent after the call completes!)
516 Sequence of events, as reported to gdb from HPUX:
518 Parent Child Action for gdb to take
519 -------------------------------------------------------
520 1 VFORK Continue child
526 target_post_follow_vfork (parent_pid
,
532 pending_follow
.fork_event
.saw_parent_fork
= 0;
533 pending_follow
.fork_event
.saw_child_fork
= 0;
539 follow_fork (parent_pid
, child_pid
)
543 follow_inferior_fork (parent_pid
, child_pid
, 1, 0);
547 /* Forward declaration. */
548 static void follow_exec
PARAMS ((int, char *));
551 follow_vfork (parent_pid
, child_pid
)
555 follow_inferior_fork (parent_pid
, child_pid
, 0, 1);
557 /* Did we follow the child? Had it exec'd before we saw the parent vfork? */
558 if (pending_follow
.fork_event
.saw_child_exec
&& (inferior_pid
== child_pid
))
560 pending_follow
.fork_event
.saw_child_exec
= 0;
561 pending_follow
.kind
= TARGET_WAITKIND_SPURIOUS
;
562 follow_exec (inferior_pid
, pending_follow
.execd_pathname
);
563 free (pending_follow
.execd_pathname
);
568 follow_exec (pid
, execd_pathname
)
570 char *execd_pathname
;
573 struct target_ops
*tgt
;
575 if (!may_follow_exec
)
578 /* Did this exec() follow a vfork()? If so, we must follow the
579 vfork now too. Do it before following the exec. */
580 if (follow_vfork_when_exec
&&
581 (pending_follow
.kind
== TARGET_WAITKIND_VFORKED
))
583 pending_follow
.kind
= TARGET_WAITKIND_SPURIOUS
;
584 follow_vfork (inferior_pid
, pending_follow
.fork_event
.child_pid
);
585 follow_vfork_when_exec
= 0;
586 saved_pid
= inferior_pid
;
588 /* Did we follow the parent? If so, we're done. If we followed
589 the child then we must also follow its exec(). */
590 if (inferior_pid
== pending_follow
.fork_event
.parent_pid
)
594 /* This is an exec event that we actually wish to pay attention to.
595 Refresh our symbol table to the newly exec'd program, remove any
598 If there are breakpoints, they aren't really inserted now,
599 since the exec() transformed our inferior into a fresh set
602 We want to preserve symbolic breakpoints on the list, since
603 we have hopes that they can be reset after the new a.out's
604 symbol table is read.
606 However, any "raw" breakpoints must be removed from the list
607 (e.g., the solib bp's), since their address is probably invalid
610 And, we DON'T want to call delete_breakpoints() here, since
611 that may write the bp's "shadow contents" (the instruction
612 value that was overwritten witha TRAP instruction). Since
613 we now have a new a.out, those shadow contents aren't valid. */
614 update_breakpoints_after_exec ();
616 /* If there was one, it's gone now. We cannot truly step-to-next
617 statement through an exec(). */
618 step_resume_breakpoint
= NULL
;
619 step_range_start
= 0;
622 /* If there was one, it's gone now. */
623 through_sigtramp_breakpoint
= NULL
;
625 /* What is this a.out's name? */
626 printf_unfiltered ("Executing new program: %s\n", execd_pathname
);
628 /* We've followed the inferior through an exec. Therefore, the
629 inferior has essentially been killed & reborn. */
631 /* First collect the run target in effect. */
632 tgt
= find_run_target ();
633 /* If we can't find one, things are in a very strange state... */
635 error ("Could find run target to save before following exec");
637 gdb_flush (gdb_stdout
);
638 target_mourn_inferior ();
639 inferior_pid
= saved_pid
; /* Because mourn_inferior resets inferior_pid. */
642 /* That a.out is now the one to use. */
643 exec_file_attach (execd_pathname
, 0);
645 /* And also is where symbols can be found. */
646 symbol_file_command (execd_pathname
, 0);
648 /* Reset the shared library package. This ensures that we get
649 a shlib event when the child reaches "_start", at which point
650 the dld will have had a chance to initialize the child. */
651 #if defined(SOLIB_RESTART)
654 #ifdef SOLIB_CREATE_INFERIOR_HOOK
655 SOLIB_CREATE_INFERIOR_HOOK (inferior_pid
);
658 /* Reinsert all breakpoints. (Those which were symbolic have
659 been reset to the proper address in the new a.out, thanks
660 to symbol_file_command...) */
661 insert_breakpoints ();
663 /* The next resume of this inferior should bring it to the shlib
664 startup breakpoints. (If the user had also set bp's on
665 "main" from the old (parent) process, then they'll auto-
666 matically get reset there in the new process.) */
669 /* Non-zero if we just simulating a single-step. This is needed
670 because we cannot remove the breakpoints in the inferior process
671 until after the `wait' in `wait_for_inferior'. */
672 static int singlestep_breakpoints_inserted_p
= 0;
675 /* Things to clean up if we QUIT out of resume (). */
678 resume_cleanups (arg
)
684 static char schedlock_off
[] = "off";
685 static char schedlock_on
[] = "on";
686 static char schedlock_step
[] = "step";
687 static char *scheduler_mode
= schedlock_off
;
688 static char *scheduler_enums
[] =
689 {schedlock_off
, schedlock_on
, schedlock_step
};
692 set_schedlock_func (args
, from_tty
, c
)
695 struct cmd_list_element
*c
;
697 if (c
->type
== set_cmd
)
698 if (!target_can_lock_scheduler
)
700 scheduler_mode
= schedlock_off
;
701 error ("Target '%s' cannot support this command.",
707 /* Resume the inferior, but allow a QUIT. This is useful if the user
708 wants to interrupt some lengthy single-stepping operation
709 (for child processes, the SIGINT goes to the inferior, and so
710 we get a SIGINT random_signal, but for remote debugging and perhaps
711 other targets, that's not true).
713 STEP nonzero if we should step (zero to continue instead).
714 SIG is the signal to give the inferior (zero for none). */
718 enum target_signal sig
;
720 int should_resume
= 1;
721 struct cleanup
*old_cleanups
= make_cleanup ((make_cleanup_func
)
725 #ifdef CANNOT_STEP_BREAKPOINT
726 /* Most targets can step a breakpoint instruction, thus executing it
727 normally. But if this one cannot, just continue and we will hit
729 if (step
&& breakpoints_inserted
&& breakpoint_here_p (read_pc ()))
733 if (SOFTWARE_SINGLE_STEP_P
&& step
)
735 /* Do it the hard way, w/temp breakpoints */
736 SOFTWARE_SINGLE_STEP (sig
, 1 /*insert-breakpoints*/ );
737 /* ...and don't ask hardware to do it. */
739 /* and do not pull these breakpoints until after a `wait' in
740 `wait_for_inferior' */
741 singlestep_breakpoints_inserted_p
= 1;
744 /* Handle any optimized stores to the inferior NOW... */
745 #ifdef DO_DEFERRED_STORES
749 /* If there were any forks/vforks/execs that were caught and are
750 now to be followed, then do so. */
751 switch (pending_follow
.kind
)
753 case (TARGET_WAITKIND_FORKED
):
754 pending_follow
.kind
= TARGET_WAITKIND_SPURIOUS
;
755 follow_fork (inferior_pid
, pending_follow
.fork_event
.child_pid
);
758 case (TARGET_WAITKIND_VFORKED
):
760 int saw_child_exec
= pending_follow
.fork_event
.saw_child_exec
;
762 pending_follow
.kind
= TARGET_WAITKIND_SPURIOUS
;
763 follow_vfork (inferior_pid
, pending_follow
.fork_event
.child_pid
);
765 /* Did we follow the child, but not yet see the child's exec event?
766 If so, then it actually ought to be waiting for us; we respond to
767 parent vfork events. We don't actually want to resume the child
768 in this situation; we want to just get its exec event. */
769 if (!saw_child_exec
&&
770 (inferior_pid
== pending_follow
.fork_event
.child_pid
))
775 case (TARGET_WAITKIND_EXECD
):
776 /* If we saw a vfork event but couldn't follow it until we saw
777 an exec, then now might be the time! */
778 pending_follow
.kind
= TARGET_WAITKIND_SPURIOUS
;
779 /* follow_exec is called as soon as the exec event is seen. */
786 /* Install inferior's terminal modes. */
787 target_terminal_inferior ();
791 if (use_thread_step_needed
&& thread_step_needed
)
793 /* We stopped on a BPT instruction;
794 don't continue other threads and
795 just step this thread. */
796 thread_step_needed
= 0;
798 if (!breakpoint_here_p (read_pc ()))
800 /* Breakpoint deleted: ok to do regular resume
801 where all the threads either step or continue. */
802 target_resume (-1, step
, sig
);
808 warning ("Internal error, changing continue to step.");
809 remove_breakpoints ();
810 breakpoints_inserted
= 0;
815 target_resume (inferior_pid
, step
, sig
);
820 /* Vanilla resume. */
822 if ((scheduler_mode
== schedlock_on
) ||
823 (scheduler_mode
== schedlock_step
&& step
!= 0))
824 target_resume (inferior_pid
, step
, sig
);
826 target_resume (-1, step
, sig
);
830 discard_cleanups (old_cleanups
);
834 /* Clear out all variables saying what to do when inferior is continued.
835 First do this, then set the ones you want, then call `proceed'. */
838 clear_proceed_status ()
841 step_range_start
= 0;
843 step_frame_address
= 0;
844 step_over_calls
= -1;
846 stop_soon_quietly
= 0;
847 proceed_to_finish
= 0;
848 breakpoint_proceeded
= 1; /* We're about to proceed... */
850 /* Discard any remaining commands or status from previous stop. */
851 bpstat_clear (&stop_bpstat
);
854 /* Basic routine for continuing the program in various fashions.
856 ADDR is the address to resume at, or -1 for resume where stopped.
857 SIGGNAL is the signal to give it, or 0 for none,
858 or -1 for act according to how it stopped.
859 STEP is nonzero if should trap after one instruction.
860 -1 means return after that and print nothing.
861 You should probably set various step_... variables
862 before calling here, if you are stepping.
864 You should call clear_proceed_status before calling proceed. */
867 proceed (addr
, siggnal
, step
)
869 enum target_signal siggnal
;
875 step_start_function
= find_pc_function (read_pc ());
879 if (addr
== (CORE_ADDR
) - 1)
881 /* If there is a breakpoint at the address we will resume at,
882 step one instruction before inserting breakpoints
883 so that we do not stop right away (and report a second
884 hit at this breakpoint). */
886 if (read_pc () == stop_pc
&& breakpoint_here_p (read_pc ()))
889 #ifndef STEP_SKIPS_DELAY
890 #define STEP_SKIPS_DELAY(pc) (0)
891 #define STEP_SKIPS_DELAY_P (0)
893 /* Check breakpoint_here_p first, because breakpoint_here_p is fast
894 (it just checks internal GDB data structures) and STEP_SKIPS_DELAY
895 is slow (it needs to read memory from the target). */
896 if (STEP_SKIPS_DELAY_P
897 && breakpoint_here_p (read_pc () + 4)
898 && STEP_SKIPS_DELAY (read_pc ()))
905 /* New address; we don't need to single-step a thread
906 over a breakpoint we just hit, 'cause we aren't
907 continuing from there.
909 It's not worth worrying about the case where a user
910 asks for a "jump" at the current PC--if they get the
911 hiccup of re-hiting a hit breakpoint, what else do
913 thread_step_needed
= 0;
916 #ifdef PREPARE_TO_PROCEED
917 /* In a multi-threaded task we may select another thread
918 and then continue or step.
920 But if the old thread was stopped at a breakpoint, it
921 will immediately cause another breakpoint stop without
922 any execution (i.e. it will report a breakpoint hit
923 incorrectly). So we must step over it first.
925 PREPARE_TO_PROCEED checks the current thread against the thread
926 that reported the most recent event. If a step-over is required
927 it returns TRUE and sets the current thread to the old thread. */
928 if (PREPARE_TO_PROCEED () && breakpoint_here_p (read_pc ()))
931 thread_step_needed
= 1;
934 #endif /* PREPARE_TO_PROCEED */
937 if (trap_expected_after_continue
)
939 /* If (step == 0), a trap will be automatically generated after
940 the first instruction is executed. Force step one
941 instruction to clear this condition. This should not occur
942 if step is nonzero, but it is harmless in that case. */
944 trap_expected_after_continue
= 0;
946 #endif /* HP_OS_BUG */
949 /* We will get a trace trap after one instruction.
950 Continue it automatically and insert breakpoints then. */
954 int temp
= insert_breakpoints ();
957 print_sys_errmsg ("ptrace", temp
);
958 error ("Cannot insert breakpoints.\n\
959 The same program may be running in another process.");
962 breakpoints_inserted
= 1;
965 if (siggnal
!= TARGET_SIGNAL_DEFAULT
)
966 stop_signal
= siggnal
;
967 /* If this signal should not be seen by program,
968 give it zero. Used for debugging signals. */
969 else if (!signal_program
[stop_signal
])
970 stop_signal
= TARGET_SIGNAL_0
;
972 annotate_starting ();
974 /* Make sure that output from GDB appears before output from the
976 gdb_flush (gdb_stdout
);
978 /* Resume inferior. */
979 resume (oneproc
|| step
|| bpstat_should_step (), stop_signal
);
981 /* Wait for it to stop (if not standalone)
982 and in any case decode why it stopped, and act accordingly. */
984 wait_for_inferior ();
988 /* Record the pc and sp of the program the last time it stopped.
989 These are just used internally by wait_for_inferior, but need
990 to be preserved over calls to it and cleared when the inferior
992 static CORE_ADDR prev_pc
;
993 static CORE_ADDR prev_func_start
;
994 static char *prev_func_name
;
997 /* Start remote-debugging of a machine over a serial link. */
1002 init_thread_list ();
1003 init_wait_for_inferior ();
1004 stop_soon_quietly
= 1;
1006 wait_for_inferior ();
1010 /* Initialize static vars when a new inferior begins. */
1013 init_wait_for_inferior ()
1015 /* These are meaningless until the first time through wait_for_inferior. */
1017 prev_func_start
= 0;
1018 prev_func_name
= NULL
;
1021 trap_expected_after_continue
= 0;
1023 breakpoints_inserted
= 0;
1024 breakpoint_init_inferior (inf_starting
);
1026 /* Don't confuse first call to proceed(). */
1027 stop_signal
= TARGET_SIGNAL_0
;
1029 /* The first resume is not following a fork/vfork/exec. */
1030 pending_follow
.kind
= TARGET_WAITKIND_SPURIOUS
; /* I.e., none. */
1031 pending_follow
.fork_event
.saw_parent_fork
= 0;
1032 pending_follow
.fork_event
.saw_child_fork
= 0;
1033 pending_follow
.fork_event
.saw_child_exec
= 0;
1035 /* See wait_for_inferior's handling of SYSCALL_ENTRY/RETURN events. */
1036 number_of_threads_in_syscalls
= 0;
1038 clear_proceed_status ();
1042 delete_breakpoint_current_contents (arg
)
1045 struct breakpoint
**breakpointp
= (struct breakpoint
**) arg
;
1046 if (*breakpointp
!= NULL
)
1048 delete_breakpoint (*breakpointp
);
1049 *breakpointp
= NULL
;
1053 /* Wait for control to return from inferior to debugger.
1054 If inferior gets a signal, we may decide to start it up again
1055 instead of returning. That is why there is a loop in this function.
1056 When this function actually returns it means the inferior
1057 should be left stopped and GDB should read more commands. */
1060 wait_for_inferior ()
1062 struct cleanup
*old_cleanups
;
1063 struct target_waitstatus w
;
1065 int random_signal
= 0;
1066 CORE_ADDR stop_func_start
;
1067 CORE_ADDR stop_func_end
;
1068 char *stop_func_name
;
1070 struct symtab_and_line sal
;
1071 int remove_breakpoints_on_following_step
= 0;
1073 struct symtab
*current_symtab
;
1074 int handling_longjmp
= 0; /* FIXME */
1076 int saved_inferior_pid
;
1077 int update_step_sp
= 0;
1078 int stepping_through_solib_after_catch
= 0;
1079 bpstat stepping_through_solib_catchpoints
= NULL
;
1080 int enable_hw_watchpoints_after_wait
= 0;
1081 int stepping_through_sigtramp
= 0;
1082 int new_thread_event
;
1083 int stepped_after_stopped_by_watchpoint
;
1085 old_cleanups
= make_cleanup (delete_breakpoint_current_contents
,
1086 &step_resume_breakpoint
);
1087 make_cleanup (delete_breakpoint_current_contents
,
1088 &through_sigtramp_breakpoint
);
1089 sal
= find_pc_line (prev_pc
, 0);
1090 current_line
= sal
.line
;
1091 current_symtab
= sal
.symtab
;
1093 /* Are we stepping? */
1094 #define CURRENTLY_STEPPING() \
1095 ((through_sigtramp_breakpoint == NULL \
1096 && !handling_longjmp \
1097 && ((step_range_end && step_resume_breakpoint == NULL) \
1098 || trap_expected)) \
1099 || stepping_through_solib_after_catch \
1100 || bpstat_should_step ())
1102 thread_step_needed
= 0;
1104 /* We'll update this if & when we switch to a new thread. */
1105 if (may_switch_from_inferior_pid
)
1106 switched_from_inferior_pid
= inferior_pid
;
1110 overlay_cache_invalid
= 1;
1112 /* We have to invalidate the registers BEFORE calling target_wait because
1113 they can be loaded from the target while in target_wait. This makes
1114 remote debugging a bit more efficient for those targets that provide
1115 critical registers as part of their normal status mechanism. */
1117 registers_changed ();
1119 if (target_wait_hook
)
1120 pid
= target_wait_hook (-1, &w
);
1122 pid
= target_wait (-1, &w
);
1124 /* Since we've done a wait, we have a new event. Don't carry
1125 over any expectations about needing to step over a
1127 thread_step_needed
= 0;
1129 /* See comments where a TARGET_WAITKIND_SYSCALL_RETURN event is
1130 serviced in this loop, below. */
1131 if (enable_hw_watchpoints_after_wait
)
1133 TARGET_ENABLE_HW_WATCHPOINTS (inferior_pid
);
1134 enable_hw_watchpoints_after_wait
= 0;
1137 stepped_after_stopped_by_watchpoint
= 0;
1141 We goto this label from elsewhere in wait_for_inferior when we want
1142 to continue the main loop without calling "wait" and trashing the
1143 waitstatus contained in W. */
1146 flush_cached_frames ();
1148 /* If it's a new process, add it to the thread database */
1150 new_thread_event
= ((pid
!= inferior_pid
) && !in_thread_list (pid
));
1152 if (w
.kind
!= TARGET_WAITKIND_EXITED
1153 && w
.kind
!= TARGET_WAITKIND_SIGNALLED
1154 && new_thread_event
)
1158 printf_filtered ("[New %s]\n", target_pid_or_tid_to_str (pid
));
1161 /* NOTE: This block is ONLY meant to be invoked in case of a
1162 "thread creation event"! If it is invoked for any other
1163 sort of event (such as a new thread landing on a breakpoint),
1164 the event will be discarded, which is almost certainly
1167 To avoid this, the low-level module (eg. target_wait)
1168 should call in_thread_list and add_thread, so that the
1169 new thread is known by the time we get here. */
1171 /* We may want to consider not doing a resume here in order
1172 to give the user a chance to play with the new thread.
1173 It might be good to make that a user-settable option. */
1175 /* At this point, all threads are stopped (happens
1176 automatically in either the OS or the native code).
1177 Therefore we need to continue all threads in order to
1180 target_resume (-1, 0, TARGET_SIGNAL_0
);
1187 case TARGET_WAITKIND_LOADED
:
1188 /* Ignore gracefully during startup of the inferior, as it
1189 might be the shell which has just loaded some objects,
1190 otherwise add the symbols for the newly loaded objects. */
1192 if (!stop_soon_quietly
)
1194 /* Remove breakpoints, SOLIB_ADD might adjust
1195 breakpoint addresses via breakpoint_re_set. */
1196 if (breakpoints_inserted
)
1197 remove_breakpoints ();
1199 /* Check for any newly added shared libraries if we're
1200 supposed to be adding them automatically. */
1203 /* Switch terminal for any messages produced by
1204 breakpoint_re_set. */
1205 target_terminal_ours_for_output ();
1206 SOLIB_ADD (NULL
, 0, NULL
);
1207 target_terminal_inferior ();
1210 /* Reinsert breakpoints and continue. */
1211 if (breakpoints_inserted
)
1212 insert_breakpoints ();
1215 resume (0, TARGET_SIGNAL_0
);
1218 case TARGET_WAITKIND_SPURIOUS
:
1219 resume (0, TARGET_SIGNAL_0
);
1222 case TARGET_WAITKIND_EXITED
:
1223 target_terminal_ours (); /* Must do this before mourn anyway */
1224 annotate_exited (w
.value
.integer
);
1225 if (w
.value
.integer
)
1226 printf_filtered ("\nProgram exited with code 0%o.\n",
1227 (unsigned int) w
.value
.integer
);
1229 printf_filtered ("\nProgram exited normally.\n");
1231 /* Record the exit code in the convenience variable $_exitcode, so
1232 that the user can inspect this again later. */
1233 set_internalvar (lookup_internalvar ("_exitcode"),
1234 value_from_longest (builtin_type_int
,
1235 (LONGEST
) w
.value
.integer
));
1236 gdb_flush (gdb_stdout
);
1237 target_mourn_inferior ();
1238 singlestep_breakpoints_inserted_p
= 0; /*SOFTWARE_SINGLE_STEP_P*/
1239 stop_print_frame
= 0;
1242 case TARGET_WAITKIND_SIGNALLED
:
1243 stop_print_frame
= 0;
1244 stop_signal
= w
.value
.sig
;
1245 target_terminal_ours (); /* Must do this before mourn anyway */
1246 annotate_signalled ();
1248 /* This looks pretty bogus to me. Doesn't TARGET_WAITKIND_SIGNALLED
1249 mean it is already dead? This has been here since GDB 2.8, so
1250 perhaps it means rms didn't understand unix waitstatuses?
1251 For the moment I'm just kludging around this in remote.c
1252 rather than trying to change it here --kingdon, 5 Dec 1994. */
1253 target_kill (); /* kill mourns as well */
1255 printf_filtered ("\nProgram terminated with signal ");
1256 annotate_signal_name ();
1257 printf_filtered ("%s", target_signal_to_name (stop_signal
));
1258 annotate_signal_name_end ();
1259 printf_filtered (", ");
1260 annotate_signal_string ();
1261 printf_filtered ("%s", target_signal_to_string (stop_signal
));
1262 annotate_signal_string_end ();
1263 printf_filtered (".\n");
1265 printf_filtered ("The program no longer exists.\n");
1266 gdb_flush (gdb_stdout
);
1267 singlestep_breakpoints_inserted_p
= 0; /*SOFTWARE_SINGLE_STEP_P*/
1270 /* The following are the only cases in which we keep going;
1271 the above cases end in a continue or goto. */
1272 case TARGET_WAITKIND_FORKED
:
1273 stop_signal
= TARGET_SIGNAL_TRAP
;
1274 pending_follow
.kind
= w
.kind
;
1276 /* Ignore fork events reported for the parent; we're only
1277 interested in reacting to forks of the child. Note that
1278 we expect the child's fork event to be available if we
1279 waited for it now. */
1280 if (inferior_pid
== pid
)
1282 pending_follow
.fork_event
.saw_parent_fork
= 1;
1283 pending_follow
.fork_event
.parent_pid
= pid
;
1284 pending_follow
.fork_event
.child_pid
= w
.value
.related_pid
;
1289 pending_follow
.fork_event
.saw_child_fork
= 1;
1290 pending_follow
.fork_event
.child_pid
= pid
;
1291 pending_follow
.fork_event
.parent_pid
= w
.value
.related_pid
;
1294 stop_pc
= read_pc_pid (pid
);
1295 saved_inferior_pid
= inferior_pid
;
1297 stop_bpstat
= bpstat_stop_status
1299 (DECR_PC_AFTER_BREAK
?
1300 (prev_pc
!= stop_pc
- DECR_PC_AFTER_BREAK
1301 && CURRENTLY_STEPPING ())
1304 random_signal
= !bpstat_explains_signal (stop_bpstat
);
1305 inferior_pid
= saved_inferior_pid
;
1306 goto process_event_stop_test
;
1308 /* If this a platform which doesn't allow a debugger to touch a
1309 vfork'd inferior until after it exec's, then we'd best keep
1310 our fingers entirely off the inferior, other than continuing
1311 it. This has the unfortunate side-effect that catchpoints
1312 of vforks will be ignored. But since the platform doesn't
1313 allow the inferior be touched at vfork time, there's really
1315 case TARGET_WAITKIND_VFORKED
:
1316 stop_signal
= TARGET_SIGNAL_TRAP
;
1317 pending_follow
.kind
= w
.kind
;
1319 /* Is this a vfork of the parent? If so, then give any
1320 vfork catchpoints a chance to trigger now. (It's
1321 dangerous to do so if the child canot be touched until
1322 it execs, and the child has not yet exec'd. We probably
1323 should warn the user to that effect when the catchpoint
1325 if (pid
== inferior_pid
)
1327 pending_follow
.fork_event
.saw_parent_fork
= 1;
1328 pending_follow
.fork_event
.parent_pid
= pid
;
1329 pending_follow
.fork_event
.child_pid
= w
.value
.related_pid
;
1332 /* If we've seen the child's vfork event but cannot really touch
1333 the child until it execs, then we must continue the child now.
1334 Else, give any vfork catchpoints a chance to trigger now. */
1337 pending_follow
.fork_event
.saw_child_fork
= 1;
1338 pending_follow
.fork_event
.child_pid
= pid
;
1339 pending_follow
.fork_event
.parent_pid
= w
.value
.related_pid
;
1340 target_post_startup_inferior (pending_follow
.fork_event
.child_pid
);
1341 follow_vfork_when_exec
= !target_can_follow_vfork_prior_to_exec ();
1342 if (follow_vfork_when_exec
)
1344 target_resume (pid
, 0, TARGET_SIGNAL_0
);
1349 stop_pc
= read_pc ();
1350 stop_bpstat
= bpstat_stop_status
1352 (DECR_PC_AFTER_BREAK
?
1353 (prev_pc
!= stop_pc
- DECR_PC_AFTER_BREAK
1354 && CURRENTLY_STEPPING ())
1357 random_signal
= !bpstat_explains_signal (stop_bpstat
);
1358 goto process_event_stop_test
;
1360 case TARGET_WAITKIND_EXECD
:
1361 stop_signal
= TARGET_SIGNAL_TRAP
;
1363 /* Is this a target which reports multiple exec events per actual
1364 call to exec()? (HP-UX using ptrace does, for example.) If so,
1365 ignore all but the last one. Just resume the exec'r, and wait
1366 for the next exec event. */
1367 if (inferior_ignoring_leading_exec_events
)
1369 inferior_ignoring_leading_exec_events
--;
1370 if (pending_follow
.kind
== TARGET_WAITKIND_VFORKED
)
1371 ENSURE_VFORKING_PARENT_REMAINS_STOPPED (pending_follow
.fork_event
.parent_pid
);
1372 target_resume (pid
, 0, TARGET_SIGNAL_0
);
1375 inferior_ignoring_leading_exec_events
=
1376 target_reported_exec_events_per_exec_call () - 1;
1378 pending_follow
.execd_pathname
= savestring (w
.value
.execd_pathname
,
1379 strlen (w
.value
.execd_pathname
));
1381 /* Did inferior_pid exec, or did a (possibly not-yet-followed)
1382 child of a vfork exec?
1384 ??rehrauer: This is unabashedly an HP-UX specific thing. On
1385 HP-UX, events associated with a vforking inferior come in
1386 threes: a vfork event for the child (always first), followed
1387 a vfork event for the parent and an exec event for the child.
1388 The latter two can come in either order.
1390 If we get the parent vfork event first, life's good: We follow
1391 either the parent or child, and then the child's exec event is
1394 But if we get the child's exec event first, then we delay
1395 responding to it until we handle the parent's vfork. Because,
1396 otherwise we can't satisfy a "catch vfork". */
1397 if (pending_follow
.kind
== TARGET_WAITKIND_VFORKED
)
1399 pending_follow
.fork_event
.saw_child_exec
= 1;
1401 /* On some targets, the child must be resumed before
1402 the parent vfork event is delivered. A single-step
1404 if (RESUME_EXECD_VFORKING_CHILD_TO_GET_PARENT_VFORK ())
1405 target_resume (pid
, 1, TARGET_SIGNAL_0
);
1406 /* We expect the parent vfork event to be available now. */
1410 /* This causes the eventpoints and symbol table to be reset. Must
1411 do this now, before trying to determine whether to stop. */
1412 follow_exec (inferior_pid
, pending_follow
.execd_pathname
);
1413 free (pending_follow
.execd_pathname
);
1415 stop_pc
= read_pc_pid (pid
);
1416 saved_inferior_pid
= inferior_pid
;
1418 stop_bpstat
= bpstat_stop_status
1420 (DECR_PC_AFTER_BREAK
?
1421 (prev_pc
!= stop_pc
- DECR_PC_AFTER_BREAK
1422 && CURRENTLY_STEPPING ())
1425 random_signal
= !bpstat_explains_signal (stop_bpstat
);
1426 inferior_pid
= saved_inferior_pid
;
1427 goto process_event_stop_test
;
1429 /* These syscall events are returned on HP-UX, as part of its
1430 implementation of page-protection-based "hardware" watchpoints.
1431 HP-UX has unfortunate interactions between page-protections and
1432 some system calls. Our solution is to disable hardware watches
1433 when a system call is entered, and reenable them when the syscall
1434 completes. The downside of this is that we may miss the precise
1435 point at which a watched piece of memory is modified. "Oh well."
1437 Note that we may have multiple threads running, which may each
1438 enter syscalls at roughly the same time. Since we don't have a
1439 good notion currently of whether a watched piece of memory is
1440 thread-private, we'd best not have any page-protections active
1441 when any thread is in a syscall. Thus, we only want to reenable
1442 hardware watches when no threads are in a syscall.
1444 Also, be careful not to try to gather much state about a thread
1445 that's in a syscall. It's frequently a losing proposition. */
1446 case TARGET_WAITKIND_SYSCALL_ENTRY
:
1447 number_of_threads_in_syscalls
++;
1448 if (number_of_threads_in_syscalls
== 1)
1450 TARGET_DISABLE_HW_WATCHPOINTS (inferior_pid
);
1452 resume (0, TARGET_SIGNAL_0
);
1455 /* Before examining the threads further, step this thread to
1456 get it entirely out of the syscall. (We get notice of the
1457 event when the thread is just on the verge of exiting a
1458 syscall. Stepping one instruction seems to get it back
1461 Note that although the logical place to reenable h/w watches
1462 is here, we cannot. We cannot reenable them before stepping
1463 the thread (this causes the next wait on the thread to hang).
1465 Nor can we enable them after stepping until we've done a wait.
1466 Thus, we simply set the flag enable_hw_watchpoints_after_wait
1467 here, which will be serviced immediately after the target
1469 case TARGET_WAITKIND_SYSCALL_RETURN
:
1470 target_resume (pid
, 1, TARGET_SIGNAL_0
);
1472 if (number_of_threads_in_syscalls
> 0)
1474 number_of_threads_in_syscalls
--;
1475 enable_hw_watchpoints_after_wait
=
1476 (number_of_threads_in_syscalls
== 0);
1480 case TARGET_WAITKIND_STOPPED
:
1481 stop_signal
= w
.value
.sig
;
1485 /* We may want to consider not doing a resume here in order to give
1486 the user a chance to play with the new thread. It might be good
1487 to make that a user-settable option. */
1489 /* At this point, all threads are stopped (happens automatically in
1490 either the OS or the native code). Therefore we need to continue
1491 all threads in order to make progress. */
1492 if (new_thread_event
)
1494 target_resume (-1, 0, TARGET_SIGNAL_0
);
1498 stop_pc
= read_pc_pid (pid
);
1500 /* See if a thread hit a thread-specific breakpoint that was meant for
1501 another thread. If so, then step that thread past the breakpoint,
1504 if (stop_signal
== TARGET_SIGNAL_TRAP
)
1506 if (SOFTWARE_SINGLE_STEP_P
&& singlestep_breakpoints_inserted_p
)
1508 else if (breakpoints_inserted
1509 && breakpoint_here_p (stop_pc
- DECR_PC_AFTER_BREAK
))
1512 if (!breakpoint_thread_match (stop_pc
- DECR_PC_AFTER_BREAK
,
1517 /* Saw a breakpoint, but it was hit by the wrong thread.
1519 write_pc_pid (stop_pc
- DECR_PC_AFTER_BREAK
, pid
);
1521 remove_status
= remove_breakpoints ();
1522 /* Did we fail to remove breakpoints? If so, try
1523 to set the PC past the bp. (There's at least
1524 one situation in which we can fail to remove
1525 the bp's: On HP-UX's that use ttrace, we can't
1526 change the address space of a vforking child
1527 process until the child exits (well, okay, not
1528 then either :-) or execs. */
1529 if (remove_status
!= 0)
1531 write_pc_pid (stop_pc
- DECR_PC_AFTER_BREAK
+ 4, pid
);
1535 target_resume (pid
, 1, TARGET_SIGNAL_0
);
1536 /* FIXME: What if a signal arrives instead of the
1537 single-step happening? */
1539 if (target_wait_hook
)
1540 target_wait_hook (pid
, &w
);
1542 target_wait (pid
, &w
);
1543 insert_breakpoints ();
1546 /* We need to restart all the threads now,
1547 * unles we're running in scheduler-locked mode.
1548 * FIXME: shouldn't we look at CURRENTLY_STEPPING ()?
1550 if (scheduler_mode
== schedlock_on
)
1551 target_resume (pid
, 0, TARGET_SIGNAL_0
);
1553 target_resume (-1, 0, TARGET_SIGNAL_0
);
1558 /* This breakpoint matches--either it is the right
1559 thread or it's a generic breakpoint for all threads.
1560 Remember that we'll need to step just _this_ thread
1561 on any following user continuation! */
1562 thread_step_needed
= 1;
1569 /* See if something interesting happened to the non-current thread. If
1570 so, then switch to that thread, and eventually give control back to
1573 Note that if there's any kind of pending follow (i.e., of a fork,
1574 vfork or exec), we don't want to do this now. Rather, we'll let
1575 the next resume handle it. */
1576 if ((pid
!= inferior_pid
) &&
1577 (pending_follow
.kind
== TARGET_WAITKIND_SPURIOUS
))
1581 /* If it's a random signal for a non-current thread, notify user
1582 if he's expressed an interest. */
1584 && signal_print
[stop_signal
])
1586 /* ??rehrauer: I don't understand the rationale for this code. If the
1587 inferior will stop as a result of this signal, then the act of handling
1588 the stop ought to print a message that's couches the stoppage in user
1589 terms, e.g., "Stopped for breakpoint/watchpoint". If the inferior
1590 won't stop as a result of the signal -- i.e., if the signal is merely
1591 a side-effect of something GDB's doing "under the covers" for the
1592 user, such as stepping threads over a breakpoint they shouldn't stop
1593 for -- then the message seems to be a serious annoyance at best.
1595 For now, remove the message altogether. */
1598 target_terminal_ours_for_output ();
1599 printf_filtered ("\nProgram received signal %s, %s.\n",
1600 target_signal_to_name (stop_signal
),
1601 target_signal_to_string (stop_signal
));
1602 gdb_flush (gdb_stdout
);
1606 /* If it's not SIGTRAP and not a signal we want to stop for, then
1607 continue the thread. */
1609 if (stop_signal
!= TARGET_SIGNAL_TRAP
1610 && !signal_stop
[stop_signal
])
1613 target_terminal_inferior ();
1615 /* Clear the signal if it should not be passed. */
1616 if (signal_program
[stop_signal
] == 0)
1617 stop_signal
= TARGET_SIGNAL_0
;
1619 target_resume (pid
, 0, stop_signal
);
1623 /* It's a SIGTRAP or a signal we're interested in. Switch threads,
1624 and fall into the rest of wait_for_inferior(). */
1626 /* Save infrun state for the old thread. */
1627 save_infrun_state (inferior_pid
, prev_pc
,
1628 prev_func_start
, prev_func_name
,
1629 trap_expected
, step_resume_breakpoint
,
1630 through_sigtramp_breakpoint
,
1631 step_range_start
, step_range_end
,
1632 step_frame_address
, handling_longjmp
,
1634 stepping_through_solib_after_catch
,
1635 stepping_through_solib_catchpoints
,
1636 stepping_through_sigtramp
);
1638 if (may_switch_from_inferior_pid
)
1639 switched_from_inferior_pid
= inferior_pid
;
1643 /* Load infrun state for the new thread. */
1644 load_infrun_state (inferior_pid
, &prev_pc
,
1645 &prev_func_start
, &prev_func_name
,
1646 &trap_expected
, &step_resume_breakpoint
,
1647 &through_sigtramp_breakpoint
,
1648 &step_range_start
, &step_range_end
,
1649 &step_frame_address
, &handling_longjmp
,
1651 &stepping_through_solib_after_catch
,
1652 &stepping_through_solib_catchpoints
,
1653 &stepping_through_sigtramp
);
1656 context_hook (pid_to_thread_id (pid
));
1658 printf_filtered ("[Switching to %s]\n", target_pid_to_str (pid
));
1659 flush_cached_frames ();
1662 if (SOFTWARE_SINGLE_STEP_P
&& singlestep_breakpoints_inserted_p
)
1664 /* Pull the single step breakpoints out of the target. */
1665 SOFTWARE_SINGLE_STEP (0, 0);
1666 singlestep_breakpoints_inserted_p
= 0;
1669 /* If PC is pointing at a nullified instruction, then step beyond
1670 it so that the user won't be confused when GDB appears to be ready
1673 /* if (INSTRUCTION_NULLIFIED && CURRENTLY_STEPPING ()) */
1674 if (INSTRUCTION_NULLIFIED
)
1676 struct target_waitstatus tmpstatus
;
1678 registers_changed ();
1679 target_resume (pid
, 1, TARGET_SIGNAL_0
);
1681 /* We may have received a signal that we want to pass to
1682 the inferior; therefore, we must not clobber the waitstatus
1683 in W. So we call wait ourselves, then continue the loop
1684 at the "have_waited" label. */
1685 if (target_wait_hook
)
1686 target_wait_hook (pid
, &tmpstatus
);
1688 target_wait (pid
, &tmpstatus
);
1693 /* It may not be necessary to disable the watchpoint to stop over
1694 it. For example, the PA can (with some kernel cooperation)
1695 single step over a watchpoint without disabling the watchpoint. */
1696 if (HAVE_STEPPABLE_WATCHPOINT
&& STOPPED_BY_WATCHPOINT (w
))
1702 /* It is far more common to need to disable a watchpoint to step
1703 the inferior over it. FIXME. What else might a debug
1704 register or page protection watchpoint scheme need here? */
1705 if (HAVE_NONSTEPPABLE_WATCHPOINT
&& STOPPED_BY_WATCHPOINT (w
))
1707 /* At this point, we are stopped at an instruction which has
1708 attempted to write to a piece of memory under control of
1709 a watchpoint. The instruction hasn't actually executed
1710 yet. If we were to evaluate the watchpoint expression
1711 now, we would get the old value, and therefore no change
1712 would seem to have occurred.
1714 In order to make watchpoints work `right', we really need
1715 to complete the memory write, and then evaluate the
1716 watchpoint expression. The following code does that by
1717 removing the watchpoint (actually, all watchpoints and
1718 breakpoints), single-stepping the target, re-inserting
1719 watchpoints, and then falling through to let normal
1720 single-step processing handle proceed. Since this
1721 includes evaluating watchpoints, things will come to a
1722 stop in the correct manner. */
1724 write_pc (stop_pc
- DECR_PC_AFTER_BREAK
);
1726 remove_breakpoints ();
1727 registers_changed ();
1728 target_resume (pid
, 1, TARGET_SIGNAL_0
); /* Single step */
1730 if (target_wait_hook
)
1731 target_wait_hook (pid
, &w
);
1733 target_wait (pid
, &w
);
1734 insert_breakpoints ();
1736 /* FIXME-maybe: is this cleaner than setting a flag? Does it
1737 handle things like signals arriving and other things happening
1738 in combination correctly? */
1739 stepped_after_stopped_by_watchpoint
= 1;
1743 /* It may be possible to simply continue after a watchpoint. */
1744 if (HAVE_CONTINUABLE_WATCHPOINT
)
1745 STOPPED_BY_WATCHPOINT (w
);
1747 stop_func_start
= 0;
1750 /* Don't care about return value; stop_func_start and stop_func_name
1751 will both be 0 if it doesn't work. */
1752 find_pc_partial_function (stop_pc
, &stop_func_name
, &stop_func_start
,
1754 stop_func_start
+= FUNCTION_START_OFFSET
;
1756 bpstat_clear (&stop_bpstat
);
1758 stop_stack_dummy
= 0;
1759 stop_print_frame
= 1;
1761 stopped_by_random_signal
= 0;
1762 breakpoints_failed
= 0;
1764 /* Look at the cause of the stop, and decide what to do.
1765 The alternatives are:
1766 1) break; to really stop and return to the debugger,
1767 2) drop through to start up again
1768 (set another_trap to 1 to single step once)
1769 3) set random_signal to 1, and the decision between 1 and 2
1770 will be made according to the signal handling tables. */
1772 /* First, distinguish signals caused by the debugger from signals
1773 that have to do with the program's own actions.
1774 Note that breakpoint insns may cause SIGTRAP or SIGILL
1775 or SIGEMT, depending on the operating system version.
1776 Here we detect when a SIGILL or SIGEMT is really a breakpoint
1777 and change it to SIGTRAP. */
1779 if (stop_signal
== TARGET_SIGNAL_TRAP
1780 || (breakpoints_inserted
&&
1781 (stop_signal
== TARGET_SIGNAL_ILL
1782 || stop_signal
== TARGET_SIGNAL_EMT
1784 || stop_soon_quietly
)
1786 if (stop_signal
== TARGET_SIGNAL_TRAP
&& stop_after_trap
)
1788 stop_print_frame
= 0;
1791 if (stop_soon_quietly
)
1794 /* Don't even think about breakpoints
1795 if just proceeded over a breakpoint.
1797 However, if we are trying to proceed over a breakpoint
1798 and end up in sigtramp, then through_sigtramp_breakpoint
1799 will be set and we should check whether we've hit the
1801 if (stop_signal
== TARGET_SIGNAL_TRAP
&& trap_expected
1802 && through_sigtramp_breakpoint
== NULL
)
1803 bpstat_clear (&stop_bpstat
);
1806 /* See if there is a breakpoint at the current PC. */
1807 stop_bpstat
= bpstat_stop_status
1809 (DECR_PC_AFTER_BREAK
?
1810 /* Notice the case of stepping through a jump
1811 that lands just after a breakpoint.
1812 Don't confuse that with hitting the breakpoint.
1813 What we check for is that 1) stepping is going on
1814 and 2) the pc before the last insn does not match
1815 the address of the breakpoint before the current pc
1816 and 3) we didn't hit a breakpoint in a signal handler
1817 without an intervening stop in sigtramp, which is
1818 detected by a new stack pointer value below
1819 any usual function calling stack adjustments. */
1820 (CURRENTLY_STEPPING ()
1821 && prev_pc
!= stop_pc
- DECR_PC_AFTER_BREAK
1823 && INNER_THAN (read_sp (), (step_sp
- 16)))) :
1826 /* Following in case break condition called a
1828 stop_print_frame
= 1;
1831 if (stop_signal
== TARGET_SIGNAL_TRAP
)
1833 = !(bpstat_explains_signal (stop_bpstat
)
1835 || (!CALL_DUMMY_BREAKPOINT_OFFSET_P
1836 && PC_IN_CALL_DUMMY (stop_pc
, read_sp (),
1837 FRAME_FP (get_current_frame ())))
1838 || (step_range_end
&& step_resume_breakpoint
== NULL
));
1843 = !(bpstat_explains_signal (stop_bpstat
)
1844 /* End of a stack dummy. Some systems (e.g. Sony
1845 news) give another signal besides SIGTRAP, so
1846 check here as well as above. */
1847 || (!CALL_DUMMY_BREAKPOINT_OFFSET_P
1848 && PC_IN_CALL_DUMMY (stop_pc
, read_sp (),
1849 FRAME_FP (get_current_frame ())))
1852 stop_signal
= TARGET_SIGNAL_TRAP
;
1856 /* When we reach this point, we've pretty much decided
1857 that the reason for stopping must've been a random
1858 (unexpected) signal. */
1862 /* If a fork, vfork or exec event was seen, then there are two
1863 possible responses we can make:
1865 1. If a catchpoint triggers for the event (random_signal == 0),
1866 then we must stop now and issue a prompt. We will resume
1867 the inferior when the user tells us to.
1868 2. If no catchpoint triggers for the event (random_signal == 1),
1869 then we must resume the inferior now and keep checking.
1871 In either case, we must take appropriate steps to "follow" the
1872 the fork/vfork/exec when the inferior is resumed. For example,
1873 if follow-fork-mode is "child", then we must detach from the
1874 parent inferior and follow the new child inferior.
1876 In either case, setting pending_follow causes the next resume()
1877 to take the appropriate following action. */
1878 process_event_stop_test
:
1879 if (w
.kind
== TARGET_WAITKIND_FORKED
)
1881 if (random_signal
) /* I.e., no catchpoint triggered for this. */
1884 stop_signal
= TARGET_SIGNAL_0
;
1888 else if (w
.kind
== TARGET_WAITKIND_VFORKED
)
1890 if (random_signal
) /* I.e., no catchpoint triggered for this. */
1892 stop_signal
= TARGET_SIGNAL_0
;
1896 else if (w
.kind
== TARGET_WAITKIND_EXECD
)
1898 pending_follow
.kind
= w
.kind
;
1899 if (random_signal
) /* I.e., no catchpoint triggered for this. */
1902 stop_signal
= TARGET_SIGNAL_0
;
1907 /* For the program's own signals, act according to
1908 the signal handling tables. */
1912 /* Signal not for debugging purposes. */
1915 stopped_by_random_signal
= 1;
1917 if (signal_print
[stop_signal
])
1920 target_terminal_ours_for_output ();
1922 printf_filtered ("\nProgram received signal ");
1923 annotate_signal_name ();
1924 printf_filtered ("%s", target_signal_to_name (stop_signal
));
1925 annotate_signal_name_end ();
1926 printf_filtered (", ");
1927 annotate_signal_string ();
1928 printf_filtered ("%s", target_signal_to_string (stop_signal
));
1929 annotate_signal_string_end ();
1930 printf_filtered (".\n");
1931 gdb_flush (gdb_stdout
);
1933 if (signal_stop
[stop_signal
])
1935 /* If not going to stop, give terminal back
1936 if we took it away. */
1938 target_terminal_inferior ();
1940 /* Clear the signal if it should not be passed. */
1941 if (signal_program
[stop_signal
] == 0)
1942 stop_signal
= TARGET_SIGNAL_0
;
1944 /* If we're in the middle of a "next" command, let the code for
1945 stepping over a function handle this. pai/1997-09-10
1947 A previous comment here suggested it was possible to change
1948 this to jump to keep_going in all cases. */
1950 if (step_over_calls
> 0)
1951 goto step_over_function
;
1953 goto check_sigtramp2
;
1956 /* Handle cases caused by hitting a breakpoint. */
1958 CORE_ADDR jmp_buf_pc
;
1959 struct bpstat_what what
;
1961 what
= bpstat_what (stop_bpstat
);
1963 if (what
.call_dummy
)
1965 stop_stack_dummy
= 1;
1967 trap_expected_after_continue
= 1;
1971 switch (what
.main_action
)
1973 case BPSTAT_WHAT_SET_LONGJMP_RESUME
:
1974 /* If we hit the breakpoint at longjmp, disable it for the
1975 duration of this command. Then, install a temporary
1976 breakpoint at the target of the jmp_buf. */
1977 disable_longjmp_breakpoint ();
1978 remove_breakpoints ();
1979 breakpoints_inserted
= 0;
1980 if (!GET_LONGJMP_TARGET (&jmp_buf_pc
))
1983 /* Need to blow away step-resume breakpoint, as it
1984 interferes with us */
1985 if (step_resume_breakpoint
!= NULL
)
1987 delete_breakpoint (step_resume_breakpoint
);
1988 step_resume_breakpoint
= NULL
;
1990 /* Not sure whether we need to blow this away too, but probably
1991 it is like the step-resume breakpoint. */
1992 if (through_sigtramp_breakpoint
!= NULL
)
1994 delete_breakpoint (through_sigtramp_breakpoint
);
1995 through_sigtramp_breakpoint
= NULL
;
1999 /* FIXME - Need to implement nested temporary breakpoints */
2000 if (step_over_calls
> 0)
2001 set_longjmp_resume_breakpoint (jmp_buf_pc
,
2002 get_current_frame ());
2005 set_longjmp_resume_breakpoint (jmp_buf_pc
, NULL
);
2006 handling_longjmp
= 1; /* FIXME */
2009 case BPSTAT_WHAT_CLEAR_LONGJMP_RESUME
:
2010 case BPSTAT_WHAT_CLEAR_LONGJMP_RESUME_SINGLE
:
2011 remove_breakpoints ();
2012 breakpoints_inserted
= 0;
2014 /* FIXME - Need to implement nested temporary breakpoints */
2016 && (INNER_THAN (FRAME_FP (get_current_frame ()),
2017 step_frame_address
)))
2023 disable_longjmp_breakpoint ();
2024 handling_longjmp
= 0; /* FIXME */
2025 if (what
.main_action
== BPSTAT_WHAT_CLEAR_LONGJMP_RESUME
)
2027 /* else fallthrough */
2029 case BPSTAT_WHAT_SINGLE
:
2030 if (breakpoints_inserted
)
2032 thread_step_needed
= 1;
2033 remove_breakpoints ();
2035 breakpoints_inserted
= 0;
2037 /* Still need to check other stuff, at least the case
2038 where we are stepping and step out of the right range. */
2041 case BPSTAT_WHAT_STOP_NOISY
:
2042 stop_print_frame
= 1;
2044 /* We are about to nuke the step_resume_breakpoint and
2045 through_sigtramp_breakpoint via the cleanup chain, so
2046 no need to worry about it here. */
2050 case BPSTAT_WHAT_STOP_SILENT
:
2051 stop_print_frame
= 0;
2053 /* We are about to nuke the step_resume_breakpoint and
2054 through_sigtramp_breakpoint via the cleanup chain, so
2055 no need to worry about it here. */
2059 case BPSTAT_WHAT_STEP_RESUME
:
2060 /* This proably demands a more elegant solution, but, yeah
2063 This function's use of the simple variable
2064 step_resume_breakpoint doesn't seem to accomodate
2065 simultaneously active step-resume bp's, although the
2066 breakpoint list certainly can.
2068 If we reach here and step_resume_breakpoint is already
2069 NULL, then apparently we have multiple active
2070 step-resume bp's. We'll just delete the breakpoint we
2071 stopped at, and carry on. */
2072 if (step_resume_breakpoint
== NULL
)
2074 step_resume_breakpoint
=
2075 bpstat_find_step_resume_breakpoint (stop_bpstat
);
2077 delete_breakpoint (step_resume_breakpoint
);
2078 step_resume_breakpoint
= NULL
;
2081 case BPSTAT_WHAT_THROUGH_SIGTRAMP
:
2082 if (through_sigtramp_breakpoint
)
2083 delete_breakpoint (through_sigtramp_breakpoint
);
2084 through_sigtramp_breakpoint
= NULL
;
2086 /* If were waiting for a trap, hitting the step_resume_break
2087 doesn't count as getting it. */
2092 case BPSTAT_WHAT_CHECK_SHLIBS
:
2093 case BPSTAT_WHAT_CHECK_SHLIBS_RESUME_FROM_HOOK
:
2096 /* Remove breakpoints, we eventually want to step over the
2097 shlib event breakpoint, and SOLIB_ADD might adjust
2098 breakpoint addresses via breakpoint_re_set. */
2099 if (breakpoints_inserted
)
2100 remove_breakpoints ();
2101 breakpoints_inserted
= 0;
2103 /* Check for any newly added shared libraries if we're
2104 supposed to be adding them automatically. */
2107 /* Switch terminal for any messages produced by
2108 breakpoint_re_set. */
2109 target_terminal_ours_for_output ();
2110 SOLIB_ADD (NULL
, 0, NULL
);
2111 target_terminal_inferior ();
2114 /* Try to reenable shared library breakpoints, additional
2115 code segments in shared libraries might be mapped in now. */
2116 re_enable_breakpoints_in_shlibs ();
2118 /* If requested, stop when the dynamic linker notifies
2119 gdb of events. This allows the user to get control
2120 and place breakpoints in initializer routines for
2121 dynamically loaded objects (among other things). */
2122 if (stop_on_solib_events
)
2124 stop_print_frame
= 0;
2128 /* If we stopped due to an explicit catchpoint, then the
2129 (see above) call to SOLIB_ADD pulled in any symbols
2130 from a newly-loaded library, if appropriate.
2132 We do want the inferior to stop, but not where it is
2133 now, which is in the dynamic linker callback. Rather,
2134 we would like it stop in the user's program, just after
2135 the call that caused this catchpoint to trigger. That
2136 gives the user a more useful vantage from which to
2137 examine their program's state. */
2138 else if (what
.main_action
== BPSTAT_WHAT_CHECK_SHLIBS_RESUME_FROM_HOOK
)
2140 /* ??rehrauer: If I could figure out how to get the
2141 right return PC from here, we could just set a temp
2142 breakpoint and resume. I'm not sure we can without
2143 cracking open the dld's shared libraries and sniffing
2144 their unwind tables and text/data ranges, and that's
2145 not a terribly portable notion.
2147 Until that time, we must step the inferior out of the
2148 dld callback, and also out of the dld itself (and any
2149 code or stubs in libdld.sl, such as "shl_load" and
2150 friends) until we reach non-dld code. At that point,
2151 we can stop stepping. */
2152 bpstat_get_triggered_catchpoints (stop_bpstat
,
2153 &stepping_through_solib_catchpoints
);
2154 stepping_through_solib_after_catch
= 1;
2156 /* Be sure to lift all breakpoints, so the inferior does
2157 actually step past this point... */
2163 /* We want to step over this breakpoint, then keep going. */
2171 case BPSTAT_WHAT_LAST
:
2172 /* Not a real code, but listed here to shut up gcc -Wall. */
2174 case BPSTAT_WHAT_KEEP_CHECKING
:
2179 /* We come here if we hit a breakpoint but should not
2180 stop for it. Possibly we also were stepping
2181 and should stop for that. So fall through and
2182 test for stepping. But, if not stepping,
2185 /* Are we stepping to get the inferior out of the dynamic
2186 linker's hook (and possibly the dld itself) after catching
2188 if (stepping_through_solib_after_catch
)
2190 #if defined(SOLIB_ADD)
2191 /* Have we reached our destination? If not, keep going. */
2192 if (SOLIB_IN_DYNAMIC_LINKER (pid
, stop_pc
))
2198 /* Else, stop and report the catchpoint(s) whose triggering
2199 caused us to begin stepping. */
2200 stepping_through_solib_after_catch
= 0;
2201 bpstat_clear (&stop_bpstat
);
2202 stop_bpstat
= bpstat_copy (stepping_through_solib_catchpoints
);
2203 bpstat_clear (&stepping_through_solib_catchpoints
);
2204 stop_print_frame
= 1;
2208 if (!CALL_DUMMY_BREAKPOINT_OFFSET_P
)
2210 /* This is the old way of detecting the end of the stack dummy.
2211 An architecture which defines CALL_DUMMY_BREAKPOINT_OFFSET gets
2212 handled above. As soon as we can test it on all of them, all
2213 architectures should define it. */
2215 /* If this is the breakpoint at the end of a stack dummy,
2216 just stop silently, unless the user was doing an si/ni, in which
2217 case she'd better know what she's doing. */
2219 if (CALL_DUMMY_HAS_COMPLETED (stop_pc
, read_sp (),
2220 FRAME_FP (get_current_frame ()))
2223 stop_print_frame
= 0;
2224 stop_stack_dummy
= 1;
2226 trap_expected_after_continue
= 1;
2232 if (step_resume_breakpoint
)
2233 /* Having a step-resume breakpoint overrides anything
2234 else having to do with stepping commands until
2235 that breakpoint is reached. */
2236 /* I'm not sure whether this needs to be check_sigtramp2 or
2237 whether it could/should be keep_going. */
2238 goto check_sigtramp2
;
2240 if (step_range_end
== 0)
2241 /* Likewise if we aren't even stepping. */
2242 /* I'm not sure whether this needs to be check_sigtramp2 or
2243 whether it could/should be keep_going. */
2244 goto check_sigtramp2
;
2246 /* If stepping through a line, keep going if still within it.
2248 Note that step_range_end is the address of the first instruction
2249 beyond the step range, and NOT the address of the last instruction
2251 if (stop_pc
>= step_range_start
2252 && stop_pc
< step_range_end
)
2254 /* We might be doing a BPSTAT_WHAT_SINGLE and getting a signal.
2255 So definately need to check for sigtramp here. */
2256 goto check_sigtramp2
;
2259 /* We stepped out of the stepping range. */
2261 /* If we are stepping at the source level and entered the runtime
2262 loader dynamic symbol resolution code, we keep on single stepping
2263 until we exit the run time loader code and reach the callee's
2265 if (step_over_calls
< 0 && IN_SOLIB_DYNSYM_RESOLVE_CODE (stop_pc
))
2268 /* We can't update step_sp every time through the loop, because
2269 reading the stack pointer would slow down stepping too much.
2270 But we can update it every time we leave the step range. */
2273 /* Did we just take a signal? */
2274 if (IN_SIGTRAMP (stop_pc
, stop_func_name
)
2275 && !IN_SIGTRAMP (prev_pc
, prev_func_name
)
2276 && INNER_THAN (read_sp (), step_sp
))
2278 /* We've just taken a signal; go until we are back to
2279 the point where we took it and one more. */
2281 /* Note: The test above succeeds not only when we stepped
2282 into a signal handler, but also when we step past the last
2283 statement of a signal handler and end up in the return stub
2284 of the signal handler trampoline. To distinguish between
2285 these two cases, check that the frame is INNER_THAN the
2286 previous one below. pai/1997-09-11 */
2290 CORE_ADDR current_frame
= FRAME_FP (get_current_frame ());
2292 if (INNER_THAN (current_frame
, step_frame_address
))
2294 /* We have just taken a signal; go until we are back to
2295 the point where we took it and one more. */
2297 /* This code is needed at least in the following case:
2298 The user types "next" and then a signal arrives (before
2299 the "next" is done). */
2301 /* Note that if we are stopped at a breakpoint, then we need
2302 the step_resume breakpoint to override any breakpoints at
2303 the same location, so that we will still step over the
2304 breakpoint even though the signal happened. */
2305 struct symtab_and_line sr_sal
;
2308 sr_sal
.symtab
= NULL
;
2310 sr_sal
.pc
= prev_pc
;
2311 /* We could probably be setting the frame to
2312 step_frame_address; I don't think anyone thought to
2314 step_resume_breakpoint
=
2315 set_momentary_breakpoint (sr_sal
, NULL
, bp_step_resume
);
2316 if (breakpoints_inserted
)
2317 insert_breakpoints ();
2321 /* We just stepped out of a signal handler and into
2322 its calling trampoline.
2324 Normally, we'd jump to step_over_function from
2325 here, but for some reason GDB can't unwind the
2326 stack correctly to find the real PC for the point
2327 user code where the signal trampoline will return
2328 -- FRAME_SAVED_PC fails, at least on HP-UX 10.20.
2329 But signal trampolines are pretty small stubs of
2330 code, anyway, so it's OK instead to just
2331 single-step out. Note: assuming such trampolines
2332 don't exhibit recursion on any platform... */
2333 find_pc_partial_function (stop_pc
, &stop_func_name
,
2336 /* Readjust stepping range */
2337 step_range_start
= stop_func_start
;
2338 step_range_end
= stop_func_end
;
2339 stepping_through_sigtramp
= 1;
2344 /* If this is stepi or nexti, make sure that the stepping range
2345 gets us past that instruction. */
2346 if (step_range_end
== 1)
2347 /* FIXME: Does this run afoul of the code below which, if
2348 we step into the middle of a line, resets the stepping
2350 step_range_end
= (step_range_start
= prev_pc
) + 1;
2352 remove_breakpoints_on_following_step
= 1;
2356 if (stop_pc
== stop_func_start
/* Quick test */
2357 || (in_prologue (stop_pc
, stop_func_start
) &&
2358 !IN_SOLIB_RETURN_TRAMPOLINE (stop_pc
, stop_func_name
))
2359 || IN_SOLIB_CALL_TRAMPOLINE (stop_pc
, stop_func_name
)
2360 || stop_func_name
== 0)
2362 /* It's a subroutine call. */
2364 if (step_over_calls
== 0)
2366 /* I presume that step_over_calls is only 0 when we're
2367 supposed to be stepping at the assembly language level
2368 ("stepi"). Just stop. */
2373 if (step_over_calls
> 0 || IGNORE_HELPER_CALL (stop_pc
))
2374 /* We're doing a "next". */
2375 goto step_over_function
;
2377 /* If we are in a function call trampoline (a stub between
2378 the calling routine and the real function), locate the real
2379 function. That's what tells us (a) whether we want to step
2380 into it at all, and (b) what prologue we want to run to
2381 the end of, if we do step into it. */
2382 tmp
= SKIP_TRAMPOLINE_CODE (stop_pc
);
2384 stop_func_start
= tmp
;
2387 tmp
= DYNAMIC_TRAMPOLINE_NEXTPC (stop_pc
);
2390 struct symtab_and_line xxx
;
2391 /* Why isn't this s_a_l called "sr_sal", like all of the
2392 other s_a_l's where this code is duplicated? */
2393 INIT_SAL (&xxx
); /* initialize to zeroes */
2395 xxx
.section
= find_pc_overlay (xxx
.pc
);
2396 step_resume_breakpoint
=
2397 set_momentary_breakpoint (xxx
, NULL
, bp_step_resume
);
2398 insert_breakpoints ();
2403 /* If we have line number information for the function we
2404 are thinking of stepping into, step into it.
2406 If there are several symtabs at that PC (e.g. with include
2407 files), just want to know whether *any* of them have line
2408 numbers. find_pc_line handles this. */
2410 struct symtab_and_line tmp_sal
;
2412 tmp_sal
= find_pc_line (stop_func_start
, 0);
2413 if (tmp_sal
.line
!= 0)
2414 goto step_into_function
;
2418 /* A subroutine call has happened. */
2420 /* Set a special breakpoint after the return */
2421 struct symtab_and_line sr_sal
;
2424 sr_sal
.symtab
= NULL
;
2427 /* If we came here after encountering a signal in the middle of
2428 a "next", use the stashed-away previous frame pc */
2430 = stopped_by_random_signal
2432 : ADDR_BITS_REMOVE (SAVED_PC_AFTER_CALL (get_current_frame ()));
2434 step_resume_breakpoint
=
2435 set_momentary_breakpoint (sr_sal
,
2436 stopped_by_random_signal
?
2437 NULL
: get_current_frame (),
2440 /* We've just entered a callee, and we wish to resume until
2441 it returns to the caller. Setting a step_resume bp on
2442 the return PC will catch a return from the callee.
2444 However, if the callee is recursing, we want to be
2445 careful not to catch returns of those recursive calls,
2446 but of THIS instance of the call.
2448 To do this, we set the step_resume bp's frame to our
2449 current caller's frame (step_frame_address, which is
2450 set by the "next" or "until" command, before execution
2453 But ... don't do it if we're single-stepping out of a
2454 sigtramp, because the reason we're single-stepping is
2455 precisely because unwinding is a problem (HP-UX 10.20,
2456 e.g.) and the frame address is likely to be incorrect.
2457 No danger of sigtramp recursion. */
2459 if (stepping_through_sigtramp
)
2461 step_resume_breakpoint
->frame
= (CORE_ADDR
) NULL
;
2462 stepping_through_sigtramp
= 0;
2464 else if (!IN_SOLIB_DYNSYM_RESOLVE_CODE (sr_sal
.pc
))
2465 step_resume_breakpoint
->frame
= step_frame_address
;
2467 if (breakpoints_inserted
)
2468 insert_breakpoints ();
2473 /* Subroutine call with source code we should not step over.
2474 Do step to the first line of code in it. */
2478 s
= find_pc_symtab (stop_pc
);
2479 if (s
&& s
->language
!= language_asm
)
2480 SKIP_PROLOGUE (stop_func_start
);
2482 sal
= find_pc_line (stop_func_start
, 0);
2483 /* Use the step_resume_break to step until
2484 the end of the prologue, even if that involves jumps
2485 (as it seems to on the vax under 4.2). */
2486 /* If the prologue ends in the middle of a source line,
2487 continue to the end of that source line (if it is still
2488 within the function). Otherwise, just go to end of prologue. */
2489 #ifdef PROLOGUE_FIRSTLINE_OVERLAP
2490 /* no, don't either. It skips any code that's
2491 legitimately on the first line. */
2493 if (sal
.end
&& sal
.pc
!= stop_func_start
&& sal
.end
< stop_func_end
)
2494 stop_func_start
= sal
.end
;
2497 if (stop_func_start
== stop_pc
)
2499 /* We are already there: stop now. */
2504 /* Put the step-breakpoint there and go until there. */
2506 struct symtab_and_line sr_sal
;
2508 INIT_SAL (&sr_sal
); /* initialize to zeroes */
2509 sr_sal
.pc
= stop_func_start
;
2510 sr_sal
.section
= find_pc_overlay (stop_func_start
);
2511 /* Do not specify what the fp should be when we stop
2512 since on some machines the prologue
2513 is where the new fp value is established. */
2514 step_resume_breakpoint
=
2515 set_momentary_breakpoint (sr_sal
, NULL
, bp_step_resume
);
2516 if (breakpoints_inserted
)
2517 insert_breakpoints ();
2519 /* And make sure stepping stops right away then. */
2520 step_range_end
= step_range_start
;
2525 /* We've wandered out of the step range. */
2527 sal
= find_pc_line (stop_pc
, 0);
2529 if (step_range_end
== 1)
2531 /* It is stepi or nexti. We always want to stop stepping after
2537 /* If we're in the return path from a shared library trampoline,
2538 we want to proceed through the trampoline when stepping. */
2539 if (IN_SOLIB_RETURN_TRAMPOLINE (stop_pc
, stop_func_name
))
2543 /* Determine where this trampoline returns. */
2544 tmp
= SKIP_TRAMPOLINE_CODE (stop_pc
);
2546 /* Only proceed through if we know where it's going. */
2549 /* And put the step-breakpoint there and go until there. */
2550 struct symtab_and_line sr_sal
;
2552 INIT_SAL (&sr_sal
); /* initialize to zeroes */
2554 sr_sal
.section
= find_pc_overlay (sr_sal
.pc
);
2555 /* Do not specify what the fp should be when we stop
2556 since on some machines the prologue
2557 is where the new fp value is established. */
2558 step_resume_breakpoint
=
2559 set_momentary_breakpoint (sr_sal
, NULL
, bp_step_resume
);
2560 if (breakpoints_inserted
)
2561 insert_breakpoints ();
2563 /* Restart without fiddling with the step ranges or
2571 /* We have no line number information. That means to stop
2572 stepping (does this always happen right after one instruction,
2573 when we do "s" in a function with no line numbers,
2574 or can this happen as a result of a return or longjmp?). */
2579 if ((stop_pc
== sal
.pc
)
2580 && (current_line
!= sal
.line
|| current_symtab
!= sal
.symtab
))
2582 /* We are at the start of a different line. So stop. Note that
2583 we don't stop if we step into the middle of a different line.
2584 That is said to make things like for (;;) statements work
2590 /* We aren't done stepping.
2592 Optimize by setting the stepping range to the line.
2593 (We might not be in the original line, but if we entered a
2594 new line in mid-statement, we continue stepping. This makes
2595 things like for(;;) statements work better.) */
2597 if (stop_func_end
&& sal
.end
>= stop_func_end
)
2599 /* If this is the last line of the function, don't keep stepping
2600 (it would probably step us out of the function).
2601 This is particularly necessary for a one-line function,
2602 in which after skipping the prologue we better stop even though
2603 we will be in mid-line. */
2607 step_range_start
= sal
.pc
;
2608 step_range_end
= sal
.end
;
2609 step_frame_address
= FRAME_FP (get_current_frame ());
2610 current_line
= sal
.line
;
2611 current_symtab
= sal
.symtab
;
2613 /* In the case where we just stepped out of a function into the middle
2614 of a line of the caller, continue stepping, but step_frame_address
2615 must be modified to current frame */
2617 CORE_ADDR current_frame
= FRAME_FP (get_current_frame ());
2618 if (!(INNER_THAN (current_frame
, step_frame_address
)))
2619 step_frame_address
= current_frame
;
2627 && IN_SIGTRAMP (stop_pc
, stop_func_name
)
2628 && !IN_SIGTRAMP (prev_pc
, prev_func_name
)
2629 && INNER_THAN (read_sp (), step_sp
))
2631 /* What has happened here is that we have just stepped the inferior
2632 with a signal (because it is a signal which shouldn't make
2633 us stop), thus stepping into sigtramp.
2635 So we need to set a step_resume_break_address breakpoint
2636 and continue until we hit it, and then step. FIXME: This should
2637 be more enduring than a step_resume breakpoint; we should know
2638 that we will later need to keep going rather than re-hitting
2639 the breakpoint here (see testsuite/gdb.t06/signals.exp where
2640 it says "exceedingly difficult"). */
2641 struct symtab_and_line sr_sal
;
2643 INIT_SAL (&sr_sal
); /* initialize to zeroes */
2644 sr_sal
.pc
= prev_pc
;
2645 sr_sal
.section
= find_pc_overlay (sr_sal
.pc
);
2646 /* We perhaps could set the frame if we kept track of what
2647 the frame corresponding to prev_pc was. But we don't,
2649 through_sigtramp_breakpoint
=
2650 set_momentary_breakpoint (sr_sal
, NULL
, bp_through_sigtramp
);
2651 if (breakpoints_inserted
)
2652 insert_breakpoints ();
2654 remove_breakpoints_on_following_step
= 1;
2659 /* Come to this label when you need to resume the inferior.
2660 It's really much cleaner to do a goto than a maze of if-else
2663 /* ??rehrauer: ttrace on HP-UX theoretically allows one to debug
2664 a vforked child beetween its creation and subsequent exit or
2665 call to exec(). However, I had big problems in this rather
2666 creaky exec engine, getting that to work. The fundamental
2667 problem is that I'm trying to debug two processes via an
2668 engine that only understands a single process with possibly
2671 Hence, this spot is known to have problems when
2672 target_can_follow_vfork_prior_to_exec returns 1. */
2674 /* Save the pc before execution, to compare with pc after stop. */
2675 prev_pc
= read_pc (); /* Might have been DECR_AFTER_BREAK */
2676 prev_func_start
= stop_func_start
; /* Ok, since if DECR_PC_AFTER
2677 BREAK is defined, the
2678 original pc would not have
2679 been at the start of a
2681 prev_func_name
= stop_func_name
;
2684 step_sp
= read_sp ();
2687 /* If we did not do break;, it means we should keep
2688 running the inferior and not return to debugger. */
2690 if (trap_expected
&& stop_signal
!= TARGET_SIGNAL_TRAP
)
2692 /* We took a signal (which we are supposed to pass through to
2693 the inferior, else we'd have done a break above) and we
2694 haven't yet gotten our trap. Simply continue. */
2695 resume (CURRENTLY_STEPPING (), stop_signal
);
2699 /* Either the trap was not expected, but we are continuing
2700 anyway (the user asked that this signal be passed to the
2703 The signal was SIGTRAP, e.g. it was our signal, but we
2704 decided we should resume from it.
2706 We're going to run this baby now!
2708 Insert breakpoints now, unless we are trying
2709 to one-proceed past a breakpoint. */
2710 /* If we've just finished a special step resume and we don't
2711 want to hit a breakpoint, pull em out. */
2712 if (step_resume_breakpoint
== NULL
2713 && through_sigtramp_breakpoint
== NULL
2714 && remove_breakpoints_on_following_step
)
2716 remove_breakpoints_on_following_step
= 0;
2717 remove_breakpoints ();
2718 breakpoints_inserted
= 0;
2720 else if (!breakpoints_inserted
&&
2721 (through_sigtramp_breakpoint
!= NULL
|| !another_trap
))
2723 breakpoints_failed
= insert_breakpoints ();
2724 if (breakpoints_failed
)
2726 breakpoints_inserted
= 1;
2729 trap_expected
= another_trap
;
2731 /* Do not deliver SIGNAL_TRAP (except when the user
2732 explicitly specifies that such a signal should be
2733 delivered to the target program).
2735 Typically, this would occure when a user is debugging a
2736 target monitor on a simulator: the target monitor sets a
2737 breakpoint; the simulator encounters this break-point and
2738 halts the simulation handing control to GDB; GDB, noteing
2739 that the break-point isn't valid, returns control back to
2740 the simulator; the simulator then delivers the hardware
2741 equivalent of a SIGNAL_TRAP to the program being
2744 if (stop_signal
== TARGET_SIGNAL_TRAP
2745 && !signal_program
[stop_signal
])
2746 stop_signal
= TARGET_SIGNAL_0
;
2748 #ifdef SHIFT_INST_REGS
2749 /* I'm not sure when this following segment applies. I do know,
2750 now, that we shouldn't rewrite the regs when we were stopped
2751 by a random signal from the inferior process. */
2752 /* FIXME: Shouldn't this be based on the valid bit of the SXIP?
2753 (this is only used on the 88k). */
2755 if (!bpstat_explains_signal (stop_bpstat
)
2756 && (stop_signal
!= TARGET_SIGNAL_CHLD
)
2757 && !stopped_by_random_signal
)
2759 #endif /* SHIFT_INST_REGS */
2761 resume (CURRENTLY_STEPPING (), stop_signal
);
2766 if (target_has_execution
)
2768 /* Are we stopping for a vfork event? We only stop when we see
2769 the child's event. However, we may not yet have seen the
2770 parent's event. And, inferior_pid is still set to the parent's
2771 pid, until we resume again and follow either the parent or child.
2773 To ensure that we can really touch inferior_pid (aka, the
2774 parent process) -- which calls to functions like read_pc
2775 implicitly do -- wait on the parent if necessary. */
2776 if ((pending_follow
.kind
== TARGET_WAITKIND_VFORKED
)
2777 && !pending_follow
.fork_event
.saw_parent_fork
)
2783 if (target_wait_hook
)
2784 parent_pid
= target_wait_hook (-1, &w
);
2786 parent_pid
= target_wait (-1, &w
);
2788 while (parent_pid
!= inferior_pid
);
2791 /* Assuming the inferior still exists, set these up for next
2792 time, just like we did above if we didn't break out of the
2794 prev_pc
= read_pc ();
2795 prev_func_start
= stop_func_start
;
2796 prev_func_name
= stop_func_name
;
2798 do_cleanups (old_cleanups
);
2801 /* This function returns TRUE if ep is an internal breakpoint
2802 set to catch generic shared library (aka dynamically-linked
2803 library) events. (This is *NOT* the same as a catchpoint for a
2804 shlib event. The latter is something a user can set; this is
2805 something gdb sets for its own use, and isn't ever shown to a
2808 is_internal_shlib_eventpoint (ep
)
2809 struct breakpoint
*ep
;
2812 (ep
->type
== bp_shlib_event
)
2816 /* This function returns TRUE if bs indicates that the inferior
2817 stopped due to a shared library (aka dynamically-linked library)
2820 stopped_for_internal_shlib_event (bs
)
2823 /* Note that multiple eventpoints may've caused the stop. Any
2824 that are associated with shlib events will be accepted. */
2825 for (; bs
!= NULL
; bs
= bs
->next
)
2827 if ((bs
->breakpoint_at
!= NULL
)
2828 && is_internal_shlib_eventpoint (bs
->breakpoint_at
))
2832 /* If we get here, then no candidate was found. */
2836 /* This function returns TRUE if bs indicates that the inferior
2837 stopped due to a shared library (aka dynamically-linked library)
2838 event caught by a catchpoint.
2840 If TRUE, cp_p is set to point to the catchpoint.
2842 Else, the value of cp_p is undefined. */
2844 stopped_for_shlib_catchpoint (bs
, cp_p
)
2846 struct breakpoint
**cp_p
;
2848 /* Note that multiple eventpoints may've caused the stop. Any
2849 that are associated with shlib events will be accepted. */
2852 for (; bs
!= NULL
; bs
= bs
->next
)
2854 if ((bs
->breakpoint_at
!= NULL
)
2855 && ep_is_shlib_catchpoint (bs
->breakpoint_at
))
2857 *cp_p
= bs
->breakpoint_at
;
2862 /* If we get here, then no candidate was found. */
2867 /* Here to return control to GDB when the inferior stops for real.
2868 Print appropriate messages, remove breakpoints, give terminal our modes.
2870 STOP_PRINT_FRAME nonzero means print the executing frame
2871 (pc, function, args, file, line number and line text).
2872 BREAKPOINTS_FAILED nonzero means stop was due to error
2873 attempting to insert breakpoints. */
2878 /* As with the notification of thread events, we want to delay
2879 notifying the user that we've switched thread context until
2880 the inferior actually stops.
2882 (Note that there's no point in saying anything if the inferior
2884 if (may_switch_from_inferior_pid
2885 && (switched_from_inferior_pid
!= inferior_pid
)
2886 && target_has_execution
)
2888 target_terminal_ours_for_output ();
2889 printf_filtered ("[Switched to %s]\n",
2890 target_pid_or_tid_to_str (inferior_pid
));
2891 switched_from_inferior_pid
= inferior_pid
;
2894 /* Make sure that the current_frame's pc is correct. This
2895 is a correction for setting up the frame info before doing
2896 DECR_PC_AFTER_BREAK */
2897 if (target_has_execution
&& get_current_frame ())
2898 (get_current_frame ())->pc
= read_pc ();
2900 if (breakpoints_failed
)
2902 target_terminal_ours_for_output ();
2903 print_sys_errmsg ("ptrace", breakpoints_failed
);
2904 printf_filtered ("Stopped; cannot insert breakpoints.\n\
2905 The same program may be running in another process.\n");
2908 if (target_has_execution
&& breakpoints_inserted
)
2910 if (remove_breakpoints ())
2912 target_terminal_ours_for_output ();
2913 printf_filtered ("Cannot remove breakpoints because ");
2914 printf_filtered ("program is no longer writable.\n");
2915 printf_filtered ("It might be running in another process.\n");
2916 printf_filtered ("Further execution is probably impossible.\n");
2919 breakpoints_inserted
= 0;
2921 /* Delete the breakpoint we stopped at, if it wants to be deleted.
2922 Delete any breakpoint that is to be deleted at the next stop. */
2924 breakpoint_auto_delete (stop_bpstat
);
2926 /* If an auto-display called a function and that got a signal,
2927 delete that auto-display to avoid an infinite recursion. */
2929 if (stopped_by_random_signal
)
2930 disable_current_display ();
2932 /* Don't print a message if in the middle of doing a "step n"
2933 operation for n > 1 */
2934 if (step_multi
&& stop_step
)
2937 target_terminal_ours ();
2939 /* Did we stop because the user set the stop_on_solib_events
2940 variable? (If so, we report this as a generic, "Stopped due
2941 to shlib event" message.) */
2942 if (stopped_for_internal_shlib_event (stop_bpstat
))
2944 printf_filtered ("Stopped due to shared library event\n");
2947 /* Look up the hook_stop and run it if it exists. */
2949 if (stop_command
&& stop_command
->hook
)
2951 catch_errors (hook_stop_stub
, stop_command
->hook
,
2952 "Error while running hook_stop:\n", RETURN_MASK_ALL
);
2955 if (!target_has_stack
)
2961 /* Select innermost stack frame - i.e., current frame is frame 0,
2962 and current location is based on that.
2963 Don't do this on return from a stack dummy routine,
2964 or if the program has exited. */
2966 if (!stop_stack_dummy
)
2968 select_frame (get_current_frame (), 0);
2970 /* Print current location without a level number, if
2971 we have changed functions or hit a breakpoint.
2972 Print source line if we have one.
2973 bpstat_print() contains the logic deciding in detail
2974 what to print, based on the event(s) that just occurred. */
2976 if (stop_print_frame
)
2981 bpstat_ret
= bpstat_print (stop_bpstat
);
2982 /* bpstat_print() returned one of:
2983 -1: Didn't print anything
2984 0: Printed preliminary "Breakpoint n, " message, desires
2986 1: Printed something, don't tack on location */
2988 if (bpstat_ret
== -1)
2990 && step_frame_address
== FRAME_FP (get_current_frame ())
2991 && step_start_function
== find_pc_function (stop_pc
))
2992 source_flag
= -1; /* finished step, just print source line */
2994 source_flag
= 1; /* print location and source line */
2995 else if (bpstat_ret
== 0) /* hit bpt, desire location */
2996 source_flag
= 1; /* print location and source line */
2997 else /* bpstat_ret == 1, hit bpt, do not desire location */
2998 source_flag
= -1; /* just print source line */
3000 /* The behavior of this routine with respect to the source
3002 -1: Print only source line
3003 0: Print only location
3004 1: Print location and source line */
3005 show_and_print_stack_frame (selected_frame
, -1, source_flag
);
3007 /* Display the auto-display expressions. */
3012 /* Save the function value return registers, if we care.
3013 We might be about to restore their previous contents. */
3014 if (proceed_to_finish
)
3015 read_register_bytes (0, stop_registers
, REGISTER_BYTES
);
3017 if (stop_stack_dummy
)
3019 /* Pop the empty frame that contains the stack dummy.
3020 POP_FRAME ends with a setting of the current frame, so we
3021 can use that next. */
3023 /* Set stop_pc to what it was before we called the function.
3024 Can't rely on restore_inferior_status because that only gets
3025 called if we don't stop in the called function. */
3026 stop_pc
= read_pc ();
3027 select_frame (get_current_frame (), 0);
3031 TUIDO (((TuiOpaqueFuncPtr
) tui_vCheckDataValues
, selected_frame
));
3034 annotate_stopped ();
3038 hook_stop_stub (cmd
)
3041 execute_user_command ((struct cmd_list_element
*) cmd
, 0);
3046 signal_stop_state (signo
)
3049 return signal_stop
[signo
];
3053 signal_print_state (signo
)
3056 return signal_print
[signo
];
3060 signal_pass_state (signo
)
3063 return signal_program
[signo
];
3070 Signal Stop\tPrint\tPass to program\tDescription\n");
3074 sig_print_info (oursig
)
3075 enum target_signal oursig
;
3077 char *name
= target_signal_to_name (oursig
);
3078 int name_padding
= 13 - strlen (name
);
3079 if (name_padding
<= 0)
3082 printf_filtered ("%s", name
);
3083 printf_filtered ("%*.*s ", name_padding
, name_padding
,
3085 printf_filtered ("%s\t", signal_stop
[oursig
] ? "Yes" : "No");
3086 printf_filtered ("%s\t", signal_print
[oursig
] ? "Yes" : "No");
3087 printf_filtered ("%s\t\t", signal_program
[oursig
] ? "Yes" : "No");
3088 printf_filtered ("%s\n", target_signal_to_string (oursig
));
3091 /* Specify how various signals in the inferior should be handled. */
3094 handle_command (args
, from_tty
)
3099 int digits
, wordlen
;
3100 int sigfirst
, signum
, siglast
;
3101 enum target_signal oursig
;
3104 unsigned char *sigs
;
3105 struct cleanup
*old_chain
;
3109 error_no_arg ("signal to handle");
3112 /* Allocate and zero an array of flags for which signals to handle. */
3114 nsigs
= (int) TARGET_SIGNAL_LAST
;
3115 sigs
= (unsigned char *) alloca (nsigs
);
3116 memset (sigs
, 0, nsigs
);
3118 /* Break the command line up into args. */
3120 argv
= buildargv (args
);
3125 old_chain
= make_cleanup_freeargv (argv
);
3127 /* Walk through the args, looking for signal oursigs, signal names, and
3128 actions. Signal numbers and signal names may be interspersed with
3129 actions, with the actions being performed for all signals cumulatively
3130 specified. Signal ranges can be specified as <LOW>-<HIGH>. */
3132 while (*argv
!= NULL
)
3134 wordlen
= strlen (*argv
);
3135 for (digits
= 0; isdigit ((*argv
)[digits
]); digits
++)
3139 sigfirst
= siglast
= -1;
3141 if (wordlen
>= 1 && !strncmp (*argv
, "all", wordlen
))
3143 /* Apply action to all signals except those used by the
3144 debugger. Silently skip those. */
3147 siglast
= nsigs
- 1;
3149 else if (wordlen
>= 1 && !strncmp (*argv
, "stop", wordlen
))
3151 SET_SIGS (nsigs
, sigs
, signal_stop
);
3152 SET_SIGS (nsigs
, sigs
, signal_print
);
3154 else if (wordlen
>= 1 && !strncmp (*argv
, "ignore", wordlen
))
3156 UNSET_SIGS (nsigs
, sigs
, signal_program
);
3158 else if (wordlen
>= 2 && !strncmp (*argv
, "print", wordlen
))
3160 SET_SIGS (nsigs
, sigs
, signal_print
);
3162 else if (wordlen
>= 2 && !strncmp (*argv
, "pass", wordlen
))
3164 SET_SIGS (nsigs
, sigs
, signal_program
);
3166 else if (wordlen
>= 3 && !strncmp (*argv
, "nostop", wordlen
))
3168 UNSET_SIGS (nsigs
, sigs
, signal_stop
);
3170 else if (wordlen
>= 3 && !strncmp (*argv
, "noignore", wordlen
))
3172 SET_SIGS (nsigs
, sigs
, signal_program
);
3174 else if (wordlen
>= 4 && !strncmp (*argv
, "noprint", wordlen
))
3176 UNSET_SIGS (nsigs
, sigs
, signal_print
);
3177 UNSET_SIGS (nsigs
, sigs
, signal_stop
);
3179 else if (wordlen
>= 4 && !strncmp (*argv
, "nopass", wordlen
))
3181 UNSET_SIGS (nsigs
, sigs
, signal_program
);
3183 else if (digits
> 0)
3185 /* It is numeric. The numeric signal refers to our own
3186 internal signal numbering from target.h, not to host/target
3187 signal number. This is a feature; users really should be
3188 using symbolic names anyway, and the common ones like
3189 SIGHUP, SIGINT, SIGALRM, etc. will work right anyway. */
3191 sigfirst
= siglast
= (int)
3192 target_signal_from_command (atoi (*argv
));
3193 if ((*argv
)[digits
] == '-')
3196 target_signal_from_command (atoi ((*argv
) + digits
+ 1));
3198 if (sigfirst
> siglast
)
3200 /* Bet he didn't figure we'd think of this case... */
3208 oursig
= target_signal_from_name (*argv
);
3209 if (oursig
!= TARGET_SIGNAL_UNKNOWN
)
3211 sigfirst
= siglast
= (int) oursig
;
3215 /* Not a number and not a recognized flag word => complain. */
3216 error ("Unrecognized or ambiguous flag word: \"%s\".", *argv
);
3220 /* If any signal numbers or symbol names were found, set flags for
3221 which signals to apply actions to. */
3223 for (signum
= sigfirst
; signum
>= 0 && signum
<= siglast
; signum
++)
3225 switch ((enum target_signal
) signum
)
3227 case TARGET_SIGNAL_TRAP
:
3228 case TARGET_SIGNAL_INT
:
3229 if (!allsigs
&& !sigs
[signum
])
3231 if (query ("%s is used by the debugger.\n\
3232 Are you sure you want to change it? ",
3233 target_signal_to_name
3234 ((enum target_signal
) signum
)))
3240 printf_unfiltered ("Not confirmed, unchanged.\n");
3241 gdb_flush (gdb_stdout
);
3245 case TARGET_SIGNAL_0
:
3246 case TARGET_SIGNAL_DEFAULT
:
3247 case TARGET_SIGNAL_UNKNOWN
:
3248 /* Make sure that "all" doesn't print these. */
3259 target_notice_signals (inferior_pid
);
3263 /* Show the results. */
3264 sig_print_header ();
3265 for (signum
= 0; signum
< nsigs
; signum
++)
3269 sig_print_info (signum
);
3274 do_cleanups (old_chain
);
3278 xdb_handle_command (args
, from_tty
)
3283 struct cleanup
*old_chain
;
3285 /* Break the command line up into args. */
3287 argv
= buildargv (args
);
3292 old_chain
= make_cleanup_freeargv (argv
);
3293 if (argv
[1] != (char *) NULL
)
3298 bufLen
= strlen (argv
[0]) + 20;
3299 argBuf
= (char *) xmalloc (bufLen
);
3303 enum target_signal oursig
;
3305 oursig
= target_signal_from_name (argv
[0]);
3306 memset (argBuf
, 0, bufLen
);
3307 if (strcmp (argv
[1], "Q") == 0)
3308 sprintf (argBuf
, "%s %s", argv
[0], "noprint");
3311 if (strcmp (argv
[1], "s") == 0)
3313 if (!signal_stop
[oursig
])
3314 sprintf (argBuf
, "%s %s", argv
[0], "stop");
3316 sprintf (argBuf
, "%s %s", argv
[0], "nostop");
3318 else if (strcmp (argv
[1], "i") == 0)
3320 if (!signal_program
[oursig
])
3321 sprintf (argBuf
, "%s %s", argv
[0], "pass");
3323 sprintf (argBuf
, "%s %s", argv
[0], "nopass");
3325 else if (strcmp (argv
[1], "r") == 0)
3327 if (!signal_print
[oursig
])
3328 sprintf (argBuf
, "%s %s", argv
[0], "print");
3330 sprintf (argBuf
, "%s %s", argv
[0], "noprint");
3336 handle_command (argBuf
, from_tty
);
3338 printf_filtered ("Invalid signal handling flag.\n");
3343 do_cleanups (old_chain
);
3346 /* Print current contents of the tables set by the handle command.
3347 It is possible we should just be printing signals actually used
3348 by the current target (but for things to work right when switching
3349 targets, all signals should be in the signal tables). */
3352 signals_info (signum_exp
, from_tty
)
3356 enum target_signal oursig
;
3357 sig_print_header ();
3361 /* First see if this is a symbol name. */
3362 oursig
= target_signal_from_name (signum_exp
);
3363 if (oursig
== TARGET_SIGNAL_UNKNOWN
)
3365 /* No, try numeric. */
3367 target_signal_from_command (parse_and_eval_address (signum_exp
));
3369 sig_print_info (oursig
);
3373 printf_filtered ("\n");
3374 /* These ugly casts brought to you by the native VAX compiler. */
3375 for (oursig
= TARGET_SIGNAL_FIRST
;
3376 (int) oursig
< (int) TARGET_SIGNAL_LAST
;
3377 oursig
= (enum target_signal
) ((int) oursig
+ 1))
3381 if (oursig
!= TARGET_SIGNAL_UNKNOWN
3382 && oursig
!= TARGET_SIGNAL_DEFAULT
3383 && oursig
!= TARGET_SIGNAL_0
)
3384 sig_print_info (oursig
);
3387 printf_filtered ("\nUse the \"handle\" command to change these tables.\n");
3390 struct inferior_status
3392 enum target_signal stop_signal
;
3396 int stop_stack_dummy
;
3397 int stopped_by_random_signal
;
3399 CORE_ADDR step_range_start
;
3400 CORE_ADDR step_range_end
;
3401 CORE_ADDR step_frame_address
;
3402 int step_over_calls
;
3403 CORE_ADDR step_resume_break_address
;
3404 int stop_after_trap
;
3405 int stop_soon_quietly
;
3406 CORE_ADDR selected_frame_address
;
3407 char *stop_registers
;
3409 /* These are here because if call_function_by_hand has written some
3410 registers and then decides to call error(), we better not have changed
3415 int breakpoint_proceeded
;
3416 int restore_stack_info
;
3417 int proceed_to_finish
;
3421 static struct inferior_status
*xmalloc_inferior_status
PARAMS ((void));
3422 static struct inferior_status
*
3423 xmalloc_inferior_status ()
3425 struct inferior_status
*inf_status
;
3426 inf_status
= xmalloc (sizeof (struct inferior_status
));
3427 inf_status
->stop_registers
= xmalloc (REGISTER_BYTES
);
3428 inf_status
->registers
= xmalloc (REGISTER_BYTES
);
3432 static void free_inferior_status
PARAMS ((struct inferior_status
*));
3434 free_inferior_status (inf_status
)
3435 struct inferior_status
*inf_status
;
3437 free (inf_status
->registers
);
3438 free (inf_status
->stop_registers
);
3443 write_inferior_status_register (inf_status
, regno
, val
)
3444 struct inferior_status
*inf_status
;
3448 int size
= REGISTER_RAW_SIZE(regno
);
3449 void *buf
= alloca (size
);
3450 store_signed_integer (buf
, size
, val
);
3451 memcpy (&inf_status
->registers
[REGISTER_BYTE (regno
)], buf
, size
);
3456 /* Save all of the information associated with the inferior<==>gdb
3457 connection. INF_STATUS is a pointer to a "struct inferior_status"
3458 (defined in inferior.h). */
3460 struct inferior_status
*
3461 save_inferior_status (restore_stack_info
)
3462 int restore_stack_info
;
3464 struct inferior_status
*inf_status
= xmalloc_inferior_status ();
3466 inf_status
->stop_signal
= stop_signal
;
3467 inf_status
->stop_pc
= stop_pc
;
3468 inf_status
->stop_step
= stop_step
;
3469 inf_status
->stop_stack_dummy
= stop_stack_dummy
;
3470 inf_status
->stopped_by_random_signal
= stopped_by_random_signal
;
3471 inf_status
->trap_expected
= trap_expected
;
3472 inf_status
->step_range_start
= step_range_start
;
3473 inf_status
->step_range_end
= step_range_end
;
3474 inf_status
->step_frame_address
= step_frame_address
;
3475 inf_status
->step_over_calls
= step_over_calls
;
3476 inf_status
->stop_after_trap
= stop_after_trap
;
3477 inf_status
->stop_soon_quietly
= stop_soon_quietly
;
3478 /* Save original bpstat chain here; replace it with copy of chain.
3479 If caller's caller is walking the chain, they'll be happier if we
3480 hand them back the original chain when restore_inferior_status is
3482 inf_status
->stop_bpstat
= stop_bpstat
;
3483 stop_bpstat
= bpstat_copy (stop_bpstat
);
3484 inf_status
->breakpoint_proceeded
= breakpoint_proceeded
;
3485 inf_status
->restore_stack_info
= restore_stack_info
;
3486 inf_status
->proceed_to_finish
= proceed_to_finish
;
3488 memcpy (inf_status
->stop_registers
, stop_registers
, REGISTER_BYTES
);
3490 read_register_bytes (0, inf_status
->registers
, REGISTER_BYTES
);
3492 record_selected_frame (&(inf_status
->selected_frame_address
),
3493 &(inf_status
->selected_level
));
3497 struct restore_selected_frame_args
3499 CORE_ADDR frame_address
;
3503 static int restore_selected_frame
PARAMS ((PTR
));
3506 restore_selected_frame (args
)
3509 struct restore_selected_frame_args
*fr
=
3510 (struct restore_selected_frame_args
*) args
;
3511 struct frame_info
*frame
;
3512 int level
= fr
->level
;
3514 frame
= find_relative_frame (get_current_frame (), &level
);
3516 /* If inf_status->selected_frame_address is NULL, there was no
3517 previously selected frame. */
3518 if (frame
== NULL
||
3519 /* FRAME_FP (frame) != fr->frame_address || */
3520 /* elz: deleted this check as a quick fix to the problem that
3521 for function called by hand gdb creates no internal frame
3522 structure and the real stack and gdb's idea of stack are
3523 different if nested calls by hands are made.
3525 mvs: this worries me. */
3528 warning ("Unable to restore previously selected frame.\n");
3532 select_frame (frame
, fr
->level
);
3538 restore_inferior_status (inf_status
)
3539 struct inferior_status
*inf_status
;
3541 stop_signal
= inf_status
->stop_signal
;
3542 stop_pc
= inf_status
->stop_pc
;
3543 stop_step
= inf_status
->stop_step
;
3544 stop_stack_dummy
= inf_status
->stop_stack_dummy
;
3545 stopped_by_random_signal
= inf_status
->stopped_by_random_signal
;
3546 trap_expected
= inf_status
->trap_expected
;
3547 step_range_start
= inf_status
->step_range_start
;
3548 step_range_end
= inf_status
->step_range_end
;
3549 step_frame_address
= inf_status
->step_frame_address
;
3550 step_over_calls
= inf_status
->step_over_calls
;
3551 stop_after_trap
= inf_status
->stop_after_trap
;
3552 stop_soon_quietly
= inf_status
->stop_soon_quietly
;
3553 bpstat_clear (&stop_bpstat
);
3554 stop_bpstat
= inf_status
->stop_bpstat
;
3555 breakpoint_proceeded
= inf_status
->breakpoint_proceeded
;
3556 proceed_to_finish
= inf_status
->proceed_to_finish
;
3558 /* FIXME: Is the restore of stop_registers always needed */
3559 memcpy (stop_registers
, inf_status
->stop_registers
, REGISTER_BYTES
);
3561 /* The inferior can be gone if the user types "print exit(0)"
3562 (and perhaps other times). */
3563 if (target_has_execution
)
3564 write_register_bytes (0, inf_status
->registers
, REGISTER_BYTES
);
3566 /* FIXME: If we are being called after stopping in a function which
3567 is called from gdb, we should not be trying to restore the
3568 selected frame; it just prints a spurious error message (The
3569 message is useful, however, in detecting bugs in gdb (like if gdb
3570 clobbers the stack)). In fact, should we be restoring the
3571 inferior status at all in that case? . */
3573 if (target_has_stack
&& inf_status
->restore_stack_info
)
3575 struct restore_selected_frame_args fr
;
3576 fr
.level
= inf_status
->selected_level
;
3577 fr
.frame_address
= inf_status
->selected_frame_address
;
3578 /* The point of catch_errors is that if the stack is clobbered,
3579 walking the stack might encounter a garbage pointer and error()
3580 trying to dereference it. */
3581 if (catch_errors (restore_selected_frame
, &fr
,
3582 "Unable to restore previously selected frame:\n",
3583 RETURN_MASK_ERROR
) == 0)
3584 /* Error in restoring the selected frame. Select the innermost
3588 select_frame (get_current_frame (), 0);
3592 free_inferior_status (inf_status
);
3596 discard_inferior_status (inf_status
)
3597 struct inferior_status
*inf_status
;
3599 /* See save_inferior_status for info on stop_bpstat. */
3600 bpstat_clear (&inf_status
->stop_bpstat
);
3601 free_inferior_status (inf_status
);
3605 set_follow_fork_mode_command (arg
, from_tty
, c
)
3608 struct cmd_list_element
*c
;
3610 if (!STREQ (arg
, "parent") &&
3611 !STREQ (arg
, "child") &&
3612 !STREQ (arg
, "both") &&
3613 !STREQ (arg
, "ask"))
3614 error ("follow-fork-mode must be one of \"parent\", \"child\", \"both\" or \"ask\".");
3616 if (follow_fork_mode_string
!= NULL
)
3617 free (follow_fork_mode_string
);
3618 follow_fork_mode_string
= savestring (arg
, strlen (arg
));
3623 static void build_infrun
PARAMS ((void));
3627 stop_registers
= xmalloc (REGISTER_BYTES
);
3632 _initialize_infrun ()
3635 register int numsigs
;
3636 struct cmd_list_element
*c
;
3640 add_info ("signals", signals_info
,
3641 "What debugger does when program gets various signals.\n\
3642 Specify a signal as argument to print info on that signal only.");
3643 add_info_alias ("handle", "signals", 0);
3645 add_com ("handle", class_run
, handle_command
,
3646 concat ("Specify how to handle a signal.\n\
3647 Args are signals and actions to apply to those signals.\n\
3648 Symbolic signals (e.g. SIGSEGV) are recommended but numeric signals\n\
3649 from 1-15 are allowed for compatibility with old versions of GDB.\n\
3650 Numeric ranges may be specified with the form LOW-HIGH (e.g. 1-5).\n\
3651 The special arg \"all\" is recognized to mean all signals except those\n\
3652 used by the debugger, typically SIGTRAP and SIGINT.\n",
3653 "Recognized actions include \"stop\", \"nostop\", \"print\", \"noprint\",\n\
3654 \"pass\", \"nopass\", \"ignore\", or \"noignore\".\n\
3655 Stop means reenter debugger if this signal happens (implies print).\n\
3656 Print means print a message if this signal happens.\n\
3657 Pass means let program see this signal; otherwise program doesn't know.\n\
3658 Ignore is a synonym for nopass and noignore is a synonym for pass.\n\
3659 Pass and Stop may be combined.", NULL
));
3662 add_com ("lz", class_info
, signals_info
,
3663 "What debugger does when program gets various signals.\n\
3664 Specify a signal as argument to print info on that signal only.");
3665 add_com ("z", class_run
, xdb_handle_command
,
3666 concat ("Specify how to handle a signal.\n\
3667 Args are signals and actions to apply to those signals.\n\
3668 Symbolic signals (e.g. SIGSEGV) are recommended but numeric signals\n\
3669 from 1-15 are allowed for compatibility with old versions of GDB.\n\
3670 Numeric ranges may be specified with the form LOW-HIGH (e.g. 1-5).\n\
3671 The special arg \"all\" is recognized to mean all signals except those\n\
3672 used by the debugger, typically SIGTRAP and SIGINT.\n",
3673 "Recognized actions include \"s\" (toggles between stop and nostop), \n\
3674 \"r\" (toggles between print and noprint), \"i\" (toggles between pass and \
3675 nopass), \"Q\" (noprint)\n\
3676 Stop means reenter debugger if this signal happens (implies print).\n\
3677 Print means print a message if this signal happens.\n\
3678 Pass means let program see this signal; otherwise program doesn't know.\n\
3679 Ignore is a synonym for nopass and noignore is a synonym for pass.\n\
3680 Pass and Stop may be combined.", NULL
));
3684 stop_command
= add_cmd ("stop", class_obscure
, not_just_help_class_command
,
3685 "There is no `stop' command, but you can set a hook on `stop'.\n\
3686 This allows you to set a list of commands to be run each time execution\n\
3687 of the program stops.", &cmdlist
);
3689 numsigs
= (int) TARGET_SIGNAL_LAST
;
3690 signal_stop
= (unsigned char *)
3691 xmalloc (sizeof (signal_stop
[0]) * numsigs
);
3692 signal_print
= (unsigned char *)
3693 xmalloc (sizeof (signal_print
[0]) * numsigs
);
3694 signal_program
= (unsigned char *)
3695 xmalloc (sizeof (signal_program
[0]) * numsigs
);
3696 for (i
= 0; i
< numsigs
; i
++)
3699 signal_print
[i
] = 1;
3700 signal_program
[i
] = 1;
3703 /* Signals caused by debugger's own actions
3704 should not be given to the program afterwards. */
3705 signal_program
[TARGET_SIGNAL_TRAP
] = 0;
3706 signal_program
[TARGET_SIGNAL_INT
] = 0;
3708 /* Signals that are not errors should not normally enter the debugger. */
3709 signal_stop
[TARGET_SIGNAL_ALRM
] = 0;
3710 signal_print
[TARGET_SIGNAL_ALRM
] = 0;
3711 signal_stop
[TARGET_SIGNAL_VTALRM
] = 0;
3712 signal_print
[TARGET_SIGNAL_VTALRM
] = 0;
3713 signal_stop
[TARGET_SIGNAL_PROF
] = 0;
3714 signal_print
[TARGET_SIGNAL_PROF
] = 0;
3715 signal_stop
[TARGET_SIGNAL_CHLD
] = 0;
3716 signal_print
[TARGET_SIGNAL_CHLD
] = 0;
3717 signal_stop
[TARGET_SIGNAL_IO
] = 0;
3718 signal_print
[TARGET_SIGNAL_IO
] = 0;
3719 signal_stop
[TARGET_SIGNAL_POLL
] = 0;
3720 signal_print
[TARGET_SIGNAL_POLL
] = 0;
3721 signal_stop
[TARGET_SIGNAL_URG
] = 0;
3722 signal_print
[TARGET_SIGNAL_URG
] = 0;
3723 signal_stop
[TARGET_SIGNAL_WINCH
] = 0;
3724 signal_print
[TARGET_SIGNAL_WINCH
] = 0;
3728 (add_set_cmd ("stop-on-solib-events", class_support
, var_zinteger
,
3729 (char *) &stop_on_solib_events
,
3730 "Set stopping for shared library events.\n\
3731 If nonzero, gdb will give control to the user when the dynamic linker\n\
3732 notifies gdb of shared library events. The most common event of interest\n\
3733 to the user would be loading/unloading of a new library.\n",
3738 c
= add_set_enum_cmd ("follow-fork-mode",
3740 follow_fork_mode_kind_names
,
3741 (char *) &follow_fork_mode_string
,
3742 /* ??rehrauer: The "both" option is broken, by what may be a 10.20
3743 kernel problem. It's also not terribly useful without a GUI to
3744 help the user drive two debuggers. So for now, I'm disabling
3745 the "both" option. */
3746 /* "Set debugger response to a program call of fork \
3748 A fork or vfork creates a new process. follow-fork-mode can be:\n\
3749 parent - the original process is debugged after a fork\n\
3750 child - the new process is debugged after a fork\n\
3751 both - both the parent and child are debugged after a fork\n\
3752 ask - the debugger will ask for one of the above choices\n\
3753 For \"both\", another copy of the debugger will be started to follow\n\
3754 the new child process. The original debugger will continue to follow\n\
3755 the original parent process. To distinguish their prompts, the\n\
3756 debugger copy's prompt will be changed.\n\
3757 For \"parent\" or \"child\", the unfollowed process will run free.\n\
3758 By default, the debugger will follow the parent process.",
3760 "Set debugger response to a program call of fork \
3762 A fork or vfork creates a new process. follow-fork-mode can be:\n\
3763 parent - the original process is debugged after a fork\n\
3764 child - the new process is debugged after a fork\n\
3765 ask - the debugger will ask for one of the above choices\n\
3766 For \"parent\" or \"child\", the unfollowed process will run free.\n\
3767 By default, the debugger will follow the parent process.",
3769 /* c->function.sfunc = ;*/
3770 add_show_from_set (c
, &showlist
);
3772 set_follow_fork_mode_command ("parent", 0, NULL
);
3774 c
= add_set_enum_cmd ("scheduler-locking", class_run
,
3775 scheduler_enums
, /* array of string names */
3776 (char *) &scheduler_mode
, /* current mode */
3777 "Set mode for locking scheduler during execution.\n\
3778 off == no locking (threads may preempt at any time)\n\
3779 on == full locking (no thread except the current thread may run)\n\
3780 step == scheduler locked during every single-step operation.\n\
3781 In this mode, no other thread may run during a step command.\n\
3782 Other threads may run while stepping over a function call ('next').",
3785 c
->function
.sfunc
= set_schedlock_func
; /* traps on target vector */
3786 add_show_from_set (c
, &showlist
);