Mercurial > hg > octave-nkf
comparison 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 |
comparison
equal
deleted
inserted
replaced
7735:6848970153ba | 7736:a059b5679fbb |
---|---|
26 | 26 |
27 #include <iostream> | 27 #include <iostream> |
28 #include <fstream> | 28 #include <fstream> |
29 #include <string> | 29 #include <string> |
30 #include <set> | 30 #include <set> |
31 | |
32 | 31 |
33 #include "defun.h" | 32 #include "defun.h" |
34 #include "error.h" | 33 #include "error.h" |
35 #include "help.h" | 34 #include "help.h" |
36 #include "input.h" | 35 #include "input.h" |
56 #include "debug.h" | 55 #include "debug.h" |
57 | 56 |
58 // Initialize the singleton object | 57 // Initialize the singleton object |
59 bp_table *bp_table::instance = 0; | 58 bp_table *bp_table::instance = 0; |
60 | 59 |
60 // FIXME -- dbup and dbdown will need to modify this variable. | |
61 static int current_stack_frame = 1; | |
62 | |
61 // Return a pointer to the user-defined function FNAME. If FNAME is | 63 // Return a pointer to the user-defined function FNAME. If FNAME is |
62 // empty, search backward for the first user-defined function in the | 64 // empty, search backward for the first user-defined function in the |
63 // current call stack. | 65 // current call stack. |
64 | 66 |
65 static octave_user_code * | 67 static octave_user_code * |
691 } | 693 } |
692 | 694 |
693 return retval; | 695 return retval; |
694 } | 696 } |
695 | 697 |
698 DEFUN (__dbstack__, args, , | |
699 "-*- texinfo -*-\n\ | |
700 @deftypefn {Loadable Function} {[@var{stack}, @var{idx}]} __dbstack__ (@var{n})\n\ | |
701 Undocumented internal function.\n\ | |
702 @end deftypefn") | |
703 { | |
704 octave_value_list retval; | |
705 | |
706 int n = 0; | |
707 | |
708 if (args.length () == 1) | |
709 n = args(0).int_value (); | |
710 | |
711 if (! error_state) | |
712 { | |
713 retval(1) = current_stack_frame; | |
714 | |
715 // Add one here to skip the __dbstack__ stack frame. | |
716 retval(0) = octave_call_stack::backtrace (n+1); | |
717 } | |
718 | |
719 return retval; | |
720 } | |
721 | |
696 /* | 722 /* |
697 ;;; Local Variables: *** | 723 ;;; Local Variables: *** |
698 ;;; mode: C++ *** | 724 ;;; mode: C++ *** |
699 ;;; End: *** | 725 ;;; End: *** |
700 */ | 726 */ |