Mercurial > octave
changeset 20785:b6f2909e7f94
always throw exception after debugging with debug_on_error
* quit.h (octave_execution_exception::set_stack_trace (void)):
New overloaded function.
* error.h, error.cc (maybe_enter_debugger): Rename from
debug_or_throw_exception. Just handle debugging. Display stack trace
from exception object instead of calling pr_where. If stack trace is
printed, clear stack trace info from exception object. Pass object as
non-const reference.
(usage_1, error_1): Throw execption after call to maybe_enter_debugger.
Pass exception object by non-const reference.
(verror, error): Pass exception object by non-const reference.
* gripes.h, gripes.cc (gripe_user_supplied_eval,
gripe_wrong_type_arg): Pass exception object by non-const reference.
* __qp__.cc, daspk.cc, dasrt.cc, dassl.cc, data.cc, file-io.cc,
graphics.cc, graphics.in.h, lsode.cc, oct-handle.h, oct-map.cc,
quad.cc, rand.cc, toplev.cc, __eigs__.cc, ov-base.cc, ov.cc,
oct-parse.in.yy: Catch octave_execution_exception as non-const
reference as needed.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 02 Dec 2015 16:54:13 -0500 |
parents | 52f6921dde09 |
children | 62564952e161 |
files | libinterp/corefcn/__qp__.cc libinterp/corefcn/daspk.cc libinterp/corefcn/dasrt.cc libinterp/corefcn/dassl.cc libinterp/corefcn/data.cc libinterp/corefcn/error.cc libinterp/corefcn/error.h libinterp/corefcn/file-io.cc libinterp/corefcn/graphics.cc libinterp/corefcn/graphics.in.h libinterp/corefcn/gripes.cc libinterp/corefcn/gripes.h libinterp/corefcn/lsode.cc libinterp/corefcn/oct-handle.h libinterp/corefcn/oct-map.cc libinterp/corefcn/quad.cc libinterp/corefcn/rand.cc libinterp/corefcn/toplev.cc libinterp/dldfcn/__eigs__.cc libinterp/octave-value/ov-base.cc libinterp/octave-value/ov.cc libinterp/parse-tree/oct-parse.in.yy liboctave/cruft/misc/quit.h |
diffstat | 23 files changed, 94 insertions(+), 74 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/__qp__.cc Wed Dec 02 14:41:32 2015 -0500 +++ b/libinterp/corefcn/__qp__.cc Wed Dec 02 16:54:13 2015 -0500 @@ -142,7 +142,7 @@ { eigH = EIG (H); } - catch (const octave_execution_exception& e) + catch (octave_execution_exception& e) { error (e, "qp: failed to compute eigenvalues of H"); } @@ -290,7 +290,7 @@ { eigrH = EIG (rH); } - catch (const octave_execution_exception& e) + catch (octave_execution_exception& e) { error (e, "qp: failed to compute eigenvalues of rH"); }
--- a/libinterp/corefcn/daspk.cc Wed Dec 02 14:41:32 2015 -0500 +++ b/libinterp/corefcn/daspk.cc Wed Dec 02 16:54:13 2015 -0500 @@ -79,7 +79,7 @@ { tmp = daspk_fcn->do_multi_index_op (1, args); } - catch (const octave_execution_exception& e) + catch (octave_execution_exception& e) { gripe_user_supplied_eval (e, "daspk"); } @@ -131,7 +131,7 @@ { tmp = daspk_jac->do_multi_index_op (1, args); } - catch (const octave_execution_exception& e) + catch (octave_execution_exception& e) { gripe_user_supplied_eval (e, "daspk"); }
--- a/libinterp/corefcn/dasrt.cc Wed Dec 02 14:41:32 2015 -0500 +++ b/libinterp/corefcn/dasrt.cc Wed Dec 02 16:54:13 2015 -0500 @@ -79,7 +79,7 @@ { tmp = dasrt_f->do_multi_index_op (1, args); } - catch (const octave_execution_exception& e) + catch (octave_execution_exception& e) { gripe_user_supplied_eval (e, "dasrt"); } @@ -122,7 +122,7 @@ { tmp = dasrt_cf->do_multi_index_op (1, args); } - catch (const octave_execution_exception& e) + catch (octave_execution_exception& e) { gripe_user_supplied_eval (e, "dasrt"); } @@ -170,7 +170,7 @@ { tmp = dasrt_j->do_multi_index_op (1, args); } - catch (const octave_execution_exception& e) + catch (octave_execution_exception& e) { gripe_user_supplied_eval (e, "dasrt"); }
--- a/libinterp/corefcn/dassl.cc Wed Dec 02 14:41:32 2015 -0500 +++ b/libinterp/corefcn/dassl.cc Wed Dec 02 16:54:13 2015 -0500 @@ -79,7 +79,7 @@ { tmp = dassl_fcn->do_multi_index_op (1, args); } - catch (const octave_execution_exception& e) + catch (octave_execution_exception& e) { gripe_user_supplied_eval (e, "dassl"); } @@ -131,7 +131,7 @@ { tmp = dassl_jac->do_multi_index_op (1, args); } - catch (const octave_execution_exception& e) + catch (octave_execution_exception& e) { gripe_user_supplied_eval (e, "dassl"); }
--- a/libinterp/corefcn/data.cc Wed Dec 02 14:41:32 2015 -0500 +++ b/libinterp/corefcn/data.cc Wed Dec 02 16:54:13 2015 -0500 @@ -1810,7 +1810,7 @@ { result = fcn.do_multi_index_op (1, octave_value_list (1, ov)); } - catch (const octave_execution_exception& e) + catch (octave_execution_exception& e) { error (e, "conversion from %s to %s failed", dtype.c_str (), cname.c_str ()); @@ -1837,7 +1837,7 @@ { result = fcn.do_multi_index_op (1, octave_value_list (1, ov)); } - catch (const octave_execution_exception& e) + catch (octave_execution_exception& e) { error (e, "%s constructor failed for %s argument", dtype.c_str (), cname.c_str ()); @@ -1877,7 +1877,7 @@ { tmp2 = fcn.do_multi_index_op (1, ovl); } - catch (const octave_execution_exception& e) + catch (octave_execution_exception& e) { error (e, "%s/%s method failed", dtype.c_str (), cattype.c_str ()); }
--- a/libinterp/corefcn/error.cc Wed Dec 02 14:41:32 2015 -0500 +++ b/libinterp/corefcn/error.cc Wed Dec 02 16:54:13 2015 -0500 @@ -297,8 +297,8 @@ } static void -debug_or_throw_exception (const octave_execution_exception& e, - bool show_stack_trace = false) +maybe_enter_debugger (octave_execution_exception& e, + bool show_stack_trace = false) { if ((interactive || forced_interactive) && Vdebug_on_error && octave_call_stack::caller_user_code ()) @@ -312,12 +312,19 @@ tree_evaluator::current_frame = octave_call_stack::current_frame (); if (show_stack_trace) - pr_where (std::cerr, "error"); + { + std::string stack_trace = e.info (); + + if (! stack_trace.empty ()) + { + std::cerr << stack_trace; + + e.set_stack_trace (); + } + } do_keyboard (octave_value_list ()); } - else - throw e; } // Warning messages are never buffered. @@ -389,18 +396,22 @@ } static void -usage_1 (const octave_execution_exception& e, const char *id, +usage_1 (octave_execution_exception& e, const char *id, const char *fmt, va_list args) { verror (true, std::cerr, "usage", id, fmt, args); - debug_or_throw_exception (e); + maybe_enter_debugger (e); + + throw e; } static void usage_1 (const char *id, const char *fmt, va_list args) { - usage_1 (make_execution_exception ("usage"), id, fmt, args); + octave_execution_exception e = make_execution_exception ("usage"); + + usage_1 (e, id, fmt, args); } void @@ -434,7 +445,7 @@ } static void -error_1 (const octave_execution_exception& e, std::ostream& os, +error_1 (octave_execution_exception& e, std::ostream& os, const char *name, const char *id, const char *fmt, va_list args, bool with_cfn = false) { @@ -473,15 +484,18 @@ else panic ("error_1: invalid format"); - debug_or_throw_exception (e, show_stack_trace); + maybe_enter_debugger (e, show_stack_trace); + + throw e; } static void error_1 (std::ostream& os, const char *name, const char *id, const char *fmt, va_list args, bool with_cfn = false) { - error_1 (make_execution_exception ("error"), os, name, id, fmt, - args, with_cfn); + octave_execution_exception e = make_execution_exception ("error"); + + error_1 (e, os, name, id, fmt, args, with_cfn); } void @@ -500,13 +514,13 @@ } void -verror (const octave_execution_exception& e, const char *fmt, va_list args) +verror (octave_execution_exception& e, const char *fmt, va_list args) { error_1 (e, std::cerr, "error", "", fmt, args); } void -error (const octave_execution_exception& e, const char *fmt, ...) +error (octave_execution_exception& e, const char *fmt, ...) { va_list args; va_start (args, fmt);
--- a/libinterp/corefcn/error.h Wed Dec 02 14:41:32 2015 -0500 +++ b/libinterp/corefcn/error.h Wed Dec 02 16:54:13 2015 -0500 @@ -52,9 +52,9 @@ extern OCTINTERP_API void verror (const char *fmt, va_list args); extern OCTINTERP_API void error (const char *fmt, ...); -extern OCTINTERP_API void verror (const octave_execution_exception&, +extern OCTINTERP_API void verror (octave_execution_exception&, const char *fmt, va_list args); -extern OCTINTERP_API void error (const octave_execution_exception&, +extern OCTINTERP_API void error (octave_execution_exception&, const char *fmt, ...); extern OCTINTERP_API void verror_with_cfn (const char *fmt, va_list args);
--- a/libinterp/corefcn/file-io.cc Wed Dec 02 14:41:32 2015 -0500 +++ b/libinterp/corefcn/file-io.cc Wed Dec 02 16:54:13 2015 -0500 @@ -1329,7 +1329,7 @@ oct_data_conv::string_to_data_type (prec, block_size, input_type, output_type); } - catch (const octave_execution_exception& e) + catch (octave_execution_exception& e) { error (e, "fread: invalid PRECISION specified"); } @@ -1340,7 +1340,7 @@ { skip = skip_arg.int_value (true); } - catch (const octave_execution_exception& e) + catch (octave_execution_exception& e) { error (e, "fread: SKIP must be an integer"); } @@ -1587,7 +1587,7 @@ { oct_data_conv::string_to_data_type (prec, block_size, output_type); } - catch (const octave_execution_exception& e) + catch (octave_execution_exception& e) { error (e, "fwrite: invalid PRECISION specified"); } @@ -1598,7 +1598,7 @@ { skip = skip_arg.int_value (true); } - catch (const octave_execution_exception& e) + catch (octave_execution_exception& e) { error (e, "fwrite: SKIP must be an integer"); }
--- a/libinterp/corefcn/graphics.cc Wed Dec 02 14:41:32 2015 -0500 +++ b/libinterp/corefcn/graphics.cc Wed Dec 02 16:54:13 2015 -0500 @@ -1304,7 +1304,7 @@ return true; } } - catch (const octave_execution_exception& e) + catch (octave_execution_exception& e) { error (e, "invalid value for color property \"%s\" (value = %s)", get_name ().c_str (), s.c_str ()); @@ -2903,7 +2903,7 @@ { bgo.set (pname, q->second); } - catch (const octave_execution_exception& e) + catch (octave_execution_exception& e) { error (e, "error setting default property %s", pname.c_str ()); } @@ -10234,7 +10234,7 @@ integer_figure_handle, false, false); } - catch (const octave_execution_exception& e) + catch (octave_execution_exception& e) { error (e, "__go%s__: unable to create graphics handle", go_name.c_str ());
--- a/libinterp/corefcn/graphics.in.h Wed Dec 02 14:41:32 2015 -0500 +++ b/libinterp/corefcn/graphics.in.h Wed Dec 02 16:54:13 2015 -0500 @@ -806,7 +806,7 @@ { nda = val.array_value (); } - catch (const octave_execution_exception& e) + catch (octave_execution_exception& e) { error (e, "set: invalid string property value for \"%s\"", get_name ().c_str ()); @@ -1700,7 +1700,7 @@ { new_kids = val.matrix_value (); } - catch (const octave_execution_exception& e) + catch (octave_execution_exception& e) { error (e, "set: children must be an array of graphics handles"); }
--- a/libinterp/corefcn/gripes.cc Wed Dec 02 14:41:32 2015 -0500 +++ b/libinterp/corefcn/gripes.cc Wed Dec 02 16:54:13 2015 -0500 @@ -92,7 +92,7 @@ } void -gripe_user_supplied_eval (const octave_execution_exception& e, +gripe_user_supplied_eval (octave_execution_exception& e, const char *name) { error (e, "%s: evaluation of user-supplied function failed", name); @@ -149,7 +149,7 @@ } void -gripe_wrong_type_arg (const octave_execution_exception& e, +gripe_wrong_type_arg (octave_execution_exception& e, const char *name, const char *s, bool is_error) { if (is_error) @@ -167,7 +167,7 @@ } void -gripe_wrong_type_arg (const octave_execution_exception& e, +gripe_wrong_type_arg (octave_execution_exception& e, const char *name, const std::string& s, bool is_error) { gripe_wrong_type_arg (e, name, s.c_str (), is_error); @@ -183,7 +183,7 @@ } void -gripe_wrong_type_arg (const octave_execution_exception& e, +gripe_wrong_type_arg (octave_execution_exception& e, const char *name, const octave_value& tc, bool is_error) { @@ -202,7 +202,7 @@ } void -gripe_wrong_type_arg (const octave_execution_exception& e, +gripe_wrong_type_arg (octave_execution_exception& e, const std::string& name, const octave_value& tc, bool is_error) { @@ -218,7 +218,7 @@ } void -gripe_wrong_type_arg (const octave_execution_exception& e, +gripe_wrong_type_arg (octave_execution_exception& e, const char *s, bool is_error) { if (is_error) @@ -236,7 +236,7 @@ } void -gripe_wrong_type_arg (const octave_execution_exception& e, +gripe_wrong_type_arg (octave_execution_exception& e, const std::string& s, bool is_error) { gripe_wrong_type_arg (e, s.c_str (), is_error); @@ -251,7 +251,7 @@ } void -gripe_wrong_type_arg (const octave_execution_exception& e, +gripe_wrong_type_arg (octave_execution_exception& e, const octave_value& tc, bool is_error) { std::string type = tc.type_name ();
--- a/libinterp/corefcn/gripes.h Wed Dec 02 14:41:32 2015 -0500 +++ b/libinterp/corefcn/gripes.h Wed Dec 02 16:54:13 2015 -0500 @@ -59,7 +59,7 @@ gripe_user_supplied_eval (const char *name); extern OCTINTERP_API void -gripe_user_supplied_eval (const octave_execution_exception& e, +gripe_user_supplied_eval (octave_execution_exception& e, const char *name); extern OCTINTERP_API void @@ -88,7 +88,7 @@ bool is_error = true); extern OCTINTERP_API void -gripe_wrong_type_arg (const octave_execution_exception& e, +gripe_wrong_type_arg (octave_execution_exception& e, const char *name, const char *s, bool is_error = true); @@ -97,7 +97,7 @@ bool is_error = true); extern OCTINTERP_API void -gripe_wrong_type_arg (const octave_execution_exception& e, +gripe_wrong_type_arg (octave_execution_exception& e, const char *name, const std::string& s, bool is_error = true); @@ -106,7 +106,7 @@ bool is_error = true); extern OCTINTERP_API void -gripe_wrong_type_arg (const octave_execution_exception& e, +gripe_wrong_type_arg (octave_execution_exception& e, const char *name, const octave_value& tc, bool is_error = true); @@ -115,7 +115,7 @@ bool is_error = true); extern OCTINTERP_API void -gripe_wrong_type_arg (const octave_execution_exception& e, +gripe_wrong_type_arg (octave_execution_exception& e, const std::string& name, const octave_value& tc, bool is_error = true); @@ -123,21 +123,21 @@ gripe_wrong_type_arg (const char *s, bool is_error = true); extern OCTINTERP_API void -gripe_wrong_type_arg (const octave_execution_exception& e, +gripe_wrong_type_arg (octave_execution_exception& e, const char *s, bool is_error = true); extern OCTINTERP_API void gripe_wrong_type_arg (const std::string& s, bool is_error = true); extern OCTINTERP_API void -gripe_wrong_type_arg (const octave_execution_exception& e, +gripe_wrong_type_arg (octave_execution_exception& e, const std::string& s, bool is_error = true); extern OCTINTERP_API void gripe_wrong_type_arg (const octave_value& tc, bool is_error = true); extern OCTINTERP_API void -gripe_wrong_type_arg (const octave_execution_exception& e, +gripe_wrong_type_arg (octave_execution_exception& e, const octave_value& tc, bool is_error = true); extern OCTINTERP_API void
--- a/libinterp/corefcn/lsode.cc Wed Dec 02 14:41:32 2015 -0500 +++ b/libinterp/corefcn/lsode.cc Wed Dec 02 16:54:13 2015 -0500 @@ -76,7 +76,7 @@ { tmp = lsode_fcn->do_multi_index_op (1, args); } - catch (const octave_execution_exception& e) + catch (octave_execution_exception& e) { gripe_user_supplied_eval (e, "lsode"); } @@ -118,7 +118,7 @@ { tmp = lsode_jac->do_multi_index_op (1, args); } - catch (const octave_execution_exception& e) + catch (octave_execution_exception& e) { gripe_user_supplied_eval (e, "lsode"); }
--- a/libinterp/corefcn/oct-handle.h Wed Dec 02 14:41:32 2015 -0500 +++ b/libinterp/corefcn/oct-handle.h Wed Dec 02 16:54:13 2015 -0500 @@ -46,7 +46,7 @@ { val = a.double_value (); } - catch (const octave_execution_exception& e) + catch (octave_execution_exception& e) { error (e, "invalid handle"); }
--- a/libinterp/corefcn/oct-map.cc Wed Dec 02 14:41:32 2015 -0500 +++ b/libinterp/corefcn/oct-map.cc Wed Dec 02 16:54:13 2015 -0500 @@ -650,7 +650,7 @@ new_map_list[i], perm); } } - catch (const octave_execution_exception& e) + catch (octave_execution_exception& e) { error (e, "cat: field names mismatch in concatenating structs"); } @@ -1001,7 +1001,7 @@ { rhs1 = rhs.orderfields (*this, perm); } - catch (const octave_execution_exception& e) + catch (octave_execution_exception& e) { error (e, "incompatible fields in struct assignment"); } @@ -1049,7 +1049,7 @@ { rhs1 = rhs.orderfields (*this, perm); } - catch (const octave_execution_exception& e) + catch (octave_execution_exception& e) { error (e, "incompatible fields in struct assignment"); } @@ -1097,7 +1097,7 @@ { rhs1 = rhs.orderfields (*this, perm); } - catch (const octave_execution_exception& e) + catch (octave_execution_exception& e) { error (e, "incompatible fields in struct assignment"); }
--- a/libinterp/corefcn/quad.cc Wed Dec 02 14:41:32 2015 -0500 +++ b/libinterp/corefcn/quad.cc Wed Dec 02 16:54:13 2015 -0500 @@ -73,7 +73,7 @@ { tmp = quad_fcn->do_multi_index_op (1, args); } - catch (const octave_execution_exception& e) + catch (octave_execution_exception& e) { gripe_user_supplied_eval (e, "quad"); } @@ -111,7 +111,7 @@ { tmp = quad_fcn->do_multi_index_op (1, args); } - catch (const octave_execution_exception& e) + catch (octave_execution_exception& e) { gripe_user_supplied_eval (e, "quad"); }
--- a/libinterp/corefcn/rand.cc Wed Dec 02 14:41:32 2015 -0500 +++ b/libinterp/corefcn/rand.cc Wed Dec 02 16:54:13 2015 -0500 @@ -214,7 +214,7 @@ { iv = tmp.int_vector_value (true); } - catch (const octave_execution_exception& e) + catch (octave_execution_exception& e) { error (e, "%s: dimensions must be a scalar or array of integers", fcn); }
--- a/libinterp/corefcn/toplev.cc Wed Dec 02 14:41:32 2015 -0500 +++ b/libinterp/corefcn/toplev.cc Wed Dec 02 16:54:13 2015 -0500 @@ -1056,7 +1056,7 @@ { return_output = args(1).is_true (); } - catch (const octave_execution_exception& e) + catch (octave_execution_exception& e) { error (e, "system: RETURN_OUTPUT must be boolean value true or false"); }
--- a/libinterp/dldfcn/__eigs__.cc Wed Dec 02 14:41:32 2015 -0500 +++ b/libinterp/dldfcn/__eigs__.cc Wed Dec 02 16:54:13 2015 -0500 @@ -62,7 +62,7 @@ { tmp = eigs_fcn->do_multi_index_op (1, args); } - catch (const octave_execution_exception& e) + catch (octave_execution_exception& e) { gripe_user_supplied_eval (e, "eigs"); } @@ -102,7 +102,7 @@ { tmp = eigs_fcn->do_multi_index_op (1, args); } - catch (const octave_execution_exception& e) + catch (octave_execution_exception& e) { gripe_user_supplied_eval (e, "eigs"); }
--- a/libinterp/octave-value/ov-base.cc Wed Dec 02 14:41:32 2015 -0500 +++ b/libinterp/octave-value/ov-base.cc Wed Dec 02 16:54:13 2015 -0500 @@ -464,7 +464,7 @@ { \ d = double_value (frc_str_conv); \ } \ - catch (const octave_execution_exception& e) \ + catch (octave_execution_exception& e) \ { \ gripe_wrong_type_arg (e, "octave_base_value::" #F "_value ()", type_name ()); \ } \ @@ -502,7 +502,7 @@ { d = double_value (frc_str_conv); } - catch (const octave_execution_exception& e) + catch (octave_execution_exception& e) { gripe_wrong_type_arg (e, "octave_base_value::nint_value ()", type_name ()); }
--- a/libinterp/octave-value/ov.cc Wed Dec 02 14:41:32 2015 -0500 +++ b/libinterp/octave-value/ov.cc Wed Dec 02 16:54:13 2015 -0500 @@ -1873,7 +1873,7 @@ { \ retval = FCN (); \ } \ - catch (const octave_execution_exception& e) \ + catch (octave_execution_exception& e) \ { \ if (fmt) \ { \ @@ -2474,7 +2474,7 @@ { m_base = base.matrix_value (true); } - catch (const octave_execution_exception& e) + catch (octave_execution_exception& e) { error (e, "invalid base value in colon expression"); } @@ -2483,7 +2483,7 @@ { m_limit = limit.matrix_value (true); } - catch (const octave_execution_exception& e) + catch (octave_execution_exception& e) { error (e, "invalid limit value in colon expression"); } @@ -2494,7 +2494,7 @@ ? increment.matrix_value (true) : Matrix (1, 1, 1.0)); } - catch (const octave_execution_exception& e) + catch (octave_execution_exception& e) { error (e, "invalid increment value in colon expression"); }
--- a/libinterp/parse-tree/oct-parse.in.yy Wed Dec 02 14:41:32 2015 -0500 +++ b/libinterp/parse-tree/oct-parse.in.yy Wed Dec 02 16:54:13 2015 -0500 @@ -4508,7 +4508,7 @@ fcn = parse_fcn_file (file_full_name, file_name, "", "", require_file, true, false, false, warn_for); } - catch (const octave_execution_exception& e) + catch (octave_execution_exception& e) { error (e, "source: error sourcing file '%s'", file_full_name.c_str ()); } @@ -4648,7 +4648,7 @@ { maybe_missing_function_hook (name); } - catch (const octave_execution_exception& e) + catch (octave_execution_exception& e) { error (e, "feval: function '%s' not found", name.c_str ()); }
--- a/liboctave/cruft/misc/quit.h Wed Dec 02 14:41:32 2015 -0500 +++ b/liboctave/cruft/misc/quit.h Wed Dec 02 16:54:13 2015 -0500 @@ -98,12 +98,18 @@ m_stack_trace = st; } + virtual void set_stack_trace (void) + { + m_stack_trace = ""; + } + virtual std::string info (void) const { return m_stack_trace; } private: + std::string m_stack_trace; };