Mercurial > hg > octave-lyh
diff src/debug.cc @ 7736:a059b5679fbb
implement dbstack
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 25 Apr 2008 15:11:03 -0400 |
parents | 87eda1f8faaa |
children | 40c428ea3408 |
line wrap: on
line diff
--- a/src/debug.cc +++ b/src/debug.cc @@ -29,7 +29,6 @@ #include <string> #include <set> - #include "defun.h" #include "error.h" #include "help.h" @@ -58,6 +57,9 @@ // Initialize the singleton object bp_table *bp_table::instance = 0; +// FIXME -- dbup and dbdown will need to modify this variable. +static int current_stack_frame = 1; + // Return a pointer to the user-defined function FNAME. If FNAME is // empty, search backward for the first user-defined function in the // current call stack. @@ -693,6 +695,30 @@ return retval; } +DEFUN (__dbstack__, args, , + "-*- texinfo -*-\n\ +@deftypefn {Loadable Function} {[@var{stack}, @var{idx}]} __dbstack__ (@var{n})\n\ +Undocumented internal function.\n\ +@end deftypefn") +{ + octave_value_list retval; + + int n = 0; + + if (args.length () == 1) + n = args(0).int_value (); + + if (! error_state) + { + retval(1) = current_stack_frame; + + // Add one here to skip the __dbstack__ stack frame. + retval(0) = octave_call_stack::backtrace (n+1); + } + + return retval; +} + /* ;;; Local Variables: *** ;;; mode: C++ ***