MCPcopy Create free account
hub / github.com/WebFreak001/code-debug / addBreakPoint

Method addBreakPoint

src/backend/mi2/mi2.ts:583–633  ·  view source on GitHub ↗
(breakpoint: Breakpoint)

Source from the content-addressed store, hash-verified

581 }
582
583 addBreakPoint(breakpoint: Breakpoint): Thenable<[boolean, Breakpoint]> {
584 if (trace)
585 this.log("stderr", "addBreakPoint");
586 return new Promise((resolve, reject) => {
587 if (this.breakpoints.has(breakpoint))
588 return resolve([false, undefined]);
589 let location = "";
590 if (breakpoint.countCondition) {
591 if (breakpoint.countCondition[0] == ">")
592 location += "-i " + numRegex.exec(breakpoint.countCondition.substring(1))[0] + " ";
593 else {
594 const match = numRegex.exec(breakpoint.countCondition)[0];
595 if (match.length != breakpoint.countCondition.length) {
596 this.log("stderr", "Unsupported break count expression: '" + breakpoint.countCondition + "'. Only supports 'X' for breaking once after X times or '>X' for ignoring the first X breaks");
597 location += "-t ";
598 } else if (parseInt(match) != 0)
599 location += "-t -i " + parseInt(match) + " ";
600 }
601 }
602 if (breakpoint.raw)
603 location += '"' + escape(breakpoint.raw) + '"';
604 else
605 location += '"' + escape(breakpoint.file) + ":" + breakpoint.line + '"';
606 this.sendCommand("break-insert -f " + location).then((result) => {
607 if (result.resultRecords.resultClass == "done") {
608 const bkptNum = parseInt(result.result("bkpt.number"));
609 const newBrk = {
610 file: breakpoint.file ? breakpoint.file : result.result("bkpt.file"),
611 raw: breakpoint.raw,
612 line: parseInt(result.result("bkpt.line")),
613 condition: breakpoint.condition
614 };
615 if (breakpoint.condition) {
616 this.setBreakPointCondition(bkptNum, breakpoint.condition).then((result) => {
617 if (result.resultRecords.resultClass == "done") {
618 this.breakpoints.set(newBrk, bkptNum);
619 resolve([true, newBrk]);
620 } else {
621 resolve([false, undefined]);
622 }
623 }, reject);
624 } else {
625 this.breakpoints.set(newBrk, bkptNum);
626 resolve([true, newBrk]);
627 }
628 } else {
629 reject(result);
630 }
631 }, reject);
632 });
633 }
634
635 removeBreakPoint(breakpoint: Breakpoint): Thenable<boolean> {
636 if (trace)

Callers 1

loadBreakPointsMethod · 0.95

Calls 5

logMethod · 0.95
sendCommandMethod · 0.95
escapeFunction · 0.85
resultMethod · 0.80

Tested by

no test coverage detected