# HG changeset patch # User Markus Mützel # Date 1713544239 -7200 # Node ID 69eb4c27d8c80e8a21a96fc69cf76c0f27c30486 # Parent 761b404e9569423b235218bd014e074d6fab77db Emit error when trying to set breakpoint in non-existent method (bug #65610). * libinterp/corefcn/debug.cc (Fdbstop): Use a line number of -1 to indicate that the function was called without line number. * libinterp/parse-tree/bp-table.cc (octave_usercode::operator ()): Return nullptr if `dbstop` was called without line number on a classdef class without having explicitly specified a (valid) method name. (bp_table::add_breakpoints_in_function): Emit error if no function could be found with the specified name. Remove checks for valid pointer that are no longer needed. * test/classdef-debug/test-classdef-breakpoints.tst: Mark test as fixed. diff -r 761b404e9569 -r 69eb4c27d8c8 libinterp/corefcn/debug.cc --- a/libinterp/corefcn/debug.cc Thu Apr 18 19:43:23 2024 -0700 +++ b/libinterp/corefcn/debug.cc Fri Apr 19 18:30:39 2024 +0200 @@ -185,7 +185,7 @@ class_name, lines, condition); if (lines.size () == 0) - lines.insert (1); + lines.insert (-1); if (symbol_name != "") { diff -r 761b404e9569 -r 69eb4c27d8c8 libinterp/parse-tree/bp-table.cc --- a/libinterp/parse-tree/bp-table.cc Thu Apr 18 19:43:23 2024 -0700 +++ b/libinterp/parse-tree/bp-table.cc Fri Apr 19 18:30:39 2024 +0200 @@ -797,6 +797,9 @@ if (is_function ()) return find_fcn_by_line (m_fcn, line); + if (line < 0) + return nullptr; + return m_cls.get_method (line).user_code_value (true); } @@ -834,7 +837,7 @@ { if (m_methods_cache.empty ()) { - // Not the most effecient, but reuses code: + // Not the most efficient, but reuses code: const std::map& map = m_cls.get_method_map (false, true); for (auto iter = map.cbegin (); iter != map.cend (); ++iter) @@ -872,6 +875,10 @@ { octave_user_code *dbg_fcn = user_code (lineno); + if (! dbg_fcn) + error ("add_breakpoints_in_function: unable to find function '%s'\n", + fcn_ident.c_str ()); + // We've found the right (sub)function. Now insert the breakpoint. bp_lines line_info; line_info.insert (lineno); @@ -879,14 +886,13 @@ bp_lines ret_one; std::string ident = fcn_ident; - if (! user_code.is_function () && fcn_ident[0] != '@' && dbg_fcn) + if (! user_code.is_function () && fcn_ident[0] != '@') { // identifier of the form @class_name/method_name ident = "@" + fcn_ident + "/" + dbg_fcn->name (); } - if (dbg_fcn && add_breakpoint_1 (dbg_fcn, ident, line_info, - condition, ret_one)) + if (add_breakpoint_1 (dbg_fcn, ident, line_info, condition, ret_one)) { if (! ret_one.empty ()) { diff -r 761b404e9569 -r 69eb4c27d8c8 test/classdef-debug/test-classdef-breakpoints.tst --- a/test/classdef-debug/test-classdef-breakpoints.tst Thu Apr 18 19:43:23 2024 -0700 +++ b/test/classdef-debug/test-classdef-breakpoints.tst Fri Apr 19 18:30:39 2024 +0200 @@ -65,13 +65,12 @@ %! end_unwind_protect ## Try to add breakpoint in non-existent method -%!test <65610> +%!test <65610*> %! if (isguirunning ()) %! orig_show_dbg = __event_manager_gui_preference__ ("editor/show_dbg_file", %! "false"); %! endif %! unwind_protect -%! ## This should error. But it does not. %! fail ("dbstop @classdef_breakpoints/baz;", "unable to find function"); %! unwind_protect_cleanup %! dbclear classdef_breakpoints;