comparison src/debug.cc @ 9183:94ae487acd1b

use set instead of map to keep track of debugger breakpoints
author jpswensen@compsci34-754-2010.compscidhcp.jhu.edu
date Tue, 05 May 2009 15:10:25 -0400
parents 51dc9691f23f
children 610bf90fce2a
comparison
equal deleted inserted replaced
9182:23af5910e5f5 9183:94ae487acd1b
275 int lineno = p->second; 275 int lineno = p->second;
276 276
277 retval[i] = cmds->set_breakpoint (lineno); 277 retval[i] = cmds->set_breakpoint (lineno);
278 278
279 if (retval[i] != 0) 279 if (retval[i] != 0)
280 bp_map[fname] = dbg_fcn; 280 {
281 bp_set.insert (fname);
282 }
281 } 283 }
282 } 284 }
283 } 285 }
284 } 286 }
285 else 287 else
326 cmds->delete_breakpoint (p->second); 328 cmds->delete_breakpoint (p->second);
327 } 329 }
328 330
329 results = cmds->list_breakpoints (); 331 results = cmds->list_breakpoints ();
330 332
331 breakpoint_map_iterator it = bp_map.find (fname); 333 bp_set_iterator it = bp_set.find (fname);
332 334 if (results.length () == 0 && it != bp_set.end ())
333 if (results.length () == 0 && it != bp_map.end ()) 335 bp_set.erase (it);
334 bp_map.erase (it); 336
335 } 337 }
336 338
337 retval = results.length (); 339 retval = results.length ();
338 } 340 }
339 } 341 }
368 int lineno = static_cast<int> (bkpts(i).int_value ()); 370 int lineno = static_cast<int> (bkpts(i).int_value ());
369 cmds->delete_breakpoint (lineno); 371 cmds->delete_breakpoint (lineno);
370 retval[i] = lineno; 372 retval[i] = lineno;
371 } 373 }
372 374
373 breakpoint_map_iterator it = bp_map.find (fname); 375 bp_set_iterator it = bp_set.find (fname);
374 376 if (it != bp_set.end ())
375 if (it != bp_map.end ()) 377 bp_set.erase (it);
376 bp_map.erase (it); 378
377 } 379 }
378 } 380 }
379 else if (! silent) 381 else if (! silent)
380 error ("remove_all_breakpoint_in_file: " 382 error ("remove_all_breakpoint_in_file: "
381 "unable to find the function requested\n"); 383 "unable to find the function requested\n");
386 } 388 }
387 389
388 void 390 void
389 bp_table::do_remove_all_breakpoints (void) 391 bp_table::do_remove_all_breakpoints (void)
390 { 392 {
391 for (const_breakpoint_map_iterator it = bp_map.begin (); 393 for (const_bp_set_iterator it = bp_set.begin (); it != bp_set.end (); it++)
392 it != bp_map.end (); it++) 394 remove_all_breakpoints_in_file (*it);
393 remove_all_breakpoints_in_file (it->first); 395
394 396
395 tree_evaluator::debug_mode = bp_table::have_breakpoints (); 397 tree_evaluator::debug_mode = bp_table::have_breakpoints ();
396 } 398 }
397 399
398 std::string 400 std::string
417 bp_table::fname_line_map 419 bp_table::fname_line_map
418 bp_table::do_get_breakpoint_list (const octave_value_list& fname_list) 420 bp_table::do_get_breakpoint_list (const octave_value_list& fname_list)
419 { 421 {
420 fname_line_map retval; 422 fname_line_map retval;
421 423
422 // Clear the breakpoints in the function if it has been updated. 424 for (bp_set_iterator it = bp_set.begin (); it != bp_set.end (); it++)
423 // FIXME: This is a bad way of doing this, but I can't think of another. The
424 // problem is due to the fact that out_of_date_check(...) calls
425 // remove_breakpoints_in_file(...), which in turn modifies bp_map while we are
426 // in the middle of iterating through it.
427
428 std::list<octave_user_code*> usercode_list;
429
430 for (breakpoint_map_iterator it = bp_map.begin (); it != bp_map.end (); it++)
431 usercode_list.push_back (it->second);
432
433 for (std::list<octave_user_code*>::iterator it = usercode_list.begin ();
434 it != usercode_list.end (); it++)
435 out_of_date_check (*it);
436
437
438 // Iterate through each of the files in the map and get the
439 // name and list of breakpoints.
440 for (breakpoint_map_iterator it = bp_map.begin (); it != bp_map.end (); it++)
441 { 425 {
442 if (fname_list.length () == 0 426 if (fname_list.length () == 0
443 || do_find_bkpt_list (fname_list, it->first) != "") 427 || do_find_bkpt_list (fname_list, *it) != "")
444 { 428 {
445 octave_user_code *f = it->second; 429 octave_user_code *f = get_user_code (*it);
446 tree_statement_list *cmds = f->body (); 430
447 431 if (f)
448 if (cmds)
449 { 432 {
450 octave_value_list bkpts = cmds->list_breakpoints (); 433 tree_statement_list *cmds = f->body ();
451 434
452 octave_idx_type len = bkpts.length (); 435 if (cmds)
453
454 if (len > 0)
455 { 436 {
456 bp_table::intmap bkpts_vec; 437 octave_value_list bkpts = cmds->list_breakpoints ();
457 438 octave_idx_type len = bkpts.length ();
458 for (int i = 0; i < len; i++) 439
459 bkpts_vec[i] = bkpts (i).double_value (); 440 if (len > 0)
460 441 {
461 retval[it->first] = bkpts_vec; 442 bp_table::intmap bkpts_vec;
443
444 for (int i = 0; i < len; i++)
445 bkpts_vec[i] = bkpts (i).double_value ();
446
447 std::string symbol_name = f->name ();
448
449 retval[symbol_name] = bkpts_vec;
450 }
462 } 451 }
463 } 452 }
464 } 453 }
465 } 454 }
466 455