# HG changeset patch # User Rik # Date 1391899461 28800 # Node ID 96a4958130471a6ecaeb7e36d61a60313dcae4e4 # Parent d5aa615dcf4c139c4790614dc5252733da2205bb Don't put parent function in subfunction stack structure name (bug #41506). * debug.cc (do_dbstack): When returning a structure, call octave_call_stack::backtrace with print_subfn set to false. * toplev.h (octave_call_stack::backtrace): Create new 2 argument function signature which calls do_backtrace with print_subfn set to true. Create new 3 argument function signature which passes print_subfn argument through to do_backtrace. * toplev.cc (octave_call_stack::do_backtrace): Change function to accept 3rd argument, print_subfn, which decides whether the parent function should be printed in the name field of the backtrace. diff -r d5aa615dcf4c -r 96a495813047 libinterp/corefcn/debug.cc --- a/libinterp/corefcn/debug.cc Sat Feb 08 17:10:01 2014 -0500 +++ b/libinterp/corefcn/debug.cc Sat Feb 08 14:44:21 2014 -0800 @@ -1224,10 +1224,9 @@ if (! error_state) { - octave_map stk = octave_call_stack::backtrace (nskip, curr_frame); - if (nargout == 0) { + octave_map stk = octave_call_stack::backtrace (nskip, curr_frame); octave_idx_type nframes_to_display = stk.numel (); if (nframes_to_display > 0) @@ -1273,6 +1272,10 @@ } else { + octave_map stk = octave_call_stack::backtrace (nskip, + curr_frame, + false); + retval(1) = curr_frame < 0 ? 1 : curr_frame + 1; retval(0) = stk; } diff -r d5aa615dcf4c -r 96a495813047 libinterp/corefcn/toplev.cc --- a/libinterp/corefcn/toplev.cc Sat Feb 08 17:10:01 2014 -0500 +++ b/libinterp/corefcn/toplev.cc Sat Feb 08 14:44:21 2014 -0800 @@ -301,7 +301,8 @@ octave_map octave_call_stack::do_backtrace (size_t nskip, - octave_idx_type& curr_user_frame) const + octave_idx_type& curr_user_frame, + bool print_subfn) const { size_t user_code_frames = do_num_user_code_frames (curr_user_frame); @@ -340,7 +341,7 @@ file(k) = f->fcn_file_name (); std::string parent_fcn_name = f->parent_fcn_name (); - if (parent_fcn_name == std::string ()) + if (! print_subfn || parent_fcn_name == std::string ()) name(k) = f->name (); else name(k) = f->parent_fcn_name () + Vfilemarker + f->name (); diff -r d5aa615dcf4c -r 96a495813047 libinterp/corefcn/toplev.h --- a/libinterp/corefcn/toplev.h Sat Feb 08 17:10:01 2014 -0500 +++ b/libinterp/corefcn/toplev.h Sat Feb 08 14:44:21 2014 -0800 @@ -278,7 +278,16 @@ static octave_map backtrace (size_t nskip, octave_idx_type& curr_user_frame) { return instance_ok () - ? instance->do_backtrace (nskip, curr_user_frame) : octave_map (); + ? instance->do_backtrace (nskip, curr_user_frame, true) + : octave_map (); + } + + static octave_map backtrace (size_t nskip, octave_idx_type& curr_user_frame, + bool print_subfn) + { + return instance_ok () + ? instance->do_backtrace (nskip, curr_user_frame, print_subfn) + : octave_map (); } static octave_map empty_backtrace (void); @@ -414,7 +423,8 @@ } octave_map do_backtrace (size_t nskip, - octave_idx_type& curr_user_frame) const; + octave_idx_type& curr_user_frame, + bool print_subfn) const; bool do_goto_frame (size_t n, bool verbose);