1. 解决设置异常断点后不显示断点问题

This commit is contained in:
xuhong 2023-09-21 19:01:55 +08:00
parent 29d4b36587
commit 21a95aef96
3 changed files with 16 additions and 5 deletions

View File

@ -4,12 +4,14 @@ import { DebugProtocol } from "vscode-debugprotocol/lib/debugProtocol";
export type ValuesFormattingMode = "disabled" | "parseText" | "prettyPrinters"; export type ValuesFormattingMode = "disabled" | "parseText" | "prettyPrinters";
export interface Breakpoint { export interface Breakpoint {
id?:number;
file?: string; file?: string;
line?: number; line?: number;
raw?: string; raw?: string;
condition: string; condition: string;
countCondition?: string; countCondition?: string;
logMessage?: string; logMessage?: string;
message?: any;
} }
export interface OurInstructionBreakpoint extends DebugProtocol.InstructionBreakpoint { export interface OurInstructionBreakpoint extends DebugProtocol.InstructionBreakpoint {

View File

@ -608,7 +608,7 @@ export class MI2 extends EventEmitter implements IBackend {
setBreakPointCondition(bkptNum, condition): Thenable<any> { setBreakPointCondition(bkptNum, condition): Thenable<any> {
if (trace) if (trace)
this.log("stderr", "setBreakPointCondition"); this.log("stderr", "setBreakPointCondition");
return this.sendCommand("break-condition " + bkptNum + " " + condition); return this.sendCommand("break-condition " + bkptNum + " " + condition, true);
} }
setLogPoint(bkptNum, command): Thenable<any> { setLogPoint(bkptNum, command): Thenable<any> {
@ -662,10 +662,13 @@ export class MI2 extends EventEmitter implements IBackend {
if (result.resultRecords.resultClass == "done") { if (result.resultRecords.resultClass == "done") {
const bkptNum = parseInt(result.result("bkpt.number")); const bkptNum = parseInt(result.result("bkpt.number"));
const newBrk = { const newBrk = {
id: bkptNum,
file: breakpoint.file ? breakpoint.file : result.result("bkpt.file"), file: breakpoint.file ? breakpoint.file : result.result("bkpt.file"),
raw: breakpoint.raw, raw: breakpoint.raw,
line: parseInt(result.result("bkpt.line")), line: parseInt(result.result("bkpt.line")),
condition: breakpoint.condition condition: breakpoint.condition,
message:undefined,
verified:undefined
}; };
if (breakpoint.condition) { if (breakpoint.condition) {
this.setBreakPointCondition(bkptNum, breakpoint.condition).then((result) => { this.setBreakPointCondition(bkptNum, breakpoint.condition).then((result) => {
@ -675,7 +678,10 @@ export class MI2 extends EventEmitter implements IBackend {
} else { } else {
resolve([false, undefined]); resolve([false, undefined]);
} }
}, reject); }, (msg)=>{
newBrk.message = msg;
resolve([false, newBrk]);
});
} }
else if(breakpoint.logMessage) { else if(breakpoint.logMessage) {
this.setLogPoint(bkptNum, breakpoint.logMessage).then((result) => { this.setLogPoint(bkptNum, breakpoint.logMessage).then((result) => {

View File

@ -269,12 +269,15 @@ export class MI2DebugSession extends DebugSession {
brkpoints.forEach(brkp => { brkpoints.forEach(brkp => {
// TODO: Currently all breakpoints returned are marked as verified, // TODO: Currently all breakpoints returned are marked as verified,
// which leads to verified breakpoints on a broken lldb. // which leads to verified breakpoints on a broken lldb.
if (brkp[0]) let bp:any = new DebugAdapter.Breakpoint(brkp[0], brkp[1].line);
finalBrks.push(new DebugAdapter.Breakpoint(true, brkp[1].line)); bp.id = brkp[1].id;
bp.message = brkp[1].message?.toString();
finalBrks.push(bp);
}); });
response.body = { response.body = {
breakpoints: finalBrks breakpoints: finalBrks
}; };
this.handleMsg("stdout", `response: ${JSON.stringify(response)}\n`);
this.sendResponse(response); this.sendResponse(response);
}, msg => { }, msg => {
this.sendErrorResponse(response, 9, msg.toString()); this.sendErrorResponse(response, 9, msg.toString());