This is the mail archive of the
gdb-patches@sourceware.cygnus.com
mailing list for the GDB project.
RFA: unwindonsignal (REPOST)
- To: Fernando Nasser <fnasser at cygnus dot com>
- Subject: RFA: unwindonsignal (REPOST)
- From: David Taylor <taylor at cygnus dot com>
- Date: Mon, 21 Feb 2000 16:24:54 -0500
- cc: gdb-patches at sourceware dot cygnus dot com
Date: Mon, 21 Feb 2000 15:19:24 -0500
From: Fernando Nasser <fnasser@cygnus.com>
As suggested by Elena, the command was moved to valops.c
2000-02-18 Fernando Nasser <fnasser@cygnus.com>
* infcmd.c (run_stack_dummy): Do not pop frame on random signal.
* valops.c (_initialize_valops): Add command set unwindonsignal.
(hand_function_call): Test for unwind_on_signal and act
accordingly.
--
Fernando Nasser
Red Hat - Toronto E-Mail: fnasser@cygnus.com
2323 Yonge Street, Suite #300 Tel: 416-482-2661 ext. 311
Toronto, Ontario M4P 2C9 Fax: 416-482-6299
Index: valops.c
===================================================================
RCS file: /cvs/src/src/gdb/valops.c,v
retrieving revision 1.1.1.11
diff -c -p -r1.1.1.11 valops.c
*** valops.c 2000/02/01 03:19:12 1.1.1.11
--- valops.c 2000/02/21 20:15:48
*************** static int auto_abandon = 0;
*** 84,89 ****
--- 83,95 ----
#endif
int overload_resolution = 0;
+
+ /* This boolean tells what gdb should do if a signal is received while
in
+ a function called from gdb (call dummy). If set, gdb unwinds the
stack
+ and restore the context to what as it was before the call.
+ The default is to stop in the frame where the signal was received.
*/
+
+ int unwind_on_signal_p = 0;
*************** You must use a pointer to function type
*** 1695,1710 ****
/* We stopped inside the FUNCTION because of a random signal.
Further execution of the FUNCTION is not allowed. */
! /* In this case, we must do the cleanups because we don't
! want the dummy anymore (the dummy frame has been poped
already. */
! do_cleanups (old_chain);
! /* FIXME: Insert a bunch of wrap_here; name can be very long if
it's
! a C++ name with arguments and stuff. */
! error ("\
! The program being debugged stopped while in a function called from
GDB.\n\
Evaluation of the expression containing the function (%s) will be
abandoned.",
! name);
}
if (rc == 2)
--- 1701,1746 ----
/* We stopped inside the FUNCTION because of a random signal.
Further execution of the FUNCTION is not allowed. */
! if (unwind_on_signal_p)
! {
! /* The user wants the context restored. */
! /* We must get back to the frame we were before the dummy
call. */
! POP_FRAME;
!
! /* In this case, we must do the cleanups because we don't
! want the dummy anymore */
! do_cleanups (old_chain);
!
! /* FIXME: Insert a bunch of wrap_here; name can be very long
if it's
! a C++ name with arguments and stuff. */
! error ("\
! The program being debugged was signaled while in a function called
from GDB.\n\
! GDB has restored the context to what it was before the call.\n\
! To change this behavior use \"set unwindonsignal off\"\n\
Evaluation of the expression containing the function (%s) will be
abandoned.",
! name);
! }
! else
! {
! /* The user wants to stay in the frame where we stopped
(default).*/
!
! /* If we did the cleanups, we would print a spurious error
! message (Unable to restore previously selected frame),
! would write the registers from the inf_status (which is
! wrong), and would do other wrong things. */
! discard_cleanups (old_chain);
! discard_inferior_status (inf_status);
!
! /* FIXME: Insert a bunch of wrap_here; name can be very long
if it's
! a C++ name with arguments and stuff. */
! error ("\
! The program being debugged was signaled while in a function called
from GDB.\n\
! GDB remains in the frame where the signal was received.\n\
! To change this behavior use \"set unwindonsignal on\"\n\
! Evaluation of the expression containing the function (%s) will be
abandoned.",
! name);
! }
}
if (rc == 2)
*************** _initialize_valops ()
*** 3531,3534 ****
--- 3567,3579 ----
&showlist);
overload_resolution = 1;
+ add_show_from_set (
+ add_set_cmd ("unwindonsignal", no_class, var_boolean,
+ (char *) &unwind_on_signal_p,
+ "Set unwinding of stack if a signal is received while in a call
dummy.\n\
+ The unwindonsignal lets the user determine what gdb should do if a
signal\n\
+ is received while in a function called from gdb (call dummy). If set,
gdb\n\
+ unwinds the stack and restore the context to what as it was before the
call.\n\
+ The default is to stop in the frame where the signal was received.",
&setlist),
+ &showlist);
}
Index: infcmd.c
===================================================================
RCS file: /cvs/src/src/gdb/infcmd.c,v
retrieving revision 1.1.1.17
diff -c -p -r1.1.1.17 infcmd.c
*** infcmd.c 2000/02/03 04:14:31 1.1.1.17
--- infcmd.c 2000/02/21 20:15:48
*************** run_stack_dummy (addr, buffer)
*** 926,945 ****
discard_cleanups (old_cleanups);
if (stopped_by_random_signal)
! {
! /* If the inferior execution fails we need to restore our
! stack. It is not done by proceed() in this case. */
! /* Pop the empty frame that contains the stack dummy.
! POP_FRAME ends with a setting of the current frame, so we
! can use that next. */
! POP_FRAME;
! return 1;
! }
/* We may also stop prematurely because we hit a breakpoint in the
! called routine. We do not pop the frame as the user may wish
! to single step or continue from there. */
if (!stop_stack_dummy)
return 2;
--- 926,937 ----
discard_cleanups (old_cleanups);
+ /* We can stop during an inferior call because a signal is received.
*/
if (stopped_by_random_signal)
! return 1;
/* We may also stop prematurely because we hit a breakpoint in the
! called routine. */
if (!stop_stack_dummy)
return 2;
You don't need the calls to do_cleanups in valops.c -- error
unconditionally calls return_to_top_level which unconditionally calls
do_cleanups. Please remove them.
Assuming the extra line breaks above are due to a mis-configured
mailer at your end and not actually present in the diff, then the
valops.c part of this is approved.