changeset 20127:a42de4173533

also provide stack traces for errors in script files (bug #44862) * error.cc (error_2, warning_1): Check whether we are in user code rather than at the top-level symbol table to determine whether to display a stack trace.
author John W. Eaton <jwe@octave.org>
date Fri, 24 Apr 2015 22:31:21 -0400
parents d34e31b07966
children e05fe4260252
files libinterp/corefcn/error.cc
diffstat 1 files changed, 8 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/error.cc	Fri Apr 24 09:01:38 2015 -0700
+++ b/libinterp/corefcn/error.cc	Fri Apr 24 22:31:21 2015 -0400
@@ -447,13 +447,12 @@
 
   error_1 (std::cerr, "error", id, fmt, args, with_cfn);
 
-  if (error_state != -2 && ! symbol_table::at_top_level ()
-      && ! discard_error_messages)
+  bool in_user_code = octave_call_stack::caller_user_code () != 0;
+
+  if (error_state != -2 && in_user_code && ! discard_error_messages)
     pr_where ("error");
 
-  if (interactive
-      && Vdebug_on_error && init_state == 0
-      && octave_call_stack::caller_user_code ())
+  if (interactive && Vdebug_on_error && init_state == 0 && in_user_code)
     {
       unwind_protect frame;
       frame.protect_var (Vdebug_on_error);
@@ -637,17 +636,16 @@
     {
       vwarning ("warning", id, fmt, args);
 
-      if (! symbol_table::at_top_level ()
-          && Vbacktrace_on_warning
-          && ! warning_state
+      bool in_user_code = octave_call_stack::caller_user_code () != 0;
+
+      if (in_user_code && Vbacktrace_on_warning && ! warning_state
           && ! discard_warning_messages)
         pr_where ("warning");
 
       warning_state = 1;
 
       if ((interactive || forced_interactive)
-          && Vdebug_on_warning
-          && octave_call_stack::caller_user_code ())
+          && Vdebug_on_warning && in_user_code)
         {
           unwind_protect frame;
           frame.protect_var (Vdebug_on_warning);