Mercurial > octave
comparison libinterp/corefcn/toplev.h @ 21322:909129eb77c5
use correct stack frame when reporting debug location
* toplev.h, toplev.cc (octave_call_stack::debug_user_code,
octave_call_stack::debug_user_code_line,
octave_call_stack::debug_user_code_column): New static functions.
(octave_call_stack::do_debug_user_code,
octave_call_stack::do_debug_user_code_line,
octave_call_stack::do_debug_user_code_column): New member functions.
* debug.cc (get_user_code): Use octave_call_stack::debug_user_code.
(Fdblist): Use octave_call_stack::debug_user_code_line and
octave_call_stack::debug_user_code_column.
(Fdbwhere): Don't error if at top level. Improve location message.
(octave_call_stack::do_goto_frame,
octave_call_stack::do_goto_frame_relative): Improve location message.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 23 Feb 2016 15:05:45 -0500 |
parents | 1473547f50f5 |
children | 1d8e020d86df |
comparison
equal
deleted
inserted
replaced
21321:79a51b7e00b6 | 21322:909129eb77c5 |
---|---|
158 static int current_column (void) | 158 static int current_column (void) |
159 { | 159 { |
160 return instance_ok () ? instance->do_current_column () : -1; | 160 return instance_ok () ? instance->do_current_column () : -1; |
161 } | 161 } |
162 | 162 |
163 // Line in user code caller. | |
164 static int caller_user_code_line (void) | |
165 { | |
166 return instance_ok () ? instance->do_caller_user_code_line () : -1; | |
167 } | |
168 | |
169 // Column in user code caller. | |
170 static int caller_user_code_column (void) | |
171 { | |
172 return instance_ok () ? instance->do_caller_user_code_column () : -1; | |
173 } | |
174 | |
175 // Caller function, may be built-in. | 163 // Caller function, may be built-in. |
176 static octave_function *caller (void) | 164 static octave_function *caller (void) |
177 { | 165 { |
178 return instance_ok () ? instance->do_caller () : 0; | 166 return instance_ok () ? instance->do_caller () : 0; |
179 } | 167 } |
216 static octave_function *element (size_t n) | 204 static octave_function *element (size_t n) |
217 { | 205 { |
218 return instance_ok () ? instance->do_element (n) : 0; | 206 return instance_ok () ? instance->do_element (n) : 0; |
219 } | 207 } |
220 | 208 |
221 // First user-defined function on the stack. | 209 // User code caller. |
222 static octave_user_code *caller_user_code (size_t nskip = 0) | 210 static octave_user_code *caller_user_code (void) |
223 { | 211 { |
224 return instance_ok () ? instance->do_caller_user_code (nskip) : 0; | 212 return instance_ok () ? instance->do_debug_user_code () : 0; |
213 } | |
214 | |
215 // Line in user code caller. | |
216 static int caller_user_code_line (void) | |
217 { | |
218 return instance_ok () ? instance->do_caller_user_code_line () : -1; | |
219 } | |
220 | |
221 // Column in user code caller. | |
222 static int caller_user_code_column (void) | |
223 { | |
224 return instance_ok () ? instance->do_caller_user_code_column () : -1; | |
225 } | |
226 | |
227 // Current function that we are debugging. | |
228 static octave_user_code *debug_user_code (void) | |
229 { | |
230 return instance_ok () ? instance->do_debug_user_code () : 0; | |
231 } | |
232 | |
233 // Line number in current function that we are debugging. | |
234 static int debug_user_code_line (void) | |
235 { | |
236 return instance_ok () ? instance->do_debug_user_code_line () : 0; | |
237 } | |
238 | |
239 // Column number in current function that we are debugging. | |
240 static int debug_user_code_column (void) | |
241 { | |
242 return instance_ok () ? instance->do_debug_user_code_column () : 0; | |
225 } | 243 } |
226 | 244 |
227 // Return TRUE if all elements on the call stack are scripts. | 245 // Return TRUE if all elements on the call stack are scripts. |
228 static bool all_scripts (void) | 246 static bool all_scripts (void) |
229 { | 247 { |
354 static void cleanup_instance (void) { delete instance; instance = 0; } | 372 static void cleanup_instance (void) { delete instance; instance = 0; } |
355 | 373 |
356 int do_current_line (void) const; | 374 int do_current_line (void) const; |
357 | 375 |
358 int do_current_column (void) const; | 376 int do_current_column (void) const; |
359 | |
360 int do_caller_user_code_line (void) const; | |
361 | |
362 int do_caller_user_code_column (void) const; | |
363 | 377 |
364 octave_function *do_caller (void) const | 378 octave_function *do_caller (void) const |
365 { | 379 { |
366 return curr_frame > 1 ? cs[curr_frame-1].m_fcn : cs[0].m_fcn; | 380 return curr_frame > 1 ? cs[curr_frame-1].m_fcn : cs[0].m_fcn; |
367 } | 381 } |
405 | 419 |
406 return retval; | 420 return retval; |
407 } | 421 } |
408 | 422 |
409 octave_user_code *do_caller_user_code (size_t nskip) const; | 423 octave_user_code *do_caller_user_code (size_t nskip) const; |
424 int do_caller_user_code_line (void) const; | |
425 int do_caller_user_code_column (void) const; | |
426 | |
427 octave_user_code *do_debug_user_code (void) const; | |
428 int do_debug_user_code_line (void) const; | |
429 int do_debug_user_code_column (void) const; | |
410 | 430 |
411 bool do_all_scripts (void) const; | 431 bool do_all_scripts (void) const; |
412 | 432 |
413 void do_push (octave_function *fcn, symbol_table::scope_id scope, | 433 void do_push (octave_function *fcn, symbol_table::scope_id scope, |
414 symbol_table::context_id context) | 434 symbol_table::context_id context) |