This is the mail archive of the gdb-patches@sourceware.cygnus.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RFA: set unwindonsignal (as promissed)


This patch makes everybody happy.  Just set the flag as you like.

The default behavior is what gdb used to do before: stay in the frame
where the signal occurred.


2000-02-18  Fernando Nasser  <fnasser@cygnus.com>

        * top.c (init_main): Add command set unwindonsignal.
        * infcmd.c (run_stack_dummy): Do not pop frame on random signal.
        * valops.c (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: top.c
===================================================================
RCS file: /cvs/src/src/gdb/top.c,v
retrieving revision 1.2
diff -c -p -r1.2 top.c
*** top.c       2000/02/09 03:28:18     1.2
--- top.c       2000/02/19 01:57:16
*************** int linesize = 100;
*** 298,304 ****
--- 298,311 ----
     from the user, and have the user not notice that the user interface
     is issuing commands too.  */
  int server_command;
+  
+ /* 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;
+ 
  /* Baud rate specified for talking to serial target systems.  Default
     is left as -1, so targets can choose their own defaults.  */
  /* FIXME: This means that "show remotebaud" and gr_files_info can
print -1
*************** The conditional expression must follow t
*** 4266,4271 ****
--- 4273,4288 ----
  followed by a new line.  The nested commands must be entered one per
line,\n\
  and should be terminated by the word 'else' or `end'.  If an else
clause\n\
  is used, the same rules apply to its nested commands as to the first
ones.");
+ 
+   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);
  
    /* If target is open when baud changes, it doesn't take effect until
the
       next open (I think, not sure).  */
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/19 01:57:17
***************
*** 47,52 ****
--- 47,57 ----
     value operations with HP aCC code/runtime. */
  extern int hp_som_som_object_present;
  
+ /* 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.
*/
+ extern int unwind_on_signal_p;
  
  /* Local functions.  */
  
*************** 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)
--- 1700,1745 ----
        /* 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)
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/19 01:57:18
*************** 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;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]