Mercurial > octave
view test/classdef-debug/test_classdef_breakpoints.tst @ 33431:af2b017a5a7a stable
Fix segmentation fault when trying to set breakpoint in non-existent method (bug #65610).
* libinterp/parse-tree/pt-eval.cc (tree_evaluator::get_user_code): Check if
classdef method with given name exists before trying to dereference
representation.
* test/classdef-debug/test_classdef_breakpints.tst: Add tests for setting
breakpoints using method names.
* etc/NEWS.9.md: Add note.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Thu, 18 Apr 2024 20:59:19 +0200 |
parents | 175eb207d9d9 |
children |
line wrap: on
line source
## Test script for setting breakpoints in classdefs ## using line numbers or method names. %!function assert_dbstatus (bp0) %! dbs = dbstatus (); %! bp = [dbs(:).line]; %! assert (length (bp) == length (bp0), %! 'Number of breakpoints set must match'); %! if (length (bp) != 0) %! assert (sort (bp) == bp0, 'Breakpoint line numbers must be equal'); %! endif %!endfunction ## Set breakpoints by line numbers %!test <*46451> %! if (isguirunning ()) %! orig_show_dbg = __event_manager_gui_preference__ ("editor/show_dbg_file", %! "false"); %! endif %! unwind_protect %! ## Add breakpoints in different member functions using line numbers. %! dbstop classdef_breakpoints 13 7 10; %! assert_dbstatus ([7, 10, 13]); %! %! ## Remove one breakpoint and confirm the others remain. %! dbclear classdef_breakpoints 10; %! assert_dbstatus ([7, 13]); %! %! ## Clear all breakpoints, none should be left. %! dbclear classdef_breakpoints; %! assert_dbstatus ([]); %! unwind_protect_cleanup %! if (isguirunning ()) %! __event_manager_gui_preference__ ("editor/show_dbg_file", orig_show_dbg); %! endif %! end_unwind_protect ## Set breakpoints by method name %!test %! if (isguirunning ()) %! orig_show_dbg = __event_manager_gui_preference__ ("editor/show_dbg_file", %! "false"); %! endif %! unwind_protect %! ## Add breakpoint in constructor %! dbstop @classdef_breakpoints/classdef_breakpoints; %! assert_dbstatus ([7]); %! %! ## Add breakpoints in methods. %! dbstop @classdef_breakpoints/foo; %! dbstop @classdef_breakpoints/bar; %! assert_dbstatus ([7, 10, 13]); %! %! ## Remove breakpoint from one method. %! dbclear @classdef_breakpoints/foo; %! assert_dbstatus ([7, 13]); %! %! ## Clear all breakpoints, none should be left. %! dbclear classdef_breakpoints; %! assert_dbstatus ([]); %! unwind_protect_cleanup %! if (isguirunning ()) %! __event_manager_gui_preference__ ("editor/show_dbg_file", orig_show_dbg); %! endif %! end_unwind_protect ## Try to add breakpoint in non-existent method %!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; %! if (isguirunning ()) %! __event_manager_gui_preference__ ("editor/show_dbg_file", orig_show_dbg); %! endif %! end_unwind_protect %!test <46451> %! if (isguirunning ()) %! orig_show_dbg = __event_manager_gui_preference__ ("editor/show_dbg_file", %! "false"); %! endif %! unwind_protect %! ## Add breakpoint in local function. %! dbstop classdef_breakpoints 19; %! assert_dbstatus ([20]); %! unwind_protect_cleanup %! if (isguirunning ()) %! __event_manager_gui_preference__ ("editor/show_dbg_file", orig_show_dbg); %! endif %! end_unwind_protect