# HG changeset patch # User John W. Eaton # Date 1365038130 14400 # Node ID 16bfbf9136d31d14205398945b502dc6889c3c32 # Parent e1d92db3a715e4cbf9013cea642139bafd401dac avoid creating unnecessary octave_value objects for octave_link calls * octave-link.h (octave_linke::enter_debugger_event, octave_linke::exit_debugger_event, octave_linke::update_breakpoint, octave_linke::do_insert_debugger_pointer, octave_linke::do_delete_debugger_pointer, octave_linke::do_enter_debugger_event, octave_linke::do_exit_debugger_event, octave_linke::do_update_breakpoint): Pass file and line info as string and int instead of octave_value_list. Change all callers. * octave-qt-link.h, octave-qt-link.cc (octave_qt_link::do_insert_debugger_pointer, octave_qt_link::do_delete_debugger_pointer, octave_qt_link::do_enter_debugger_event, octave_qt_link::do_exit_debugger_event, octave_qt_link::do_update_breakpoint): Likewise. * debug.h, debug.cc (location_info): Delete. * input.cc (exit_debugger_handler): New function. (get_debug_input): Use it. diff -r e1d92db3a715 -r 16bfbf9136d3 libgui/src/octave-qt-link.cc --- a/libgui/src/octave-qt-link.cc Wed Apr 03 20:28:44 2013 -0400 +++ b/libgui/src/octave-qt-link.cc Wed Apr 03 21:15:30 2013 -0400 @@ -65,70 +65,24 @@ } void -octave_qt_link::do_insert_debugger_pointer (const octave_value_list& args) +octave_qt_link::do_insert_debugger_pointer (const std::string& file, int line) { if (event_listener) { - if (args.length () == 1) - { - octave_scalar_map m = args(0).scalar_map_value (); - - if (! error_state) - { - octave_value ov_file = m.getfield ("file"); - octave_value ov_line = m.getfield ("line"); - - std::string file = ov_file.string_value (); - int line = ov_line.int_value (); + event_listener->insert_debugger_pointer (file, line); - if (! error_state) - { - event_listener->insert_debugger_pointer (file, line); - - do_process_events (); - } - else - ::error ("invalid struct in debug pointer callback"); - } - else - ::error ("expecting struct in debug pointer callback"); - } - else - ::error ("invalid call to debug pointer callback"); + do_process_events (); } } void -octave_qt_link::do_delete_debugger_pointer (const octave_value_list& args) +octave_qt_link::do_delete_debugger_pointer (const std::string& file, int line) { if (event_listener) { - if (args.length () == 1) - { - octave_scalar_map m = args(0).scalar_map_value (); - - if (! error_state) - { - octave_value ov_file = m.getfield ("file"); - octave_value ov_line = m.getfield ("line"); - - std::string file = ov_file.string_value (); - int line = ov_line.int_value (); + event_listener->delete_debugger_pointer (file, line); - if (! error_state) - { - event_listener->delete_debugger_pointer (file, line); - - do_process_events (); - } - else - ::error ("invalid struct in debug pointer callback"); - } - else - ::error ("expecting struct in debug pointer callback"); - } - else - ::error ("invalid call to debug pointer callback"); + do_process_events (); } } @@ -145,49 +99,26 @@ } void -octave_qt_link::do_enter_debugger_event (const octave_value_list& args) +octave_qt_link::do_enter_debugger_event (const std::string& file, int line) { - do_insert_debugger_pointer (args); + do_insert_debugger_pointer (file, line); } void -octave_qt_link::do_exit_debugger_event (const octave_value_list& args) +octave_qt_link::do_exit_debugger_event (const std::string& file, int line) { - do_delete_debugger_pointer (args); + do_delete_debugger_pointer (file, line); } void octave_qt_link::do_update_breakpoint (bool insert, - const octave_value_list& args) + const std::string& file, int line) { if (event_listener) { - if (args.length () == 1) - { - octave_scalar_map m = args(0).scalar_map_value (); - - if (! error_state) - { - octave_value ov_file = m.getfield ("file"); - octave_value ov_line = m.getfield ("line"); - - std::string file = ov_file.string_value (); - int line = ov_line.int_value (); + event_listener->update_dbstop_marker (insert, file, line); - if (! error_state) - { - event_listener->update_dbstop_marker (insert, file, line); - - do_process_events (); - } - else - ::error ("invalid struct in dbstop marker callback"); - } - else - ::error ("expecting struct in dbstop marker callback"); - } - else - ::error ("invalid call to dbstop marker callback"); + do_process_events (); } } diff -r e1d92db3a715 -r 16bfbf9136d3 libgui/src/octave-qt-link.h --- a/libgui/src/octave-qt-link.h Wed Apr 03 20:28:44 2013 -0400 +++ b/libgui/src/octave-qt-link.h Wed Apr 03 21:15:30 2013 -0400 @@ -57,16 +57,16 @@ void do_update_history (void); - void do_insert_debugger_pointer (const octave_value_list& args); - void do_delete_debugger_pointer (const octave_value_list& args); + void do_insert_debugger_pointer (const std::string& file, int line); + void do_delete_debugger_pointer (const std::string& file, int line); void do_pre_input_event (void); void do_post_input_event (void); - void do_enter_debugger_event (const octave_value_list& args); - void do_exit_debugger_event (const octave_value_list& args); + void do_enter_debugger_event (const std::string& file, int line); + void do_exit_debugger_event (const std::string& file, int line); - void do_update_breakpoint (bool insert, const octave_value_list& args); + void do_update_breakpoint (bool insert, const std::string& file, int line); void do_edit_file (const octave_value_list& args); diff -r e1d92db3a715 -r 16bfbf9136d3 libinterp/interp-core/octave-link.h --- a/libinterp/interp-core/octave-link.h Wed Apr 03 20:28:44 2013 -0400 +++ b/libinterp/interp-core/octave-link.h Wed Apr 03 21:15:30 2013 -0400 @@ -140,23 +140,23 @@ instance->do_post_input_event (); } - static void enter_debugger_event (const octave_value_list& args) + static void enter_debugger_event (const std::string& file, int line) { if (instance_ok ()) - instance->do_enter_debugger_event (args); + instance->do_enter_debugger_event (file, line); } - static void exit_debugger_event (const octave_value_list& args) + static void exit_debugger_event (const std::string& file, int line) { if (instance_ok ()) - instance->do_exit_debugger_event (args); + instance->do_exit_debugger_event (file, line); } static void - update_breakpoint (bool insert, const octave_value_list& args) + update_breakpoint (bool insert, const std::string& file, int line) { if (instance_ok ()) - instance->do_update_breakpoint (insert, args); + instance->do_update_breakpoint (insert, file, line); } static void @@ -231,17 +231,20 @@ virtual void do_update_history (void) = 0; - virtual void do_insert_debugger_pointer (const octave_value_list& args) = 0; - virtual void do_delete_debugger_pointer (const octave_value_list& args) = 0; + virtual void + do_insert_debugger_pointer (const std::string& file, int line) = 0; + + virtual void + do_delete_debugger_pointer (const std::string& file, int line) = 0; virtual void do_pre_input_event (void) = 0; virtual void do_post_input_event (void) = 0; - virtual void do_enter_debugger_event (const octave_value_list& args) = 0; - virtual void do_exit_debugger_event (const octave_value_list& args) = 0; + virtual void do_enter_debugger_event (const std::string& file, int line) = 0; + virtual void do_exit_debugger_event (const std::string& file, int line) = 0; virtual void do_update_breakpoint (bool insert, - const octave_value_list& args) = 0; + const std::string& file, int line) = 0; virtual void do_edit_file (const octave_value_list& args) = 0; }; diff -r e1d92db3a715 -r 16bfbf9136d3 libinterp/interpfcn/debug.cc --- a/libinterp/interpfcn/debug.cc Wed Apr 03 20:28:44 2013 -0400 +++ b/libinterp/interpfcn/debug.cc Wed Apr 03 21:15:30 2013 -0400 @@ -186,17 +186,6 @@ return dbg_fcn; } -octave_value -location_info (const std::string& fname, int line) -{ - octave_scalar_map location_info_map; - - location_info_map.setfield ("file", fname); - location_info_map.setfield ("line", line); - - return octave_value (location_info_map); -} - static void parse_dbfunction_params (const char *who, const octave_value_list& args, std::string& symbol_name, bp_table::intmap& lines) @@ -318,12 +307,7 @@ std::string file = dbg_fcn->fcn_file_name (); if (! file.empty ()) - { - octave_value_list - args (location_info (file, retval[i])); - - octave_link::update_breakpoint (true, args); - } + octave_link::update_breakpoint (true, file, retval[i]); } } } @@ -378,12 +362,7 @@ cmds->delete_breakpoint (lineno); if (! file.empty ()) - { - octave_value_list - args (location_info (file, lineno)); - - octave_link::update_breakpoint (false, args); - } + octave_link::update_breakpoint (false, file, lineno); } } @@ -432,11 +411,7 @@ retval[i] = lineno; if (! file.empty ()) - { - octave_value_list args (location_info (file, lineno)); - - octave_link::update_breakpoint (false, args); - } + octave_link::update_breakpoint (false, file, lineno); } bp_set_iterator it = bp_set.find (fname); diff -r e1d92db3a715 -r 16bfbf9136d3 libinterp/interpfcn/debug.h --- a/libinterp/interpfcn/debug.h Wed Apr 03 20:28:44 2013 -0400 +++ b/libinterp/interpfcn/debug.h Wed Apr 03 21:15:30 2013 -0400 @@ -131,6 +131,4 @@ extern std::string get_file_line (const std::string& fname, size_t line); -extern octave_value location_info (const std::string& fname, int line); - #endif diff -r e1d92db3a715 -r 16bfbf9136d3 libinterp/interpfcn/input.cc --- a/libinterp/interpfcn/input.cc Wed Apr 03 20:28:44 2013 -0400 +++ b/libinterp/interpfcn/input.cc Wed Apr 03 21:15:30 2013 -0400 @@ -455,6 +455,12 @@ } static void +exit_debugger_handler (const std::pair& arg) +{ + octave_link::exit_debugger_event (arg.first, arg.second); +} + +static void get_debug_input (const std::string& prompt) { unwind_protect frame; @@ -501,13 +507,10 @@ if (have_file) { - octave_value loc_info = location_info (nm, curr_debug_line); - - octave_value_list args (loc_info); + octave_link::enter_debugger_event (nm, curr_debug_line); - octave_link::enter_debugger_event (args); - - frame.add_fcn (octave_link::exit_debugger_event, args); + frame.add_fcn (exit_debugger_handler, + std::pair (nm, curr_debug_line)); std::string line_buf = get_file_line (nm, curr_debug_line);