changeset 32406:d82d9e06fc50

dbclear: Support clearing breakpoint by method name (bug #46451). * libinterp/parse-tree/bp-table.h (remove_breakpoint_from_function, remove_all_breakpoints_from_function): Add class name to input arguments. * libinterp/parse-tree/bp-table.cc (remove_breakpoint_from_function, remove_all_breakpoints_from_function): Optionally, get handle to method in classdef from evaluator. * libinterp/corefcn/debug.cc (Fdbclear): Pass class name when removing breakpoints. * libinterp/corefcn/fcn-info (out_of_date_check): Adapt for changed function prototype.
author paulo <paulo.fernando.silva@gmail.com>
date Sun, 08 Oct 2023 11:32:22 +0200
parents f8b21920fe91
children 818698c4f296
files libinterp/corefcn/debug.cc libinterp/corefcn/fcn-info.cc libinterp/parse-tree/bp-table.cc libinterp/parse-tree/bp-table.h
diffstat 4 files changed, 16 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/debug.cc	Fri Oct 13 14:59:26 2023 +0200
+++ b/libinterp/corefcn/debug.cc	Sun Oct 08 11:32:22 2023 +0200
@@ -321,7 +321,7 @@
   else
     {
       if (symbol_name != "")
-        bptab.remove_breakpoints_from_function (symbol_name, lines);
+        bptab.remove_breakpoints_from_function (symbol_name, class_name, lines);
     }
 
   // If we remove a breakpoint, we also need to reset debug_mode.
--- a/libinterp/corefcn/fcn-info.cc	Fri Oct 13 14:59:26 2023 +0200
+++ b/libinterp/corefcn/fcn-info.cc	Sun Oct 08 11:32:22 2023 +0200
@@ -644,7 +644,7 @@
                       bp_table& bptab = __get_bp_table__ ();
 
                       bptab.remove_all_breakpoints_from_function (canonical_nm,
-                          true);
+                          "", true);
                     }
                 }
             }
--- a/libinterp/parse-tree/bp-table.cc	Fri Oct 13 14:59:26 2023 +0200
+++ b/libinterp/parse-tree/bp-table.cc	Sun Oct 08 11:32:22 2023 +0200
@@ -899,28 +899,30 @@
 }
 
 int
-bp_table::remove_breakpoint_from_function (const std::string& fname, int line)
+bp_table::remove_breakpoint_from_function (const std::string& fname,
+                                           const std::string& cname, int line)
 {
   bp_lines line_info;
   line_info.insert (line);
 
-  return remove_breakpoints_from_function (fname, line_info);
+  return remove_breakpoints_from_function (fname, cname, line_info);
 }
 
 int
 bp_table::remove_breakpoints_from_function (const std::string& fname,
+                                            const std::string& cname,
                                             const bp_table::bp_lines& lines)
 {
   int retval = 0;
 
   if (lines.empty ())
     {
-      bp_lines results = remove_all_breakpoints_from_function (fname);
+      bp_lines results = remove_all_breakpoints_from_function (fname, cname);
       retval = results.size ();
     }
   else
     {
-      octave_user_code *dbg_fcn = m_evaluator.get_user_code (fname);
+      octave_user_code *dbg_fcn = m_evaluator.get_user_code (fname, cname);
       user_code_provider user_code (fname, dbg_fcn);
 
       if (user_code.is_valid ())
@@ -994,11 +996,12 @@
 
 bp_table::bp_lines
 bp_table::remove_all_breakpoints_from_function (const std::string& fname,
+                                                const std::string& cname,
                                                 bool silent)
 {
   bp_lines retval;
 
-  octave_user_code *fcn = m_evaluator.get_user_code (fname);
+  octave_user_code *fcn = m_evaluator.get_user_code (fname, cname);
   user_code_provider user_code (fname, fcn);
 
   if (user_code.is_valid ())
@@ -1043,7 +1046,7 @@
   if (! info.ok ())
     return 0;
 
-  return remove_breakpoint_from_function (info.fcn (), line);
+  return remove_breakpoint_from_function (info.fcn (), "", line);
 }
 
 int
@@ -1058,7 +1061,7 @@
   if (! info.ok ())
     return 0;
 
-  return remove_breakpoints_from_function (info.fcn (), lines);
+  return remove_breakpoints_from_function (info.fcn (), "", lines);
 }
 
 bp_table::bp_lines
@@ -1073,7 +1076,7 @@
   if (! info.ok ())
     return bp_lines ();
 
-  return remove_all_breakpoints_from_function (info.fcn (), silent);
+  return remove_all_breakpoints_from_function (info.fcn (), "", silent);
 }
 
 void bp_table::remove_all_breakpoints ()
--- a/libinterp/parse-tree/bp-table.h	Fri Oct 13 14:59:26 2023 +0200
+++ b/libinterp/parse-tree/bp-table.h	Sun Oct 08 11:32:22 2023 +0200
@@ -107,14 +107,17 @@
 
   // Remove a breakpoint from the given line in file.
   int remove_breakpoint_from_function (const std::string& fname = "",
+                                       const std::string& cname = "",
                                        int line = 1);
 
   // Remove a set of breakpoints from the given lines in file.
   int remove_breakpoints_from_function (const std::string& fname = "",
+                                        const std::string& cname = "",
                                         const bp_lines& lines = bp_lines ());
 
   // Remove all the breakpoints in a specified function.
   bp_lines remove_all_breakpoints_from_function (const std::string& fname,
+                                                 const std::string& cname = "",
                                                  bool silent = false);
 
   // Remove a breakpoint from the given line in file.