Mercurial > octave-nkf
annotate libinterp/corefcn/toplev.h @ 19631:db92e7e28e1f
strip trailing whitespace from most source files
* NEWS, doc/interpreter/contributors.in, doc/interpreter/func.txi,
doc/interpreter/genpropdoc.m, doc/interpreter/octave_logo.eps,
doc/interpreter/plot.txi, doc/interpreter/stmt.txi,
examples/data/Makefile.am, libinterp/corefcn/data.cc,
libinterp/corefcn/debug.cc, libinterp/corefcn/error.cc,
libinterp/corefcn/file-io.cc, libinterp/corefcn/gl-render.cc,
libinterp/corefcn/graphics.cc, libinterp/corefcn/graphics.in.h,
libinterp/corefcn/load-path.cc, libinterp/corefcn/pr-output.cc,
libinterp/corefcn/pt-jit.cc, libinterp/corefcn/strfind.cc,
libinterp/corefcn/toplev.cc, libinterp/corefcn/toplev.h,
libinterp/corefcn/urlwrite.cc, libinterp/corefcn/variables.cc,
libinterp/octave-value/ov-classdef.cc,
libinterp/octave-value/ov-classdef.h, libinterp/octave.cc,
libinterp/parse-tree/lex.h, libinterp/parse-tree/oct-parse.in.yy,
libinterp/parse-tree/pt-classdef.h, liboctave/system/file-ops.cc,
liboctave/system/oct-env.cc, m4/acinclude.m4,
scripts/deprecated/finite.m, scripts/deprecated/fmod.m,
scripts/deprecated/fnmatch.m, scripts/deprecated/luinc.m,
scripts/deprecated/octave_tmp_file_name.m, scripts/deprecated/syl.m,
scripts/deprecated/usage.m, scripts/general/inputParser.m,
scripts/general/interp1.m, scripts/general/interp2.m,
scripts/general/interp3.m, scripts/general/isequal.m,
scripts/general/private/__isequal__.m, scripts/geometry/voronoi.m,
scripts/image/image.m, scripts/image/imshow.m,
scripts/image/ind2rgb.m, scripts/linear-algebra/bandwidth.m,
scripts/linear-algebra/isbanded.m, scripts/miscellaneous/bzip2.m,
scripts/miscellaneous/cast.m, scripts/miscellaneous/copyfile.m,
scripts/miscellaneous/delete.m, scripts/miscellaneous/fullfile.m,
scripts/miscellaneous/getappdata.m, scripts/miscellaneous/gunzip.m,
scripts/miscellaneous/isappdata.m, scripts/miscellaneous/ls.m,
scripts/miscellaneous/mex.m, scripts/miscellaneous/movefile.m,
scripts/miscellaneous/orderfields.m, scripts/miscellaneous/recycle.m,
scripts/miscellaneous/rmappdata.m, scripts/miscellaneous/setfield.m,
scripts/miscellaneous/symvar.m, scripts/miscellaneous/tar.m,
scripts/miscellaneous/tmpnam.m, scripts/miscellaneous/unpack.m,
scripts/miscellaneous/ver.m, scripts/miscellaneous/what.m,
scripts/miscellaneous/xor.m, scripts/miscellaneous/zip.m,
scripts/optimization/fminbnd.m, scripts/optimization/sqp.m,
scripts/path/private/getsavepath.m, scripts/path/savepath.m,
scripts/pkg/pkg.m, scripts/pkg/private/installed_packages.m,
scripts/plot/draw/plotyy.m, scripts/plot/draw/polar.m,
scripts/plot/draw/private/__quiver__.m,
scripts/plot/draw/private/__scatter__.m,
scripts/plot/draw/private/__stem__.m, scripts/plot/draw/surface.m,
scripts/plot/draw/surfnorm.m, scripts/plot/util/copyobj.m,
scripts/plot/util/hgload.m, scripts/plot/util/hgsave.m,
scripts/plot/util/isprop.m, scripts/plot/util/linkprop.m,
scripts/plot/util/private/__go_draw_axes__.m, scripts/set/setdiff.m,
scripts/set/union.m, scripts/signal/periodogram.m,
scripts/sparse/eigs.m, scripts/sparse/ilu.m, scripts/sparse/qmr.m,
scripts/sparse/sprand.m, scripts/sparse/sprandn.m,
scripts/specfun/beta.m, scripts/specfun/ellipke.m,
scripts/specfun/isprime.m, scripts/statistics/base/lscov.m,
scripts/testfun/__run_test_suite__.m, scripts/testfun/test.m:
Strip trailing whitespace.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 20 Jan 2015 10:29:54 -0500 |
parents | 972abb60c30f |
children | 4197fc428c7d |
rev | line source |
---|---|
1 | 1 /* |
2 | |
17744
d63878346099
maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents:
17084
diff
changeset
|
3 Copyright (C) 1993-2013 John W. Eaton |
1 | 4 |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
8 under the terms of the GNU General Public License as published by the | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
1 | 11 |
12 Octave is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
1 | 20 |
21 */ | |
22 | |
1670 | 23 #if !defined (octave_toplev_h) |
24 #define octave_toplev_h 1 | |
1 | 25 |
1355 | 26 #include <cstdio> |
1 | 27 |
7552
6070c3bd69c4
Arbitrary call stack access for external debuggers changeset
ryanru@PrinceHumperdinck
parents:
7409
diff
changeset
|
28 #include <deque> |
3503 | 29 #include <string> |
30 | |
2086 | 31 class octave_value; |
2796 | 32 class octave_value_list; |
5743 | 33 class octave_function; |
5744 | 34 class octave_user_script; |
7734
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
35 class tree_statement; |
578 | 36 class tree_statement_list; |
1572 | 37 class charMatrix; |
1 | 38 |
9217
ee7cf4d963f3
smarter handling of quit()
Jaroslav Hajek <highegg@gmail.com>
parents:
9144
diff
changeset
|
39 #include "quit.h" |
ee7cf4d963f3
smarter handling of quit()
Jaroslav Hajek <highegg@gmail.com>
parents:
9144
diff
changeset
|
40 |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
41 #include "input.h" |
7734
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
42 #include "oct-map.h" |
17084
872947f3f9f1
* toplev.cc: Include symtab.h
John W. Eaton <jwe@octave.org>
parents:
16892
diff
changeset
|
43 #include "symtab.h" |
7734
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
44 |
9217
ee7cf4d963f3
smarter handling of quit()
Jaroslav Hajek <highegg@gmail.com>
parents:
9144
diff
changeset
|
45 |
9221
659657942ba6
declare octave_exit using a typedef
Jaroslav Hajek <highegg@gmail.com>
parents:
9218
diff
changeset
|
46 typedef void (*octave_exit_func) (int); |
659657942ba6
declare octave_exit using a typedef
Jaroslav Hajek <highegg@gmail.com>
parents:
9218
diff
changeset
|
47 extern OCTINTERP_API octave_exit_func octave_exit; |
9217
ee7cf4d963f3
smarter handling of quit()
Jaroslav Hajek <highegg@gmail.com>
parents:
9144
diff
changeset
|
48 |
9255
1c2d2c9f4a8d
don't allow quit() in embedded mode by default, make configurable
Jaroslav Hajek <highegg@gmail.com>
parents:
9247
diff
changeset
|
49 extern OCTINTERP_API bool quit_allowed; |
1c2d2c9f4a8d
don't allow quit() in embedded mode by default, make configurable
Jaroslav Hajek <highegg@gmail.com>
parents:
9247
diff
changeset
|
50 |
9383 | 51 extern OCTINTERP_API bool quitting_gracefully; |
52 | |
53 extern OCTINTERP_API int exit_status; | |
9217
ee7cf4d963f3
smarter handling of quit()
Jaroslav Hajek <highegg@gmail.com>
parents:
9144
diff
changeset
|
54 |
7250 | 55 extern OCTINTERP_API void |
16485
8b783661e03f
improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
56 clean_up_and_exit (int status, bool safe_to_return = false); |
574 | 57 |
7250 | 58 extern OCTINTERP_API void recover_from_exception (void); |
7202 | 59 |
9247
b2790fd23800
More export symbols to allow usage from an IDE.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9237
diff
changeset
|
60 extern OCTINTERP_API int main_loop (void); |
1907 | 61 |
7250 | 62 extern OCTINTERP_API void |
7409 | 63 octave_add_atexit_function (const std::string& fname); |
64 | |
65 extern OCTINTERP_API bool | |
66 octave_remove_atexit_function (const std::string& fname); | |
67 | |
4217 | 68 // TRUE means we are ready to interpret commands, but not everything |
69 // is ready for interactive use. | |
7185 | 70 extern OCTINTERP_API bool octave_interpreter_ready; |
4217 | 71 |
4172 | 72 // TRUE means we've processed all the init code and we are good to go. |
7185 | 73 extern OCTINTERP_API bool octave_initialized; |
4172 | 74 |
5743 | 75 class |
9237
3c1762c7e787
Add missing xxx_API decoration and remove misplaced ones
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9221
diff
changeset
|
76 OCTINTERP_API |
5743 | 77 octave_call_stack |
78 { | |
79 protected: | |
80 | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
81 octave_call_stack (void) : cs (), curr_frame (0) { } |
5743 | 82 |
83 public: | |
84 | |
19449
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
85 class stack_frame |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
86 { |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
87 public: |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
88 |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
89 friend class octave_call_stack; |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
90 |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
91 stack_frame (octave_function *fcn = 0, symbol_table::scope_id scope = 0, |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
92 symbol_table::context_id context = 0, size_t prev = 0) |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
93 : m_fcn (fcn), m_line (-1), m_column (-1), m_scope (scope), |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
94 m_context (context), m_prev (prev) |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
95 { } |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
96 |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
97 stack_frame (const stack_frame& elt) |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
98 : m_fcn (elt.m_fcn), m_line (elt.m_line), m_column (elt.m_column), |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
99 m_scope (elt.m_scope), m_context (elt.m_context), m_prev (elt.m_prev) |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
100 { } |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
101 |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
102 int line (void) const { return m_line; } |
7901 | 103 |
19449
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
104 int column (void) const { return m_column; } |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
105 |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
106 std::string fcn_file_name (void) const; |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
107 |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
108 std::string fcn_name (bool print_subfn = true) const; |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
109 |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
110 private: |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
111 |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
112 octave_function *m_fcn; |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
113 int m_line; |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
114 int m_column; |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
115 symbol_table::scope_id m_scope; |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
116 symbol_table::context_id m_context; |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
117 size_t m_prev; |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
118 }; |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
119 |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
120 typedef std::deque<stack_frame>::iterator iterator; |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
121 typedef std::deque<stack_frame>::const_iterator const_iterator; |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
122 |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
123 typedef std::deque<stack_frame>::reverse_iterator reverse_iterator; |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
124 typedef std::deque<stack_frame>::const_reverse_iterator const_reverse_iterator; |
7901 | 125 |
13983
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
126 static void create_instance (void); |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
127 |
5743 | 128 static bool instance_ok (void) |
129 { | |
130 bool retval = true; | |
131 | |
132 if (! instance) | |
13983
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
133 create_instance (); |
5743 | 134 |
13983
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
135 if (! instance) |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
136 { |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
137 ::error ("unable to create call stack object!"); |
5743 | 138 |
13983
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
139 retval = false; |
5743 | 140 } |
141 | |
142 return retval; | |
143 } | |
144 | |
145 // Current function (top of stack). | |
9484
bbe033dcfe13
make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents:
9396
diff
changeset
|
146 static octave_function *current (void) |
bbe033dcfe13
make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents:
9396
diff
changeset
|
147 { |
bbe033dcfe13
make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents:
9396
diff
changeset
|
148 return instance_ok () ? instance->do_current () : 0; |
bbe033dcfe13
make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents:
9396
diff
changeset
|
149 } |
5743 | 150 |
7734
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
151 // Current line in current function. |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
152 static int current_line (void) |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
153 { |
7877 | 154 return instance_ok () ? instance->do_current_line () : -1; |
7734
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
155 } |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
156 |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
157 // Current column in current function. |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
158 static int current_column (void) |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
159 { |
7877 | 160 return instance_ok () ? instance->do_current_column () : -1; |
161 } | |
162 | |
163 // Line in user code caller. | |
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:
7912
diff
changeset
|
164 static int caller_user_code_line (void) |
7877 | 165 { |
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:
7912
diff
changeset
|
166 return instance_ok () ? instance->do_caller_user_code_line () : -1; |
7877 | 167 } |
168 | |
169 // Column in user code caller. | |
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:
7912
diff
changeset
|
170 static int caller_user_code_column (void) |
7877 | 171 { |
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:
7912
diff
changeset
|
172 return instance_ok () ? instance->do_caller_user_code_column () : -1; |
7734
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
173 } |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
174 |
5743 | 175 // Caller function, may be built-in. |
176 static octave_function *caller (void) | |
177 { | |
7942
db6478d9c669
out_of_date_check_internal: make it work for class methods
John W. Eaton <jwe@octave.org>
parents:
7923
diff
changeset
|
178 return instance_ok () ? instance->do_caller () : 0; |
5743 | 179 } |
180 | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
181 static size_t current_frame (void) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
182 { |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
183 return instance_ok () ? instance->do_current_frame () : 0; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
184 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
185 |
7890 | 186 static size_t size (void) |
187 { | |
188 return instance_ok () ? instance->do_size () : 0; | |
189 } | |
190 | |
7901 | 191 static size_t num_user_code_frames (octave_idx_type& curr_user_frame) |
192 { | |
193 return instance_ok () | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
194 ? instance->do_num_user_code_frames (curr_user_frame) : 0; |
7901 | 195 } |
196 | |
197 static symbol_table::scope_id current_scope (void) | |
198 { | |
199 return instance_ok () ? instance->do_current_scope () : 0; | |
200 } | |
201 | |
202 static symbol_table::context_id current_context (void) | |
203 { | |
204 return instance_ok () ? instance->do_current_context () : 0; | |
205 } | |
206 | |
19449
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
207 /* |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
208 static stack_frame frame (size_t idx) |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
209 { |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
210 return instance_ok () ? instance->do_frame (idx) : stack_frame (); |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
211 } |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
212 */ |
7552
6070c3bd69c4
Arbitrary call stack access for external debuggers changeset
ryanru@PrinceHumperdinck
parents:
7409
diff
changeset
|
213 // Function at location N on the call stack (N == 0 is current), may |
6070c3bd69c4
Arbitrary call stack access for external debuggers changeset
ryanru@PrinceHumperdinck
parents:
7409
diff
changeset
|
214 // be built-in. |
6070c3bd69c4
Arbitrary call stack access for external debuggers changeset
ryanru@PrinceHumperdinck
parents:
7409
diff
changeset
|
215 static octave_function *element (size_t n) |
6070c3bd69c4
Arbitrary call stack access for external debuggers changeset
ryanru@PrinceHumperdinck
parents:
7409
diff
changeset
|
216 { |
6070c3bd69c4
Arbitrary call stack access for external debuggers changeset
ryanru@PrinceHumperdinck
parents:
7409
diff
changeset
|
217 return instance_ok () ? instance->do_element (n) : 0; |
6070c3bd69c4
Arbitrary call stack access for external debuggers changeset
ryanru@PrinceHumperdinck
parents:
7409
diff
changeset
|
218 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
219 |
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:
7912
diff
changeset
|
220 // First user-defined function on the stack. |
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:
7912
diff
changeset
|
221 static octave_user_code *caller_user_code (size_t nskip = 0) |
5743 | 222 { |
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:
7912
diff
changeset
|
223 return instance_ok () ? instance->do_caller_user_code (nskip) : 0; |
5743 | 224 } |
225 | |
18267
bc139ccccef9
Don't echo scripts not executed from the cmd line when using 'echo on'(bug #41202)
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
226 // Return TRUE if all elements on the call stack are scripts. |
bc139ccccef9
Don't echo scripts not executed from the cmd line when using 'echo on'(bug #41202)
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
227 static bool all_scripts (void) |
bc139ccccef9
Don't echo scripts not executed from the cmd line when using 'echo on'(bug #41202)
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
228 { |
bc139ccccef9
Don't echo scripts not executed from the cmd line when using 'echo on'(bug #41202)
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
229 return instance_ok () ? instance->do_all_scripts () : false; |
bc139ccccef9
Don't echo scripts not executed from the cmd line when using 'echo on'(bug #41202)
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
230 } |
bc139ccccef9
Don't echo scripts not executed from the cmd line when using 'echo on'(bug #41202)
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
231 |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
232 static void |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
233 push (octave_function *f, |
10313 | 234 symbol_table::scope_id scope = symbol_table::current_scope (), |
235 symbol_table::context_id context = symbol_table::current_context ()) | |
5743 | 236 { |
237 if (instance_ok ()) | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
238 instance->do_push (f, scope, context); |
5743 | 239 } |
240 | |
9144
c6463412aebb
eliminate symbol_table::scope_stack; fix scoping issue with evalin
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
241 static void |
c6463412aebb
eliminate symbol_table::scope_stack; fix scoping issue with evalin
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
242 push (symbol_table::scope_id scope = symbol_table::current_scope (), |
10313 | 243 symbol_table::context_id context = symbol_table::current_context ()) |
9144
c6463412aebb
eliminate symbol_table::scope_stack; fix scoping issue with evalin
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
244 { |
c6463412aebb
eliminate symbol_table::scope_stack; fix scoping issue with evalin
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
245 if (instance_ok ()) |
c6463412aebb
eliminate symbol_table::scope_stack; fix scoping issue with evalin
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
246 instance->do_push (0, scope, context); |
c6463412aebb
eliminate symbol_table::scope_stack; fix scoping issue with evalin
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
247 } |
c6463412aebb
eliminate symbol_table::scope_stack; fix scoping issue with evalin
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
248 |
16354
fb27f1e08297
track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
249 static void set_location (int l, int c) |
7734
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
250 { |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
251 if (instance_ok ()) |
16354
fb27f1e08297
track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
252 instance->do_set_location (l, c); |
fb27f1e08297
track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
253 } |
fb27f1e08297
track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
254 |
fb27f1e08297
track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
255 static void set_line (int l) |
fb27f1e08297
track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
256 { |
fb27f1e08297
track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
257 if (instance_ok ()) |
fb27f1e08297
track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
258 instance->do_set_line (l); |
fb27f1e08297
track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
259 } |
fb27f1e08297
track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
260 |
fb27f1e08297
track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
261 static void set_column (int c) |
fb27f1e08297
track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
262 { |
fb27f1e08297
track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
263 if (instance_ok ()) |
fb27f1e08297
track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
264 instance->do_set_column (c); |
7734
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
265 } |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
266 |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
267 static bool goto_frame (size_t n = 0, bool verbose = false) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
268 { |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
269 return instance_ok () ? instance->do_goto_frame (n, verbose) : false; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
270 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
271 |
9396
17af7cce7d1b
yet more unwind_protect improvements
Jaroslav Hajek <highegg@gmail.com>
parents:
9383
diff
changeset
|
272 static void restore_frame (size_t n) |
17af7cce7d1b
yet more unwind_protect improvements
Jaroslav Hajek <highegg@gmail.com>
parents:
9383
diff
changeset
|
273 { |
17af7cce7d1b
yet more unwind_protect improvements
Jaroslav Hajek <highegg@gmail.com>
parents:
9383
diff
changeset
|
274 goto_frame (n); |
17af7cce7d1b
yet more unwind_protect improvements
Jaroslav Hajek <highegg@gmail.com>
parents:
9383
diff
changeset
|
275 } |
17af7cce7d1b
yet more unwind_protect improvements
Jaroslav Hajek <highegg@gmail.com>
parents:
9383
diff
changeset
|
276 |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
277 static bool goto_frame_relative (int n, bool verbose = false) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
278 { |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
279 return instance_ok () |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
280 ? instance->do_goto_frame_relative (n, verbose) : false; |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
281 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
282 |
7901 | 283 static void goto_caller_frame (void) |
284 { | |
285 if (instance_ok ()) | |
286 instance->do_goto_caller_frame (); | |
287 } | |
288 | |
289 static void goto_base_frame (void) | |
7734
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
290 { |
7901 | 291 if (instance_ok ()) |
292 instance->do_goto_base_frame (); | |
293 } | |
294 | |
19449
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
295 static octave_map backtrace (size_t nskip = 0) |
7901 | 296 { |
19449
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
297 octave_idx_type curr_user_frame = -1; |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
298 |
7901 | 299 return instance_ok () |
18440
96a495813047
Don't put parent function in subfunction stack structure name (bug #41506).
Rik <rik@octave.org>
parents:
18267
diff
changeset
|
300 ? instance->do_backtrace (nskip, curr_user_frame, true) |
96a495813047
Don't put parent function in subfunction stack structure name (bug #41506).
Rik <rik@octave.org>
parents:
18267
diff
changeset
|
301 : octave_map (); |
96a495813047
Don't put parent function in subfunction stack structure name (bug #41506).
Rik <rik@octave.org>
parents:
18267
diff
changeset
|
302 } |
19631
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19449
diff
changeset
|
303 |
18440
96a495813047
Don't put parent function in subfunction stack structure name (bug #41506).
Rik <rik@octave.org>
parents:
18267
diff
changeset
|
304 static octave_map backtrace (size_t nskip, octave_idx_type& curr_user_frame, |
19449
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
305 bool print_subfn = true) |
18440
96a495813047
Don't put parent function in subfunction stack structure name (bug #41506).
Rik <rik@octave.org>
parents:
18267
diff
changeset
|
306 { |
96a495813047
Don't put parent function in subfunction stack structure name (bug #41506).
Rik <rik@octave.org>
parents:
18267
diff
changeset
|
307 return instance_ok () |
96a495813047
Don't put parent function in subfunction stack structure name (bug #41506).
Rik <rik@octave.org>
parents:
18267
diff
changeset
|
308 ? instance->do_backtrace (nskip, curr_user_frame, print_subfn) |
96a495813047
Don't put parent function in subfunction stack structure name (bug #41506).
Rik <rik@octave.org>
parents:
18267
diff
changeset
|
309 : octave_map (); |
7734
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
310 } |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
311 |
19449
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
312 static std::list<octave_call_stack::stack_frame> |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
313 backtrace_frames (size_t nskip = 0) |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
314 { |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
315 octave_idx_type curr_user_frame = -1; |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
316 |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
317 return instance_ok () |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
318 ? instance->do_backtrace_frames (nskip, curr_user_frame) |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
319 : std::list<octave_call_stack::stack_frame> (); |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
320 } |
19631
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19449
diff
changeset
|
321 |
19449
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
322 static std::list<octave_call_stack::stack_frame> |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
323 backtrace_frames (size_t nskip, octave_idx_type& curr_user_frame) |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
324 { |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
325 return instance_ok () |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
326 ? instance->do_backtrace_frames (nskip, curr_user_frame) |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
327 : std::list<octave_call_stack::stack_frame> (); |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
328 } |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
329 |
10767
2b041d3995a3
modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
330 static octave_map empty_backtrace (void); |
2b041d3995a3
modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
331 |
5743 | 332 static void pop (void) |
333 { | |
334 if (instance_ok ()) | |
335 instance->do_pop (); | |
336 } | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
337 |
5743 | 338 static void clear (void) |
339 { | |
340 if (instance_ok ()) | |
341 instance->do_clear (); | |
342 } | |
7552
6070c3bd69c4
Arbitrary call stack access for external debuggers changeset
ryanru@PrinceHumperdinck
parents:
7409
diff
changeset
|
343 |
5743 | 344 private: |
345 | |
346 // The current call stack. | |
19449
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
347 std::deque<stack_frame> cs; |
5743 | 348 |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
349 size_t curr_frame; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
350 |
5743 | 351 static octave_call_stack *instance; |
352 | |
13983
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
353 static void cleanup_instance (void) { delete instance; instance = 0; } |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
354 |
7734
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
355 int do_current_line (void) const; |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
356 |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
357 int do_current_column (void) const; |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
358 |
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:
7912
diff
changeset
|
359 int do_caller_user_code_line (void) const; |
7877 | 360 |
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:
7912
diff
changeset
|
361 int do_caller_user_code_column (void) const; |
7877 | 362 |
7942
db6478d9c669
out_of_date_check_internal: make it work for class methods
John W. Eaton <jwe@octave.org>
parents:
7923
diff
changeset
|
363 octave_function *do_caller (void) const |
db6478d9c669
out_of_date_check_internal: make it work for class methods
John W. Eaton <jwe@octave.org>
parents:
7923
diff
changeset
|
364 { |
19449
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
365 return curr_frame > 1 ? cs[curr_frame-1].m_fcn : cs[0].m_fcn; |
7942
db6478d9c669
out_of_date_check_internal: make it work for class methods
John W. Eaton <jwe@octave.org>
parents:
7923
diff
changeset
|
366 } |
db6478d9c669
out_of_date_check_internal: make it work for class methods
John W. Eaton <jwe@octave.org>
parents:
7923
diff
changeset
|
367 |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
368 size_t do_current_frame (void) { return curr_frame; } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
369 |
7890 | 370 size_t do_size (void) { return cs.size (); } |
371 | |
7901 | 372 size_t do_num_user_code_frames (octave_idx_type& curr_user_frame) const; |
373 | |
374 symbol_table::scope_id do_current_scope (void) const | |
375 { | |
376 return curr_frame > 0 && curr_frame < cs.size () | |
19449
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
377 ? cs[curr_frame].m_scope : 0; |
7901 | 378 } |
379 | |
380 symbol_table::context_id do_current_context (void) const | |
381 { | |
382 return curr_frame > 0 && curr_frame < cs.size () | |
19449
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
383 ? cs[curr_frame].m_context : 0; |
7901 | 384 } |
385 | |
19449
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
386 /* const stack_frame& do_frame (size_t idx) |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
387 { |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
388 static stack_frame foobar; |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
389 |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
390 return idx < cs.size () ? cs[idx] : foobar; |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
391 } |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
392 */ |
7734
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
393 octave_function *do_element (size_t n) |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
394 { |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
395 octave_function *retval = 0; |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
396 |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
397 if (cs.size () > n) |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
398 { |
19449
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
399 stack_frame& elt = cs[n]; |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
400 retval = elt.m_fcn; |
7734
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
401 } |
5743 | 402 |
7734
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
403 return retval; |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
404 } |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
405 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
406 octave_user_code *do_caller_user_code (size_t nskip) const; |
5744 | 407 |
18267
bc139ccccef9
Don't echo scripts not executed from the cmd line when using 'echo on'(bug #41202)
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
408 bool do_all_scripts (void) const; |
bc139ccccef9
Don't echo scripts not executed from the cmd line when using 'echo on'(bug #41202)
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
409 |
19449
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
410 void do_push (octave_function *fcn, symbol_table::scope_id scope, |
10313 | 411 symbol_table::context_id context) |
7734
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
412 { |
7901 | 413 size_t prev_frame = curr_frame; |
414 curr_frame = cs.size (); | |
19449
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
415 cs.push_back (stack_frame (fcn, scope, context, prev_frame)); |
7901 | 416 symbol_table::set_scope_and_context (scope, context); |
7734
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
417 } |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
418 |
9484
bbe033dcfe13
make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents:
9396
diff
changeset
|
419 octave_function *do_current (void) const |
7734
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
420 { |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
421 octave_function *retval = 0; |
5744 | 422 |
7734
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
423 if (! cs.empty ()) |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
424 { |
19449
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
425 const stack_frame& elt = cs[curr_frame]; |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
426 retval = elt.m_fcn; |
7734
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
427 } |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
428 |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
429 return retval; |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
430 } |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
431 |
16354
fb27f1e08297
track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
432 void do_set_location (int l, int c) |
7734
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
433 { |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
434 if (! cs.empty ()) |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
435 { |
19449
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
436 stack_frame& elt = cs.back (); |
16354
fb27f1e08297
track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
437 |
19449
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
438 elt.m_line = l; |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
439 elt.m_column = c; |
16354
fb27f1e08297
track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
440 } |
fb27f1e08297
track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
441 } |
fb27f1e08297
track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
442 |
fb27f1e08297
track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
443 void do_set_line (int l) |
fb27f1e08297
track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
444 { |
fb27f1e08297
track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
445 if (! cs.empty ()) |
fb27f1e08297
track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
446 { |
19449
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
447 stack_frame& elt = cs.back (); |
16354
fb27f1e08297
track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
448 |
19449
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
449 elt.m_line = l; |
16354
fb27f1e08297
track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
450 } |
fb27f1e08297
track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
451 } |
fb27f1e08297
track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
452 |
fb27f1e08297
track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
453 void do_set_column (int c) |
fb27f1e08297
track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
454 { |
fb27f1e08297
track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
455 if (! cs.empty ()) |
fb27f1e08297
track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
456 { |
19449
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
457 stack_frame& elt = cs.back (); |
16354
fb27f1e08297
track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents:
16177
diff
changeset
|
458 |
19449
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
459 elt.m_column = c; |
7734
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
460 } |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
461 } |
2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents:
7733
diff
changeset
|
462 |
19449
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
463 std::list<octave_call_stack::stack_frame> |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
464 do_backtrace_frames (size_t nskip, octave_idx_type& curr_user_frame) const; |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
465 |
10767
2b041d3995a3
modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
466 octave_map do_backtrace (size_t nskip, |
18440
96a495813047
Don't put parent function in subfunction stack structure name (bug #41506).
Rik <rik@octave.org>
parents:
18267
diff
changeset
|
467 octave_idx_type& curr_user_frame, |
96a495813047
Don't put parent function in subfunction stack structure name (bug #41506).
Rik <rik@octave.org>
parents:
18267
diff
changeset
|
468 bool print_subfn) const; |
5744 | 469 |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
470 bool do_goto_frame (size_t n, bool verbose); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
471 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
472 bool do_goto_frame_relative (int n, bool verbose); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
473 |
7901 | 474 void do_goto_caller_frame (void); |
475 | |
476 void do_goto_base_frame (void); | |
477 | |
5743 | 478 void do_pop (void) |
479 { | |
7901 | 480 if (cs.size () > 1) |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
481 { |
19449
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
482 const stack_frame& elt = cs.back (); |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
483 curr_frame = elt.m_prev; |
10313 | 484 cs.pop_back (); |
19449
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
485 const stack_frame& new_elt = cs[curr_frame]; |
972abb60c30f
emit stack trace immediately at point of error
John W. Eaton <jwe@octave.org>
parents:
18440
diff
changeset
|
486 symbol_table::set_scope_and_context (new_elt.m_scope, new_elt.m_context); |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
487 } |
5743 | 488 } |
489 | |
490 void do_clear (void) { cs.clear (); } | |
491 }; | |
492 | |
14014
907d03def9d5
explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents:
13983
diff
changeset
|
493 // Call a function with exceptions handled to avoid problems with |
907d03def9d5
explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents:
13983
diff
changeset
|
494 // errors while shutting down. |
907d03def9d5
explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents:
13983
diff
changeset
|
495 |
907d03def9d5
explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents:
13983
diff
changeset
|
496 #define OCTAVE_IGNORE_EXCEPTION(E) \ |
907d03def9d5
explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents:
13983
diff
changeset
|
497 catch (E) \ |
907d03def9d5
explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents:
13983
diff
changeset
|
498 { \ |
907d03def9d5
explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents:
13983
diff
changeset
|
499 std::cerr << "error: ignoring " #E " while preparing to exit" << std::endl; \ |
907d03def9d5
explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents:
13983
diff
changeset
|
500 recover_from_exception (); \ |
907d03def9d5
explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents:
13983
diff
changeset
|
501 } |
907d03def9d5
explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents:
13983
diff
changeset
|
502 |
907d03def9d5
explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents:
13983
diff
changeset
|
503 #define OCTAVE_SAFE_CALL(F, ARGS) \ |
907d03def9d5
explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents:
13983
diff
changeset
|
504 do \ |
907d03def9d5
explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents:
13983
diff
changeset
|
505 { \ |
907d03def9d5
explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents:
13983
diff
changeset
|
506 try \ |
907d03def9d5
explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents:
13983
diff
changeset
|
507 { \ |
907d03def9d5
explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents:
13983
diff
changeset
|
508 unwind_protect frame; \ |
907d03def9d5
explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents:
13983
diff
changeset
|
509 \ |
907d03def9d5
explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents:
13983
diff
changeset
|
510 frame.protect_var (Vdebug_on_error); \ |
907d03def9d5
explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents:
13983
diff
changeset
|
511 frame.protect_var (Vdebug_on_warning); \ |
907d03def9d5
explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents:
13983
diff
changeset
|
512 \ |
907d03def9d5
explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents:
13983
diff
changeset
|
513 Vdebug_on_error = false; \ |
907d03def9d5
explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents:
13983
diff
changeset
|
514 Vdebug_on_warning = false; \ |
907d03def9d5
explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents:
13983
diff
changeset
|
515 \ |
907d03def9d5
explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents:
13983
diff
changeset
|
516 F ARGS; \ |
907d03def9d5
explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents:
13983
diff
changeset
|
517 } \ |
907d03def9d5
explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents:
13983
diff
changeset
|
518 OCTAVE_IGNORE_EXCEPTION (octave_interrupt_exception) \ |
907d03def9d5
explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents:
13983
diff
changeset
|
519 OCTAVE_IGNORE_EXCEPTION (octave_execution_exception) \ |
907d03def9d5
explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents:
13983
diff
changeset
|
520 OCTAVE_IGNORE_EXCEPTION (std::bad_alloc) \ |
907d03def9d5
explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents:
13983
diff
changeset
|
521 \ |
907d03def9d5
explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents:
13983
diff
changeset
|
522 if (error_state) \ |
907d03def9d5
explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents:
13983
diff
changeset
|
523 error_state = 0; \ |
907d03def9d5
explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents:
13983
diff
changeset
|
524 } \ |
907d03def9d5
explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents:
13983
diff
changeset
|
525 while (0) |
907d03def9d5
explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents:
13983
diff
changeset
|
526 |
1 | 527 #endif |