Mercurial > hg > octave-terminal
changeset 8973:ddea8b06ed7c
fix warning backtrace
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 13 Mar 2009 09:45:07 -0400 |
parents | 5fa53d1b6247 |
children | fde2a916b2ac |
files | src/ChangeLog src/error.cc |
diffstat | 2 files changed, 31 insertions(+), 57 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -7,6 +7,14 @@ * data.cc (fill_matrix): Return packed form (zero-step range) if possible. +2009-03-13 John W. Eaton <jwe@octave.org> + + * 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 <jason@acm.org> * DLD-FUNCTIONS/lu.cc (lu): Call fact.Pr_mat () and fact.Pc_mat ()
--- a/src/error.cc +++ b/src/error.cc @@ -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;