Mercurial > hg > octave-nkf
comparison src/debug.cc @ 11586:12df7854fa7c
strip trailing whitespace from source files
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 20 Jan 2011 17:24:59 -0500 |
parents | fd0a3ac60b0e |
children | f96b9b9f141b |
comparison
equal
deleted
inserted
replaced
11585:1473d0cf86d2 | 11586:12df7854fa7c |
---|---|
183 | 183 |
184 return dbg_fcn; | 184 return dbg_fcn; |
185 } | 185 } |
186 | 186 |
187 static void | 187 static void |
188 parse_dbfunction_params (const char *who, const octave_value_list& args, | 188 parse_dbfunction_params (const char *who, const octave_value_list& args, |
189 std::string& symbol_name, bp_table::intmap& lines) | 189 std::string& symbol_name, bp_table::intmap& lines) |
190 { | 190 { |
191 int nargin = args.length (); | 191 int nargin = args.length (); |
192 int idx = 0; | 192 int idx = 0; |
193 int list_idx = 0; | 193 int list_idx = 0; |
230 else if (args(i).is_map ()) | 230 else if (args(i).is_map ()) |
231 octave_stdout << who << ": accepting a struct" << std::endl; | 231 octave_stdout << who << ": accepting a struct" << std::endl; |
232 else | 232 else |
233 { | 233 { |
234 const NDArray arg = args(i).array_value (); | 234 const NDArray arg = args(i).array_value (); |
235 | 235 |
236 if (error_state) | 236 if (error_state) |
237 break; | 237 break; |
238 | 238 |
239 for (octave_idx_type j = 0; j < arg.nelem (); j++) | 239 for (octave_idx_type j = 0; j < arg.nelem (); j++) |
240 { | 240 { |
241 int line = static_cast<int> (arg.elem (j)); | 241 int line = static_cast<int> (arg.elem (j)); |
242 if (error_state) | 242 if (error_state) |
243 break; | 243 break; |
244 lines[list_idx++] = line; | 244 lines[list_idx++] = line; |
245 } | 245 } |
246 | 246 |
247 if (error_state) | 247 if (error_state) |
248 break; | 248 break; |
249 } | 249 } |
250 } | 250 } |
251 } | 251 } |
252 | 252 |
253 bp_table::intmap | 253 bp_table::intmap |
254 bp_table::do_add_breakpoint (const std::string& fname, | 254 bp_table::do_add_breakpoint (const std::string& fname, |
255 const bp_table::intmap& line) | 255 const bp_table::intmap& line) |
256 { | 256 { |
257 intmap retval; | 257 intmap retval; |
258 | 258 |
259 octave_idx_type len = line.size (); | 259 octave_idx_type len = line.size (); |
291 | 291 |
292 return retval; | 292 return retval; |
293 } | 293 } |
294 | 294 |
295 | 295 |
296 int | 296 int |
297 bp_table::do_remove_breakpoint (const std::string& fname, | 297 bp_table::do_remove_breakpoint (const std::string& fname, |
298 const bp_table::intmap& line) | 298 const bp_table::intmap& line) |
299 { | 299 { |
300 int retval = 0; | 300 int retval = 0; |
301 | 301 |
302 octave_idx_type len = line.size (); | 302 octave_idx_type len = line.size (); |
348 return retval; | 348 return retval; |
349 } | 349 } |
350 | 350 |
351 | 351 |
352 bp_table::intmap | 352 bp_table::intmap |
353 bp_table::do_remove_all_breakpoints_in_file (const std::string& fname, | 353 bp_table::do_remove_all_breakpoints_in_file (const std::string& fname, |
354 bool silent) | 354 bool silent) |
355 { | 355 { |
356 intmap retval; | 356 intmap retval; |
357 | 357 |
358 octave_user_code *dbg_fcn = get_user_code (fname); | 358 octave_user_code *dbg_fcn = get_user_code (fname); |
359 | 359 |
360 if (dbg_fcn) | 360 if (dbg_fcn) |
361 { | 361 { |
362 tree_statement_list *cmds = dbg_fcn->body (); | 362 tree_statement_list *cmds = dbg_fcn->body (); |
363 | 363 |
364 if (cmds) | 364 if (cmds) |
385 tree_evaluator::debug_mode = bp_table::have_breakpoints () || Vdebugging; | 385 tree_evaluator::debug_mode = bp_table::have_breakpoints () || Vdebugging; |
386 | 386 |
387 return retval; | 387 return retval; |
388 } | 388 } |
389 | 389 |
390 void | 390 void |
391 bp_table::do_remove_all_breakpoints (void) | 391 bp_table::do_remove_all_breakpoints (void) |
392 { | 392 { |
393 for (const_bp_set_iterator it = bp_set.begin (); it != bp_set.end (); it++) | 393 for (const_bp_set_iterator it = bp_set.begin (); it != bp_set.end (); it++) |
394 remove_all_breakpoints_in_file (*it); | 394 remove_all_breakpoints_in_file (*it); |
395 | 395 |
396 | 396 |
397 tree_evaluator::debug_mode = bp_table::have_breakpoints () || Vdebugging; | 397 tree_evaluator::debug_mode = bp_table::have_breakpoints () || Vdebugging; |
398 } | 398 } |
399 | 399 |
400 std::string | 400 std::string |
401 do_find_bkpt_list (octave_value_list slist, | 401 do_find_bkpt_list (octave_value_list slist, |
402 std::string match) | 402 std::string match) |
403 { | 403 { |
404 std::string retval; | 404 std::string retval; |
405 | 405 |
406 for (int i = 0; i < slist.length (); i++) | 406 for (int i = 0; i < slist.length (); i++) |
433 tree_statement_list *cmds = f->body (); | 433 tree_statement_list *cmds = f->body (); |
434 | 434 |
435 if (cmds) | 435 if (cmds) |
436 { | 436 { |
437 octave_value_list bkpts = cmds->list_breakpoints (); | 437 octave_value_list bkpts = cmds->list_breakpoints (); |
438 octave_idx_type len = bkpts.length (); | 438 octave_idx_type len = bkpts.length (); |
439 | 439 |
440 if (len > 0) | 440 if (len > 0) |
441 { | 441 { |
442 bp_table::intmap bkpts_vec; | 442 bp_table::intmap bkpts_vec; |
443 | 443 |
444 for (int i = 0; i < len; i++) | 444 for (int i = 0; i < len; i++) |
445 bkpts_vec[i] = bkpts (i).double_value (); | 445 bkpts_vec[i] = bkpts (i).double_value (); |
446 | 446 |
447 std::string symbol_name = f->name (); | 447 std::string symbol_name = f->name (); |
448 | 448 |
449 retval[symbol_name] = bkpts_vec; | 449 retval[symbol_name] = bkpts_vec; |
450 } | 450 } |
451 } | 451 } |
455 | 455 |
456 return retval; | 456 return retval; |
457 } | 457 } |
458 | 458 |
459 static octave_value | 459 static octave_value |
460 intmap_to_ov (const bp_table::intmap& line) | 460 intmap_to_ov (const bp_table::intmap& line) |
461 { | 461 { |
462 int idx = 0; | 462 int idx = 0; |
463 | 463 |
464 NDArray retval (dim_vector (1, line.size ())); | 464 NDArray retval (dim_vector (1, line.size ())); |
465 | 465 |
533 octave_value retval; | 533 octave_value retval; |
534 std::string symbol_name = ""; | 534 std::string symbol_name = ""; |
535 bp_table::intmap lines; | 535 bp_table::intmap lines; |
536 | 536 |
537 parse_dbfunction_params ("dbclear", args, symbol_name, lines); | 537 parse_dbfunction_params ("dbclear", args, symbol_name, lines); |
538 | 538 |
539 if (! error_state) | 539 if (! error_state) |
540 bp_table::remove_breakpoint (symbol_name, lines); | 540 bp_table::remove_breakpoint (symbol_name, lines); |
541 | 541 |
542 return retval; | 542 return retval; |
543 } | 543 } |
594 { | 594 { |
595 // Print out the breakpoint information. | 595 // Print out the breakpoint information. |
596 | 596 |
597 for (bp_table::fname_line_map_iterator it = bp_list.begin (); | 597 for (bp_table::fname_line_map_iterator it = bp_list.begin (); |
598 it != bp_list.end (); it++) | 598 it != bp_list.end (); it++) |
599 { | 599 { |
600 octave_stdout << "breakpoint in " << it->first << " at line(s) "; | 600 octave_stdout << "breakpoint in " << it->first << " at line(s) "; |
601 | 601 |
602 bp_table::intmap m = it->second; | 602 bp_table::intmap m = it->second; |
603 | 603 |
604 size_t nel = m.size (); | 604 size_t nel = m.size (); |
699 | 699 |
700 if (fs) | 700 if (fs) |
701 { | 701 { |
702 char ch; | 702 char ch; |
703 int line = 1; | 703 int line = 1; |
704 | 704 |
705 if (line >= start && line <= end) | 705 if (line >= start && line <= end) |
706 os << line << "\t"; | 706 os << line << "\t"; |
707 | 707 |
708 while (fs.get (ch)) | 708 while (fs.get (ch)) |
709 { | 709 { |
710 if (line >= start && line <= end) | 710 if (line >= start && line <= end) |
711 { | 711 { |
712 os << ch; | 712 os << ch; |
775 std::string start_str = arg.substr (0, ind); | 775 std::string start_str = arg.substr (0, ind); |
776 std::string end_str = arg.substr (ind + 1); | 776 std::string end_str = arg.substr (ind + 1); |
777 | 777 |
778 int start = atoi (start_str.c_str ()); | 778 int start = atoi (start_str.c_str ()); |
779 int end = atoi (end_str.c_str ()); | 779 int end = atoi (end_str.c_str ()); |
780 | 780 |
781 if (std::min (start, end) <= 0) | 781 if (std::min (start, end) <= 0) |
782 error ("dbtype: start and end lines must be >= 1\n"); | 782 error ("dbtype: start and end lines must be >= 1\n"); |
783 | 783 |
784 if (start <= end) | 784 if (start <= end) |
785 do_dbtype (octave_stdout, dbg_fcn->name (), start, end); | 785 do_dbtype (octave_stdout, dbg_fcn->name (), start, end); |
807 std::string start_str = arg.substr (0, ind); | 807 std::string start_str = arg.substr (0, ind); |
808 std::string end_str = arg.substr (ind + 1); | 808 std::string end_str = arg.substr (ind + 1); |
809 | 809 |
810 start = atoi (start_str.c_str ()); | 810 start = atoi (start_str.c_str ()); |
811 end = atoi (end_str.c_str ()); | 811 end = atoi (end_str.c_str ()); |
812 | 812 |
813 } | 813 } |
814 else | 814 else |
815 { | 815 { |
816 start = atoi (arg.c_str ()); | 816 start = atoi (arg.c_str ()); |
817 end = start; | 817 end = start; |
818 } | 818 } |
819 | 819 |
820 if (std::min (start, end) <= 0) | 820 if (std::min (start, end) <= 0) |
821 error ("dbtype: start and end lines must be >= 1\n"); | 821 error ("dbtype: start and end lines must be >= 1\n"); |
822 | 822 |
823 if (start <= end) | 823 if (start <= end) |
824 do_dbtype (octave_stdout, dbg_fcn->name (), start, end); | 824 do_dbtype (octave_stdout, dbg_fcn->name (), start, end); |
825 else | 825 else |
826 error ("dbtype: start line must be less than end line\n"); | 826 error ("dbtype: start line must be less than end line\n"); |
827 } | 827 } |
1008 @end deftypefn") | 1008 @end deftypefn") |
1009 { | 1009 { |
1010 if (Vdebugging) | 1010 if (Vdebugging) |
1011 { | 1011 { |
1012 int nargin = args.length (); | 1012 int nargin = args.length (); |
1013 | 1013 |
1014 if (nargin > 1) | 1014 if (nargin > 1) |
1015 print_usage (); | 1015 print_usage (); |
1016 else if (nargin == 1) | 1016 else if (nargin == 1) |
1017 { | 1017 { |
1018 if (args(0).is_string ()) | 1018 if (args(0).is_string ()) |