Added function breakpoints (fix #45)
This commit is contained in:
parent
4cbb822d39
commit
50fb4798b7
7 changed files with 71 additions and 23 deletions
|
|
@ -1,6 +1,7 @@
|
|||
export interface Breakpoint {
|
||||
file: string;
|
||||
line: number;
|
||||
file?: string;
|
||||
line?: number;
|
||||
raw?: string;
|
||||
condition: string;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@ export function escape(str: string) {
|
|||
return str.replace(/\\/g, "\\\\").replace(/"/g, "\\\"");
|
||||
}
|
||||
|
||||
const nonOutput = /^[0-9]*[\*\+\=]|[\~\@\&\^]/;
|
||||
const gdbMatch = /(undefined|\d*)\(gdb\)/;
|
||||
const nonOutput = /^(?:\d*|undefined)[\*\+\=]|[\~\@\&\^]/;
|
||||
const gdbMatch = /(?:\d*|undefined)\(gdb\)/;
|
||||
|
||||
function couldBeOutput(line: string) {
|
||||
if (nonOutput.exec(line))
|
||||
|
|
@ -409,7 +409,12 @@ export class MI2 extends EventEmitter implements IBackend {
|
|||
return new Promise((resolve, reject) => {
|
||||
if (this.breakpoints.has(breakpoint))
|
||||
return resolve(false);
|
||||
this.sendCommand("break-insert -f " + breakpoint.file + ":" + breakpoint.line).then((result) => {
|
||||
let location = "";
|
||||
if (breakpoint.raw)
|
||||
location = '"' + escape(breakpoint.raw) + '"';
|
||||
else
|
||||
location = breakpoint.file + ":" + breakpoint.line;
|
||||
this.sendCommand("break-insert -f " + location).then((result) => {
|
||||
if (result.resultRecords.resultClass == "done") {
|
||||
let bkptNum = parseInt(result.result("bkpt.number"));
|
||||
let newBrk = {
|
||||
|
|
@ -425,7 +430,7 @@ export class MI2 extends EventEmitter implements IBackend {
|
|||
} else {
|
||||
resolve([false, null]);
|
||||
}
|
||||
});
|
||||
}, reject);
|
||||
}
|
||||
else {
|
||||
this.breakpoints.set(newBrk, bkptNum);
|
||||
|
|
@ -433,9 +438,9 @@ export class MI2 extends EventEmitter implements IBackend {
|
|||
}
|
||||
}
|
||||
else {
|
||||
resolve([false, null]);
|
||||
reject(result);
|
||||
}
|
||||
});
|
||||
}, reject);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -461,6 +466,8 @@ export class MI2 extends EventEmitter implements IBackend {
|
|||
resolve(true);
|
||||
}
|
||||
else resolve(false);
|
||||
}, () => {
|
||||
resolve(false);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,9 +77,9 @@ export class MINode implements MIInfo {
|
|||
}
|
||||
}
|
||||
|
||||
const tokenRegex = /^[0-9]+/;
|
||||
const outOfBandRecordRegex = /^(?:([0-9]*)([\*\+\=])|([\~\@\&]))/;
|
||||
const resultRecordRegex = /^([0-9]*)\^(done|running|connected|error|exit)/;
|
||||
const tokenRegex = /^\d+/;
|
||||
const outOfBandRecordRegex = /^(?:(\d*|undefined)([\*\+\=])|([\~\@\&]))/;
|
||||
const resultRecordRegex = /^(\d*)\^(done|running|connected|error|exit)/;
|
||||
const newlineRegex = /^\r\n?/;
|
||||
const endRegex = /^\(gdb\)\r\n?/;
|
||||
const variableRegex = /^([a-zA-Z_\-][a-zA-Z0-9_\-]*)/;
|
||||
|
|
@ -212,7 +212,7 @@ export function parseMI(output: string): MINode {
|
|||
|
||||
while (match = outOfBandRecordRegex.exec(output)) {
|
||||
output = output.substr(match[0].length);
|
||||
if (match[1] && token === undefined) {
|
||||
if (match[1] && token === undefined && match[1] !== "undefined") {
|
||||
token = parseInt(match[1]);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue