annotate libinterp/corefcn/toplev.h @ 18440:96a495813047

Don't put parent function in subfunction stack structure name (bug #41506). * debug.cc (do_dbstack): When returning a structure, call octave_call_stack::backtrace with print_subfn set to false. * toplev.h (octave_call_stack::backtrace): Create new 2 argument function signature which calls do_backtrace with print_subfn set to true. Create new 3 argument function signature which passes print_subfn argument through to do_backtrace. * toplev.cc (octave_call_stack::do_backtrace): Change function to accept 3rd argument, print_subfn, which decides whether the parent function should be printed in the name field of the backtrace.
author Rik <rik@octave.org>
date Sat, 08 Feb 2014 14:44:21 -0800
parents bc139ccccef9
children 972abb60c30f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
1 /*
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
2
17744
d63878346099 maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents: 17084
diff changeset
3 Copyright (C) 1993-2013 John W. Eaton
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
4
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
5 This file is part of Octave.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
6
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5744
diff changeset
9 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5744
diff changeset
10 option) any later version.
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
11
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
15 for more details.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
16
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5744
diff changeset
18 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5744
diff changeset
19 <http://www.gnu.org/licenses/>.
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
20
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
21 */
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
22
1670
6708c53892c1 [project @ 1995-12-27 04:33:00 by jwe]
jwe
parents: 1613
diff changeset
23 #if !defined (octave_toplev_h)
6708c53892c1 [project @ 1995-12-27 04:33:00 by jwe]
jwe
parents: 1613
diff changeset
24 #define octave_toplev_h 1
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
25
1355
94697d007075 [project @ 1995-09-05 20:04:15 by jwe]
jwe
parents: 1315
diff changeset
26 #include <cstdio>
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
27
7552
6070c3bd69c4 Arbitrary call stack access for external debuggers changeset
ryanru@PrinceHumperdinck
parents: 7409
diff changeset
28 #include <deque>
3503
d14c483b3c12 [project @ 2000-02-01 04:06:07 by jwe]
jwe
parents: 3216
diff changeset
29 #include <string>
d14c483b3c12 [project @ 2000-02-01 04:06:07 by jwe]
jwe
parents: 3216
diff changeset
30
2086
bfb775fb6fe8 [project @ 1996-04-25 05:55:19 by jwe]
jwe
parents: 2077
diff changeset
31 class octave_value;
2796
74bc1ede3c3d [project @ 1997-03-07 06:55:47 by jwe]
jwe
parents: 2440
diff changeset
32 class octave_value_list;
5743
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
33 class octave_function;
5744
1c36a2e82266 [project @ 2006-04-06 19:38:34 by jwe]
jwe
parents: 5743
diff changeset
34 class octave_user_script;
7734
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
35 class tree_statement;
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 574
diff changeset
36 class tree_statement_list;
1572
0d9e10d10bd7 [project @ 1995-10-19 04:31:30 by jwe]
jwe
parents: 1516
diff changeset
37 class charMatrix;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
38
9217
ee7cf4d963f3 smarter handling of quit()
Jaroslav Hajek <highegg@gmail.com>
parents: 9144
diff changeset
39 #include "quit.h"
ee7cf4d963f3 smarter handling of quit()
Jaroslav Hajek <highegg@gmail.com>
parents: 9144
diff changeset
40
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
41 #include "input.h"
7734
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
42 #include "oct-map.h"
17084
872947f3f9f1 * toplev.cc: Include symtab.h
John W. Eaton <jwe@octave.org>
parents: 16892
diff changeset
43 #include "symtab.h"
7734
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
44
9217
ee7cf4d963f3 smarter handling of quit()
Jaroslav Hajek <highegg@gmail.com>
parents: 9144
diff changeset
45
9221
659657942ba6 declare octave_exit using a typedef
Jaroslav Hajek <highegg@gmail.com>
parents: 9218
diff changeset
46 typedef void (*octave_exit_func) (int);
659657942ba6 declare octave_exit using a typedef
Jaroslav Hajek <highegg@gmail.com>
parents: 9218
diff changeset
47 extern OCTINTERP_API octave_exit_func octave_exit;
9217
ee7cf4d963f3 smarter handling of quit()
Jaroslav Hajek <highegg@gmail.com>
parents: 9144
diff changeset
48
9255
1c2d2c9f4a8d don't allow quit() in embedded mode by default, make configurable
Jaroslav Hajek <highegg@gmail.com>
parents: 9247
diff changeset
49 extern OCTINTERP_API bool quit_allowed;
1c2d2c9f4a8d don't allow quit() in embedded mode by default, make configurable
Jaroslav Hajek <highegg@gmail.com>
parents: 9247
diff changeset
50
9383
d57f0c56195f improve error handling
Jaroslav Hajek <highegg@gmail.com>
parents: 9255
diff changeset
51 extern OCTINTERP_API bool quitting_gracefully;
d57f0c56195f improve error handling
Jaroslav Hajek <highegg@gmail.com>
parents: 9255
diff changeset
52
d57f0c56195f improve error handling
Jaroslav Hajek <highegg@gmail.com>
parents: 9255
diff changeset
53 extern OCTINTERP_API int exit_status;
9217
ee7cf4d963f3 smarter handling of quit()
Jaroslav Hajek <highegg@gmail.com>
parents: 9144
diff changeset
54
7250
0ff0883fb121 [project @ 2007-12-04 18:12:32 by jwe]
jwe
parents: 7202
diff changeset
55 extern OCTINTERP_API void
16485
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
56 clean_up_and_exit (int status, bool safe_to_return = false);
574
a10f1c8ab10f [project @ 1994-07-29 18:29:13 by jwe]
jwe
parents: 383
diff changeset
57
7250
0ff0883fb121 [project @ 2007-12-04 18:12:32 by jwe]
jwe
parents: 7202
diff changeset
58 extern OCTINTERP_API void recover_from_exception (void);
7202
ffdbdf53665c [project @ 2007-11-27 20:14:41 by jwe]
jwe
parents: 7185
diff changeset
59
9247
b2790fd23800 More export symbols to allow usage from an IDE.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9237
diff changeset
60 extern OCTINTERP_API int main_loop (void);
1907
8c6cea97eb80 [project @ 1996-02-10 01:12:46 by jwe]
jwe
parents: 1884
diff changeset
61
7250
0ff0883fb121 [project @ 2007-12-04 18:12:32 by jwe]
jwe
parents: 7202
diff changeset
62 extern OCTINTERP_API void
7409
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7250
diff changeset
63 octave_add_atexit_function (const std::string& fname);
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7250
diff changeset
64
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7250
diff changeset
65 extern OCTINTERP_API bool
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7250
diff changeset
66 octave_remove_atexit_function (const std::string& fname);
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7250
diff changeset
67
4217
301cc4cf87e9 [project @ 2002-12-05 03:33:01 by jwe]
jwe
parents: 4172
diff changeset
68 // TRUE means we are ready to interpret commands, but not everything
301cc4cf87e9 [project @ 2002-12-05 03:33:01 by jwe]
jwe
parents: 4172
diff changeset
69 // is ready for interactive use.
7185
83cbff53bc96 [project @ 2007-11-26 18:53:54 by jwe]
jwe
parents: 7017
diff changeset
70 extern OCTINTERP_API bool octave_interpreter_ready;
4217
301cc4cf87e9 [project @ 2002-12-05 03:33:01 by jwe]
jwe
parents: 4172
diff changeset
71
4172
2e94b2abfe6d [project @ 2002-11-12 21:14:04 by jwe]
jwe
parents: 3834
diff changeset
72 // TRUE means we've processed all the init code and we are good to go.
7185
83cbff53bc96 [project @ 2007-11-26 18:53:54 by jwe]
jwe
parents: 7017
diff changeset
73 extern OCTINTERP_API bool octave_initialized;
4172
2e94b2abfe6d [project @ 2002-11-12 21:14:04 by jwe]
jwe
parents: 3834
diff changeset
74
5743
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
75 class
9237
3c1762c7e787 Add missing xxx_API decoration and remove misplaced ones
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9221
diff changeset
76 OCTINTERP_API
5743
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
77 octave_call_stack
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
78 {
7734
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
79 private:
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
80
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
81 struct call_stack_elt
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
82 {
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
83 call_stack_elt (octave_function *f, symbol_table::scope_id s,
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
84 symbol_table::context_id c, size_t p = 0)
16354
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
85 : fcn (f), line (-1), column (-1), scope (s), context (c), prev (p)
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
86 { }
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
87
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
88 call_stack_elt (const call_stack_elt& elt)
16354
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
89 : fcn (elt.fcn), line (elt.line), column (elt.column),
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
90 scope (elt.scope), context (elt.context), prev (elt.prev)
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
91 { }
7734
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
92
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
93 octave_function *fcn;
16354
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
94 int line;
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
95 int column;
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
96 symbol_table::scope_id scope;
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
97 symbol_table::context_id context;
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
98 size_t prev;
7734
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
99 };
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
100
5743
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
101 protected:
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
102
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
103 octave_call_stack (void) : cs (), curr_frame (0) { }
5743
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
104
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
105 public:
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
106
7734
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
107 typedef std::deque<call_stack_elt>::iterator iterator;
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
108 typedef std::deque<call_stack_elt>::const_iterator const_iterator;
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
109
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
110 typedef std::deque<call_stack_elt>::reverse_iterator
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
111 reverse_iterator;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
112 typedef std::deque<call_stack_elt>::const_reverse_iterator
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
113 const_reverse_iterator;
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
114
13983
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
115 static void create_instance (void);
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
116
5743
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
117 static bool instance_ok (void)
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
118 {
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
119 bool retval = true;
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
120
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
121 if (! instance)
13983
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
122 create_instance ();
5743
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
123
13983
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
124 if (! instance)
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
125 {
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
126 ::error ("unable to create call stack object!");
5743
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
127
13983
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
128 retval = false;
5743
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
129 }
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
130
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
131 return retval;
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
132 }
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
133
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
134 // Current function (top of stack).
9484
bbe033dcfe13 make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents: 9396
diff changeset
135 static octave_function *current (void)
bbe033dcfe13 make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents: 9396
diff changeset
136 {
bbe033dcfe13 make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents: 9396
diff changeset
137 return instance_ok () ? instance->do_current () : 0;
bbe033dcfe13 make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents: 9396
diff changeset
138 }
5743
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
139
7734
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
140 // Current line in current function.
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
141 static int current_line (void)
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
142 {
7877
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7787
diff changeset
143 return instance_ok () ? instance->do_current_line () : -1;
7734
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
144 }
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
145
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
146 // Current column in current function.
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
147 static int current_column (void)
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
148 {
7877
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7787
diff changeset
149 return instance_ok () ? instance->do_current_column () : -1;
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7787
diff changeset
150 }
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7787
diff changeset
151
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7787
diff changeset
152 // Line in user code caller.
7923
c3d21b9b94b6 eliminate octave_call_stack member functions caller_user_script and caller_user_function, and unused difference_type args
John W. Eaton <jwe@octave.org>
parents: 7912
diff changeset
153 static int caller_user_code_line (void)
7877
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7787
diff changeset
154 {
7923
c3d21b9b94b6 eliminate octave_call_stack member functions caller_user_script and caller_user_function, and unused difference_type args
John W. Eaton <jwe@octave.org>
parents: 7912
diff changeset
155 return instance_ok () ? instance->do_caller_user_code_line () : -1;
7877
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7787
diff changeset
156 }
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7787
diff changeset
157
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7787
diff changeset
158 // Column in user code caller.
7923
c3d21b9b94b6 eliminate octave_call_stack member functions caller_user_script and caller_user_function, and unused difference_type args
John W. Eaton <jwe@octave.org>
parents: 7912
diff changeset
159 static int caller_user_code_column (void)
7877
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7787
diff changeset
160 {
7923
c3d21b9b94b6 eliminate octave_call_stack member functions caller_user_script and caller_user_function, and unused difference_type args
John W. Eaton <jwe@octave.org>
parents: 7912
diff changeset
161 return instance_ok () ? instance->do_caller_user_code_column () : -1;
7734
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
162 }
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
163
5743
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
164 // Caller function, may be built-in.
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
165 static octave_function *caller (void)
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
166 {
7942
db6478d9c669 out_of_date_check_internal: make it work for class methods
John W. Eaton <jwe@octave.org>
parents: 7923
diff changeset
167 return instance_ok () ? instance->do_caller () : 0;
5743
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
168 }
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
169
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
170 static size_t current_frame (void)
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
171 {
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
172 return instance_ok () ? instance->do_current_frame () : 0;
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
173 }
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
174
7890
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7877
diff changeset
175 static size_t size (void)
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7877
diff changeset
176 {
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7877
diff changeset
177 return instance_ok () ? instance->do_size () : 0;
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7877
diff changeset
178 }
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7877
diff changeset
179
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
180 static size_t num_user_code_frames (octave_idx_type& curr_user_frame)
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
181 {
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
182 return instance_ok ()
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
183 ? instance->do_num_user_code_frames (curr_user_frame) : 0;
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
184 }
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
185
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
186 static symbol_table::scope_id current_scope (void)
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
187 {
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
188 return instance_ok () ? instance->do_current_scope () : 0;
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
189 }
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
190
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
191 static symbol_table::context_id current_context (void)
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
192 {
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
193 return instance_ok () ? instance->do_current_context () : 0;
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
194 }
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
195
7552
6070c3bd69c4 Arbitrary call stack access for external debuggers changeset
ryanru@PrinceHumperdinck
parents: 7409
diff changeset
196 // Function at location N on the call stack (N == 0 is current), may
6070c3bd69c4 Arbitrary call stack access for external debuggers changeset
ryanru@PrinceHumperdinck
parents: 7409
diff changeset
197 // be built-in.
6070c3bd69c4 Arbitrary call stack access for external debuggers changeset
ryanru@PrinceHumperdinck
parents: 7409
diff changeset
198 static octave_function *element (size_t n)
6070c3bd69c4 Arbitrary call stack access for external debuggers changeset
ryanru@PrinceHumperdinck
parents: 7409
diff changeset
199 {
6070c3bd69c4 Arbitrary call stack access for external debuggers changeset
ryanru@PrinceHumperdinck
parents: 7409
diff changeset
200 return instance_ok () ? instance->do_element (n) : 0;
6070c3bd69c4 Arbitrary call stack access for external debuggers changeset
ryanru@PrinceHumperdinck
parents: 7409
diff changeset
201 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
202
7923
c3d21b9b94b6 eliminate octave_call_stack member functions caller_user_script and caller_user_function, and unused difference_type args
John W. Eaton <jwe@octave.org>
parents: 7912
diff changeset
203 // First user-defined function on the stack.
c3d21b9b94b6 eliminate octave_call_stack member functions caller_user_script and caller_user_function, and unused difference_type args
John W. Eaton <jwe@octave.org>
parents: 7912
diff changeset
204 static octave_user_code *caller_user_code (size_t nskip = 0)
5743
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
205 {
7923
c3d21b9b94b6 eliminate octave_call_stack member functions caller_user_script and caller_user_function, and unused difference_type args
John W. Eaton <jwe@octave.org>
parents: 7912
diff changeset
206 return instance_ok () ? instance->do_caller_user_code (nskip) : 0;
5743
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
207 }
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
208
18267
bc139ccccef9 Don't echo scripts not executed from the cmd line when using 'echo on'(bug #41202)
Rik <rik@octave.org>
parents: 17787
diff changeset
209 // Return TRUE if all elements on the call stack are scripts.
bc139ccccef9 Don't echo scripts not executed from the cmd line when using 'echo on'(bug #41202)
Rik <rik@octave.org>
parents: 17787
diff changeset
210 static bool all_scripts (void)
bc139ccccef9 Don't echo scripts not executed from the cmd line when using 'echo on'(bug #41202)
Rik <rik@octave.org>
parents: 17787
diff changeset
211 {
bc139ccccef9 Don't echo scripts not executed from the cmd line when using 'echo on'(bug #41202)
Rik <rik@octave.org>
parents: 17787
diff changeset
212 return instance_ok () ? instance->do_all_scripts () : false;
bc139ccccef9 Don't echo scripts not executed from the cmd line when using 'echo on'(bug #41202)
Rik <rik@octave.org>
parents: 17787
diff changeset
213 }
bc139ccccef9 Don't echo scripts not executed from the cmd line when using 'echo on'(bug #41202)
Rik <rik@octave.org>
parents: 17787
diff changeset
214
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
215 static void
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
216 push (octave_function *f,
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
217 symbol_table::scope_id scope = symbol_table::current_scope (),
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
218 symbol_table::context_id context = symbol_table::current_context ())
5743
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
219 {
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
220 if (instance_ok ())
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
221 instance->do_push (f, scope, context);
5743
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
222 }
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
223
9144
c6463412aebb eliminate symbol_table::scope_stack; fix scoping issue with evalin
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
224 static void
c6463412aebb eliminate symbol_table::scope_stack; fix scoping issue with evalin
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
225 push (symbol_table::scope_id scope = symbol_table::current_scope (),
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
226 symbol_table::context_id context = symbol_table::current_context ())
9144
c6463412aebb eliminate symbol_table::scope_stack; fix scoping issue with evalin
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
227 {
c6463412aebb eliminate symbol_table::scope_stack; fix scoping issue with evalin
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
228 if (instance_ok ())
c6463412aebb eliminate symbol_table::scope_stack; fix scoping issue with evalin
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
229 instance->do_push (0, scope, context);
c6463412aebb eliminate symbol_table::scope_stack; fix scoping issue with evalin
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
230 }
c6463412aebb eliminate symbol_table::scope_stack; fix scoping issue with evalin
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
231
16354
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
232 static void set_location (int l, int c)
7734
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
233 {
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
234 if (instance_ok ())
16354
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
235 instance->do_set_location (l, c);
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
236 }
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
237
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
238 static void set_line (int l)
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
239 {
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
240 if (instance_ok ())
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
241 instance->do_set_line (l);
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
242 }
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
243
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
244 static void set_column (int c)
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
245 {
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
246 if (instance_ok ())
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
247 instance->do_set_column (c);
7734
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
248 }
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
249
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
250 static bool goto_frame (size_t n = 0, bool verbose = false)
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
251 {
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
252 return instance_ok () ? instance->do_goto_frame (n, verbose) : false;
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
253 }
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
254
9396
17af7cce7d1b yet more unwind_protect improvements
Jaroslav Hajek <highegg@gmail.com>
parents: 9383
diff changeset
255 static void restore_frame (size_t n)
17af7cce7d1b yet more unwind_protect improvements
Jaroslav Hajek <highegg@gmail.com>
parents: 9383
diff changeset
256 {
17af7cce7d1b yet more unwind_protect improvements
Jaroslav Hajek <highegg@gmail.com>
parents: 9383
diff changeset
257 goto_frame (n);
17af7cce7d1b yet more unwind_protect improvements
Jaroslav Hajek <highegg@gmail.com>
parents: 9383
diff changeset
258 }
17af7cce7d1b yet more unwind_protect improvements
Jaroslav Hajek <highegg@gmail.com>
parents: 9383
diff changeset
259
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
260 static bool goto_frame_relative (int n, bool verbose = false)
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
261 {
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
262 return instance_ok ()
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
263 ? instance->do_goto_frame_relative (n, verbose) : false;
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
264 }
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
265
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
266 static void goto_caller_frame (void)
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
267 {
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
268 if (instance_ok ())
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
269 instance->do_goto_caller_frame ();
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
270 }
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
271
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
272 static void goto_base_frame (void)
7734
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
273 {
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
274 if (instance_ok ())
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
275 instance->do_goto_base_frame ();
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
276 }
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
277
10767
2b041d3995a3 modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10313
diff changeset
278 static octave_map backtrace (size_t nskip, octave_idx_type& curr_user_frame)
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
279 {
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
280 return instance_ok ()
18440
96a495813047 Don't put parent function in subfunction stack structure name (bug #41506).
Rik <rik@octave.org>
parents: 18267
diff changeset
281 ? instance->do_backtrace (nskip, curr_user_frame, true)
96a495813047 Don't put parent function in subfunction stack structure name (bug #41506).
Rik <rik@octave.org>
parents: 18267
diff changeset
282 : octave_map ();
96a495813047 Don't put parent function in subfunction stack structure name (bug #41506).
Rik <rik@octave.org>
parents: 18267
diff changeset
283 }
96a495813047 Don't put parent function in subfunction stack structure name (bug #41506).
Rik <rik@octave.org>
parents: 18267
diff changeset
284
96a495813047 Don't put parent function in subfunction stack structure name (bug #41506).
Rik <rik@octave.org>
parents: 18267
diff changeset
285 static octave_map backtrace (size_t nskip, octave_idx_type& curr_user_frame,
96a495813047 Don't put parent function in subfunction stack structure name (bug #41506).
Rik <rik@octave.org>
parents: 18267
diff changeset
286 bool print_subfn)
96a495813047 Don't put parent function in subfunction stack structure name (bug #41506).
Rik <rik@octave.org>
parents: 18267
diff changeset
287 {
96a495813047 Don't put parent function in subfunction stack structure name (bug #41506).
Rik <rik@octave.org>
parents: 18267
diff changeset
288 return instance_ok ()
96a495813047 Don't put parent function in subfunction stack structure name (bug #41506).
Rik <rik@octave.org>
parents: 18267
diff changeset
289 ? instance->do_backtrace (nskip, curr_user_frame, print_subfn)
96a495813047 Don't put parent function in subfunction stack structure name (bug #41506).
Rik <rik@octave.org>
parents: 18267
diff changeset
290 : octave_map ();
7734
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
291 }
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
292
10767
2b041d3995a3 modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10313
diff changeset
293 static octave_map empty_backtrace (void);
2b041d3995a3 modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10313
diff changeset
294
5743
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
295 static void pop (void)
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
296 {
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
297 if (instance_ok ())
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
298 instance->do_pop ();
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
299 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
300
5743
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
301 static void clear (void)
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
302 {
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
303 if (instance_ok ())
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
304 instance->do_clear ();
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
305 }
7552
6070c3bd69c4 Arbitrary call stack access for external debuggers changeset
ryanru@PrinceHumperdinck
parents: 7409
diff changeset
306
8013
b3e667f1ab4c call backtrace_error_message in eval functions, not when popping stack
John W. Eaton <jwe@octave.org>
parents: 8011
diff changeset
307 static void backtrace_error_message (void)
b3e667f1ab4c call backtrace_error_message in eval functions, not when popping stack
John W. Eaton <jwe@octave.org>
parents: 8011
diff changeset
308 {
b3e667f1ab4c call backtrace_error_message in eval functions, not when popping stack
John W. Eaton <jwe@octave.org>
parents: 8011
diff changeset
309 if (instance_ok ())
b3e667f1ab4c call backtrace_error_message in eval functions, not when popping stack
John W. Eaton <jwe@octave.org>
parents: 8011
diff changeset
310 instance->do_backtrace_error_message ();
b3e667f1ab4c call backtrace_error_message in eval functions, not when popping stack
John W. Eaton <jwe@octave.org>
parents: 8011
diff changeset
311 }
b3e667f1ab4c call backtrace_error_message in eval functions, not when popping stack
John W. Eaton <jwe@octave.org>
parents: 8011
diff changeset
312
5743
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
313 private:
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
314
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
315 // The current call stack.
7734
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
316 std::deque<call_stack_elt> cs;
5743
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
317
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
318 size_t curr_frame;
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
319
5743
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
320 static octave_call_stack *instance;
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
321
13983
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
322 static void cleanup_instance (void) { delete instance; instance = 0; }
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
323
7734
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
324 int do_current_line (void) const;
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
325
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
326 int do_current_column (void) const;
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
327
7923
c3d21b9b94b6 eliminate octave_call_stack member functions caller_user_script and caller_user_function, and unused difference_type args
John W. Eaton <jwe@octave.org>
parents: 7912
diff changeset
328 int do_caller_user_code_line (void) const;
7877
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7787
diff changeset
329
7923
c3d21b9b94b6 eliminate octave_call_stack member functions caller_user_script and caller_user_function, and unused difference_type args
John W. Eaton <jwe@octave.org>
parents: 7912
diff changeset
330 int do_caller_user_code_column (void) const;
7877
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7787
diff changeset
331
7942
db6478d9c669 out_of_date_check_internal: make it work for class methods
John W. Eaton <jwe@octave.org>
parents: 7923
diff changeset
332 octave_function *do_caller (void) const
db6478d9c669 out_of_date_check_internal: make it work for class methods
John W. Eaton <jwe@octave.org>
parents: 7923
diff changeset
333 {
db6478d9c669 out_of_date_check_internal: make it work for class methods
John W. Eaton <jwe@octave.org>
parents: 7923
diff changeset
334 return curr_frame > 1 ? cs[curr_frame-1].fcn : cs[0].fcn;
db6478d9c669 out_of_date_check_internal: make it work for class methods
John W. Eaton <jwe@octave.org>
parents: 7923
diff changeset
335 }
db6478d9c669 out_of_date_check_internal: make it work for class methods
John W. Eaton <jwe@octave.org>
parents: 7923
diff changeset
336
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
337 size_t do_current_frame (void) { return curr_frame; }
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
338
7890
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7877
diff changeset
339 size_t do_size (void) { return cs.size (); }
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7877
diff changeset
340
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
341 size_t do_num_user_code_frames (octave_idx_type& curr_user_frame) const;
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
342
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
343 symbol_table::scope_id do_current_scope (void) const
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
344 {
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
345 return curr_frame > 0 && curr_frame < cs.size ()
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
346 ? cs[curr_frame].scope : 0;
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
347 }
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
348
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
349 symbol_table::context_id do_current_context (void) const
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
350 {
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
351 return curr_frame > 0 && curr_frame < cs.size ()
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
352 ? cs[curr_frame].context : 0;
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
353 }
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
354
7734
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
355 octave_function *do_element (size_t n)
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
356 {
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
357 octave_function *retval = 0;
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
358
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
359 if (cs.size () > n)
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
360 {
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
361 call_stack_elt& elt = cs[n];
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
362 retval = elt.fcn;
7734
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
363 }
5743
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
364
7734
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
365 return retval;
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
366 }
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
367
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
368 octave_user_code *do_caller_user_code (size_t nskip) const;
5744
1c36a2e82266 [project @ 2006-04-06 19:38:34 by jwe]
jwe
parents: 5743
diff changeset
369
18267
bc139ccccef9 Don't echo scripts not executed from the cmd line when using 'echo on'(bug #41202)
Rik <rik@octave.org>
parents: 17787
diff changeset
370 bool do_all_scripts (void) const;
bc139ccccef9 Don't echo scripts not executed from the cmd line when using 'echo on'(bug #41202)
Rik <rik@octave.org>
parents: 17787
diff changeset
371
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
372 void do_push (octave_function *f, symbol_table::scope_id scope,
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
373 symbol_table::context_id context)
7734
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
374 {
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
375 size_t prev_frame = curr_frame;
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
376 curr_frame = cs.size ();
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
377 cs.push_back (call_stack_elt (f, scope, context, prev_frame));
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
378 symbol_table::set_scope_and_context (scope, context);
7734
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
379 }
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
380
9484
bbe033dcfe13 make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents: 9396
diff changeset
381 octave_function *do_current (void) const
7734
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
382 {
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
383 octave_function *retval = 0;
5744
1c36a2e82266 [project @ 2006-04-06 19:38:34 by jwe]
jwe
parents: 5743
diff changeset
384
7734
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
385 if (! cs.empty ())
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
386 {
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
387 const call_stack_elt& elt = cs[curr_frame];
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
388 retval = elt.fcn;
7734
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
389 }
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
390
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
391 return retval;
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
392 }
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
393
16354
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
394 void do_set_location (int l, int c)
7734
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
395 {
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
396 if (! cs.empty ())
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
397 {
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
398 call_stack_elt& elt = cs.back ();
16354
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
399
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
400 elt.line = l;
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
401 elt.column = c;
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
402 }
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
403 }
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
404
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
405 void do_set_line (int l)
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
406 {
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
407 if (! cs.empty ())
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
408 {
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
409 call_stack_elt& elt = cs.back ();
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
410
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
411 elt.line = l;
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
412 }
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
413 }
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
414
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
415 void do_set_column (int c)
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
416 {
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
417 if (! cs.empty ())
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
418 {
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
419 call_stack_elt& elt = cs.back ();
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
420
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 16177
diff changeset
421 elt.column = c;
7734
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
422 }
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
423 }
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
424
10767
2b041d3995a3 modernize some map usage on toplev.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10313
diff changeset
425 octave_map do_backtrace (size_t nskip,
18440
96a495813047 Don't put parent function in subfunction stack structure name (bug #41506).
Rik <rik@octave.org>
parents: 18267
diff changeset
426 octave_idx_type& curr_user_frame,
96a495813047 Don't put parent function in subfunction stack structure name (bug #41506).
Rik <rik@octave.org>
parents: 18267
diff changeset
427 bool print_subfn) const;
5744
1c36a2e82266 [project @ 2006-04-06 19:38:34 by jwe]
jwe
parents: 5743
diff changeset
428
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
429 bool do_goto_frame (size_t n, bool verbose);
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
430
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
431 bool do_goto_frame_relative (int n, bool verbose);
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
432
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
433 void do_goto_caller_frame (void);
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
434
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
435 void do_goto_base_frame (void);
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
436
5743
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
437 void do_pop (void)
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
438 {
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
439 if (cs.size () > 1)
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
440 {
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
441 const call_stack_elt& elt = cs.back ();
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
442 curr_frame = elt.prev;
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
443 cs.pop_back ();
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
444 const call_stack_elt& new_elt = cs[curr_frame];
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
445 symbol_table::set_scope_and_context (new_elt.scope, new_elt.context);
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
446 }
5743
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
447 }
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
448
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
449 void do_clear (void) { cs.clear (); }
8011
3100283874d7 improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents: 7968
diff changeset
450
8013
b3e667f1ab4c call backtrace_error_message in eval functions, not when popping stack
John W. Eaton <jwe@octave.org>
parents: 8011
diff changeset
451 void do_backtrace_error_message (void) const;
5743
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
452 };
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
453
14014
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 13983
diff changeset
454 // Call a function with exceptions handled to avoid problems with
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 13983
diff changeset
455 // errors while shutting down.
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 13983
diff changeset
456
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 13983
diff changeset
457 #define OCTAVE_IGNORE_EXCEPTION(E) \
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 13983
diff changeset
458 catch (E) \
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 13983
diff changeset
459 { \
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 13983
diff changeset
460 std::cerr << "error: ignoring " #E " while preparing to exit" << std::endl; \
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 13983
diff changeset
461 recover_from_exception (); \
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 13983
diff changeset
462 }
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 13983
diff changeset
463
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 13983
diff changeset
464 #define OCTAVE_SAFE_CALL(F, ARGS) \
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 13983
diff changeset
465 do \
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 13983
diff changeset
466 { \
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 13983
diff changeset
467 try \
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 13983
diff changeset
468 { \
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 13983
diff changeset
469 unwind_protect frame; \
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 13983
diff changeset
470 \
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 13983
diff changeset
471 frame.protect_var (Vdebug_on_error); \
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 13983
diff changeset
472 frame.protect_var (Vdebug_on_warning); \
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 13983
diff changeset
473 \
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 13983
diff changeset
474 Vdebug_on_error = false; \
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 13983
diff changeset
475 Vdebug_on_warning = false; \
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 13983
diff changeset
476 \
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 13983
diff changeset
477 F ARGS; \
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 13983
diff changeset
478 } \
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 13983
diff changeset
479 OCTAVE_IGNORE_EXCEPTION (octave_interrupt_exception) \
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 13983
diff changeset
480 OCTAVE_IGNORE_EXCEPTION (octave_execution_exception) \
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 13983
diff changeset
481 OCTAVE_IGNORE_EXCEPTION (std::bad_alloc) \
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 13983
diff changeset
482 \
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 13983
diff changeset
483 if (error_state) \
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 13983
diff changeset
484 error_state = 0; \
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 13983
diff changeset
485 } \
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 13983
diff changeset
486 while (0)
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 13983
diff changeset
487
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
488 #endif