Implements the break command to list, add and remove breakpoints. */
| 2512 | |
| 2513 | /* Implements the break command to list, add and remove breakpoints. */ |
| 2514 | void ldbBreak(sds *argv, int argc) { |
| 2515 | if (argc == 1) { |
| 2516 | if (ldb.bpcount == 0) { |
| 2517 | ldbLog(sdsnew("No breakpoints set. Use 'b <line>' to add one.")); |
| 2518 | return; |
| 2519 | } else { |
| 2520 | ldbLog(sdscatfmt(sdsempty(),"%i breakpoints set:",ldb.bpcount)); |
| 2521 | int j; |
| 2522 | for (j = 0; j < ldb.bpcount; j++) |
| 2523 | ldbLogSourceLine(ldb.bp[j]); |
| 2524 | } |
| 2525 | } else { |
| 2526 | int j; |
| 2527 | for (j = 1; j < argc; j++) { |
| 2528 | char *arg = argv[j]; |
| 2529 | long line; |
| 2530 | if (!string2l(arg,sdslen(arg),&line)) { |
| 2531 | ldbLog(sdscatfmt(sdsempty(),"Invalid argument:'%s'",arg)); |
| 2532 | } else { |
| 2533 | if (line == 0) { |
| 2534 | ldb.bpcount = 0; |
| 2535 | ldbLog(sdsnew("All breakpoints removed.")); |
| 2536 | } else if (line > 0) { |
| 2537 | if (ldb.bpcount == LDB_BREAKPOINTS_MAX) { |
| 2538 | ldbLog(sdsnew("Too many breakpoints set.")); |
| 2539 | } else if (ldbAddBreakpoint(line)) { |
| 2540 | ldbList(line,1); |
| 2541 | } else { |
| 2542 | ldbLog(sdsnew("Wrong line number.")); |
| 2543 | } |
| 2544 | } else if (line < 0) { |
| 2545 | if (ldbDelBreakpoint(-line)) |
| 2546 | ldbLog(sdsnew("Breakpoint removed.")); |
| 2547 | else |
| 2548 | ldbLog(sdsnew("No breakpoint in the specified line.")); |
| 2549 | } |
| 2550 | } |
| 2551 | } |
| 2552 | } |
| 2553 | } |
| 2554 | |
| 2555 | /* Implements the Lua debugger "eval" command. It just compiles the user |
| 2556 | * passed fragment of code and executes it, showing the result left on |
no test coverage detected