comparison libinterp/interpfcn/debug.cc @ 16596:645672f1c873

handle setting breakpoints in subfunctions in GUI editor * symtab.h (symbol_table::subfunctions_defined_in_scope): Now public. * debug.h, debug.cc (bp_table::do_add_breakpoint_1): New function. (bp_table::do_add_breakpoint): Handle subfunctions. * ov-usr-fcn.h, ov-usr-fcn.cc (octave_user_code::subfunctions, octave_user_function::subfunctions): New functions. * pt-bp.h (tree_breakpoint::get_line): Return 0 if line wasn't found.
author John W. Eaton <jwe@octave.org>
date Tue, 30 Apr 2013 14:32:16 -0400
parents f3a63fdbd725
children de91b1621260
comparison
equal deleted inserted replaced
16594:3ce0c312a40b 16596:645672f1c873
272 } 272 }
273 273
274 return retval; 274 return retval;
275 } 275 }
276 276
277 bool
278 bp_table::do_add_breakpoint_1 (octave_user_code *fcn,
279 const std::string& fname,
280 const bp_table::intmap& line,
281 bp_table::intmap& retval)
282 {
283 bool found = false;
284
285 tree_statement_list *cmds = fcn->body ();
286
287 std::string file = fcn->fcn_file_name ();
288
289 if (cmds)
290 {
291 retval = cmds->add_breakpoint (file, line);
292
293 for (intmap_iterator p = retval.begin (); p != retval.end (); p++)
294 {
295 if (p->second != 0)
296 {
297 bp_set.insert (fname);
298 found = true;
299 break;
300 }
301 }
302 }
303
304 return found;
305 }
306
277 bp_table::intmap 307 bp_table::intmap
278 bp_table::do_add_breakpoint (const std::string& fname, 308 bp_table::do_add_breakpoint (const std::string& fname,
279 const bp_table::intmap& line) 309 const bp_table::intmap& line)
280 { 310 {
281 intmap retval; 311 intmap retval;
282 312
283 octave_user_code *dbg_fcn = get_user_code (fname); 313 octave_user_code *dbg_fcn = get_user_code (fname);
284 314
285 if (dbg_fcn) 315 if (dbg_fcn)
286 { 316 {
287 tree_statement_list *cmds = dbg_fcn->body (); 317 if (! do_add_breakpoint_1 (dbg_fcn, fname, line, retval))
288 318 {
289 std::string file = dbg_fcn->fcn_file_name (); 319 typedef std::map<std::string, octave_value>::const_iterator
290 320 subfunction_map_const_iterator;
291 if (cmds) 321
292 { 322 std::map<std::string, octave_value> subfcns
293 retval = cmds->add_breakpoint (file, line); 323 = dbg_fcn->subfunctions ();
294 324
295 for (intmap_iterator p = retval.begin (); p != retval.end (); p++) 325 for (subfunction_map_const_iterator p = subfcns.begin ();
326 p != subfcns.end (); p++)
296 { 327 {
297 if (p->second != 0) 328 octave_user_code *dbg_subfcn = p->second.user_code_value ();
298 { 329
299 bp_set.insert (fname); 330 if (do_add_breakpoint_1 (dbg_subfcn, fname, line, retval))
300 break; 331 break;
301 }
302 } 332 }
303 } 333 }
304 } 334 }
305 else 335 else
306 error ("add_breakpoint: unable to find the requested function\n"); 336 error ("add_breakpoint: unable to find the requested function\n");