diff src/sighandlers.cc @ 4185:8f6d418d31c3

[project @ 2002-11-15 23:22:03 by jwe]
author jwe
date Fri, 15 Nov 2002 23:22:27 +0000
parents 4d1d7c51205c
children ccfdb55c8156
line wrap: on
line diff
--- a/src/sighandlers.cc	Fri Nov 15 20:58:50 2002 +0000
+++ b/src/sighandlers.cc	Fri Nov 15 23:22:27 2002 +0000
@@ -39,9 +39,11 @@
 #include "cmd-edit.h"
 #include "quit.h"
 
+#include "defun.h"
 #include "error.h"
 #include "load-save.h"
 #include "pager.h"
+#include "pt-bp.h"
 #include "sighandlers.h"
 #include "syswait.h"
 #include "toplev.h"
@@ -54,6 +56,9 @@
 // TRUE means we can be interrupted.
 bool can_interrupt = false;
 
+// TRUE means we should try to enter the debugger on SIGINT.
+static bool Vdebug_on_interrupt = false;
+
 #if RETSIGTYPE == void
 #define SIGHANDLER_RETURN(status) return
 #else
@@ -266,15 +271,23 @@
 
   if (can_interrupt)
     {
-#if defined (USE_EXCEPTIONS_FOR_INTERRUPTS)
+      if (Vdebug_on_interrupt)
+	{
+	  if (! octave_debug_on_interrupt_state)
+	    {
+	      octave_debug_on_interrupt_state = true;
+
+	      SIGHANDLER_RETURN (0);
+	    }
+	  else
+	    // Clear the flag and do normal interrupt stuff.
+	    octave_debug_on_interrupt_state = false;
+	}
+
       octave_interrupt_state = 1;
 
       if (octave_interrupt_immediately)
 	octave_jump_to_enclosing_context ();
-#else
-      octave_interrupt_state = 1;
-      panic_impossible ();
-#endif
     }
 
   SIGHANDLER_RETURN (0);
@@ -601,6 +614,28 @@
     return foo;
 }
 
+static int
+debug_on_interrupt (void)
+{
+  Vdebug_on_interrupt = check_preference ("debug_on_interrupt");
+
+  return 0;
+}
+
+void
+symbols_of_sighandlers (void)
+{
+  DEFVAR (debug_on_interrupt, 0.0, debug_on_interrupt,
+    "-*- texinfo -*-\n\
+@defvr {Built-in Variable} debug_on_interrupt\n\
+If @code{debug_on_interrupt} is nonzero, Octave will try to enter\n\
+debugging mode when it receives an interrupt signal (typically\n\
+generated with @kbd{C-c}).  If a second interrupt signal is received\n\
+before reaching the debugging mode, a normal interrupt will occur.\n\
+The default value is 0.\n\
+@end defvr");
+}
+
 /*
 ;;; Local Variables: ***
 ;;; mode: C++ ***