MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / ldbBreak

Function ldbBreak

src/scripting.cpp:2537–2576  ·  view source on GitHub ↗

Implements the break command to list, add and remove breakpoints. */

Source from the content-addressed store, hash-verified

2535
2536/* Implements the break command to list, add and remove breakpoints. */
2537void ldbBreak(sds *argv, int argc) {
2538 if (argc == 1) {
2539 if (ldb.bpcount == 0) {
2540 ldbLog(sdsnew("No breakpoints set. Use 'b <line>' to add one."));
2541 return;
2542 } else {
2543 ldbLog(sdscatfmt(sdsempty(),"%i breakpoints set:",ldb.bpcount));
2544 int j;
2545 for (j = 0; j < ldb.bpcount; j++)
2546 ldbLogSourceLine(ldb.bp[j]);
2547 }
2548 } else {
2549 int j;
2550 for (j = 1; j < argc; j++) {
2551 char *arg = argv[j];
2552 long line;
2553 if (!string2l(arg,sdslen(arg),&line)) {
2554 ldbLog(sdscatfmt(sdsempty(),"Invalid argument:'%s'",arg));
2555 } else {
2556 if (line == 0) {
2557 ldb.bpcount = 0;
2558 ldbLog(sdsnew("All breakpoints removed."));
2559 } else if (line > 0) {
2560 if (ldb.bpcount == LDB_BREAKPOINTS_MAX) {
2561 ldbLog(sdsnew("Too many breakpoints set."));
2562 } else if (ldbAddBreakpoint(line)) {
2563 ldbList(line,1);
2564 } else {
2565 ldbLog(sdsnew("Wrong line number."));
2566 }
2567 } else if (line < 0) {
2568 if (ldbDelBreakpoint(-line))
2569 ldbLog(sdsnew("Breakpoint removed."));
2570 else
2571 ldbLog(sdsnew("No breakpoint in the specified line."));
2572 }
2573 }
2574 }
2575 }
2576}
2577
2578/* Implements the Lua debugger "eval" command. It just compiles the user
2579 * passed fragment of code and executes it, showing the result left on

Callers 1

ldbReplFunction · 0.85

Calls 10

ldbLogFunction · 0.85
sdsnewFunction · 0.85
sdscatfmtFunction · 0.85
sdsemptyFunction · 0.85
ldbLogSourceLineFunction · 0.85
string2lFunction · 0.85
sdslenFunction · 0.85
ldbAddBreakpointFunction · 0.85
ldbListFunction · 0.85
ldbDelBreakpointFunction · 0.85

Tested by

no test coverage detected