Mercurial > octave
annotate libinterp/corefcn/call-stack.cc @ 28930:2883b3d08b7e
maint: Remove unnecessary parentheses bracketing %!error BIST tests.
* bsxfun.cc, call-stack.cc, data.cc, environment.cc, fcn-info.cc, fft.cc,
filter.cc, quadcc.cc, sighandlers.cc, sysdep.cc, ov.cc, pt-eval.cc,
accumarray.m, repmat.m, beep.m, pchip.m, movfun.m, rosser.m:
Remove unnecessary parentheses bracketing %!error BIST tests.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 14 Oct 2020 13:14:02 -0700 |
parents | 43ad651cf5a0 |
children | be19672a3c49 |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 //////////////////////////////////////////////////////////////////////// |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
3 // Copyright (C) 1995-2020 The Octave Project Developers |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
4 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 // See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 // distribution or <https://octave.org/copyright/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
7 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
8 // This file is part of Octave. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
9 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
10 // Octave is free software: you can redistribute it and/or modify it |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
11 // under the terms of the GNU General Public License as published by |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
12 // the Free Software Foundation, either version 3 of the License, or |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
13 // (at your option) any later version. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
14 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
15 // Octave is distributed in the hope that it will be useful, but |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
16 // WITHOUT ANY WARRANTY; without even the implied warranty of |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
18 // GNU General Public License for more details. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
19 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
20 // You should have received a copy of the GNU General Public License |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
21 // along with Octave; see the file COPYING. If not, see |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
22 // <https://www.gnu.org/licenses/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 //////////////////////////////////////////////////////////////////////// |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
25 |
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
26 #if defined (HAVE_CONFIG_H) |
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
27 # include "config.h" |
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
28 #endif |
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
29 |
26089
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
30 #include "lo-regexp.h" |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
31 #include "str-vec.h" |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
32 |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
33 #include "call-stack.h" |
24855
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
34 #include "defun.h" |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
35 #include "interpreter.h" |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
36 #include "interpreter-private.h" |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
37 #include "oct-map.h" |
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
38 #include "ov.h" |
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
39 #include "ov-fcn.h" |
22253
dbf7fd79e391
More informative messages for errors in anonymous functions (bug #46136).
Olaf Till <olaf.till@uni-jena.de>
parents:
22091
diff
changeset
|
40 #include "ov-fcn-handle.h" |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
41 #include "ov-usr-fcn.h" |
23630
8a47d4735655
avoid memory leak in interpreter
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
42 #include "pager.h" |
26089
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
43 #include "parse.h" |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
44 #include "stack-frame.h" |
26089
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
45 #include "syminfo.h" |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
46 #include "symrec.h" |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
47 #include "symscope.h" |
24855
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
48 #include "variables.h" |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
49 |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
50 namespace octave |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
51 { |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27071
diff
changeset
|
52 // Use static fields for the best efficiency. |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27071
diff
changeset
|
53 // NOTE: C++0x will allow these two to be merged into one. |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27071
diff
changeset
|
54 static const char *bt_fieldnames[] = |
27470
96d4094585da
eliminate unused backtrace field name "scope"
John W. Eaton <jwe@octave.org>
parents:
27211
diff
changeset
|
55 { "file", "name", "line", "column", nullptr }; |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27071
diff
changeset
|
56 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27071
diff
changeset
|
57 static const octave_fields bt_fields (bt_fieldnames); |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27071
diff
changeset
|
58 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
59 call_stack::call_stack (tree_evaluator& evaluator) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
60 : m_evaluator (evaluator), m_cs (), m_curr_frame (0), |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
61 m_max_stack_depth (1024), m_global_values () |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
62 { |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
63 push (symbol_scope ("top scope")); |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
64 } |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
65 |
27873
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
66 octave_function * call_stack::current_function (bool skip_first) const |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
67 { |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
68 if (m_cs.empty ()) |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
69 error ("current_function: call stack is empty"); |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
70 |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
71 octave_function *fcn = nullptr; |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
72 |
28775
2893db10b8d2
search for current function at current frame, not top of stack
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
73 size_t idx = m_curr_frame; |
27873
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
74 |
28775
2893db10b8d2
search for current function at current frame, not top of stack
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
75 if (idx > 0 && skip_first) |
27873
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
76 --idx; |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
77 |
28775
2893db10b8d2
search for current function at current frame, not top of stack
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
78 while (true) |
27873
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
79 { |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
80 fcn = m_cs[idx]->function (); |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
81 |
28775
2893db10b8d2
search for current function at current frame, not top of stack
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
82 if (fcn || idx == 0) |
27873
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
83 break; |
28775
2893db10b8d2
search for current function at current frame, not top of stack
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
84 |
2893db10b8d2
search for current function at current frame, not top of stack
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
85 --idx; |
27873
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
86 } |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
87 |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
88 return fcn; |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
89 } |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
90 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
91 int call_stack::current_line (void) const |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
92 { |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
93 int retval = -1; |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
94 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
95 if (! m_cs.empty ()) |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
96 { |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28425
diff
changeset
|
97 const std::shared_ptr<stack_frame> elt = m_cs[m_curr_frame]; |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
98 retval = elt->line (); |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
99 } |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
100 |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
101 return retval; |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
102 } |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
103 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
104 int call_stack::current_column (void) const |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
105 { |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
106 int retval = -1; |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
107 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
108 if (! m_cs.empty ()) |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
109 { |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28425
diff
changeset
|
110 const std::shared_ptr<stack_frame> elt = m_cs[m_curr_frame]; |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
111 retval = elt->column (); |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
112 } |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
113 |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
114 return retval; |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
115 } |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
116 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
117 octave_user_code * call_stack::current_user_code (void) const |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
118 { |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
119 // Start at current frame. |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
120 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
121 size_t xframe = find_current_user_frame (); |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
122 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
123 if (xframe > 0) |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
124 { |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28425
diff
changeset
|
125 const std::shared_ptr<stack_frame> elt = m_cs[xframe]; |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
126 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
127 octave_function *f = elt->function (); |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
128 |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
129 if (f && f->is_user_code ()) |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
130 return dynamic_cast<octave_user_code *> (f); |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
131 } |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
132 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
133 return nullptr; |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
134 } |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
135 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
136 int call_stack::current_user_code_line (void) const |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
137 { |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
138 // Start at current frame. |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
139 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
140 size_t xframe = find_current_user_frame (); |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
141 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
142 if (xframe > 0) |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
143 { |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28425
diff
changeset
|
144 const std::shared_ptr<stack_frame> elt = m_cs[xframe]; |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
145 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
146 octave_function *f = elt->function (); |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
147 |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
148 if (f && f->is_user_code ()) |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
149 { |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
150 int line = elt->line (); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
151 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
152 if (line > 0) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
153 return line; |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
154 } |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
155 } |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
156 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
157 return -1; |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
158 } |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
159 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
160 int call_stack::current_user_code_column (void) const |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
161 { |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
162 // Start at current frame. |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
163 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
164 size_t xframe = find_current_user_frame (); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
165 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
166 if (xframe > 0) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
167 { |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28425
diff
changeset
|
168 const std::shared_ptr<stack_frame> elt = m_cs[xframe]; |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
169 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
170 octave_function *f = elt->function (); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
171 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
172 if (f && f->is_user_code ()) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
173 { |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
174 int column = elt->column (); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
175 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
176 if (column > 0) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
177 return column; |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
178 } |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
179 } |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
180 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
181 return -1; |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
182 } |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
183 |
28429
8eb8ba8aff9a
refactor octave_function call method
John W. Eaton <jwe@octave.org>
parents:
28426
diff
changeset
|
184 unwind_protect * call_stack::curr_fcn_unwind_protect_frame (void) |
25399
6ca2c0d76d84
store unwind protect frame for function evaluation in call_stack object
John W. Eaton <jwe@octave.org>
parents:
25343
diff
changeset
|
185 { |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
186 // Start at current frame. |
25399
6ca2c0d76d84
store unwind protect frame for function evaluation in call_stack object
John W. Eaton <jwe@octave.org>
parents:
25343
diff
changeset
|
187 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
188 size_t xframe = find_current_user_frame (); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
189 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
190 if (xframe > 0) |
25399
6ca2c0d76d84
store unwind protect frame for function evaluation in call_stack object
John W. Eaton <jwe@octave.org>
parents:
25343
diff
changeset
|
191 { |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28425
diff
changeset
|
192 const std::shared_ptr<stack_frame> elt = m_cs[xframe]; |
25399
6ca2c0d76d84
store unwind protect frame for function evaluation in call_stack object
John W. Eaton <jwe@octave.org>
parents:
25343
diff
changeset
|
193 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
194 octave_function *f = elt->function (); |
25399
6ca2c0d76d84
store unwind protect frame for function evaluation in call_stack object
John W. Eaton <jwe@octave.org>
parents:
25343
diff
changeset
|
195 |
6ca2c0d76d84
store unwind protect frame for function evaluation in call_stack object
John W. Eaton <jwe@octave.org>
parents:
25343
diff
changeset
|
196 if (f && f->is_user_code ()) |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
197 return elt->unwind_protect_frame (); |
25399
6ca2c0d76d84
store unwind protect frame for function evaluation in call_stack object
John W. Eaton <jwe@octave.org>
parents:
25343
diff
changeset
|
198 } |
6ca2c0d76d84
store unwind protect frame for function evaluation in call_stack object
John W. Eaton <jwe@octave.org>
parents:
25343
diff
changeset
|
199 |
6ca2c0d76d84
store unwind protect frame for function evaluation in call_stack object
John W. Eaton <jwe@octave.org>
parents:
25343
diff
changeset
|
200 return nullptr; |
6ca2c0d76d84
store unwind protect frame for function evaluation in call_stack object
John W. Eaton <jwe@octave.org>
parents:
25343
diff
changeset
|
201 } |
6ca2c0d76d84
store unwind protect frame for function evaluation in call_stack object
John W. Eaton <jwe@octave.org>
parents:
25343
diff
changeset
|
202 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
203 octave_user_code * call_stack::debug_user_code (void) const |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
204 { |
23457
21baad6b35c4
maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents:
23450
diff
changeset
|
205 octave_user_code *retval = nullptr; |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
206 |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
207 // This should never happen... |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
208 if (m_curr_frame == 0) |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
209 return retval; |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
210 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
211 size_t i = m_curr_frame; |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
212 |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
213 while (i != 0) |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
214 { |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28425
diff
changeset
|
215 const std::shared_ptr<stack_frame> elt = m_cs[i--]; |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
216 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
217 octave_function *f = elt->function (); |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
218 |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
219 if (f && f->is_user_code ()) |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
220 { |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
221 retval = dynamic_cast<octave_user_code *> (f); |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
222 break; |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
223 } |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
224 } |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
225 |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
226 return retval; |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
227 } |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
228 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
229 int call_stack::debug_user_code_line (void) const |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
230 { |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
231 int retval = -1; |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
232 |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
233 // This should never happen... |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
234 if (m_curr_frame == 0) |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
235 return retval; |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
236 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
237 size_t i = m_curr_frame; |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
238 |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
239 while (i != 0) |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
240 { |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28425
diff
changeset
|
241 const std::shared_ptr<stack_frame> elt = m_cs[i--]; |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
242 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
243 octave_function *f = elt->function (); |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
244 |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
245 if (f && f->is_user_code ()) |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
246 { |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
247 if (elt->line ()) |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
248 { |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
249 retval = elt->line (); |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
250 break; |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
251 } |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
252 } |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
253 } |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
254 |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
255 return retval; |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
256 } |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
257 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
258 int call_stack::debug_user_code_column (void) const |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
259 { |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
260 int retval = -1; |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
261 |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
262 // This should never happen... |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
263 if (m_curr_frame == 0) |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
264 return retval; |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
265 |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
266 // Start looking with the caller of the calling debug function. |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
267 size_t i = m_curr_frame; |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
268 |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
269 while (i != 0) |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
270 { |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28425
diff
changeset
|
271 const std::shared_ptr<stack_frame> elt = m_cs[i--]; |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
272 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
273 octave_function *f = elt->function (); |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
274 |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
275 if (f && f->is_user_code ()) |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
276 { |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
277 if (elt->column ()) |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
278 { |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
279 retval = elt->column (); |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
280 break; |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
281 } |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
282 } |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
283 } |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
284 |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
285 return retval; |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
286 } |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
287 |
26965
be5c2a1bad93
allow dispatch class to be stored in stack frame (bug #45351)
John W. Eaton <jwe@octave.org>
parents:
26825
diff
changeset
|
288 std::string call_stack::get_dispatch_class (void) const |
be5c2a1bad93
allow dispatch class to be stored in stack frame (bug #45351)
John W. Eaton <jwe@octave.org>
parents:
26825
diff
changeset
|
289 { |
be5c2a1bad93
allow dispatch class to be stored in stack frame (bug #45351)
John W. Eaton <jwe@octave.org>
parents:
26825
diff
changeset
|
290 return m_cs[m_curr_frame]->get_dispatch_class (); |
be5c2a1bad93
allow dispatch class to be stored in stack frame (bug #45351)
John W. Eaton <jwe@octave.org>
parents:
26825
diff
changeset
|
291 } |
be5c2a1bad93
allow dispatch class to be stored in stack frame (bug #45351)
John W. Eaton <jwe@octave.org>
parents:
26825
diff
changeset
|
292 |
be5c2a1bad93
allow dispatch class to be stored in stack frame (bug #45351)
John W. Eaton <jwe@octave.org>
parents:
26825
diff
changeset
|
293 void call_stack::set_dispatch_class (const std::string& class_name) |
be5c2a1bad93
allow dispatch class to be stored in stack frame (bug #45351)
John W. Eaton <jwe@octave.org>
parents:
26825
diff
changeset
|
294 { |
be5c2a1bad93
allow dispatch class to be stored in stack frame (bug #45351)
John W. Eaton <jwe@octave.org>
parents:
26825
diff
changeset
|
295 m_cs[m_curr_frame]->set_dispatch_class (class_name); |
be5c2a1bad93
allow dispatch class to be stored in stack frame (bug #45351)
John W. Eaton <jwe@octave.org>
parents:
26825
diff
changeset
|
296 } |
be5c2a1bad93
allow dispatch class to be stored in stack frame (bug #45351)
John W. Eaton <jwe@octave.org>
parents:
26825
diff
changeset
|
297 |
26795
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
298 bool call_stack::is_class_method_executing (std::string& dispatch_class) const |
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
299 { |
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
300 dispatch_class = ""; |
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
301 |
27873
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
302 octave_function *f = current_function (); |
26795
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
303 |
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
304 bool retval = (f && f->is_class_method ()); |
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
305 |
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
306 if (retval) |
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
307 dispatch_class = f->dispatch_class (); |
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
308 |
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
309 return retval; |
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
310 } |
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
311 |
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
312 bool call_stack::is_class_constructor_executing (std::string& dispatch_class) const |
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
313 { |
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
314 dispatch_class = ""; |
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
315 |
27873
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
316 octave_function *f = current_function (); |
26795
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
317 |
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
318 bool retval = (f && f->is_class_constructor ()); |
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
319 |
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
320 if (retval) |
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
321 dispatch_class = f->dispatch_class (); |
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
322 |
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
323 return retval; |
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
324 } |
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
325 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
326 bool call_stack::all_scripts (void) const |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
327 { |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
328 bool retval = true; |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
329 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
330 auto p = m_cs.cend (); |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
331 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
332 while (p != m_cs.cbegin ()) |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
333 { |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28425
diff
changeset
|
334 const std::shared_ptr<stack_frame> elt = *(--p); |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
335 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
336 octave_function *f = elt->function (); |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
337 |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
338 if (f && ! f->is_user_script ()) |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
339 { |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
340 retval = false; |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
341 break; |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
342 } |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
343 } |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
344 |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
345 return retval; |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
346 } |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
347 |
28796
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
348 void call_stack::get_new_frame_index_and_links |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
349 (size_t& new_frame_idx, std::shared_ptr<stack_frame>& parent_link, |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
350 std::shared_ptr<stack_frame>& static_link) const |
23630
8a47d4735655
avoid memory leak in interpreter
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
351 { |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
352 // FIXME: is there a better way? |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
353 |
28796
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
354 size_t prev_frame_idx = m_curr_frame; |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
355 |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
356 new_frame_idx = m_cs.size (); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
357 |
28796
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
358 // m_max_stack_depth should never be less than zero. |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
359 if (new_frame_idx > static_cast<size_t> (m_max_stack_depth)) |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
360 error ("max_stack_depth exceeded"); |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
361 |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
362 // There can't be any links to previous frames if this is the first |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
363 // frame on the stack. |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
364 |
28796
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
365 if (new_frame_idx == 0) |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
366 return; |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
367 |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
368 parent_link = m_cs[prev_frame_idx]; |
23630
8a47d4735655
avoid memory leak in interpreter
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
369 |
28796
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
370 octave_function *t_fcn = parent_link->function (); |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
371 |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
372 static_link = (t_fcn |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
373 ? (t_fcn->is_user_code () |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
374 ? parent_link : parent_link->static_link ()) |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
375 : parent_link); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
376 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
377 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
378 void call_stack::push (const symbol_scope& scope) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
379 { |
28796
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
380 size_t new_frame_idx; |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
381 std::shared_ptr<stack_frame> parent_link; |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
382 std::shared_ptr<stack_frame> static_link; |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
383 |
28796
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
384 get_new_frame_index_and_links (new_frame_idx, parent_link, static_link); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
385 |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28425
diff
changeset
|
386 std::shared_ptr<stack_frame> |
28796
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
387 new_frame (stack_frame::create (m_evaluator, scope, new_frame_idx, |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
388 parent_link, static_link)); |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
389 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
390 m_cs.push_back (new_frame); |
28796
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
391 |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
392 m_curr_frame = new_frame_idx; |
23630
8a47d4735655
avoid memory leak in interpreter
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
393 } |
8a47d4735655
avoid memory leak in interpreter
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
394 |
28429
8eb8ba8aff9a
refactor octave_function call method
John W. Eaton <jwe@octave.org>
parents:
28426
diff
changeset
|
395 void call_stack::push (octave_user_function *fcn, |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28425
diff
changeset
|
396 const std::shared_ptr<stack_frame>& closure_frames) |
23630
8a47d4735655
avoid memory leak in interpreter
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
397 { |
28796
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
398 size_t new_frame_idx; |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
399 std::shared_ptr<stack_frame> parent_link; |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
400 std::shared_ptr<stack_frame> static_link; |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
401 |
28796
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
402 get_new_frame_index_and_links (new_frame_idx, parent_link, static_link); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
403 |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28425
diff
changeset
|
404 std::shared_ptr<stack_frame> |
28796
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
405 new_frame (stack_frame::create (m_evaluator, fcn, new_frame_idx, |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
406 parent_link, static_link, |
28429
8eb8ba8aff9a
refactor octave_function call method
John W. Eaton <jwe@octave.org>
parents:
28426
diff
changeset
|
407 closure_frames)); |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
408 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
409 m_cs.push_back (new_frame); |
28796
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
410 |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
411 m_curr_frame = new_frame_idx; |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
412 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
413 |
28430
5bfa8e018704
store local init vars for anonymous functions in handle, not function object
John W. Eaton <jwe@octave.org>
parents:
28429
diff
changeset
|
414 void call_stack::push (octave_user_function *fcn, |
5bfa8e018704
store local init vars for anonymous functions in handle, not function object
John W. Eaton <jwe@octave.org>
parents:
28429
diff
changeset
|
415 const stack_frame::local_vars_map& local_vars) |
5bfa8e018704
store local init vars for anonymous functions in handle, not function object
John W. Eaton <jwe@octave.org>
parents:
28429
diff
changeset
|
416 { |
28796
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
417 size_t new_frame_idx; |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
418 std::shared_ptr<stack_frame> parent_link; |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
419 std::shared_ptr<stack_frame> static_link; |
28430
5bfa8e018704
store local init vars for anonymous functions in handle, not function object
John W. Eaton <jwe@octave.org>
parents:
28429
diff
changeset
|
420 |
28796
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
421 get_new_frame_index_and_links (new_frame_idx, parent_link, static_link); |
28430
5bfa8e018704
store local init vars for anonymous functions in handle, not function object
John W. Eaton <jwe@octave.org>
parents:
28429
diff
changeset
|
422 |
5bfa8e018704
store local init vars for anonymous functions in handle, not function object
John W. Eaton <jwe@octave.org>
parents:
28429
diff
changeset
|
423 std::shared_ptr<stack_frame> |
28796
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
424 new_frame (stack_frame::create (m_evaluator, fcn, new_frame_idx, |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
425 parent_link, static_link, local_vars)); |
28430
5bfa8e018704
store local init vars for anonymous functions in handle, not function object
John W. Eaton <jwe@octave.org>
parents:
28429
diff
changeset
|
426 |
5bfa8e018704
store local init vars for anonymous functions in handle, not function object
John W. Eaton <jwe@octave.org>
parents:
28429
diff
changeset
|
427 m_cs.push_back (new_frame); |
28796
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
428 |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
429 m_curr_frame = new_frame_idx; |
28430
5bfa8e018704
store local init vars for anonymous functions in handle, not function object
John W. Eaton <jwe@octave.org>
parents:
28429
diff
changeset
|
430 } |
5bfa8e018704
store local init vars for anonymous functions in handle, not function object
John W. Eaton <jwe@octave.org>
parents:
28429
diff
changeset
|
431 |
28429
8eb8ba8aff9a
refactor octave_function call method
John W. Eaton <jwe@octave.org>
parents:
28426
diff
changeset
|
432 void call_stack::push (octave_user_script *script) |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
433 { |
28796
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
434 size_t new_frame_idx; |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
435 std::shared_ptr<stack_frame> parent_link; |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
436 std::shared_ptr<stack_frame> static_link; |
24855
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
437 |
28796
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
438 get_new_frame_index_and_links (new_frame_idx, parent_link, static_link); |
23630
8a47d4735655
avoid memory leak in interpreter
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
439 |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28425
diff
changeset
|
440 std::shared_ptr<stack_frame> |
28796
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
441 new_frame (stack_frame::create (m_evaluator, script, new_frame_idx, |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
442 parent_link, static_link)); |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
443 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
444 m_cs.push_back (new_frame); |
28796
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
445 |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
446 m_curr_frame = new_frame_idx; |
23630
8a47d4735655
avoid memory leak in interpreter
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
447 } |
8a47d4735655
avoid memory leak in interpreter
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
448 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
449 void call_stack::push (octave_function *fcn) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
450 { |
28796
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
451 size_t new_frame_idx; |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
452 std::shared_ptr<stack_frame> parent_link; |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
453 std::shared_ptr<stack_frame> static_link; |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
454 |
28796
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
455 get_new_frame_index_and_links (new_frame_idx, parent_link, static_link); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
456 |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28425
diff
changeset
|
457 std::shared_ptr<stack_frame> |
28796
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
458 new_frame (stack_frame::create (m_evaluator, fcn, new_frame_idx, |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
459 parent_link, static_link)); |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
460 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
461 m_cs.push_back (new_frame); |
28796
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
462 |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
463 m_curr_frame = new_frame_idx; |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
464 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
465 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
466 bool call_stack::goto_frame (size_t n, bool verbose) |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
467 { |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
468 bool retval = false; |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
469 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
470 if (n < m_cs.size ()) |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
471 { |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
472 retval = true; |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
473 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
474 m_curr_frame = n; |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
475 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
476 if (verbose) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
477 { |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28425
diff
changeset
|
478 const std::shared_ptr<stack_frame> elt = m_cs[n]; |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
479 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
480 elt->display_stopped_in_message (octave_stdout); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
481 } |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
482 } |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
483 |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
484 return retval; |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
485 } |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
486 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
487 size_t call_stack::find_current_user_frame (void) const |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
488 { |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
489 size_t user_frame = m_curr_frame; |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
490 |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28425
diff
changeset
|
491 std::shared_ptr<stack_frame> frm = m_cs[user_frame]; |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
492 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
493 if (! (frm->is_user_fcn_frame () || frm->is_user_script_frame () |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
494 || frm->is_scope_frame ())) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
495 { |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
496 frm = frm->static_link (); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
497 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
498 user_frame = frm->index (); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
499 } |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
500 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
501 return user_frame; |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
502 } |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
503 |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28425
diff
changeset
|
504 std::shared_ptr<stack_frame> call_stack::current_user_frame (void) const |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
505 { |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
506 size_t frame = find_current_user_frame (); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
507 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
508 return m_cs[frame]; |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
509 } |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
510 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
511 // Go to the Nth frame (up if N is negative or down if positive) in |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
512 // the call stack that corresponds to a script, function, or scope |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
513 // beginning with the frame indexed by START. |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
514 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
515 size_t call_stack::dbupdown (size_t start, int n, bool verbose) |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
516 { |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
517 if (start >= m_cs.size ()) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
518 error ("invalid stack frame"); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
519 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
520 // Can't go up from here. |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
521 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
522 if (start == 0 && n < 0) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
523 { |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
524 if (verbose) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
525 m_cs[start]->display_stopped_in_message (octave_stdout); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
526 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
527 return start; |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
528 } |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
529 |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28425
diff
changeset
|
530 std::shared_ptr<stack_frame> frm = m_cs[start]; |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
531 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
532 if (! (frm && (frm->is_user_fcn_frame () |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
533 || frm->is_user_script_frame () |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
534 || frm->is_scope_frame ()))) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
535 error ("call_stack::dbupdown: invalid initial frame in call stack!"); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
536 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
537 // Use index into the call stack to begin the search. At this point |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
538 // we iterate up or down using indexing instead of static links |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
539 // because ... FIXME: it's a bit complicated, but deserves |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
540 // explanation. May be easiest with some pictures of the call stack |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
541 // for an example or two. |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
542 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
543 size_t xframe = frm->index (); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
544 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
545 if (n == 0) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
546 { |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
547 if (verbose) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
548 frm->display_stopped_in_message (octave_stdout); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
549 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
550 return xframe; |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
551 } |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
552 |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
553 int incr = 0; |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
554 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
555 if (n < 0) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
556 { |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
557 incr = -1; |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
558 n = -n; |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
559 } |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
560 else if (n > 0) |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
561 incr = 1; |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
562 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
563 size_t last_good_frame = 0; |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
564 |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
565 while (true) |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
566 { |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
567 frm = m_cs[xframe]; |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
568 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
569 if (frm->is_user_fcn_frame () || frm->is_user_script_frame () |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
570 || frm->is_scope_frame ()) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
571 { |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
572 last_good_frame = xframe; |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
573 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
574 if (n == 0) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
575 break; |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
576 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
577 n--; |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
578 } |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
579 |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
580 xframe += incr; |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
581 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
582 if (xframe == 0) |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
583 { |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
584 last_good_frame = 0; |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
585 break; |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
586 } |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
587 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
588 if (xframe == m_cs.size ()) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
589 break; |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
590 } |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
591 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
592 if (verbose) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
593 m_cs[last_good_frame]->display_stopped_in_message (octave_stdout); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
594 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
595 return last_good_frame; |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
596 } |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
597 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
598 // Like dbupdown above but find the starting frame automatically from |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
599 // the current frame. If the current frame is already a user |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
600 // function, script, or scope frame, use that. Otherwise, follow |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
601 // the static link for the current frame. If that is not a user |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
602 // function, script or scope frame then there is an error in the |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
603 // implementation. |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
604 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
605 size_t call_stack::dbupdown (int n, bool verbose) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
606 { |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
607 size_t start = find_current_user_frame (); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
608 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
609 return dbupdown (start, n, verbose); |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
610 } |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
611 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
612 // May be used to temporarily change the value ov m_curr_frame inside |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
613 // a function like evalin. If used in a function like dbup, the new |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
614 // value of m_curr_frame would be wiped out when dbup returns and the |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
615 // stack frame for dbup is popped. |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
616 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
617 void call_stack::goto_caller_frame (void) |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
618 { |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
619 size_t start = find_current_user_frame (); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
620 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
621 // FIXME: is this supposed to be an error? |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
622 if (start == 0) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
623 error ("already at top level"); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
624 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
625 m_curr_frame = dbupdown (start, -1, false); |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
626 } |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
627 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
628 void call_stack::goto_base_frame (void) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
629 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
630 if (m_curr_frame > 0) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
631 m_curr_frame = 0; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
632 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
633 |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28425
diff
changeset
|
634 std::list<std::shared_ptr<stack_frame>> |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
635 call_stack::backtrace_frames (octave_idx_type& curr_user_frame) const |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
636 { |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28425
diff
changeset
|
637 std::list<std::shared_ptr<stack_frame>> frames; |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
638 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
639 // curr_frame is the index to the current frame in the overall call |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
640 // stack, which includes any compiled function frames and scope |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
641 // frames. The curr_user_frame value we set is the index into the |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
642 // subset of frames returned in the octave_map object. |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
643 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
644 size_t curr_frame = find_current_user_frame (); |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
645 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
646 // Don't include top-level stack frame in the list. |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
647 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
648 for (size_t n = m_cs.size () - 1; n > 0; n--) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
649 { |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28425
diff
changeset
|
650 std::shared_ptr<stack_frame> frm = m_cs[n]; |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
651 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
652 if (frm->is_user_script_frame () || frm->is_user_fcn_frame () |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
653 || frm->is_scope_frame ()) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
654 { |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
655 if (frm->index () == curr_frame) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
656 curr_user_frame = frames.size (); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
657 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
658 frames.push_back (frm); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
659 } |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
660 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
661 if (n == 0) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
662 break; |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
663 } |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
664 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
665 return frames; |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
666 } |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
667 |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28425
diff
changeset
|
668 std::list<std::shared_ptr<stack_frame>> |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
669 call_stack::backtrace_frames (void) const |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
670 { |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
671 octave_idx_type curr_user_frame = -1; |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
672 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
673 return backtrace_frames (curr_user_frame); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
674 } |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
675 |
27471 | 676 std::list<frame_info> |
677 call_stack::backtrace_info (octave_idx_type& curr_user_frame, | |
678 bool print_subfn) const | |
679 { | |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28425
diff
changeset
|
680 std::list<std::shared_ptr<stack_frame>> frames |
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28425
diff
changeset
|
681 = backtrace_frames (curr_user_frame); |
27471 | 682 |
683 std::list<frame_info> retval; | |
684 | |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28425
diff
changeset
|
685 for (const auto& frm : frames) |
27471 | 686 { |
687 if (frm->is_user_script_frame () || frm->is_user_fcn_frame () | |
688 || frm->is_scope_frame ()) | |
689 { | |
690 retval.push_back (frame_info (frm->fcn_file_name (), | |
691 frm->fcn_name (print_subfn), | |
692 frm->line (), frm->column ())); | |
693 } | |
694 } | |
695 | |
696 return retval; | |
697 } | |
698 | |
699 std::list<frame_info> call_stack::backtrace_info (void) const | |
700 { | |
701 octave_idx_type curr_user_frame = -1; | |
702 | |
703 return backtrace_info (curr_user_frame, true); | |
704 } | |
705 | |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
706 octave_map call_stack::backtrace (octave_idx_type& curr_user_frame, |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
707 bool print_subfn) const |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
708 { |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28425
diff
changeset
|
709 std::list<std::shared_ptr<stack_frame>> frames |
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28425
diff
changeset
|
710 = backtrace_frames (curr_user_frame); |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
711 |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
712 size_t nframes = frames.size (); |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
713 |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
714 octave_map retval (dim_vector (nframes, 1), bt_fields); |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
715 |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
716 Cell& file = retval.contents (0); |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
717 Cell& name = retval.contents (1); |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
718 Cell& line = retval.contents (2); |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
719 Cell& column = retval.contents (3); |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
720 |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
721 octave_idx_type k = 0; |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
722 |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28425
diff
changeset
|
723 for (const auto& frm : frames) |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
724 { |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
725 if (frm->is_user_script_frame () || frm->is_user_fcn_frame () |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
726 || frm->is_scope_frame ()) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
727 { |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
728 file(k) = frm->fcn_file_name (); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
729 name(k) = frm->fcn_name (print_subfn); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
730 line(k) = frm->line (); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
731 column(k) = frm->column (); |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
732 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
733 k++; |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
734 } |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
735 } |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
736 |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
737 return retval; |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
738 } |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
739 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
740 octave_map call_stack::backtrace (void) const |
23630
8a47d4735655
avoid memory leak in interpreter
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
741 { |
8a47d4735655
avoid memory leak in interpreter
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
742 octave_idx_type curr_user_frame = -1; |
8a47d4735655
avoid memory leak in interpreter
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
743 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
744 return backtrace (curr_user_frame, true); |
23630
8a47d4735655
avoid memory leak in interpreter
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
745 } |
8a47d4735655
avoid memory leak in interpreter
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
746 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
747 octave_map call_stack::empty_backtrace (void) const |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
748 { |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
749 return octave_map (dim_vector (0, 1), bt_fields); |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
750 } |
23630
8a47d4735655
avoid memory leak in interpreter
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
751 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
752 void call_stack::pop (void) |
23630
8a47d4735655
avoid memory leak in interpreter
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
753 { |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
754 // Never pop top scope. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
755 // FIXME: is it possible for this case to happen? |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
756 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
757 if (m_cs.size () > 1) |
23630
8a47d4735655
avoid memory leak in interpreter
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
758 { |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28425
diff
changeset
|
759 std::shared_ptr<stack_frame> elt = m_cs.back (); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
760 |
28793
c5953e65c6aa
track direct caller in stack frames
John W. Eaton <jwe@octave.org>
parents:
28775
diff
changeset
|
761 std::shared_ptr<stack_frame> caller = elt->parent_link (); |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
762 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
763 m_curr_frame = caller->index (); |
23630
8a47d4735655
avoid memory leak in interpreter
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
764 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
765 m_cs.pop_back (); |
23630
8a47d4735655
avoid memory leak in interpreter
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
766 } |
8a47d4735655
avoid memory leak in interpreter
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
767 } |
24855
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
768 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
769 void call_stack::clear (void) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
770 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
771 while (! m_cs.empty ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
772 pop (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
773 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
774 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
775 symbol_info_list call_stack::all_variables (void) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
776 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
777 return m_cs[m_curr_frame]->all_variables (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
778 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
779 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
780 std::list<std::string> call_stack::global_variable_names (void) const |
26092
661dfb062485
use symbol_info_list to gather data for save function
John W. Eaton <jwe@octave.org>
parents:
26089
diff
changeset
|
781 { |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
782 std::list<std::string> retval; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
783 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
784 for (const auto& nm_ov : m_global_values) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
785 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
786 if (nm_ov.second.is_defined ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
787 retval.push_back (nm_ov.first); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
788 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
789 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
790 retval.sort (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
791 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
792 return retval; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
793 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
794 |
27594
e091e09d26f0
restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
795 std::list<std::string> call_stack::top_level_variable_names (void) const |
e091e09d26f0
restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
796 { |
e091e09d26f0
restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
797 return m_cs[0]->variable_names (); |
e091e09d26f0
restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
798 } |
e091e09d26f0
restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
799 |
e091e09d26f0
restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
800 std::list<std::string> call_stack::variable_names (void) const |
e091e09d26f0
restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
801 { |
e091e09d26f0
restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
802 return m_cs[m_curr_frame]->variable_names (); |
e091e09d26f0
restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
803 } |
e091e09d26f0
restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
804 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
805 void call_stack::clear_global_variable (const std::string& name) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
806 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
807 auto p = m_global_values.find (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
808 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
809 if (p != m_global_values.end ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
810 p->second = octave_value (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
811 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
812 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
813 void call_stack::clear_global_variable_pattern (const std::string& pattern) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
814 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
815 glob_match pat (pattern); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
816 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
817 for (auto& nm_ov : m_global_values) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
818 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
819 if (pat.match (nm_ov.first)) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
820 nm_ov.second = octave_value (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
821 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
822 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
823 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
824 void call_stack::clear_global_variable_regexp (const std::string& pattern) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
825 { |
28857
43ad651cf5a0
eliminate unnecessary uses of octave:: namespace qualifier
John W. Eaton <jwe@octave.org>
parents:
28851
diff
changeset
|
826 regexp pat (pattern); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
827 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
828 for (auto& nm_ov : m_global_values) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
829 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
830 if (pat.is_match (nm_ov.first)) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
831 nm_ov.second = octave_value (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
832 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
833 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
834 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
835 void call_stack::clear_global_variables (void) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
836 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
837 for (auto& nm_ov : m_global_values) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
838 nm_ov.second = octave_value (); |
26092
661dfb062485
use symbol_info_list to gather data for save function
John W. Eaton <jwe@octave.org>
parents:
26089
diff
changeset
|
839 } |
661dfb062485
use symbol_info_list to gather data for save function
John W. Eaton <jwe@octave.org>
parents:
26089
diff
changeset
|
840 |
26093
6a03af2c4c9e
use symbol_info_list to gather data for saving workspace on crash
John W. Eaton <jwe@octave.org>
parents:
26092
diff
changeset
|
841 symbol_info_list |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
842 call_stack::glob_symbol_info (const std::string& pattern) const |
26093
6a03af2c4c9e
use symbol_info_list to gather data for saving workspace on crash
John W. Eaton <jwe@octave.org>
parents:
26092
diff
changeset
|
843 { |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
844 return m_cs[m_curr_frame]->glob_symbol_info (pattern); |
26093
6a03af2c4c9e
use symbol_info_list to gather data for saving workspace on crash
John W. Eaton <jwe@octave.org>
parents:
26092
diff
changeset
|
845 } |
6a03af2c4c9e
use symbol_info_list to gather data for saving workspace on crash
John W. Eaton <jwe@octave.org>
parents:
26092
diff
changeset
|
846 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
847 symbol_info_list |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
848 call_stack::regexp_symbol_info (const std::string& pattern) const |
26093
6a03af2c4c9e
use symbol_info_list to gather data for saving workspace on crash
John W. Eaton <jwe@octave.org>
parents:
26092
diff
changeset
|
849 { |
28326
991dc4d31949
fix apparent copy/paste error in call stack function
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
850 return m_cs[m_curr_frame]->regexp_symbol_info (pattern); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
851 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
852 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
853 symbol_info_list call_stack::get_symbol_info (void) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
854 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
855 return m_cs[m_curr_frame]->get_symbol_info (); |
26093
6a03af2c4c9e
use symbol_info_list to gather data for saving workspace on crash
John W. Eaton <jwe@octave.org>
parents:
26092
diff
changeset
|
856 } |
6a03af2c4c9e
use symbol_info_list to gather data for saving workspace on crash
John W. Eaton <jwe@octave.org>
parents:
26092
diff
changeset
|
857 |
6a03af2c4c9e
use symbol_info_list to gather data for saving workspace on crash
John W. Eaton <jwe@octave.org>
parents:
26092
diff
changeset
|
858 symbol_info_list call_stack::top_scope_symbol_info (void) const |
6a03af2c4c9e
use symbol_info_list to gather data for saving workspace on crash
John W. Eaton <jwe@octave.org>
parents:
26092
diff
changeset
|
859 { |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
860 return m_cs[0]->get_symbol_info (); |
26093
6a03af2c4c9e
use symbol_info_list to gather data for saving workspace on crash
John W. Eaton <jwe@octave.org>
parents:
26092
diff
changeset
|
861 } |
6a03af2c4c9e
use symbol_info_list to gather data for saving workspace on crash
John W. Eaton <jwe@octave.org>
parents:
26092
diff
changeset
|
862 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
863 octave_value call_stack::max_stack_depth (const octave_value_list& args, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
864 int nargout) |
24855
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
865 { |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
866 return set_internal_variable (m_max_stack_depth, args, nargout, |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
867 "max_stack_depth", 0); |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
868 } |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
869 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
870 void call_stack::make_persistent (const symbol_record& sym) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
871 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
872 m_cs[m_curr_frame]->make_persistent (sym); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
873 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
874 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
875 void call_stack::make_global (const symbol_record& sym) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
876 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
877 m_cs[m_curr_frame]->make_global (sym); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
878 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
879 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
880 octave_value call_stack::global_varval (const std::string& name) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
881 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
882 auto p = m_global_values.find (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
883 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
884 return p == m_global_values.end () ? octave_value () : p->second; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
885 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
886 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
887 octave_value& call_stack::global_varref (const std::string& name) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
888 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
889 return m_global_values[name]; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
890 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
891 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
892 octave_value call_stack::get_top_level_value (const std::string& name) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
893 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
894 return m_cs[0]->varval (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
895 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
896 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
897 void call_stack::set_top_level_value (const std::string& name, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
898 const octave_value& value) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
899 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
900 m_cs[0]->assign (name, value); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
901 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
902 |
27005
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
903 octave_value call_stack::do_who (int argc, const string_vector& argv, |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
904 bool return_list, bool verbose) |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
905 { |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
906 octave_value retval; |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
907 |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
908 std::string my_name = argv[0]; |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
909 |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
910 std::string file_name; |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
911 |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
912 bool from_file = false; |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
913 bool global_only = false; |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
914 bool have_regexp = false; |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
915 |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
916 int i = 1; |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
917 while (i < argc) |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
918 { |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
919 if (argv[i] == "-file") |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
920 { |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
921 if (from_file) |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
922 error ("%s: -file option may only be specified once", |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
923 my_name.c_str ()); |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
924 |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
925 from_file = true; |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
926 |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
927 if (i == argc - 1) |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
928 error ("%s: -file argument must be followed by a filename", |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
929 my_name.c_str ()); |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
930 |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
931 file_name = argv[++i]; |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
932 } |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
933 else if (argv[i] == "-regexp") |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
934 { |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
935 have_regexp = true; |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
936 } |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
937 else if (argv[i] == "global") |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
938 global_only = true; |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
939 else if (argv[i][0] == '-') |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
940 warning ("%s: unrecognized option '%s'", my_name.c_str (), |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
941 argv[i].c_str ()); |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
942 else |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
943 break; |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
944 |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
945 i++; |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
946 } |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
947 |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
948 int npatterns = argc - i; |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
949 string_vector patterns; |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
950 if (npatterns > 0) |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
951 { |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
952 patterns.resize (npatterns); |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
953 for (int j = 0; j < npatterns; j++) |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
954 patterns[j] = argv[i+j]; |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
955 } |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
956 else |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
957 { |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
958 patterns.resize (1); |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
959 patterns[0] = "*"; |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
960 } |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
961 |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
962 if (from_file) |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
963 { |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
964 // FIXME: This is an inefficient manner to implement this as the |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
965 // variables are loaded in to a temporary context and then treated. |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
966 // It would be better to refactor symbol_info_list to not store the |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
967 // symbol records and then use it in load-save.cc (do_load) to |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
968 // implement this option there so that the variables are never |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
969 // stored at all. |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
970 |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
971 // Set up temporary scope. |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
972 |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
973 symbol_scope tmp_scope ("$dummy_scope$"); |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
974 |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
975 push (tmp_scope); |
28825
473ee93cf1ea
Replace unwind_protect with more efficient constructs (bug #59192).
Rik <rik@octave.org>
parents:
28796
diff
changeset
|
976 |
28851
1ac5a76ae91d
use [=] capture default specification where possible
John W. Eaton <jwe@octave.org>
parents:
28850
diff
changeset
|
977 unwind_action restore_scope ([=] (void) { pop (); }); |
27005
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
978 |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
979 feval ("load", octave_value (file_name), 0); |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
980 |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
981 std::string newmsg = "Variables in the file " + file_name + ":\n\n"; |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
982 |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
983 if (global_only) |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
984 return do_global_who_two (patterns, have_regexp, return_list, |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
985 verbose, newmsg); |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
986 else |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
987 return do_who_two (patterns, have_regexp, return_list, verbose, |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
988 newmsg); |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
989 } |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
990 else |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
991 { |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
992 if (global_only) |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
993 return do_global_who_two (patterns, have_regexp, return_list, |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
994 verbose); |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
995 else |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
996 return do_who_two (patterns, have_regexp, return_list, verbose); |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
997 } |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
998 } |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
999 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1000 octave_value call_stack::do_who_two (const string_vector& patterns, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1001 bool have_regexp, bool return_list, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1002 bool verbose, const std::string& msg) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1003 { |
28425
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28328
diff
changeset
|
1004 return m_cs[m_curr_frame]->who (patterns, have_regexp, return_list, |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28328
diff
changeset
|
1005 verbose, m_evaluator.whos_line_format (), |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28328
diff
changeset
|
1006 msg); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1007 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1008 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1009 octave_value call_stack::do_global_who_two (const string_vector& patterns, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1010 bool have_regexp, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1011 bool return_list, bool verbose, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1012 const std::string& msg) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1013 { |
27102
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27101
diff
changeset
|
1014 symbol_info_list symbol_stats; |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1015 std::list<std::string> symbol_names; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1016 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1017 octave_idx_type npatterns = patterns.numel (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1018 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1019 for (octave_idx_type j = 0; j < npatterns; j++) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1020 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1021 std::string pattern = patterns[j]; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1022 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1023 std::list<std::string> tmp; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1024 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1025 if (have_regexp) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1026 { |
28857
43ad651cf5a0
eliminate unnecessary uses of octave:: namespace qualifier
John W. Eaton <jwe@octave.org>
parents:
28851
diff
changeset
|
1027 regexp pat (pattern); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1028 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1029 for (auto& nm_ov : m_global_values) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1030 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1031 if (pat.is_match (nm_ov.first)) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1032 tmp.push_back (nm_ov.first); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1033 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1034 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1035 else |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1036 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1037 glob_match pat (pattern); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1038 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1039 for (auto& nm_ov : m_global_values) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1040 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1041 if (pat.match (nm_ov.first)) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1042 tmp.push_back (nm_ov.first); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1043 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1044 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1045 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1046 for (const auto& nm : tmp) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1047 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1048 octave_value value = m_global_values[nm]; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1049 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1050 if (value.is_defined ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1051 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1052 if (verbose) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1053 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1054 bool is_formal = false; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1055 bool is_global = true; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1056 bool is_persistent = false; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1057 |
27932
b018f553fd85
maint: Use Octave coding conventions in libinterp/
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
1058 symbol_info syminf (nm, value, is_formal, is_global, |
b018f553fd85
maint: Use Octave coding conventions in libinterp/
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
1059 is_persistent); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1060 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1061 symbol_stats.append (syminf); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1062 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1063 else |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1064 symbol_names.push_back (nm); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1065 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1066 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1067 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1068 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1069 if (return_list) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1070 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1071 if (verbose) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1072 { |
27873
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
1073 std::string caller_fcn_name; |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
1074 octave_function *caller_fcn = caller_function (); |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
1075 if (caller_fcn) |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
1076 caller_fcn_name = caller_fcn->name (); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1077 |
27873
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
1078 return symbol_stats.map_value (caller_fcn_name, 1); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1079 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1080 else |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1081 return Cell (string_vector (symbol_names)); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1082 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1083 else if (! (symbol_stats.empty () && symbol_names.empty ())) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1084 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1085 if (msg.empty ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1086 octave_stdout << "Global variables:\n\n"; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1087 else |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1088 octave_stdout << msg; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1089 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1090 if (verbose) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1091 symbol_stats.display (octave_stdout, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1092 m_evaluator.whos_line_format ()); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1093 else |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1094 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1095 string_vector names (symbol_names); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1096 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1097 names.list_in_columns (octave_stdout); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1098 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1099 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1100 octave_stdout << "\n"; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1101 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1102 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1103 return octave_value (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1104 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1105 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1106 void call_stack::clear_current_frame_values (void) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1107 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1108 m_cs[m_curr_frame]->clear_values (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1109 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1110 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1111 void call_stack::display (void) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1112 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1113 std::ostream& os = octave_stdout; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1114 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1115 size_t nframes = size (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1116 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1117 for (size_t i = 0; i < nframes; i++) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1118 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1119 m_cs[i]->display (false); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1120 if (i < nframes - 1) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1121 os << std::endl; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1122 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1123 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1124 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1125 void call_stack::set_auto_fcn_var (stack_frame::auto_var_type avt, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1126 const octave_value& val) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1127 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1128 m_cs[m_curr_frame]->set_auto_fcn_var (avt, val); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1129 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1130 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1131 octave_value call_stack::get_auto_fcn_var (stack_frame::auto_var_type avt) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1132 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1133 return m_cs[m_curr_frame]->get_auto_fcn_var (avt); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1134 } |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1135 } |
24855
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1136 |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1137 DEFMETHOD (max_stack_depth, interp, args, nargout, |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1138 doc: /* -*- texinfo -*- |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1139 @deftypefn {} {@var{val} =} max_stack_depth () |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1140 @deftypefnx {} {@var{old_val} =} max_stack_depth (@var{new_val}) |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1141 @deftypefnx {} {} max_stack_depth (@var{new_val}, "local") |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1142 Query or set the internal limit on the number of times a function may |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1143 be called recursively. |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1144 |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1145 If the limit is exceeded, an error message is printed and control returns to |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1146 the top level. |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1147 |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1148 When called from inside a function with the @qcode{"local"} option, the |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1149 variable is changed locally for the function and any subroutines it calls. |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1150 The original variable value is restored when exiting the function. |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1151 |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1152 @seealso{max_recursion_depth} |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1153 @end deftypefn */) |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1154 { |
27211
8c27802a76c4
store reference to evaluator instead of call stack in stack frame
John W. Eaton <jwe@octave.org>
parents:
27102
diff
changeset
|
1155 octave::tree_evaluator& tw = interp.get_evaluator (); |
24855
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1156 |
27211
8c27802a76c4
store reference to evaluator instead of call stack in stack frame
John W. Eaton <jwe@octave.org>
parents:
27102
diff
changeset
|
1157 return tw.max_stack_depth (args, nargout); |
24855
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1158 } |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1159 |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1160 /* |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1161 %!test |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1162 %! orig_val = max_stack_depth (); |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1163 %! old_val = max_stack_depth (2*orig_val); |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1164 %! assert (orig_val, old_val); |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1165 %! assert (max_stack_depth (), 2*orig_val); |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1166 %! max_stack_depth (orig_val); |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1167 %! assert (max_stack_depth (), orig_val); |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1168 |
28930
2883b3d08b7e
maint: Remove unnecessary parentheses bracketing %!error BIST tests.
Rik <rik@octave.org>
parents:
28857
diff
changeset
|
1169 %!error max_stack_depth (1, 2) |
24855
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1170 */ |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1171 |
26089
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1172 DEFMETHOD (who, interp, args, nargout, |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1173 doc: /* -*- texinfo -*- |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1174 @deftypefn {} {} who |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1175 @deftypefnx {} {} who pattern @dots{} |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1176 @deftypefnx {} {} who option pattern @dots{} |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1177 @deftypefnx {} {C =} who ("pattern", @dots{}) |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1178 List currently defined variables matching the given patterns. |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1179 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1180 Valid pattern syntax is the same as described for the @code{clear} command. |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1181 If no patterns are supplied, all variables are listed. |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1182 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1183 By default, only variables visible in the local scope are displayed. |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1184 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1185 The following are valid options, but may not be combined. |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1186 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1187 @table @code |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1188 @item global |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1189 List variables in the global scope rather than the current scope. |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1190 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1191 @item -regexp |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1192 The patterns are considered to be regular expressions when matching the |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1193 variables to display. The same pattern syntax accepted by the @code{regexp} |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1194 function is used. |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1195 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1196 @item -file |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1197 The next argument is treated as a filename. All variables found within the |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1198 specified file are listed. No patterns are accepted when reading variables |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1199 from a file. |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1200 @end table |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1201 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1202 If called as a function, return a cell array of defined variable names |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1203 matching the given patterns. |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1204 @seealso{whos, isglobal, isvarname, exist, regexp} |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1205 @end deftypefn */) |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1206 { |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1207 int argc = args.length () + 1; |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1208 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1209 string_vector argv = args.make_argv ("who"); |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1210 |
27005
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
1211 octave::tree_evaluator& tw = interp.get_evaluator (); |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
1212 |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
1213 return tw.do_who (argc, argv, nargout == 1); |
26089
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1214 } |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1215 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1216 /* |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1217 %!test |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1218 %! avar = magic (4); |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1219 %! ftmp = [tempname() ".mat"]; |
26698
63b5a17ba30f
Use save_default_options() to make BIST test suite robust against user configurations.
Rik <rik@octave.org>
parents:
26661
diff
changeset
|
1220 %! save_default_options ("-binary", "local"); |
26089
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1221 %! unwind_protect |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1222 %! save (ftmp, "avar"); |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1223 %! vars = whos ("-file", ftmp); |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1224 %! assert (numel (vars), 1); |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1225 %! assert (isstruct (vars)); |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1226 %! assert (vars.name, "avar"); |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1227 %! assert (vars.size, [4, 4]); |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1228 %! assert (vars.class, "double"); |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1229 %! assert (vars.bytes, 128); |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1230 %! unwind_protect_cleanup |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1231 %! unlink (ftmp); |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1232 %! end_unwind_protect |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1233 */ |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1234 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1235 DEFMETHOD (whos, interp, args, nargout, |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1236 doc: /* -*- texinfo -*- |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1237 @deftypefn {} {} whos |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1238 @deftypefnx {} {} whos pattern @dots{} |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1239 @deftypefnx {} {} whos option pattern @dots{} |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1240 @deftypefnx {} {S =} whos ("pattern", @dots{}) |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1241 Provide detailed information on currently defined variables matching the |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1242 given patterns. |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1243 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1244 Options and pattern syntax are the same as for the @code{who} command. |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1245 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1246 Extended information about each variable is summarized in a table with the |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1247 following default entries. |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1248 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1249 @table @asis |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1250 @item Attr |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1251 Attributes of the listed variable. Possible attributes are: |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1252 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1253 @table @asis |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1254 @item blank |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1255 Variable in local scope |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1256 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1257 @item @code{c} |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1258 Variable of complex type. |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1259 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1260 @item @code{f} |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1261 Formal parameter (function argument). |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1262 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1263 @item @code{g} |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1264 Variable with global scope. |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1265 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1266 @item @code{p} |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1267 Persistent variable. |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1268 @end table |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1269 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1270 @item Name |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1271 The name of the variable. |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1272 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1273 @item Size |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1274 The logical size of the variable. A scalar is 1x1, a vector is |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1275 @nospell{1xN} or @nospell{Nx1}, a 2-D matrix is @nospell{MxN}. |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1276 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1277 @item Bytes |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1278 The amount of memory currently used to store the variable. |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1279 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1280 @item Class |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1281 The class of the variable. Examples include double, single, char, uint16, |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1282 cell, and struct. |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1283 @end table |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1284 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1285 The table can be customized to display more or less information through |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1286 the function @code{whos_line_format}. |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1287 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1288 If @code{whos} is called as a function, return a struct array of defined |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1289 variable names matching the given patterns. Fields in the structure |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1290 describing each variable are: name, size, bytes, class, global, sparse, |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1291 complex, nesting, persistent. |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1292 @seealso{who, whos_line_format} |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1293 @end deftypefn */) |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1294 { |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1295 int argc = args.length () + 1; |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1296 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1297 string_vector argv = args.make_argv ("whos"); |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1298 |
27005
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
1299 octave::tree_evaluator& tw = interp.get_evaluator (); |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
1300 |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
1301 return tw.do_who (argc, argv, nargout == 1, true); |
26089
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1302 } |