# HG changeset patch # User John W. Eaton # Date 1236951907 14400 # Node ID ddea8b06ed7c320377a2165bea9e209843d74ffe # Parent 5fa53d1b6247a4f98377c1181cf6fcefdbfb9b77 fix warning backtrace diff -r 5fa53d1b6247 -r ddea8b06ed7c src/ChangeLog --- a/src/ChangeLog Fri Mar 13 13:39:22 2009 +0100 +++ b/src/ChangeLog Fri Mar 13 09:45:07 2009 -0400 @@ -7,6 +7,14 @@ * data.cc (fill_matrix): Return packed form (zero-step range) if possible. +2009-03-13 John W. Eaton + + * error.cc (pr_where): Use octave_call_stack::backtrace to print + complete stack trace at once. Don't attempt to print code. + (error_2): Set error_state to 0 before calling pr_where. + (warning_1): Switch sense of test on symbol_table::at_top_level. + Call pr_where after printing primary warning message. + 2009-03-10 Jason Riedy * DLD-FUNCTIONS/lu.cc (lu): Call fact.Pr_mat () and fact.Pc_mat () diff -r 5fa53d1b6247 -r ddea8b06ed7c src/error.cc --- a/src/error.cc Fri Mar 13 13:39:22 2009 +0100 +++ b/src/error.cc Fri Mar 13 09:45:07 2009 -0400 @@ -405,66 +405,32 @@ } static void -pr_where (const char *name, bool print_code = true) +pr_where (const char *who) { - if (octave_call_stack::current_statement ()) - { - std::string nm; + octave_idx_type curr_frame = -1; - int l = -1; - int c = -1; + Octave_map stk = octave_call_stack::backtrace (0, curr_frame); - octave_user_code *fcn = octave_call_stack::caller_user_code (); + octave_idx_type nframes_to_display = stk.numel (); - if (fcn) - { - nm = fcn->fcn_file_name (); - - if (nm.empty ()) - nm = fcn->name (); + if (nframes_to_display > 0) + { + pr_where_1 ("%s: called from\n", who); - l = octave_call_stack::current_line (); - c = octave_call_stack::current_column (); - } + Cell names = stk.contents ("name"); + Cell lines = stk.contents ("line"); + Cell columns = stk.contents ("column"); - if (nm.empty ()) - { - if (l > 0 && c > 0) - pr_where_1 ("%s: near line %d, column %d:", name, l, c); - } - else + for (octave_idx_type i = 0; i < nframes_to_display; i++) { - if (l > 0 && c > 0) - pr_where_1 ("%s: in %s near line %d, column %d:", - name, nm.c_str (), l, c); - else - pr_where_1 ("%s: in %s", name, nm.c_str ()); - } - - if (print_code) - { - // FIXME -- Note that the column number is probably - // not going to mean much here since the code is being - // reproduced from the parse tree, and we are only showing - // one statement even if there were multiple statements on - // the original source line. + octave_value name = names(i); + octave_value line = lines(i); + octave_value column = columns(i); - std::ostringstream output_buf; - - output_buf << std::endl; - - tree_print_code tpc (output_buf, ">>> "); - - tree_statement *curr_stmt = octave_call_stack::current_statement (); + std::string nm = name.string_value (); - if (curr_stmt) - curr_stmt->accept (tpc); - - output_buf << std::endl; - - std::string msg = output_buf.str (); - - pr_where_1 ("%s", msg.c_str ()); + pr_where_1 (" %s at line %d column %d\n", nm.c_str (), + line.int_value (), column.int_value ()); } } } @@ -483,9 +449,9 @@ unwind_protect_bool (Vdebug_on_error); Vdebug_on_error = false; - pr_where ("error"); + error_state = 0; - error_state = 0; + pr_where ("error"); do_keyboard (octave_value_list ()); @@ -627,13 +593,13 @@ } else if (warn_opt == 1) { - if (symbol_table::at_top_level () + vwarning ("warning", id, fmt, args); + + if (! symbol_table::at_top_level () && Vbacktrace_on_warning && ! warning_state && ! discard_warning_messages) - pr_where ("warning", false); - - vwarning ("warning", id, fmt, args); + pr_where ("warning"); warning_state = 1;