# HG changeset patch # User Rik # Date 1390601425 28800 # Node ID 7cb745caaab5254e70dfc18b43d525798d3f1f23 # Parent bb162f81881d066f642be50fb4d52880bb2991db Allow dbstop to set breakpoints outside of the function currently being debugged. * debug.cc (parse_dbfunction_params): If first input is a string, use atoi to decide whether it is a real string (function name) or a line number for a breakpoint passed in as a string. If it is a line number, grab the function name from the function currently being debugged. Issue an error message about struct input not being implemented if a struct is found. Skip struct inputs when they are encountered in the list of breakpoint line numbers. * debug.cc (Fdbstatus): Add note about breakpoint list being trimmed when in debug mode inside a function. diff -r bb162f81881d -r 7cb745caaab5 libinterp/corefcn/debug.cc --- a/libinterp/corefcn/debug.cc Fri Jan 24 12:48:22 2014 -0800 +++ b/libinterp/corefcn/debug.cc Fri Jan 24 14:10:25 2014 -0800 @@ -207,28 +207,47 @@ if (args.length () == 0) return; - // If we are already in a debugging function. - if (octave_call_stack::caller_user_code ()) - { - idx = 0; - symbol_name = get_user_code ()->name (); - } + if (args(0).is_string ()) + { + // string could be function name or line number + int isint = atoi (args(0).string_value ().c_str ()); + + if (error_state) + return; + + if (isint == 0) + { + // It was a function name + symbol_name = args(0).string_value (); + if (error_state) + return; + idx = 1; + } + else + { + // It was a line number. Need to get function name from debugger. + if (Vdebugging) + { + symbol_name = get_user_code ()->name (); + idx = 0; + } + else + { + error ("%s: no function specified", who); + } + } + } else if (args(0).is_map ()) { - // Problem because parse_dbfunction_params() can only pass out a - // single function - } - else if (args(0).is_string ()) - { - symbol_name = args(0).string_value (); - if (error_state) - return; - idx = 1; + // This is a problem because parse_dbfunction_params() + // can only pass out a single function. + error ("%s: struct input not implemented", who); + return; } else error ("%s: invalid parameter specified", who); - for (int i = idx; i < nargin; i++ ) + for (int i = idx; i < nargin; i++) { if (args(i).is_string ()) { @@ -238,7 +257,7 @@ lines[list_idx++] = line; } else if (args(i).is_map ()) - octave_stdout << who << ": accepting a struct" << std::endl; + octave_stdout << who << ": skipping struct input" << std::endl; else { const NDArray arg = args(i).array_value (); @@ -724,6 +743,9 @@ A line number, or vector of line numbers, with a breakpoint.\n\ @end table\n\ \n\ +Note: When @code{dbstatus} is called from the debug prompt within a function,\n\ +the list of breakpoints is automatically trimmed to the breakpoints in the\n\ +current function.\n\ @seealso{dbclear, dbwhere}\n\ @end deftypefn") {