Mercurial > octave-nkf
annotate libinterp/interpfcn/debug.cc @ 16386:4902484f9181
callbacks to set markers in editor using command line dbstop function
* debug.h, debug.cc (location_info): New function.
* input.cc (get_debug_input): Use it to pass location info to hook
functions.
* debug.cc (bp_table::do_add_breakpoint): Likewise.
(bp_table::do_remove_all_breakpoints_in_file): Likewise.
(bp_table::do_remove_breakpoint): Likewise.
(Fadd_dbstop_hook, Fremove_dbstop_hook, Fadd_dbclear_hook,
Fremove_dbclear_hook): New functions.
(dbstop_hook_functions, dbclear_hook_functions): New static
variables.
* file-editor-interface.h
(file_editor_interface::handle_update_dbstop_marker_request):
New pure virtual function.
(file_editor_interface::request_open_file): New args, dbstop_marker
and insert.
* file-editor.h, file-editor.cc (file_editor::request_open_file):
Likewise. Emit signal to set or remove dbstop marker.
(file_editor::handle_update_dbstop_marker_request): New function.
(file_editor::fetab_do_dbstop_marker): New signal.
(file_editor::add_file_editor_tab): Connect fetab_do_dbstop_marker
signal to do_dbstop_marker.
* file-editor-tab.h, file-editor-tab.cc
(file_editor_tab::do_dbstop_marker): New function.
* file-editor-tab.cc (file_editor::goto_line): Eliminate shadowing
variable declaration.
* main-window.h, main-window.cc
(main_window::handle_update_dbstop_marker_request): New function.
(main_window::construct): Connect update_dbstop_marker_signal signal
to handle_update_dbstop_marker_request.
* octave-event-listener.h (event_listener::update_dbstop_marker):
New pure virtual function.
* octave-link.h, octave-link.cc
(octave_link::update_breakpoint_hook_fcn,
octave_link::do_update_breakpoint_hook_fcn): New functions.
(octave_link::do_update_debug_pointer): Improve error messages.
* octave-main-thread.cc (dbstop_hook_fcn, dbclear_hook_fcn):
New functions.
(octave_main_thread::octave_main_thread): Install hook functions for
for dbstop and dbclear hooks.
* octave-qt-event-listener.h, octave-qt-event-listener.cc
(octave_qt_event_listener::update_dbstop_marker): New fucntion.
(octave_qt_event_listener::update_dbstop_marker_signal): New signal.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 28 Mar 2013 03:20:25 -0400 |
parents | b73b5ab6c277 |
children | e1d92db3a715 |
rev | line source |
---|---|
3805 | 1 /* |
2 | |
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
14049
diff
changeset
|
3 Copyright (C) 2001-2012 Ben Sapp |
11523 | 4 Copyright (C) 2007-2009 John Swensen |
3805 | 5 |
6 This file is part of Octave. | |
7 | |
8 Octave is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
3805 | 12 |
13 Octave is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
3805 | 21 |
22 */ | |
23 #ifdef HAVE_CONFIG_H | |
24 #include <config.h> | |
25 #endif | |
26 | |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
27 #include <deque> |
3895 | 28 #include <fstream> |
10839 | 29 #include <iomanip> |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
30 #include <iostream> |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
31 #include <set> |
3948 | 32 #include <string> |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
33 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
34 #include "file-stat.h" |
13983
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13784
diff
changeset
|
35 #include "singleton-cleanup.h" |
7082 | 36 |
3805 | 37 #include "defun.h" |
38 #include "error.h" | |
7082 | 39 #include "help.h" |
16386
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
40 #include "hook-fcn.h" |
3805 | 41 #include "input.h" |
42 #include "pager.h" | |
43 #include "oct-obj.h" | |
44 #include "utils.h" | |
45 #include "parse.h" | |
46 #include "symtab.h" | |
47 #include "gripes.h" | |
48 #include "ov.h" | |
49 #include "ov-usr-fcn.h" | |
50 #include "ov-fcn.h" | |
7082 | 51 #include "ov-struct.h" |
3805 | 52 #include "pt-pr-code.h" |
53 #include "pt-bp.h" | |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
54 #include "pt-eval.h" |
3805 | 55 #include "pt-stmt.h" |
56 #include "toplev.h" | |
57 #include "unwind-prot.h" | |
58 #include "variables.h" | |
59 | |
7082 | 60 #include "debug.h" |
61 | |
62 // Initialize the singleton object | |
7083 | 63 bp_table *bp_table::instance = 0; |
7082 | 64 |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
65 static std::string |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
66 snarf_file (const std::string& fname) |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
67 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
68 std::string retval; |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
69 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
70 file_stat fs (fname); |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
71 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
72 if (fs) |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
73 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
74 size_t sz = fs.size (); |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
75 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
76 std::ifstream file (fname.c_str (), std::ios::in|std::ios::binary); |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
77 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
78 if (file) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
79 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
80 std::string buf (sz+1, 0); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
81 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
82 file.read (&buf[0], sz+1); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
83 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
84 if (file.eof ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
85 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
86 // Expected to read the entire file. |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
87 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
88 retval = buf; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
89 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
90 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
91 error ("error reading file %s", fname.c_str ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
92 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
93 } |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
94 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
95 return retval; |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
96 } |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
97 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
98 static std::deque<size_t> |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
99 get_line_offsets (const std::string& buf) |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
100 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
101 // This could maybe be smarter. Is deque the right thing to use |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
102 // here? |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
103 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
104 std::deque<size_t> offsets; |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
105 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
106 offsets.push_back (0); |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
107 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
108 size_t len = buf.length (); |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
109 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
110 for (size_t i = 0; i < len; i++) |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
111 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
112 char c = buf[i]; |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
113 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
114 if (c == '\r' && ++i < len) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
115 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
116 c = buf[i]; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
117 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
118 if (c == '\n') |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
119 offsets.push_back (i+1); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
120 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
121 offsets.push_back (i); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
122 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
123 else if (c == '\n') |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
124 offsets.push_back (i+1); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
125 } |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
126 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
127 offsets.push_back (len); |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
128 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
129 return offsets; |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
130 } |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
131 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
132 std::string |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
133 get_file_line (const std::string& fname, size_t line) |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
134 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
135 std::string retval; |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
136 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
137 static std::string last_fname; |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
138 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
139 static std::string buf; |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
140 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
141 static std::deque<size_t> offsets; |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
142 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
143 if (fname != last_fname) |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
144 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
145 buf = snarf_file (fname); |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
146 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
147 offsets = get_line_offsets (buf); |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
148 } |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
149 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
150 if (line > 0) |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
151 line--; |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
152 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
153 if (line < offsets.size () - 1) |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
154 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
155 size_t bol = offsets[line]; |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
156 size_t eol = offsets[line+1]; |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
157 |
10839 | 158 while (eol > 0 && eol > bol && (buf[eol-1] == '\n' || buf[eol-1] == '\r')) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
159 eol--; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
160 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
161 retval = buf.substr (bol, eol - bol); |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
162 } |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
163 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
164 return retval; |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
165 } |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
166 |
5743 | 167 // Return a pointer to the user-defined function FNAME. If FNAME is |
168 // empty, search backward for the first user-defined function in the | |
169 // current call stack. | |
7083 | 170 |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
171 static octave_user_code * |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
172 get_user_code (const std::string& fname = std::string ()) |
3805 | 173 { |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
174 octave_user_code *dbg_fcn = 0; |
3805 | 175 |
7083 | 176 if (fname.empty ()) |
7923
c3d21b9b94b6
eliminate octave_call_stack member functions caller_user_script and caller_user_function, and unused difference_type args
John W. Eaton <jwe@octave.org>
parents:
7901
diff
changeset
|
177 dbg_fcn = octave_call_stack::caller_user_code (); |
5743 | 178 else |
3805 | 179 { |
7539
3e107d73aeb4
debug.cc: use find_function instead of find_user_function
John Swensen
parents:
7348
diff
changeset
|
180 octave_value fcn = symbol_table::find_function (fname); |
3946 | 181 |
8123
eb2beef9a9ff
clear breakpoints is function found to be out of date
David Bateman <dbateman@free.fr>
parents:
8114
diff
changeset
|
182 if (fcn.is_defined () && fcn.is_user_code ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
183 dbg_fcn = fcn.user_code_value (); |
3805 | 184 } |
185 | |
186 return dbg_fcn; | |
187 } | |
188 | |
16386
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
189 octave_value |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
190 location_info (const std::string& fname, int line) |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
191 { |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
192 octave_scalar_map location_info_map; |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
193 |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
194 location_info_map.setfield ("file", fname); |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
195 location_info_map.setfield ("line", line); |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
196 |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
197 return octave_value (location_info_map); |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
198 } |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
199 |
7082 | 200 static void |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
201 parse_dbfunction_params (const char *who, const octave_value_list& args, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
202 std::string& symbol_name, bp_table::intmap& lines) |
7082 | 203 { |
204 int nargin = args.length (); | |
205 int idx = 0; | |
206 int list_idx = 0; | |
207 symbol_name = std::string (); | |
7348 | 208 lines = bp_table::intmap (); |
209 | |
210 if (args.length () == 0) | |
211 return; | |
7082 | 212 |
7083 | 213 // If we are already in a debugging function. |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
214 if (octave_call_stack::caller_user_code ()) |
7348 | 215 { |
216 idx = 0; | |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
217 symbol_name = get_user_code ()->name (); |
7348 | 218 } |
219 else if (args(0).is_map ()) | |
7082 | 220 { |
7348 | 221 // Problem because parse_dbfunction_params() can only pass out a |
222 // single function | |
223 } | |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14228
diff
changeset
|
224 else if (args(0).is_string ()) |
7348 | 225 { |
226 symbol_name = args(0).string_value (); | |
7082 | 227 if (error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
228 return; |
7082 | 229 idx = 1; |
230 } | |
7348 | 231 else |
232 error ("%s: invalid parameter specified", who); | |
7082 | 233 |
234 for (int i = idx; i < nargin; i++ ) | |
235 { | |
7348 | 236 if (args(i).is_string ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
237 { |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14228
diff
changeset
|
238 int line = atoi (args(i).string_value ().c_str ()); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
239 if (error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
240 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
241 lines[list_idx++] = line; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
242 } |
7348 | 243 else if (args(i).is_map ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
244 octave_stdout << who << ": accepting a struct" << std::endl; |
7082 | 245 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
246 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
247 const NDArray arg = args(i).array_value (); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
248 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
249 if (error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
250 break; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
251 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
252 for (octave_idx_type j = 0; j < arg.nelem (); j++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
253 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
254 int line = static_cast<int> (arg.elem (j)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
255 if (error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
256 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
257 lines[list_idx++] = line; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
258 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
259 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
260 if (error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
261 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
262 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
263 } |
7082 | 264 } |
265 | |
13983
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13784
diff
changeset
|
266 bool |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13784
diff
changeset
|
267 bp_table::instance_ok (void) |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13784
diff
changeset
|
268 { |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13784
diff
changeset
|
269 bool retval = true; |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13784
diff
changeset
|
270 |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13784
diff
changeset
|
271 if (! instance) |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13784
diff
changeset
|
272 { |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13784
diff
changeset
|
273 instance = new bp_table (); |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13784
diff
changeset
|
274 |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13784
diff
changeset
|
275 if (instance) |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13784
diff
changeset
|
276 singleton_cleanup_list::add (cleanup_instance); |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13784
diff
changeset
|
277 } |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13784
diff
changeset
|
278 |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13784
diff
changeset
|
279 if (! instance) |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13784
diff
changeset
|
280 { |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13784
diff
changeset
|
281 ::error ("unable to create breakpoint table!"); |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13784
diff
changeset
|
282 retval = false; |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13784
diff
changeset
|
283 } |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13784
diff
changeset
|
284 |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13784
diff
changeset
|
285 return retval; |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13784
diff
changeset
|
286 } |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13784
diff
changeset
|
287 |
16386
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
288 static hook_function_list dbstop_hook_functions; |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
289 static hook_function_list dbclear_hook_functions; |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
290 |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
291 DEFUN (add_dbstop_hook, args, , |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
292 "-*- texinfo -*-\n\ |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
293 @deftypefn {Built-in Function} {@var{id} =} add_dbstop_hook (@var{fcn})\n\ |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
294 @deftypefnx {Built-in Function} {@var{id} =} add_dbstop_hook (@var{fcn}, @var{data})\n\ |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
295 Add the named function or function handle @var{fcn} to the list of\n\ |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
296 functions to call when a debugger breakpoint is set. The function\n\ |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
297 should have the form\n\ |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
298 \n\ |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
299 @example\n\ |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
300 @var{fcn} (@var{location}, @var{data})\n\ |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
301 @end example\n\ |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
302 \n\ |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
303 in which @var{location} is a structure containing the following elements:\n\ |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
304 \n\ |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
305 @table @code\n\ |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
306 @item file\n\ |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
307 The name of the file where the breakpoint is located.\n\ |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
308 @item line\n\ |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
309 The line number corresponding to the breakpoint.\n\ |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
310 @end table\n\ |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
311 \n\ |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
312 If @var{data} is omitted when the hook function is added, the hook\n\ |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
313 function is called with a single argument.\n\ |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
314 \n\ |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
315 The returned identifier may be used to remove the function handle from\n\ |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
316 the list of input hook functions.\n\ |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
317 @seealso{remove_dbstop_hook}\n\ |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
318 @end deftypefn") |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
319 { |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
320 octave_value retval; |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
321 |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
322 int nargin = args.length (); |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
323 |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
324 if (nargin == 1 || nargin == 2) |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
325 { |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
326 octave_value user_data; |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
327 |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
328 if (nargin == 2) |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
329 user_data = args(1); |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
330 |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
331 hook_function hook_fcn (args(0), user_data); |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
332 |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
333 if (! error_state) |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
334 { |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
335 dbstop_hook_functions.insert (hook_fcn.id (), hook_fcn); |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
336 |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
337 retval = hook_fcn.id (); |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
338 } |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
339 else |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
340 error ("add_dbstop_hook: expecting string as first arg"); |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
341 } |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
342 else |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
343 print_usage (); |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
344 |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
345 return retval; |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
346 } |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
347 |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
348 DEFUN (remove_dbstop_hook, args, , |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
349 "-*- texinfo -*-\n\ |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
350 @deftypefn {Built-in Function} {} remove_dbstop_hook (@var{name})\n\ |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
351 @deftypefnx {Built-in Function} {} remove_dbstop_hook (@var{fcn_id})\n\ |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
352 Remove the named function or function handle with the given identifier\n\ |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
353 from the list of functions to call when a debugger breakpoint is set.\n\ |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
354 @seealso{add_dbstop_hook}\n\ |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
355 @end deftypefn") |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
356 { |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
357 octave_value_list retval; |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
358 |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
359 int nargin = args.length (); |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
360 |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
361 if (nargin == 1 || nargin == 2) |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
362 { |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
363 std::string hook_fcn_id = args(0).string_value (); |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
364 |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
365 bool warn = (nargin < 2); |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
366 |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
367 if (! error_state) |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
368 { |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
369 hook_function_list::iterator p |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
370 = dbstop_hook_functions.find (hook_fcn_id); |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
371 |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
372 if (p != dbstop_hook_functions.end ()) |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
373 dbstop_hook_functions.erase (p); |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
374 else if (warn) |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
375 warning ("remove_dbstop_hook: %s not found in list", |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
376 hook_fcn_id.c_str ()); |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
377 } |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
378 else |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
379 error ("remove_dbstop_hook: argument not valid as a hook function name or id"); |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
380 } |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
381 else |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
382 print_usage (); |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
383 |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
384 return retval; |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
385 } |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
386 |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
387 DEFUN (add_dbclear_hook, args, , |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
388 "-*- texinfo -*-\n\ |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
389 @deftypefn {Built-in Function} {@var{id} =} add_dbclear_hook (@var{fcn})\n\ |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
390 @deftypefnx {Built-in Function} {@var{id} =} add_dbclear_hook (@var{fcn}, @var{data})\n\ |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
391 Add the named function or function handle @var{fcn} to the list of\n\ |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
392 functions to call when a debugger breakpoint is cleared. The function\n\ |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
393 should have the form\n\ |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
394 \n\ |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
395 @example\n\ |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
396 @var{fcn} (@var{location}, @var{data})\n\ |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
397 @end example\n\ |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
398 \n\ |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
399 in which @var{location} is a structure containing the following elements:\n\ |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
400 \n\ |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
401 @table @code\n\ |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
402 @item file\n\ |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
403 The name of the file where the breakpoint is located.\n\ |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
404 @item line\n\ |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
405 The line number corresponding to the breakpoint.\n\ |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
406 @end table\n\ |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
407 \n\ |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
408 If @var{data} is omitted when the hook function is added, the hook\n\ |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
409 function is called with a single argument.\n\ |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
410 \n\ |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
411 The returned identifier may be used to remove the function handle from\n\ |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
412 the list of input hook functions.\n\ |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
413 @seealso{remove_dbclear_hook}\n\ |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
414 @end deftypefn") |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
415 { |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
416 octave_value retval; |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
417 |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
418 int nargin = args.length (); |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
419 |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
420 if (nargin == 1 || nargin == 2) |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
421 { |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
422 octave_value user_data; |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
423 |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
424 if (nargin == 2) |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
425 user_data = args(1); |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
426 |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
427 hook_function hook_fcn (args(0), user_data); |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
428 |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
429 if (! error_state) |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
430 { |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
431 dbclear_hook_functions.insert (hook_fcn.id (), hook_fcn); |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
432 |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
433 retval = hook_fcn.id (); |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
434 } |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
435 else |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
436 error ("add_dbclear_hook: expecting string as first arg"); |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
437 } |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
438 else |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
439 print_usage (); |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
440 |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
441 return retval; |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
442 } |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
443 |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
444 DEFUN (remove_dbclear_hook, args, , |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
445 "-*- texinfo -*-\n\ |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
446 @deftypefn {Built-in Function} {} remove_dbclear_hook (@var{name})\n\ |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
447 @deftypefnx {Built-in Function} {} remove_dbclear_hook (@var{fcn_id})\n\ |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
448 Remove the named function or function handle with the given identifier\n\ |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
449 from the list of functions to call when a debugger breakpoint is cleared.\n\ |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
450 @seealso{add_dbclear_hook}\n\ |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
451 @end deftypefn") |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
452 { |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
453 octave_value_list retval; |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
454 |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
455 int nargin = args.length (); |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
456 |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
457 if (nargin == 1 || nargin == 2) |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
458 { |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
459 std::string hook_fcn_id = args(0).string_value (); |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
460 |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
461 bool warn = (nargin < 2); |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
462 |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
463 if (! error_state) |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
464 { |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
465 hook_function_list::iterator p |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
466 = dbclear_hook_functions.find (hook_fcn_id); |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
467 |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
468 if (p != dbclear_hook_functions.end ()) |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
469 dbclear_hook_functions.erase (p); |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
470 else if (warn) |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
471 warning ("remove_dbclear_hook: %s not found in list", |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
472 hook_fcn_id.c_str ()); |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
473 } |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
474 else |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
475 error ("remove_dbclear_hook: argument not valid as a hook function name or id"); |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
476 } |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
477 else |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
478 print_usage (); |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
479 |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
480 return retval; |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
481 } |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
482 |
7083 | 483 bp_table::intmap |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
484 bp_table::do_add_breakpoint (const std::string& fname, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
485 const bp_table::intmap& line) |
7082 | 486 { |
7083 | 487 intmap retval; |
7082 | 488 |
489 octave_idx_type len = line.size (); | |
7083 | 490 |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
491 octave_user_code *dbg_fcn = get_user_code (fname); |
7082 | 492 |
493 if (dbg_fcn) | |
494 { | |
495 tree_statement_list *cmds = dbg_fcn->body (); | |
7083 | 496 |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
497 if (cmds) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
498 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
499 for (int i = 0; i < len; i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
500 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
501 const_intmap_iterator p = line.find (i); |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
502 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
503 if (p != line.end ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
504 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
505 int lineno = p->second; |
7083 | 506 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
507 retval[i] = cmds->set_breakpoint (lineno); |
7083 | 508 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
509 if (retval[i] != 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
510 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
511 bp_set.insert (fname); |
16386
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
512 |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
513 std::string file = dbg_fcn->fcn_file_name (); |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
514 |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
515 if (! file.empty ()) |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
516 dbstop_hook_functions.run |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
517 (location_info (file, retval[i])); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
518 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
519 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
520 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
521 } |
7082 | 522 } |
523 else | |
14049
b5a8e245b4eb
Change phrasing to more assertive error() messages in debug commands
Rik <octave@nomad.inbox5.com>
parents:
14035
diff
changeset
|
524 error ("add_breakpoint: unable to find the requested function\n"); |
7082 | 525 |
10194 | 526 tree_evaluator::debug_mode = bp_table::have_breakpoints () || Vdebugging; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
527 |
7082 | 528 return retval; |
529 } | |
530 | |
531 | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
532 int |
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
533 bp_table::do_remove_breakpoint (const std::string& fname, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
534 const bp_table::intmap& line) |
7082 | 535 { |
7083 | 536 int retval = 0; |
7082 | 537 |
538 octave_idx_type len = line.size (); | |
539 | |
540 if (len == 0) | |
541 { | |
542 intmap results = remove_all_breakpoints_in_file (fname); | |
543 retval = results.size (); | |
544 } | |
545 else | |
546 { | |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
547 octave_user_code *dbg_fcn = get_user_code (fname); |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
548 |
7082 | 549 if (dbg_fcn) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
550 { |
16386
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
551 std::string file = dbg_fcn->fcn_file_name (); |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
552 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
553 tree_statement_list *cmds = dbg_fcn->body (); |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
554 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
555 if (cmds) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
556 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
557 octave_value_list results = cmds->list_breakpoints (); |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
558 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
559 if (results.length () > 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
560 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
561 for (int i = 0; i < len; i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
562 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
563 const_intmap_iterator p = line.find (i); |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
564 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
565 if (p != line.end ()) |
16386
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
566 { |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
567 int lineno = p->second; |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
568 |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
569 cmds->delete_breakpoint (lineno); |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
570 |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
571 if (! file.empty ()) |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
572 dbclear_hook_functions.run |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
573 (location_info (file, lineno)); |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
574 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
575 } |
7083 | 576 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
577 results = cmds->list_breakpoints (); |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
578 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
579 bp_set_iterator it = bp_set.find (fname); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
580 if (results.length () == 0 && it != bp_set.end ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
581 bp_set.erase (it); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
582 } |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
583 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
584 retval = results.length (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
585 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
586 } |
7082 | 587 else |
14049
b5a8e245b4eb
Change phrasing to more assertive error() messages in debug commands
Rik <octave@nomad.inbox5.com>
parents:
14035
diff
changeset
|
588 error ("remove_breakpoint: unable to find the requested function\n"); |
7082 | 589 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
590 |
10194 | 591 tree_evaluator::debug_mode = bp_table::have_breakpoints () || Vdebugging; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
592 |
7082 | 593 return retval; |
594 } | |
595 | |
596 | |
7083 | 597 bp_table::intmap |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
598 bp_table::do_remove_all_breakpoints_in_file (const std::string& fname, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
599 bool silent) |
7082 | 600 { |
7083 | 601 intmap retval; |
7082 | 602 |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
603 octave_user_code *dbg_fcn = get_user_code (fname); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
604 |
7082 | 605 if (dbg_fcn) |
606 { | |
16386
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
607 std::string file = dbg_fcn->fcn_file_name (); |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
608 |
7082 | 609 tree_statement_list *cmds = dbg_fcn->body (); |
7083 | 610 |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
611 if (cmds) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
612 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
613 octave_value_list bkpts = cmds->list_breakpoints (); |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
614 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
615 for (int i = 0; i < bkpts.length (); i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
616 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
617 int lineno = static_cast<int> (bkpts(i).int_value ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
618 cmds->delete_breakpoint (lineno); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
619 retval[i] = lineno; |
16386
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
620 |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
621 if (! file.empty ()) |
4902484f9181
callbacks to set markers in editor using command line dbstop function
John W. Eaton <jwe@octave.org>
parents:
16342
diff
changeset
|
622 dbclear_hook_functions.run (location_info (file, lineno)); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
623 } |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
624 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
625 bp_set_iterator it = bp_set.find (fname); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
626 if (it != bp_set.end ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
627 bp_set.erase (it); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
628 } |
7082 | 629 } |
8123
eb2beef9a9ff
clear breakpoints is function found to be out of date
David Bateman <dbateman@free.fr>
parents:
8114
diff
changeset
|
630 else if (! silent) |
7082 | 631 error ("remove_all_breakpoint_in_file: " |
14049
b5a8e245b4eb
Change phrasing to more assertive error() messages in debug commands
Rik <octave@nomad.inbox5.com>
parents:
14035
diff
changeset
|
632 "unable to find the requested function\n"); |
7082 | 633 |
10194 | 634 tree_evaluator::debug_mode = bp_table::have_breakpoints () || Vdebugging; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
635 |
7082 | 636 return retval; |
637 } | |
638 | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
639 void |
7083 | 640 bp_table::do_remove_all_breakpoints (void) |
7082 | 641 { |
9183
94ae487acd1b
use set instead of map to keep track of debugger breakpoints
jpswensen@compsci34-754-2010.compscidhcp.jhu.edu
parents:
9039
diff
changeset
|
642 for (const_bp_set_iterator it = bp_set.begin (); it != bp_set.end (); it++) |
94ae487acd1b
use set instead of map to keep track of debugger breakpoints
jpswensen@compsci34-754-2010.compscidhcp.jhu.edu
parents:
9039
diff
changeset
|
643 remove_all_breakpoints_in_file (*it); |
94ae487acd1b
use set instead of map to keep track of debugger breakpoints
jpswensen@compsci34-754-2010.compscidhcp.jhu.edu
parents:
9039
diff
changeset
|
644 |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
645 |
10194 | 646 tree_evaluator::debug_mode = bp_table::have_breakpoints () || Vdebugging; |
7082 | 647 } |
648 | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
649 std::string |
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
650 do_find_bkpt_list (octave_value_list slist, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
651 std::string match) |
7082 | 652 { |
653 std::string retval; | |
7083 | 654 |
7082 | 655 for (int i = 0; i < slist.length (); i++) |
656 { | |
657 if (slist (i).string_value () == match) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
658 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
659 retval = slist(i).string_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
660 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
661 } |
7082 | 662 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
663 |
7082 | 664 return retval; |
665 } | |
666 | |
667 | |
7083 | 668 bp_table::fname_line_map |
669 bp_table::do_get_breakpoint_list (const octave_value_list& fname_list) | |
7082 | 670 { |
7083 | 671 fname_line_map retval; |
7082 | 672 |
9183
94ae487acd1b
use set instead of map to keep track of debugger breakpoints
jpswensen@compsci34-754-2010.compscidhcp.jhu.edu
parents:
9039
diff
changeset
|
673 for (bp_set_iterator it = bp_set.begin (); it != bp_set.end (); it++) |
7082 | 674 { |
7083 | 675 if (fname_list.length () == 0 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
676 || do_find_bkpt_list (fname_list, *it) != "") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
677 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
678 octave_user_code *f = get_user_code (*it); |
7083 | 679 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
680 if (f) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
681 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
682 tree_statement_list *cmds = f->body (); |
7083 | 683 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
684 if (cmds) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
685 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
686 octave_value_list bkpts = cmds->list_breakpoints (); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
687 octave_idx_type len = bkpts.length (); |
7083 | 688 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
689 if (len > 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
690 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
691 bp_table::intmap bkpts_vec; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
692 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
693 for (int i = 0; i < len; i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
694 bkpts_vec[i] = bkpts (i).double_value (); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
695 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
696 std::string symbol_name = f->name (); |
7083 | 697 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
698 retval[symbol_name] = bkpts_vec; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
699 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
700 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
701 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
702 } |
7082 | 703 } |
7083 | 704 |
7082 | 705 return retval; |
706 } | |
707 | |
708 static octave_value | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
709 intmap_to_ov (const bp_table::intmap& line) |
7082 | 710 { |
711 int idx = 0; | |
7083 | 712 |
713 NDArray retval (dim_vector (1, line.size ())); | |
714 | |
715 for (size_t i = 0; i < line.size (); i++) | |
7082 | 716 { |
7083 | 717 bp_table::const_intmap_iterator p = line.find (i); |
718 | |
7082 | 719 if (p != line.end ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
720 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
721 int lineno = p->second; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
722 retval(idx++) = lineno; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
723 } |
7082 | 724 } |
7083 | 725 |
7082 | 726 retval.resize (dim_vector (1, idx)); |
7083 | 727 |
7082 | 728 return retval; |
729 } | |
3895 | 730 |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8677
diff
changeset
|
731 DEFUN (dbstop, args, , |
3805 | 732 "-*- texinfo -*-\n\ |
15038
ab18578c2ade
doc: Update docstrings for built-in functions to not use "Loadable Function" as type.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
733 @deftypefn {Built-in Function} {@var{rline} =} dbstop (\"@var{func}\")\n\ |
ab18578c2ade
doc: Update docstrings for built-in functions to not use "Loadable Function" as type.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
734 @deftypefnx {Built-in Function} {@var{rline} =} dbstop (\"@var{func}\", @var{line}, @dots{})\n\ |
14035
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
735 Set a breakpoint in function @var{func}.\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
736 \n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
737 Arguments are\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
738 \n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
739 @table @var\n\ |
3805 | 740 @item func\n\ |
14035
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
741 Function name as a string variable. When already in debug\n\ |
3805 | 742 mode this should be left out and only the line should be given.\n\ |
10840 | 743 \n\ |
3805 | 744 @item line\n\ |
14035
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
745 Line number where the breakpoint should be set. Multiple\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
746 lines may be given as separate arguments or as a vector.\n\ |
3805 | 747 @end table\n\ |
748 \n\ | |
14035
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
749 When called with a single argument @var{func}, the breakpoint\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
750 is set at the first executable line in the named function.\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
751 \n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
752 The optional output @var{rline} is the real line number where the\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
753 breakpoint was set. This can differ from specified line if\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
754 the line is not executable. For example, if a breakpoint attempted on a\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
755 blank line then Octave will set the real breakpoint at the\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
756 next executable line.\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
757 @seealso{dbclear, dbstatus, dbstep, debug_on_error, debug_on_warning, debug_on_interrupt}\n\ |
5642 | 758 @end deftypefn") |
3805 | 759 { |
7083 | 760 bp_table::intmap retval; |
761 std::string symbol_name; | |
762 bp_table::intmap lines; | |
763 | |
7348 | 764 parse_dbfunction_params ("dbstop", args, symbol_name, lines); |
6646 | 765 |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
766 if (lines.size () == 0) |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
767 lines[0] = 1; |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
768 |
7083 | 769 if (! error_state) |
7082 | 770 retval = bp_table::add_breakpoint (symbol_name, lines); |
3805 | 771 |
7083 | 772 return intmap_to_ov (retval); |
3805 | 773 } |
774 | |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8677
diff
changeset
|
775 DEFUN (dbclear, args, , |
3805 | 776 "-*- texinfo -*-\n\ |
15038
ab18578c2ade
doc: Update docstrings for built-in functions to not use "Loadable Function" as type.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
777 @deftypefn {Built-in Function} {} dbclear (\"@var{func}\")\n\ |
ab18578c2ade
doc: Update docstrings for built-in functions to not use "Loadable Function" as type.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
778 @deftypefnx {Built-in Function} {} dbclear (\"@var{func}\", @var{line}, @dots{})\n\ |
14035
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
779 Delete a breakpoint in the function @var{func}.\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
780 \n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
781 Arguments are\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
782 \n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
783 @table @var\n\ |
3805 | 784 @item func\n\ |
14035
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
785 Function name as a string variable. When already in debug\n\ |
3805 | 786 mode this should be left out and only the line should be given.\n\ |
10840 | 787 \n\ |
3805 | 788 @item line\n\ |
14035
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
789 Line number from which to remove a breakpoint. Multiple\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
790 lines may be given as separate arguments or as a vector.\n\ |
3805 | 791 @end table\n\ |
14035
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
792 \n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
793 When called without a line number specification all breakpoints\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
794 in the named function are cleared.\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
795 \n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
796 If the requested line is not a breakpoint no action is performed.\n\ |
5642 | 797 @seealso{dbstop, dbstatus, dbwhere}\n\ |
798 @end deftypefn") | |
3805 | 799 { |
800 octave_value retval; | |
801 std::string symbol_name = ""; | |
7083 | 802 bp_table::intmap lines; |
803 | |
7348 | 804 parse_dbfunction_params ("dbclear", args, symbol_name, lines); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
805 |
7083 | 806 if (! error_state) |
7082 | 807 bp_table::remove_breakpoint (symbol_name, lines); |
3805 | 808 |
809 return retval; | |
810 } | |
811 | |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8677
diff
changeset
|
812 DEFUN (dbstatus, args, nargout, |
3805 | 813 "-*- texinfo -*-\n\ |
15038
ab18578c2ade
doc: Update docstrings for built-in functions to not use "Loadable Function" as type.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
814 @deftypefn {Built-in Function} {} dbstatus ()\n\ |
ab18578c2ade
doc: Update docstrings for built-in functions to not use "Loadable Function" as type.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
815 @deftypefnx {Built-in Function} {@var{brk_list} =} dbstatus ()\n\ |
ab18578c2ade
doc: Update docstrings for built-in functions to not use "Loadable Function" as type.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
816 @deftypefnx {Built-in Function} {@var{brk_list} =} dbstatus (\"@var{func}\")\n\ |
14035
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
817 Report the location of active breakpoints.\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
818 \n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
819 When called with no input or output arguments, print the list of\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
820 all functions with breakpoints and the line numbers where those\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
821 breakpoints are set.\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
822 If a function name @var{func} is specified then only report breakpoints\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
823 for the named function.\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
824 \n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
825 The optional return argument @var{brk_list} is a struct array with the\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
826 following fields.\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
827 \n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
828 @table @asis\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
829 @item name\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
830 The name of the function with a breakpoint.\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
831 \n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
832 @item file\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
833 The name of the m-file where the function code is located.\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
834 \n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
835 @item line\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
836 A line number, or vector of line numbers, with a breakpoint.\n\ |
3805 | 837 @end table\n\ |
14035
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
838 \n\ |
5642 | 839 @seealso{dbclear, dbwhere}\n\ |
840 @end deftypefn") | |
3805 | 841 { |
11058
3329616444f0
replace Octave_map in debug.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10840
diff
changeset
|
842 octave_map retval; |
3805 | 843 int nargin = args.length (); |
7082 | 844 octave_value_list fcn_list; |
7083 | 845 bp_table::fname_line_map bp_list; |
846 std::string symbol_name; | |
3805 | 847 |
848 if (nargin != 0 && nargin != 1) | |
849 { | |
14035
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
850 error ("dbstatus: only zero or one arguments accepted\n"); |
7082 | 851 return octave_value (); |
3805 | 852 } |
853 | |
854 if (nargin == 1) | |
855 { | |
856 if (args(0).is_string ()) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
857 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
858 symbol_name = args(0).string_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
859 fcn_list(0) = symbol_name; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
860 bp_list = bp_table::get_breakpoint_list (fcn_list); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
861 } |
3805 | 862 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
863 gripe_wrong_type_arg ("dbstatus", args(0)); |
7082 | 864 } |
865 else | |
866 { | |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
867 octave_user_code *dbg_fcn = get_user_code (); |
7082 | 868 if (dbg_fcn) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
869 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
870 symbol_name = dbg_fcn->name (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
871 fcn_list(0) = symbol_name; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
872 } |
7083 | 873 |
7082 | 874 bp_list = bp_table::get_breakpoint_list (fcn_list); |
3805 | 875 } |
876 | |
7083 | 877 if (nargout == 0) |
3805 | 878 { |
7083 | 879 // Print out the breakpoint information. |
880 | |
881 for (bp_table::fname_line_map_iterator it = bp_list.begin (); | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
882 it != bp_list.end (); it++) |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
883 { |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
884 bp_table::intmap m = it->second; |
7083 | 885 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
886 size_t nel = m.size (); |
7083 | 887 |
14228
0beb62668d69
Use correct plural for dbstatus if there is more than 1 breakpoint set in file.
Rik <octave@nomad.inbox5.com>
parents:
14227
diff
changeset
|
888 octave_stdout << "breakpoint in " << it->first; |
0beb62668d69
Use correct plural for dbstatus if there is more than 1 breakpoint set in file.
Rik <octave@nomad.inbox5.com>
parents:
14227
diff
changeset
|
889 if (nel > 1) |
0beb62668d69
Use correct plural for dbstatus if there is more than 1 breakpoint set in file.
Rik <octave@nomad.inbox5.com>
parents:
14227
diff
changeset
|
890 octave_stdout << " at lines "; |
0beb62668d69
Use correct plural for dbstatus if there is more than 1 breakpoint set in file.
Rik <octave@nomad.inbox5.com>
parents:
14227
diff
changeset
|
891 else |
0beb62668d69
Use correct plural for dbstatus if there is more than 1 breakpoint set in file.
Rik <octave@nomad.inbox5.com>
parents:
14227
diff
changeset
|
892 octave_stdout << " at line "; |
0beb62668d69
Use correct plural for dbstatus if there is more than 1 breakpoint set in file.
Rik <octave@nomad.inbox5.com>
parents:
14227
diff
changeset
|
893 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
894 for (size_t j = 0; j < nel; j++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
895 octave_stdout << m[j] << ((j < nel - 1) ? ", " : "."); |
7083 | 896 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
897 if (nel > 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
898 octave_stdout << std::endl; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
899 } |
7083 | 900 return octave_value (); |
901 } | |
902 else | |
903 { | |
904 // Fill in an array for return. | |
905 | |
7082 | 906 int i = 0; |
907 Cell names (dim_vector (bp_list.size (), 1)); | |
908 Cell file (dim_vector (bp_list.size (), 1)); | |
909 Cell line (dim_vector (bp_list.size (), 1)); | |
7083 | 910 |
911 for (bp_table::const_fname_line_map_iterator it = bp_list.begin (); | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
912 it != bp_list.end (); it++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
913 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
914 names(i) = it->first; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
915 line(i) = intmap_to_ov (it->second); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
916 file(i) = do_which (it->first); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
917 i++; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
918 } |
7083 | 919 |
7082 | 920 retval.assign ("name", names); |
921 retval.assign ("file", file); | |
922 retval.assign ("line", line); | |
7083 | 923 |
7082 | 924 return octave_value (retval); |
3805 | 925 } |
926 } | |
927 | |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8677
diff
changeset
|
928 DEFUN (dbwhere, , , |
3805 | 929 "-*- texinfo -*-\n\ |
15912
8e38eac05230
doc: Change object type of dbwhere, dbstack to "Command" in docstring.
Rik <rik@octave.org>
parents:
15577
diff
changeset
|
930 @deftypefn {Command} {} dbwhere\n\ |
14035
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
931 In debugging mode, report the current file and line number where\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
932 execution is stopped.\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
933 @seealso{dbstatus, dbcont, dbstep, dbup}\n\ |
5645 | 934 @end deftypefn") |
3805 | 935 { |
936 octave_value retval; | |
3946 | 937 |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
938 octave_user_code *dbg_fcn = get_user_code (); |
3805 | 939 |
940 if (dbg_fcn) | |
941 { | |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
942 bool have_file = true; |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
943 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
944 std::string name = dbg_fcn->fcn_file_name (); |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
945 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
946 if (name.empty ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
947 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
948 have_file = false; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
949 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
950 name = dbg_fcn->name (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
951 } |
3805 | 952 |
10839 | 953 octave_stdout << "stopped in " << name << " at "; |
9484
bbe033dcfe13
make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents:
9377
diff
changeset
|
954 |
10839 | 955 int l = octave_call_stack::caller_user_code_line (); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
956 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
957 if (l > 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
958 { |
10839 | 959 octave_stdout << " line " << l << std::endl; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
960 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
961 if (have_file) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
962 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
963 std::string line = get_file_line (name, l); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
964 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
965 if (! line.empty ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
966 octave_stdout << l << ": " << line << std::endl; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
967 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
968 } |
3805 | 969 else |
10839 | 970 octave_stdout << " <unknown line>" << std::endl; |
3805 | 971 } |
972 else | |
14049
b5a8e245b4eb
Change phrasing to more assertive error() messages in debug commands
Rik <octave@nomad.inbox5.com>
parents:
14035
diff
changeset
|
973 error ("dbwhere: must be inside a user function to use dbwhere\n"); |
3895 | 974 |
975 return retval; | |
976 } | |
977 | |
978 // Copied and modified from the do_type command in help.cc | |
3946 | 979 // Maybe we could share some code? |
980 void | |
3949 | 981 do_dbtype (std::ostream& os, const std::string& name, int start, int end) |
3895 | 982 { |
983 std::string ff = fcn_file_in_path (name); | |
984 | |
985 if (! ff.empty ()) | |
986 { | |
987 std::ifstream fs (ff.c_str (), std::ios::in); | |
3946 | 988 |
3895 | 989 if (fs) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
990 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
991 char ch; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
992 int line = 1; |
16342
b73b5ab6c277
Remove extra line printed at end of dbtype (off-by-1 error).
Rik <rik@octave.org>
parents:
15912
diff
changeset
|
993 bool isnewline = true; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
994 |
16342
b73b5ab6c277
Remove extra line printed at end of dbtype (off-by-1 error).
Rik <rik@octave.org>
parents:
15912
diff
changeset
|
995 // FIXME: Why not use line-oriented input here [getline()]? |
b73b5ab6c277
Remove extra line printed at end of dbtype (off-by-1 error).
Rik <rik@octave.org>
parents:
15912
diff
changeset
|
996 while (fs.get (ch) && line <= end) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
997 { |
16342
b73b5ab6c277
Remove extra line printed at end of dbtype (off-by-1 error).
Rik <rik@octave.org>
parents:
15912
diff
changeset
|
998 if (isnewline && line >= start) |
b73b5ab6c277
Remove extra line printed at end of dbtype (off-by-1 error).
Rik <rik@octave.org>
parents:
15912
diff
changeset
|
999 { |
b73b5ab6c277
Remove extra line printed at end of dbtype (off-by-1 error).
Rik <rik@octave.org>
parents:
15912
diff
changeset
|
1000 os << line << "\t"; |
b73b5ab6c277
Remove extra line printed at end of dbtype (off-by-1 error).
Rik <rik@octave.org>
parents:
15912
diff
changeset
|
1001 isnewline = false; |
b73b5ab6c277
Remove extra line printed at end of dbtype (off-by-1 error).
Rik <rik@octave.org>
parents:
15912
diff
changeset
|
1002 } |
b73b5ab6c277
Remove extra line printed at end of dbtype (off-by-1 error).
Rik <rik@octave.org>
parents:
15912
diff
changeset
|
1003 |
b73b5ab6c277
Remove extra line printed at end of dbtype (off-by-1 error).
Rik <rik@octave.org>
parents:
15912
diff
changeset
|
1004 if (line >= start) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1005 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1006 os << ch; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1007 } |
3895 | 1008 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1009 if (ch == '\n') |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1010 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1011 line++; |
16342
b73b5ab6c277
Remove extra line printed at end of dbtype (off-by-1 error).
Rik <rik@octave.org>
parents:
15912
diff
changeset
|
1012 isnewline = true; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1013 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1014 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1015 } |
3946 | 1016 else |
15466
d174210ce1ec
use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
1017 os << "dbtype: unable to open '" << ff << "' for reading!\n"; |
3895 | 1018 } |
1019 else | |
6317 | 1020 os << "dbtype: unknown function " << name << "\n"; |
3895 | 1021 |
6646 | 1022 os.flush (); |
3895 | 1023 } |
1024 | |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8677
diff
changeset
|
1025 DEFUN (dbtype, args, , |
3895 | 1026 "-*- texinfo -*-\n\ |
15577 | 1027 @deftypefn {Command} {} dbtype\n\ |
1028 @deftypefnx {Command} {} dbtype @var{lineno}\n\ | |
1029 @deftypefnx {Command} {} dbtype @var{startl:endl}\n\ | |
1030 @deftypefnx {Command} {} dbtype @var{startl:end}\n\ | |
1031 @deftypefnx {Command} {} dbtype @var{func}\n\ | |
1032 @deftypefnx {Command} {} dbtype @var{func} @var{lineno}\n\ | |
1033 @deftypefnx {Command} {} dbtype @var{func} @var{startl:endl}\n\ | |
1034 @deftypefnx {Command} {} dbtype @var{func} @var{startl:end}\n\ | |
1035 Display a script file with line numbers.\n\ | |
14035
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1036 \n\ |
15577 | 1037 When called with no arguments in debugging mode, display the script file\n\ |
1038 currently being debugged. An optional range specification can be used to\n\ | |
1039 list only a portion of the file. The special keyword \"end\" is a valid\n\ | |
1040 line number specification for the last line of the file.\n\ | |
1041 \n\ | |
1042 When called with the name of a function, list that script file with line\n\ | |
1043 numbers.\n\ | |
1044 @seealso{dbwhere, dbstatus, dbstop}\n\ | |
5642 | 1045 @end deftypefn") |
3895 | 1046 { |
1047 octave_value retval; | |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7539
diff
changeset
|
1048 octave_user_code *dbg_fcn; |
3946 | 1049 |
3895 | 1050 int nargin = args.length (); |
1051 string_vector argv = args.make_argv ("dbtype"); | |
3946 | 1052 |
3895 | 1053 if (! error_state) |
1054 { | |
1055 switch (nargin) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1056 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1057 case 0: // dbtype |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1058 dbg_fcn = get_user_code (); |
3895 | 1059 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1060 if (dbg_fcn) |
15215
9020dddc925a
use std::numeric_limits for integer max and min values
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1061 do_dbtype (octave_stdout, dbg_fcn->name (), 0, |
9020dddc925a
use std::numeric_limits for integer max and min values
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1062 std::numeric_limits<int>::max ()); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1063 else |
14049
b5a8e245b4eb
Change phrasing to more assertive error() messages in debug commands
Rik <octave@nomad.inbox5.com>
parents:
14035
diff
changeset
|
1064 error ("dbtype: must be inside a user function to give no arguments to dbtype\n"); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1065 break; |
3895 | 1066 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1067 case 1: // (dbtype func) || (dbtype start:end) |
14227
c24833c6ebc2
Add error messages to dbtype(). Allow use of "end" keyword in linespec.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
1068 { |
c24833c6ebc2
Add error messages to dbtype(). Allow use of "end" keyword in linespec.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
1069 std::string arg = argv[1]; |
c24833c6ebc2
Add error messages to dbtype(). Allow use of "end" keyword in linespec.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
1070 |
c24833c6ebc2
Add error messages to dbtype(). Allow use of "end" keyword in linespec.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
1071 size_t ind = arg.find (':'); |
3895 | 1072 |
14227
c24833c6ebc2
Add error messages to dbtype(). Allow use of "end" keyword in linespec.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
1073 if (ind != std::string::npos) // (dbtype start:end) |
c24833c6ebc2
Add error messages to dbtype(). Allow use of "end" keyword in linespec.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
1074 { |
c24833c6ebc2
Add error messages to dbtype(). Allow use of "end" keyword in linespec.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
1075 dbg_fcn = get_user_code (); |
3895 | 1076 |
14227
c24833c6ebc2
Add error messages to dbtype(). Allow use of "end" keyword in linespec.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
1077 if (dbg_fcn) |
c24833c6ebc2
Add error messages to dbtype(). Allow use of "end" keyword in linespec.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
1078 { |
c24833c6ebc2
Add error messages to dbtype(). Allow use of "end" keyword in linespec.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
1079 std::string start_str = arg.substr (0, ind); |
c24833c6ebc2
Add error messages to dbtype(). Allow use of "end" keyword in linespec.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
1080 std::string end_str = arg.substr (ind + 1); |
3895 | 1081 |
14227
c24833c6ebc2
Add error messages to dbtype(). Allow use of "end" keyword in linespec.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
1082 int start, end; |
c24833c6ebc2
Add error messages to dbtype(). Allow use of "end" keyword in linespec.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
1083 start = atoi (start_str.c_str ()); |
c24833c6ebc2
Add error messages to dbtype(). Allow use of "end" keyword in linespec.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
1084 if (end_str == "end") |
15215
9020dddc925a
use std::numeric_limits for integer max and min values
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1085 end = std::numeric_limits<int>::max (); |
14227
c24833c6ebc2
Add error messages to dbtype(). Allow use of "end" keyword in linespec.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
1086 else |
c24833c6ebc2
Add error messages to dbtype(). Allow use of "end" keyword in linespec.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
1087 end = atoi (end_str.c_str ()); |
3948 | 1088 |
14227
c24833c6ebc2
Add error messages to dbtype(). Allow use of "end" keyword in linespec.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
1089 if (std::min (start, end) <= 0) |
c24833c6ebc2
Add error messages to dbtype(). Allow use of "end" keyword in linespec.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
1090 error ("dbtype: start and end lines must be >= 1\n"); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
1091 |
14227
c24833c6ebc2
Add error messages to dbtype(). Allow use of "end" keyword in linespec.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
1092 if (start <= end) |
c24833c6ebc2
Add error messages to dbtype(). Allow use of "end" keyword in linespec.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
1093 do_dbtype (octave_stdout, dbg_fcn->name (), start, end); |
c24833c6ebc2
Add error messages to dbtype(). Allow use of "end" keyword in linespec.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
1094 else |
c24833c6ebc2
Add error messages to dbtype(). Allow use of "end" keyword in linespec.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
1095 error ("dbtype: start line must be less than end line\n"); |
c24833c6ebc2
Add error messages to dbtype(). Allow use of "end" keyword in linespec.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
1096 } |
c24833c6ebc2
Add error messages to dbtype(). Allow use of "end" keyword in linespec.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
1097 } |
c24833c6ebc2
Add error messages to dbtype(). Allow use of "end" keyword in linespec.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
1098 else // (dbtype func) |
c24833c6ebc2
Add error messages to dbtype(). Allow use of "end" keyword in linespec.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
1099 { |
c24833c6ebc2
Add error messages to dbtype(). Allow use of "end" keyword in linespec.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
1100 dbg_fcn = get_user_code (arg); |
6317 | 1101 |
14227
c24833c6ebc2
Add error messages to dbtype(). Allow use of "end" keyword in linespec.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
1102 if (dbg_fcn) |
15215
9020dddc925a
use std::numeric_limits for integer max and min values
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1103 do_dbtype (octave_stdout, dbg_fcn->name (), 0, |
9020dddc925a
use std::numeric_limits for integer max and min values
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1104 std::numeric_limits<int>::max ()); |
14227
c24833c6ebc2
Add error messages to dbtype(). Allow use of "end" keyword in linespec.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
1105 else |
c24833c6ebc2
Add error messages to dbtype(). Allow use of "end" keyword in linespec.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
1106 error ("dbtype: function <%s> not found\n", arg.c_str ()); |
c24833c6ebc2
Add error messages to dbtype(). Allow use of "end" keyword in linespec.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
1107 } |
c24833c6ebc2
Add error messages to dbtype(). Allow use of "end" keyword in linespec.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
1108 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1109 break; |
3946 | 1110 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1111 case 2: // (dbtype func start:end) , (dbtype func start) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1112 dbg_fcn = get_user_code (argv[1]); |
3895 | 1113 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1114 if (dbg_fcn) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1115 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1116 std::string arg = argv[2]; |
14227
c24833c6ebc2
Add error messages to dbtype(). Allow use of "end" keyword in linespec.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
1117 int start, end; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1118 size_t ind = arg.find (':'); |
3895 | 1119 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1120 if (ind != std::string::npos) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1121 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1122 std::string start_str = arg.substr (0, ind); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1123 std::string end_str = arg.substr (ind + 1); |
3895 | 1124 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1125 start = atoi (start_str.c_str ()); |
14227
c24833c6ebc2
Add error messages to dbtype(). Allow use of "end" keyword in linespec.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
1126 if (end_str == "end") |
15215
9020dddc925a
use std::numeric_limits for integer max and min values
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1127 end = std::numeric_limits<int>::max (); |
14227
c24833c6ebc2
Add error messages to dbtype(). Allow use of "end" keyword in linespec.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
1128 else |
c24833c6ebc2
Add error messages to dbtype(). Allow use of "end" keyword in linespec.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
1129 end = atoi (end_str.c_str ()); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1130 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1131 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1132 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1133 start = atoi (arg.c_str ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1134 end = start; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1135 } |
6317 | 1136 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1137 if (std::min (start, end) <= 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1138 error ("dbtype: start and end lines must be >= 1\n"); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
1139 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1140 if (start <= end) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1141 do_dbtype (octave_stdout, dbg_fcn->name (), start, end); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1142 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1143 error ("dbtype: start line must be less than end line\n"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1144 } |
14227
c24833c6ebc2
Add error messages to dbtype(). Allow use of "end" keyword in linespec.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
1145 else |
c24833c6ebc2
Add error messages to dbtype(). Allow use of "end" keyword in linespec.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
1146 error ("dbtype: function <%s> not found\n", argv[1].c_str ()); |
c24833c6ebc2
Add error messages to dbtype(). Allow use of "end" keyword in linespec.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
1147 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1148 break; |
3895 | 1149 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1150 default: |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1151 error ("dbtype: expecting zero, one, or two arguments\n"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1152 } |
3895 | 1153 } |
3805 | 1154 |
1155 return retval; | |
1156 } | |
1157 | |
13689
b68d95054947
print show_octave_dbstack output to std::cerr
John W. Eaton <jwe@octave.org>
parents:
13326
diff
changeset
|
1158 static octave_value_list |
b68d95054947
print show_octave_dbstack output to std::cerr
John W. Eaton <jwe@octave.org>
parents:
13326
diff
changeset
|
1159 do_dbstack (const octave_value_list& args, int nargout, std::ostream& os) |
7736 | 1160 { |
1161 octave_value_list retval; | |
1162 | |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9724
diff
changeset
|
1163 unwind_protect frame; |
7890 | 1164 |
7901 | 1165 octave_idx_type curr_frame = -1; |
7890 | 1166 |
7901 | 1167 size_t nskip = 0; |
7736 | 1168 |
1169 if (args.length () == 1) | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1170 { |
7890 | 1171 int n = 0; |
1172 | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1173 octave_value arg = args(0); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1174 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1175 if (arg.is_string ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1176 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1177 std::string s_arg = arg.string_value (); |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1178 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1179 n = atoi (s_arg.c_str ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1180 } |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1181 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1182 n = args(0).int_value (); |
7890 | 1183 |
1184 if (n > 0) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1185 nskip = n; |
7890 | 1186 else |
14049
b5a8e245b4eb
Change phrasing to more assertive error() messages in debug commands
Rik <octave@nomad.inbox5.com>
parents:
14035
diff
changeset
|
1187 error ("dbstack: N must be a non-negative integer"); |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1188 } |
7736 | 1189 |
1190 if (! error_state) | |
1191 { | |
11058
3329616444f0
replace Octave_map in debug.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10840
diff
changeset
|
1192 octave_map stk = octave_call_stack::backtrace (nskip, curr_frame); |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1193 |
7890 | 1194 if (nargout == 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1195 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1196 octave_idx_type nframes_to_display = stk.numel (); |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1197 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1198 if (nframes_to_display > 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1199 { |
13689
b68d95054947
print show_octave_dbstack output to std::cerr
John W. Eaton <jwe@octave.org>
parents:
13326
diff
changeset
|
1200 os << "stopped in:\n\n"; |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1201 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1202 Cell names = stk.contents ("name"); |
10839 | 1203 Cell files = stk.contents ("file"); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1204 Cell lines = stk.contents ("line"); |
10839 | 1205 |
1206 bool show_top_level = true; | |
1207 | |
1208 size_t max_name_len = 0; | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1209 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1210 for (octave_idx_type i = 0; i < nframes_to_display; i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1211 { |
10839 | 1212 std::string name = names(i).string_value (); |
1213 | |
1214 max_name_len = std::max (name.length (), max_name_len); | |
1215 } | |
7890 | 1216 |
10839 | 1217 for (octave_idx_type i = 0; i < nframes_to_display; i++) |
1218 { | |
1219 std::string name = names(i).string_value (); | |
1220 std::string file = files(i).string_value (); | |
1221 int line = lines(i).int_value (); | |
1222 | |
1223 if (show_top_level && i == curr_frame) | |
1224 show_top_level = false; | |
1225 | |
13689
b68d95054947
print show_octave_dbstack output to std::cerr
John W. Eaton <jwe@octave.org>
parents:
13326
diff
changeset
|
1226 os << (i == curr_frame ? " --> " : " ") |
b68d95054947
print show_octave_dbstack output to std::cerr
John W. Eaton <jwe@octave.org>
parents:
13326
diff
changeset
|
1227 << std::setw (max_name_len) << name |
b68d95054947
print show_octave_dbstack output to std::cerr
John W. Eaton <jwe@octave.org>
parents:
13326
diff
changeset
|
1228 << " at line " << line |
b68d95054947
print show_octave_dbstack output to std::cerr
John W. Eaton <jwe@octave.org>
parents:
13326
diff
changeset
|
1229 << " [" << file << "]" |
b68d95054947
print show_octave_dbstack output to std::cerr
John W. Eaton <jwe@octave.org>
parents:
13326
diff
changeset
|
1230 << std::endl; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1231 } |
10839 | 1232 |
1233 if (show_top_level) | |
13689
b68d95054947
print show_octave_dbstack output to std::cerr
John W. Eaton <jwe@octave.org>
parents:
13326
diff
changeset
|
1234 os << " --> top level" << std::endl; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1235 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1236 } |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1237 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1238 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1239 retval(1) = curr_frame < 0 ? 1 : curr_frame + 1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1240 retval(0) = stk; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1241 } |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1242 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1243 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1244 return retval; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1245 } |
7736 | 1246 |
13326
23cc9c13b622
show_octave_dbstack: new convenience function for debugging
John W. Eaton <jwe@octave.org>
parents:
12642
diff
changeset
|
1247 // A function that can be easily called from a debugger print the Octave |
23cc9c13b622
show_octave_dbstack: new convenience function for debugging
John W. Eaton <jwe@octave.org>
parents:
12642
diff
changeset
|
1248 // stack. This can be useful for finding what line of code the |
23cc9c13b622
show_octave_dbstack: new convenience function for debugging
John W. Eaton <jwe@octave.org>
parents:
12642
diff
changeset
|
1249 // interpreter is currently executing when the debugger is stopped in |
23cc9c13b622
show_octave_dbstack: new convenience function for debugging
John W. Eaton <jwe@octave.org>
parents:
12642
diff
changeset
|
1250 // some C++ function, for example. |
23cc9c13b622
show_octave_dbstack: new convenience function for debugging
John W. Eaton <jwe@octave.org>
parents:
12642
diff
changeset
|
1251 |
13784
0bbe319bf26b
octave_class::size: return matrix with correct dimensions
John W. Eaton <jwe@octave.org>
parents:
13689
diff
changeset
|
1252 void |
13326
23cc9c13b622
show_octave_dbstack: new convenience function for debugging
John W. Eaton <jwe@octave.org>
parents:
12642
diff
changeset
|
1253 show_octave_dbstack (void) |
23cc9c13b622
show_octave_dbstack: new convenience function for debugging
John W. Eaton <jwe@octave.org>
parents:
12642
diff
changeset
|
1254 { |
13689
b68d95054947
print show_octave_dbstack output to std::cerr
John W. Eaton <jwe@octave.org>
parents:
13326
diff
changeset
|
1255 do_dbstack (octave_value_list (), 0, std::cerr); |
b68d95054947
print show_octave_dbstack output to std::cerr
John W. Eaton <jwe@octave.org>
parents:
13326
diff
changeset
|
1256 } |
b68d95054947
print show_octave_dbstack output to std::cerr
John W. Eaton <jwe@octave.org>
parents:
13326
diff
changeset
|
1257 |
b68d95054947
print show_octave_dbstack output to std::cerr
John W. Eaton <jwe@octave.org>
parents:
13326
diff
changeset
|
1258 DEFUN (dbstack, args, nargout, |
b68d95054947
print show_octave_dbstack output to std::cerr
John W. Eaton <jwe@octave.org>
parents:
13326
diff
changeset
|
1259 "-*- texinfo -*-\n\ |
15912
8e38eac05230
doc: Change object type of dbwhere, dbstack to "Command" in docstring.
Rik <rik@octave.org>
parents:
15577
diff
changeset
|
1260 @deftypefn {Command} {} dbstack\n\ |
8e38eac05230
doc: Change object type of dbwhere, dbstack to "Command" in docstring.
Rik <rik@octave.org>
parents:
15577
diff
changeset
|
1261 @deftypefnx {Command} {} dbstack @var{n}\n\ |
15038
ab18578c2ade
doc: Update docstrings for built-in functions to not use "Loadable Function" as type.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
1262 @deftypefnx {Built-in Function} {[@var{stack}, @var{idx}] =} dbstack (@dots{})\n\ |
14035
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1263 Display or return current debugging function stack information.\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1264 With optional argument @var{n}, omit the @var{n} innermost stack frames.\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1265 \n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1266 The optional return argument @var{stack} is a struct array with the\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1267 following fields:\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1268 \n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1269 @table @asis\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1270 @item file\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1271 The name of the m-file where the function code is located.\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1272 \n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1273 @item name\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1274 The name of the function with a breakpoint.\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1275 \n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1276 @item line\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1277 The line number of an active breakpoint.\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1278 \n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1279 @item column\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1280 The column number of the line where the breakpoint begins.\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1281 \n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1282 @item scope\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1283 Undocumented.\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1284 \n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1285 @item context\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1286 Undocumented.\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1287 @end table\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1288 \n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1289 The return argument @var{idx} specifies which element of the @var{stack}\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1290 struct array is currently active.\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1291 @seealso{dbup, dbdown, dbwhere, dbstatus}\n\ |
13689
b68d95054947
print show_octave_dbstack output to std::cerr
John W. Eaton <jwe@octave.org>
parents:
13326
diff
changeset
|
1292 @end deftypefn") |
b68d95054947
print show_octave_dbstack output to std::cerr
John W. Eaton <jwe@octave.org>
parents:
13326
diff
changeset
|
1293 { |
b68d95054947
print show_octave_dbstack output to std::cerr
John W. Eaton <jwe@octave.org>
parents:
13326
diff
changeset
|
1294 return do_dbstack (args, nargout, octave_stdout); |
13326
23cc9c13b622
show_octave_dbstack: new convenience function for debugging
John W. Eaton <jwe@octave.org>
parents:
12642
diff
changeset
|
1295 } |
23cc9c13b622
show_octave_dbstack: new convenience function for debugging
John W. Eaton <jwe@octave.org>
parents:
12642
diff
changeset
|
1296 |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1297 static void |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1298 do_dbupdown (const octave_value_list& args, const std::string& who) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1299 { |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1300 int n = 1; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1301 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1302 if (args.length () == 1) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1303 { |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1304 octave_value arg = args(0); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1305 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1306 if (arg.is_string ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1307 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1308 std::string s_arg = arg.string_value (); |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1309 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1310 n = atoi (s_arg.c_str ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1311 } |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1312 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1313 n = args(0).int_value (); |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1314 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1315 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1316 if (! error_state) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1317 { |
7890 | 1318 if (who == "dbup") |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1319 n = -n; |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1320 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1321 if (! octave_call_stack::goto_frame_relative (n, true)) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1322 error ("%s: invalid stack frame", who.c_str ()); |
7736 | 1323 } |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1324 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1325 |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8677
diff
changeset
|
1326 DEFUN (dbup, args, , |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1327 "-*- texinfo -*-\n\ |
15038
ab18578c2ade
doc: Update docstrings for built-in functions to not use "Loadable Function" as type.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
1328 @deftypefn {Built-in Function} {} dbup\n\ |
ab18578c2ade
doc: Update docstrings for built-in functions to not use "Loadable Function" as type.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
1329 @deftypefnx {Built-in Function} {} dbup (@var{n})\n\ |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1330 In debugging mode, move up the execution stack @var{n} frames.\n\ |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1331 If @var{n} is omitted, move up one frame.\n\ |
14035
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1332 @seealso{dbstack, dbdown}\n\ |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1333 @end deftypefn") |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1334 { |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1335 octave_value retval; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1336 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1337 do_dbupdown (args, "dbup"); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1338 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1339 return retval; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1340 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1341 |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8677
diff
changeset
|
1342 DEFUN (dbdown, args, , |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1343 "-*- texinfo -*-\n\ |
15038
ab18578c2ade
doc: Update docstrings for built-in functions to not use "Loadable Function" as type.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
1344 @deftypefn {Built-in Function} {} dbdown\n\ |
ab18578c2ade
doc: Update docstrings for built-in functions to not use "Loadable Function" as type.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
1345 @deftypefnx {Built-in Function} {} dbdown (@var{n})\n\ |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1346 In debugging mode, move down the execution stack @var{n} frames.\n\ |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1347 If @var{n} is omitted, move down one frame.\n\ |
14035
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1348 @seealso{dbstack, dbup}\n\ |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1349 @end deftypefn") |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1350 { |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1351 octave_value retval; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1352 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
1353 do_dbupdown (args, "dbdown"); |
7736 | 1354 |
1355 return retval; | |
1356 } | |
1357 | |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8677
diff
changeset
|
1358 DEFUN (dbstep, args, , |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1359 "-*- texinfo -*-\n\ |
9724
f22bbc5d56e9
Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents:
9484
diff
changeset
|
1360 @deftypefn {Command} {} dbstep\n\ |
f22bbc5d56e9
Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents:
9484
diff
changeset
|
1361 @deftypefnx {Command} {} dbstep @var{n}\n\ |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1362 @deftypefnx {Command} {} dbstep in\n\ |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1363 @deftypefnx {Command} {} dbstep out\n\ |
14035
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1364 @deftypefnx {Command} {} dbnext @dots{}\n\ |
9724
f22bbc5d56e9
Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents:
9484
diff
changeset
|
1365 In debugging mode, execute the next @var{n} lines of code.\n\ |
14035
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1366 If @var{n} is omitted, execute the next single line of code.\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1367 If the next line of code is itself defined in terms of an m-file remain in\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1368 the existing function.\n\ |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1369 \n\ |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1370 Using @code{dbstep in} will cause execution of the next line to step into\n\ |
9724
f22bbc5d56e9
Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents:
9484
diff
changeset
|
1371 any m-files defined on the next line. Using @code{dbstep out} will cause\n\ |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1372 execution to continue until the current function returns.\n\ |
14035
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1373 \n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1374 @code{dbnext} is an alias for @code{dbstep}.\n\ |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1375 @seealso{dbcont, dbquit}\n\ |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1376 @end deftypefn") |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1377 { |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1378 if (Vdebugging) |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1379 { |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1380 int nargin = args.length (); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
1381 |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1382 if (nargin > 1) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1383 print_usage (); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
1384 else if (nargin == 1) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1385 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1386 if (args(0).is_string ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1387 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1388 std::string arg = args(0).string_value (); |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1389 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1390 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1391 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1392 if (arg == "in") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1393 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1394 Vdebugging = false; |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1395 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1396 tree_evaluator::dbstep_flag = -1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1397 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1398 else if (arg == "out") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1399 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1400 Vdebugging = false; |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1401 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1402 tree_evaluator::dbstep_flag = -2; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1403 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1404 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1405 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1406 int n = atoi (arg.c_str ()); |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1407 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1408 if (n > 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1409 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1410 Vdebugging = false; |
7818
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7787
diff
changeset
|
1411 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1412 tree_evaluator::dbstep_flag = n; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1413 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1414 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1415 error ("dbstep: invalid argument"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1416 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1417 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1418 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1419 else |
14049
b5a8e245b4eb
Change phrasing to more assertive error() messages in debug commands
Rik <octave@nomad.inbox5.com>
parents:
14035
diff
changeset
|
1420 error ("dbstep: input argument must be a character string"); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1421 } |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1422 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1423 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1424 Vdebugging = false; |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1425 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1426 tree_evaluator::dbstep_flag = 1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1427 } |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1428 } |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1429 else |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1430 error ("dbstep: can only be called in debug mode"); |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1431 |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1432 return octave_value_list (); |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1433 } |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1434 |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
1435 DEFALIAS (dbnext, dbstep); |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
1436 |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8677
diff
changeset
|
1437 DEFUN (dbcont, args, , |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1438 "-*- texinfo -*-\n\ |
9724
f22bbc5d56e9
Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents:
9484
diff
changeset
|
1439 @deftypefn {Command} {} dbcont\n\ |
14035
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1440 Leave command-line debugging mode and continue code execution normally.\n\ |
9724
f22bbc5d56e9
Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents:
9484
diff
changeset
|
1441 @seealso{dbstep, dbquit}\n\ |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1442 @end deftypefn") |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1443 { |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1444 if (Vdebugging) |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
1445 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
1446 if (args.length () == 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1447 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1448 Vdebugging = false; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
1449 |
10186
095a1e670e68
make dbstep work with keyboard function
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1450 tree_evaluator::reset_debug_state (); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1451 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
1452 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1453 print_usage (); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
1454 } |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1455 else |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1456 error ("dbcont: can only be called in debug mode"); |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1457 |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1458 return octave_value_list (); |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1459 } |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1460 |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8677
diff
changeset
|
1461 DEFUN (dbquit, args, , |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1462 "-*- texinfo -*-\n\ |
9724
f22bbc5d56e9
Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents:
9484
diff
changeset
|
1463 @deftypefn {Command} {} dbquit\n\ |
14035
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1464 Quit debugging mode immediately without further code execution and\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1465 return to the Octave prompt.\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1466 @seealso{dbcont, dbstep}\n\ |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1467 @end deftypefn") |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1468 { |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1469 if (Vdebugging) |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
1470 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
1471 if (args.length () == 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1472 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1473 Vdebugging = false; |
10186
095a1e670e68
make dbstep work with keyboard function
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1474 |
095a1e670e68
make dbstep work with keyboard function
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1475 tree_evaluator::reset_debug_state (); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
1476 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1477 octave_throw_interrupt_exception (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1478 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
1479 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10232
diff
changeset
|
1480 print_usage (); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
1481 } |
7787
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1482 else |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1483 error ("dbquit: can only be called in debug mode"); |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1484 |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1485 return octave_value_list (); |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1486 } |
6b521b1e3631
Add dbquit and make dbstep compatible. Use parser in debug mode to handle multi-line input
David Bateman <dbateman@free.fr>
parents:
7752
diff
changeset
|
1487 |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8677
diff
changeset
|
1488 DEFUN (isdebugmode, args, , |
8114
cbbea37b95e8
debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents:
8021
diff
changeset
|
1489 "-*- texinfo -*-\n\ |
15038
ab18578c2ade
doc: Update docstrings for built-in functions to not use "Loadable Function" as type.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
1490 @deftypefn {Built-in Function} {} isdebugmode ()\n\ |
14035
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1491 Return true if in debugging mode, otherwise false.\n\ |
3889c3eecaf0
doc: Update docstrings for dbXXX functions
Rik <octave@nomad.inbox5.com>
parents:
13983
diff
changeset
|
1492 @seealso{dbwhere, dbstack, dbstatus}\n\ |
8114
cbbea37b95e8
debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents:
8021
diff
changeset
|
1493 @end deftypefn") |
cbbea37b95e8
debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents:
8021
diff
changeset
|
1494 { |
cbbea37b95e8
debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents:
8021
diff
changeset
|
1495 octave_value retval; |
cbbea37b95e8
debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents:
8021
diff
changeset
|
1496 |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
1497 if (args.length () == 0) |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8365
diff
changeset
|
1498 retval = Vdebugging; |
8114
cbbea37b95e8
debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents:
8021
diff
changeset
|
1499 else |
cbbea37b95e8
debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents:
8021
diff
changeset
|
1500 print_usage (); |
cbbea37b95e8
debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents:
8021
diff
changeset
|
1501 |
cbbea37b95e8
debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents:
8021
diff
changeset
|
1502 return retval; |
cbbea37b95e8
debug.cc (Fisdebugmode): New function.
Krzesimir Nowak <qdlacz@gmail.com>
parents:
8021
diff
changeset
|
1503 } |