Skip to content

Commit

Permalink
Overhaul handling of breakpoints in classdef methods (bug #46451).
Browse files Browse the repository at this point in the history
* libinterp/parse-tree/bp-table.h (bp_table::add_breakpoint_in_function,
bp_table::add_breakpoints_in_function,
bp_table::remove_breakpoint_from_function,
bp_table::remove_breakpoints_from_function): Remove separate argument for class
name. Use identifiers like "@class_name/method_name" instead.
* libinterp/parse-tree/bp-table.cc (user_code_provider): Extract class name
from function identifier.
(bp_table::add_breakpoint_in_file, bp_table::add_breakpoints_in_file): Create
function identifier for method in class.
(remaining functions): Adapt for those changes. Rename argument "fname" to
"fcn_ident" for clarity.
* libinterp/parse-tree/pt-eval.cc, pt-eval.h (tree_evaluator::get_user_code):
Remove input argument "class_name". Use similar code and identifiers to get
methods of classdef and legacy classes.
* libinterp/corefcn/debug.cc (Fdbstop, Fdbclear): Create function identifier
for method in class.
* libinterp/fcn-info.cc (out_of_date_check): Remove class_name argument of
"remove_all_breakpoints_from_function".
  • Loading branch information
mmuetzel committed Oct 15, 2023
1 parent d5b37fc commit 14fe836
Show file tree
Hide file tree
Showing 6 changed files with 129 additions and 88 deletions.
43 changes: 34 additions & 9 deletions libinterp/corefcn/debug.cc
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,14 @@ debug_on_interrupt}

if (symbol_name != "")
{
retmap = bptab.add_breakpoints_in_function (symbol_name, class_name,
lines, condition);
std::string fcn_ident;
if (class_name.empty ())
fcn_ident = symbol_name;
else
fcn_ident = "@" + class_name + "/" + symbol_name;

retmap = bptab.add_breakpoints_in_function (fcn_ident, lines,
condition);
retval = bp_lines_to_ov (retmap);
}
}
Expand Down Expand Up @@ -242,7 +248,7 @@ debug_on_interrupt}
lines.clear ();
lines.insert (line(i).int_value ());
bptab.add_breakpoints_in_function (name(i).string_value (),
"", lines,
lines,
(use_cond
? cond(i).string_value ()
: unconditional));
Expand Down Expand Up @@ -318,10 +324,15 @@ files.
bptab.remove_all_breakpoints ();
bptab.dbclear_all_signals ();
}
else
else if (symbol_name != "")
{
if (symbol_name != "")
bptab.remove_breakpoints_from_function (symbol_name, class_name, lines);
std::string fcn_ident;
if (class_name.empty ())
fcn_ident = symbol_name;
else
fcn_ident = "@" + class_name + "/" + symbol_name;

bptab.remove_breakpoints_from_function (fcn_ident, lines);
}

// If we remove a breakpoint, we also need to reset debug_mode.
Expand Down Expand Up @@ -538,13 +549,27 @@ The @qcode{"warn"} field is set similarly by @code{dbstop if warning}.
%! dbstop @audioplayer/set 75;
%! dbstop quantile>__quantile__;
%! dbstop ls;
%! s = dbstatus;
%! dbstop in inputParser at addOptional;
%! dbstop in inputParser at 285;
%! s = dbstatus ();
%! dbclear all;
%! ## For Matlab compatibility, the following name should be:
%! ## audioplayer.set>setproperty
%! assert (s(1).name, "@audioplayer/set>setproperty");
%! ## For Matlab compatibility, the following name should be:
%! ## ftp.dir
%! assert (s(2).name, "@ftp/dir");
%! assert (s(3).name, "ls");
%! assert (s(4).name, "quantile>__quantile__");
%! assert (s(2).file(end-10:end), [filesep "@ftp" filesep "dir.m"]);
%! ## For Matlab compatibility, the following two names should be:
%! ## inputParser.inputParser>inputParser.addOptional
%! assert (s(3).name, "@inputParser/addOptional");
%! assert (s(3).line, 278);
%! assert (s(4).name, "@inputParser/addOptional");
%! assert (s(4).line, 285);
%! assert (s(5).name, "ls");
%! assert (s(6).name, "quantile>__quantile__");
%! s = dbstatus ();
%! assert (isempty (s));
%! unwind_protect_cleanup
%! if (isguirunning ())
%! __event_manager_gui_preference__ ("editor/show_dbg_file", orig_show_dbg);
Expand Down
2 changes: 1 addition & 1 deletion libinterp/corefcn/fcn-info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ out_of_date_check (octave_value& function,
bp_table& bptab = __get_bp_table__ ();

bptab.remove_all_breakpoints_from_function (canonical_nm,
"", true);
true);
}
}
}
Expand Down
Loading

0 comments on commit 14fe836

Please sign in to comment.