Mercurial > hg > octave-terminal
changeset 4185:8f6d418d31c3
[project @ 2002-11-15 23:22:03 by jwe]
author | jwe |
---|---|
date | Fri, 15 Nov 2002 23:22:27 +0000 |
parents | e4b7578e5fc7 |
children | bf9c5ca4c3f3 |
files | doc/interpreter/debug.txi src/ChangeLog src/pt-bp.cc src/pt-bp.h src/sighandlers.cc |
diffstat | 5 files changed, 64 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/doc/interpreter/debug.txi +++ b/doc/interpreter/debug.txi @@ -15,6 +15,8 @@ @DOCSTRING(dbtype) -@DOCSTRING(debug_on_error) +@DOCSTRING(debug_on_interrupt) @DOCSTRING(debug_on_warning) + +@DOCSTRING(debug_on_error)
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,14 @@ 2002-11-15 John W. Eaton <jwe@bevo.che.wisc.edu> + * pt-bp.cc (octave_debug_on_interrupt_state): New global variable. + * pt-bp.h: Provide decl. + (MAYBE_DO_BREAKPOINT): Check it. + + * sighandlers.cc (sigint_handler): Handle debug_on_interrupt. + (Vdebug_on_interrupt): New static variable. + (symbols_of_sighandlers): New function. DEFVAR Vdebug_on_interrupt. + (debug_on_interrupt): New function. + * lex.h (YY_FATAL_ERROR): Use OCTAVE_QUIT here. * utils.cc (toplevel): Delete variable.
--- a/src/pt-bp.cc +++ b/src/pt-bp.cc @@ -33,6 +33,10 @@ #include "pager.h" #include "pt-all.h" +// TRUE means SIGINT should put us in the debugger at the next +// available breakpoint. +bool octave_debug_on_interrupt_state = false; + void tree_breakpoint::take_action (tree &tr) {
--- a/src/pt-bp.h +++ b/src/pt-bp.h @@ -168,15 +168,22 @@ tree_breakpoint& operator = (const tree_breakpoint&); }; +// TRUE means SIGINT should put us in the debugger at the next +// available breakpoint. +extern bool octave_debug_on_interrupt_state; + #define MAYBE_DO_BREAKPOINT \ do \ { \ - if ((tree::break_next && tree::last_line == 0) \ + if (octave_debug_on_interrupt_state \ + || (tree::break_next && tree::last_line == 0) \ || (tree::break_next \ && curr_function == tree::break_function \ && tree::last_line != line ()) \ || is_breakpoint ()) \ { \ + octave_debug_on_interrupt_state = false; \ + \ tree::break_next = false; \ \ if (curr_function) \
--- a/src/sighandlers.cc +++ b/src/sighandlers.cc @@ -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++ ***