Mercurial > octave
changeset 26975:de826e69a5ea
make breakpoints in classdef methods work (bug #45404, bug #46451)
* bp-table.h, bp-table.cc (bp_table::add_breakpoint): New argument,
CLASS_NAME. Change all uses. Pass class name on to
tree_evaluator::get_user_code.
* cdef-class.h, cdef-class.cc (cdef_class::get_method,
cdef_class::cdef_class_rep::get_method): New functions.
* cdef-manager.h, cdef-manager.cc (cdef_manager::find_method):
New function.
* pt-eval.h, pt-eval.cc (tree_evaluator::get_user_code): New argument,
CLASS_NAME. If given class name, look for classdef methods.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 26 Mar 2019 02:42:38 +0000 |
parents | aa50801747a9 |
children | eebf4b67f012 |
files | libgui/src/m-editor/file-editor-tab.cc libinterp/corefcn/debug.cc libinterp/octave-value/cdef-class.cc libinterp/octave-value/cdef-class.h libinterp/octave-value/cdef-manager.cc libinterp/octave-value/cdef-manager.h libinterp/parse-tree/bp-table.cc libinterp/parse-tree/bp-table.h libinterp/parse-tree/pt-eval.cc libinterp/parse-tree/pt-eval.h |
diffstat | 10 files changed, 54 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor-tab.cc Mon Mar 25 13:59:41 2019 -0700 +++ b/libgui/src/m-editor/file-editor-tab.cc Tue Mar 26 02:42:38 2019 +0000 @@ -1026,7 +1026,7 @@ { bp_table& bptab = __get_bp_table__ ("octave_qt_link::file_in_path"); - bptab.add_breakpoint (info.function_name, line_info, info.condition); + bptab.add_breakpoint (info.function_name, "", line_info, info.condition); } }
--- a/libinterp/corefcn/debug.cc Mon Mar 25 13:59:41 2019 -0700 +++ b/libinterp/corefcn/debug.cc Tue Mar 26 02:42:38 2019 +0000 @@ -196,7 +196,8 @@ if (symbol_name != "") { - retmap = bptab.add_breakpoint (symbol_name, lines, condition); + retmap = bptab.add_breakpoint (symbol_name, class_name, + lines, condition); retval = intmap_to_ov (retmap); } } @@ -247,7 +248,7 @@ for (octave_idx_type i = 0; i < line.numel (); i++) { lines [0] = line(i).double_value (); - bptab.add_breakpoint (name(i).string_value (), lines, + bptab.add_breakpoint (name(i).string_value (), "", lines, (use_cond ? cond(i).string_value () : unconditional));
--- a/libinterp/octave-value/cdef-class.cc Mon Mar 25 13:59:41 2019 -0700 +++ b/libinterp/octave-value/cdef-class.cc Tue Mar 26 02:42:38 2019 +0000 @@ -703,6 +703,18 @@ } octave_value + cdef_class::cdef_class_rep::get_method (const std::string& name) const + { + auto p = method_map.find (name); + + if (p == method_map.end ()) + return octave_value (); + + return p->second.get_function (); + } + + + octave_value cdef_class::cdef_class_rep::construct (const octave_value_list& args) { cdef_object obj = construct_object (args);
--- a/libinterp/octave-value/cdef-class.h Mon Mar 25 13:59:41 2019 -0700 +++ b/libinterp/octave-value/cdef-class.h Tue Mar 26 02:42:38 2019 +0000 @@ -112,6 +112,8 @@ return (type == '(' || type == '.'); } + octave_value get_method (const std::string& name) const; + octave_value construct (const octave_value_list& args); cdef_object construct_object (const octave_value_list& args); @@ -335,6 +337,11 @@ make_meta_class (interpreter& interp, tree_classdef *t, bool is_at_folder = false); + octave_value get_method (const std::string& nm) const + { + return get_rep ()->get_method (nm); + } + octave_function * get_method_function (const std::string& nm); octave_function * get_constructor_function (void)
--- a/libinterp/octave-value/cdef-manager.cc Mon Mar 25 13:59:41 2019 -0700 +++ b/libinterp/octave-value/cdef-manager.cc Tue Mar 26 02:42:38 2019 +0000 @@ -936,4 +936,13 @@ return pack; } + + octave_value + cdef_manager::find_method (const std::string& class_name, + const std::string& name) const + { + cdef_class cls = lookup_class (class_name); + + return cls.get_method (name); + } }
--- a/libinterp/octave-value/cdef-manager.h Mon Mar 25 13:59:41 2019 -0700 +++ b/libinterp/octave-value/cdef-manager.h Tue Mar 26 02:42:38 2019 +0000 @@ -130,6 +130,9 @@ cdef_package make_package (const std::string& nm, const std::string& parent = ""); + octave_value find_method (const std::string& class_name, + const std::string& name) const; + private: interpreter& m_interpreter;
--- a/libinterp/parse-tree/bp-table.cc Mon Mar 25 13:59:41 2019 -0700 +++ b/libinterp/parse-tree/bp-table.cc Tue Mar 26 02:42:38 2019 +0000 @@ -581,10 +581,11 @@ // Given file name fname, find the subfunction at line and create // a breakpoint there. Put the system into debug_mode. bp_table::intmap bp_table::add_breakpoint (const std::string& fname, + const std::string& class_name, const bp_table::intmap& line, const std::string& condition) { - octave_user_code *main_fcn = m_evaluator.get_user_code (fname); + octave_user_code *main_fcn = m_evaluator.get_user_code (fname, class_name); if (! main_fcn) error ("add_breakpoint: unable to find function '%s'\n", fname.c_str ());
--- a/libinterp/parse-tree/bp-table.h Mon Mar 25 13:59:41 2019 -0700 +++ b/libinterp/parse-tree/bp-table.h Tue Mar 26 02:42:38 2019 +0000 @@ -75,6 +75,7 @@ // Add a breakpoint at the nearest executable line. intmap add_breakpoint (const std::string& fname = "", + const std::string& class_name = "", const intmap& lines = intmap (), const std::string& condition = "");
--- a/libinterp/parse-tree/pt-eval.cc Mon Mar 25 13:59:41 2019 -0700 +++ b/libinterp/parse-tree/pt-eval.cc Tue Mar 26 02:42:38 2019 +0000 @@ -36,6 +36,7 @@ #include "bp-table.h" #include "call-stack.h" +#include "cdef-manager.h" #include "defun.h" #include "error.h" #include "errwarn.h" @@ -1345,7 +1346,8 @@ // current call stack. octave_user_code * - tree_evaluator::get_user_code (const std::string& fname) + tree_evaluator::get_user_code (const std::string& fname, + const std::string& class_name) { octave_user_code *user_code = nullptr; @@ -1373,7 +1375,7 @@ symbol_table& symtab = m_interpreter.get_symbol_table (); octave_value fcn; - size_t p2; + size_t p2 = std::string::npos; if (name[0] == '@') { @@ -1390,6 +1392,16 @@ fcn = symtab.find_method (method, dispatch_type); } + else if (! class_name.empty ()) + { + cdef_manager& cdm = m_interpreter.get_cdef_manager (); + + fcn = cdm.find_method (class_name, name); + + // If there is no classdef method, then try legacy classes. + if (fcn.is_undefined ()) + fcn = symtab.find_method (name, class_name); + } else { p2 = name.find ('>');
--- a/libinterp/parse-tree/pt-eval.h Mon Mar 25 13:59:41 2019 -0700 +++ b/libinterp/parse-tree/pt-eval.h Tue Mar 26 02:42:38 2019 +0000 @@ -481,7 +481,8 @@ std::list<std::string> variable_names (void) const; - octave_user_code * get_user_code (const std::string& fname = ""); + octave_user_code * get_user_code (const std::string& fname = "", + const std::string& class_name = ""); int max_recursion_depth (void) const { return m_max_recursion_depth; }