tslint: Enable one-line
I'm not sure what is your preference here, but I've seen both styles:
} else {
and
{
else {
I think it would be nice to have a consistent style, and the former is
more common.
This commit is contained in:
parent
9a942c5047
commit
ec95d4a433
9 changed files with 72 additions and 145 deletions
|
|
@ -75,8 +75,7 @@ export function expandValue(variableCreate: Function, value: string, root: strin
|
||||||
name = name.substr(1);
|
name = name.substr(1);
|
||||||
}
|
}
|
||||||
namespace = namespace + pointerCombineChar + name;
|
namespace = namespace + pointerCombineChar + name;
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
namespace = name;
|
namespace = name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -151,45 +150,35 @@ export function expandValue(variableCreate: Function, value: string, root: strin
|
||||||
else if (value.startsWith("true")) {
|
else if (value.startsWith("true")) {
|
||||||
primitive = "true";
|
primitive = "true";
|
||||||
value = value.substr(4).trim();
|
value = value.substr(4).trim();
|
||||||
}
|
} else if (value.startsWith("false")) {
|
||||||
else if (value.startsWith("false")) {
|
|
||||||
primitive = "false";
|
primitive = "false";
|
||||||
value = value.substr(5).trim();
|
value = value.substr(5).trim();
|
||||||
}
|
} else if (match = nullpointerRegex.exec(value)) {
|
||||||
else if (match = nullpointerRegex.exec(value)) {
|
|
||||||
primitive = "<nullptr>";
|
primitive = "<nullptr>";
|
||||||
value = value.substr(match[0].length).trim();
|
value = value.substr(match[0].length).trim();
|
||||||
}
|
} else if (match = referenceStringRegex.exec(value)) {
|
||||||
else if (match = referenceStringRegex.exec(value)) {
|
|
||||||
value = value.substr(match[1].length).trim();
|
value = value.substr(match[1].length).trim();
|
||||||
primitive = parseCString();
|
primitive = parseCString();
|
||||||
}
|
} else if (match = referenceRegex.exec(value)) {
|
||||||
else if (match = referenceRegex.exec(value)) {
|
|
||||||
primitive = "*" + match[0];
|
primitive = "*" + match[0];
|
||||||
value = value.substr(match[0].length).trim();
|
value = value.substr(match[0].length).trim();
|
||||||
}
|
} else if (match = cppReferenceRegex.exec(value)) {
|
||||||
else if (match = cppReferenceRegex.exec(value)) {
|
|
||||||
primitive = match[0];
|
primitive = match[0];
|
||||||
value = value.substr(match[0].length).trim();
|
value = value.substr(match[0].length).trim();
|
||||||
}
|
} else if (match = charRegex.exec(value)) {
|
||||||
else if (match = charRegex.exec(value)) {
|
|
||||||
primitive = match[1];
|
primitive = match[1];
|
||||||
value = value.substr(match[0].length - 1);
|
value = value.substr(match[0].length - 1);
|
||||||
primitive += " " + parseCString();
|
primitive += " " + parseCString();
|
||||||
}
|
} else if (match = numberRegex.exec(value)) {
|
||||||
else if (match = numberRegex.exec(value)) {
|
|
||||||
primitive = match[0];
|
primitive = match[0];
|
||||||
value = value.substr(match[0].length).trim();
|
value = value.substr(match[0].length).trim();
|
||||||
}
|
} else if (match = variableRegex.exec(value)) {
|
||||||
else if (match = variableRegex.exec(value)) {
|
|
||||||
primitive = match[0];
|
primitive = match[0];
|
||||||
value = value.substr(match[0].length).trim();
|
value = value.substr(match[0].length).trim();
|
||||||
}
|
} else if (match = errorRegex.exec(value)) {
|
||||||
else if (match = errorRegex.exec(value)) {
|
|
||||||
primitive = match[0];
|
primitive = match[0];
|
||||||
value = value.substr(match[0].length).trim();
|
value = value.substr(match[0].length).trim();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
primitive = value;
|
primitive = value;
|
||||||
}
|
}
|
||||||
return primitive;
|
return primitive;
|
||||||
|
|
@ -225,22 +214,18 @@ export function expandValue(variableCreate: Function, value: string, root: strin
|
||||||
if (typeof val == "object") {
|
if (typeof val == "object") {
|
||||||
ref = variableCreate(val);
|
ref = variableCreate(val);
|
||||||
val = "Object";
|
val = "Object";
|
||||||
}
|
} else if (typeof val == "string" && val.startsWith("*0x")) {
|
||||||
else if (typeof val == "string" && val.startsWith("*0x")) {
|
|
||||||
if (extra && MINode.valueOf(extra, "arg") == "1") {
|
if (extra && MINode.valueOf(extra, "arg") == "1") {
|
||||||
ref = variableCreate(getNamespace("*(" + name), { arg: true });
|
ref = variableCreate(getNamespace("*(" + name), { arg: true });
|
||||||
val = "<args>";
|
val = "<args>";
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
ref = variableCreate(getNamespace("*" + name));
|
ref = variableCreate(getNamespace("*" + name));
|
||||||
val = "Object@" + val;
|
val = "Object@" + val;
|
||||||
}
|
}
|
||||||
}
|
} else if (typeof val == "string" && val.startsWith("@0x")) {
|
||||||
else if (typeof val == "string" && val.startsWith("@0x")) {
|
|
||||||
ref = variableCreate(getNamespace("*&" + name.substr));
|
ref = variableCreate(getNamespace("*&" + name.substr));
|
||||||
val = "Ref" + val;
|
val = "Ref" + val;
|
||||||
}
|
} else if (typeof val == "string" && val.startsWith("<...>")) {
|
||||||
else if (typeof val == "string" && val.startsWith("<...>")) {
|
|
||||||
ref = variableCreate(getNamespace(name));
|
ref = variableCreate(getNamespace(name));
|
||||||
val = "...";
|
val = "...";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -71,8 +71,7 @@ export class MI2 extends EventEmitter implements IBackend {
|
||||||
this.emit("debug-ready");
|
this.emit("debug-ready");
|
||||||
resolve();
|
resolve();
|
||||||
}, reject);
|
}, reject);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if (separateConsole !== undefined) {
|
if (separateConsole !== undefined) {
|
||||||
linuxTerm.spawnTerminalEmulator(separateConsole).then(tty => {
|
linuxTerm.spawnTerminalEmulator(separateConsole).then(tty => {
|
||||||
promises.push(this.sendCommand("inferior-tty-set " + tty));
|
promises.push(this.sendCommand("inferior-tty-set " + tty));
|
||||||
|
|
@ -81,8 +80,7 @@ export class MI2 extends EventEmitter implements IBackend {
|
||||||
resolve();
|
resolve();
|
||||||
}, reject);
|
}, reject);
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
Promise.all(promises).then(() => {
|
Promise.all(promises).then(() => {
|
||||||
this.emit("debug-ready");
|
this.emit("debug-ready");
|
||||||
resolve();
|
resolve();
|
||||||
|
|
@ -187,8 +185,7 @@ export class MI2 extends EventEmitter implements IBackend {
|
||||||
if (ssh) {
|
if (ssh) {
|
||||||
if (!path.isAbsolute(target))
|
if (!path.isAbsolute(target))
|
||||||
target = path.join(cwd, target);
|
target = path.join(cwd, target);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if (!nativePath.isAbsolute(target))
|
if (!nativePath.isAbsolute(target))
|
||||||
target = nativePath.join(cwd, target);
|
target = nativePath.join(cwd, target);
|
||||||
}
|
}
|
||||||
|
|
@ -318,8 +315,7 @@ export class MI2 extends EventEmitter implements IBackend {
|
||||||
if (couldBeOutput(line)) {
|
if (couldBeOutput(line)) {
|
||||||
if (!gdbMatch.exec(line))
|
if (!gdbMatch.exec(line))
|
||||||
this.log("stdout", line);
|
this.log("stdout", line);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
const parsed = parseMI(line);
|
const parsed = parseMI(line);
|
||||||
if (this.debugOutput)
|
if (this.debugOutput)
|
||||||
this.log("log", "GDB -> App: " + JSON.stringify(parsed));
|
this.log("log", "GDB -> App: " + JSON.stringify(parsed));
|
||||||
|
|
@ -360,8 +356,7 @@ export class MI2 extends EventEmitter implements IBackend {
|
||||||
else if (reason == "exited") { // exit with error code != 0
|
else if (reason == "exited") { // exit with error code != 0
|
||||||
this.log("stderr", "Program exited with code " + parsed.record("exit-code"));
|
this.log("stderr", "Program exited with code " + parsed.record("exit-code"));
|
||||||
this.emit("exited-normally", parsed);
|
this.emit("exited-normally", parsed);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
this.log("console", "Not implemented stop reason (assuming exception): " + reason);
|
this.log("console", "Not implemented stop reason (assuming exception): " + reason);
|
||||||
this.emit("stopped", parsed);
|
this.emit("stopped", parsed);
|
||||||
}
|
}
|
||||||
|
|
@ -410,8 +405,7 @@ export class MI2 extends EventEmitter implements IBackend {
|
||||||
clearTimeout(to);
|
clearTimeout(to);
|
||||||
});
|
});
|
||||||
this.sendRaw("-gdb-exit");
|
this.sendRaw("-gdb-exit");
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
const proc = this.process;
|
const proc = this.process;
|
||||||
const to = setTimeout(() => {
|
const to = setTimeout(() => {
|
||||||
process.kill(-proc.pid);
|
process.kill(-proc.pid);
|
||||||
|
|
@ -521,8 +515,7 @@ export class MI2 extends EventEmitter implements IBackend {
|
||||||
if (match.length != breakpoint.countCondition.length) {
|
if (match.length != breakpoint.countCondition.length) {
|
||||||
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");
|
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");
|
||||||
location += "-t ";
|
location += "-t ";
|
||||||
}
|
} else if (parseInt(match) != 0)
|
||||||
else if (parseInt(match) != 0)
|
|
||||||
location += "-t -i " + parseInt(match) + " ";
|
location += "-t -i " + parseInt(match) + " ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -547,13 +540,11 @@ export class MI2 extends EventEmitter implements IBackend {
|
||||||
resolve([false, undefined]);
|
resolve([false, undefined]);
|
||||||
}
|
}
|
||||||
}, reject);
|
}, reject);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
this.breakpoints.set(newBrk, bkptNum);
|
this.breakpoints.set(newBrk, bkptNum);
|
||||||
resolve([true, newBrk]);
|
resolve([true, newBrk]);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
reject(result);
|
reject(result);
|
||||||
}
|
}
|
||||||
}, reject);
|
}, reject);
|
||||||
|
|
@ -570,8 +561,7 @@ export class MI2 extends EventEmitter implements IBackend {
|
||||||
if (result.resultRecords.resultClass == "done") {
|
if (result.resultRecords.resultClass == "done") {
|
||||||
this.breakpoints.delete(breakpoint);
|
this.breakpoints.delete(breakpoint);
|
||||||
resolve(true);
|
resolve(true);
|
||||||
}
|
} else resolve(false);
|
||||||
else resolve(false);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -584,8 +574,7 @@ export class MI2 extends EventEmitter implements IBackend {
|
||||||
if (result.resultRecords.resultClass == "done") {
|
if (result.resultRecords.resultClass == "done") {
|
||||||
this.breakpoints.clear();
|
this.breakpoints.clear();
|
||||||
resolve(true);
|
resolve(true);
|
||||||
}
|
} else resolve(false);
|
||||||
else resolve(false);
|
|
||||||
}, () => {
|
}, () => {
|
||||||
resolve(false);
|
resolve(false);
|
||||||
});
|
});
|
||||||
|
|
@ -739,8 +728,7 @@ export class MI2 extends EventEmitter implements IBackend {
|
||||||
sendUserInput(command: string, threadId: number = 0, frameLevel: number = 0): Thenable<any> {
|
sendUserInput(command: string, threadId: number = 0, frameLevel: number = 0): Thenable<any> {
|
||||||
if (command.startsWith("-")) {
|
if (command.startsWith("-")) {
|
||||||
return this.sendCommand(command.substr(1));
|
return this.sendCommand(command.substr(1));
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return this.sendCliCommand(command, threadId, frameLevel);
|
return this.sendCliCommand(command, threadId, frameLevel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -771,11 +759,9 @@ export class MI2 extends EventEmitter implements IBackend {
|
||||||
if (suppressFailure) {
|
if (suppressFailure) {
|
||||||
this.log("stderr", `WARNING: Error executing command '${command}'`);
|
this.log("stderr", `WARNING: Error executing command '${command}'`);
|
||||||
resolve(node);
|
resolve(node);
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
reject(new MIError(node.result("msg") || "Internal error", command));
|
reject(new MIError(node.result("msg") || "Internal error", command));
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
resolve(node);
|
resolve(node);
|
||||||
};
|
};
|
||||||
this.sendRaw(sel + "-" + command);
|
this.sendRaw(sel + "-" + command);
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,7 @@ export class MI2_LLDB extends MI2 {
|
||||||
if (ssh) {
|
if (ssh) {
|
||||||
if (!path.isAbsolute(target))
|
if (!path.isAbsolute(target))
|
||||||
target = path.join(cwd, target);
|
target = path.join(cwd, target);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if (!nativePath.isAbsolute(target))
|
if (!nativePath.isAbsolute(target))
|
||||||
target = nativePath.join(cwd, target);
|
target = nativePath.join(cwd, target);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,8 +39,7 @@ function parseString(str: string): string {
|
||||||
else if (m = octalMatch.exec(str.substr(i))) {
|
else if (m = octalMatch.exec(str.substr(i))) {
|
||||||
ret.writeUInt8(parseInt(m[0], 8), bufIndex++);
|
ret.writeUInt8(parseInt(m[0], 8), bufIndex++);
|
||||||
i += 2;
|
i += 2;
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
bufIndex += ret.write(str[i], bufIndex);
|
bufIndex += ret.write(str[i], bufIndex);
|
||||||
escaped = false;
|
escaped = false;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -104,12 +103,10 @@ export class MINode implements MIInfo {
|
||||||
current = found[0];
|
current = found[0];
|
||||||
} else return undefined;
|
} else return undefined;
|
||||||
} else return undefined;
|
} else return undefined;
|
||||||
}
|
} else if (path[0] == '@') {
|
||||||
else if (path[0] == '@') {
|
|
||||||
current = [current];
|
current = [current];
|
||||||
path = path.substr(1);
|
path = path.substr(1);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
target = indexRegex.exec(path);
|
target = indexRegex.exec(path);
|
||||||
if (target) {
|
if (target) {
|
||||||
path = path.substr(target[0].length);
|
path = path.substr(target[0].length);
|
||||||
|
|
@ -118,8 +115,7 @@ export class MINode implements MIInfo {
|
||||||
current = current[i];
|
current = current[i];
|
||||||
} else if (i == 0) {
|
} else if (i == 0) {
|
||||||
} else return undefined;
|
} else return undefined;
|
||||||
}
|
} else return undefined;
|
||||||
else return undefined;
|
|
||||||
}
|
}
|
||||||
path = path.trim();
|
path = path.trim();
|
||||||
} while (path);
|
} while (path);
|
||||||
|
|
@ -188,8 +184,7 @@ export function parseMI(output: string): MINode {
|
||||||
let str;
|
let str;
|
||||||
try {
|
try {
|
||||||
str = parseString(output.substr(0, stringEnd));
|
str = parseString(output.substr(0, stringEnd));
|
||||||
}
|
} catch (e) {
|
||||||
catch (e) {
|
|
||||||
str = output.substr(0, stringEnd);
|
str = output.substr(0, stringEnd);
|
||||||
}
|
}
|
||||||
output = output.substr(stringEnd);
|
output = output.substr(stringEnd);
|
||||||
|
|
@ -286,8 +281,7 @@ export function parseMI(output: string): MINode {
|
||||||
while (result = parseCommaResult())
|
while (result = parseCommaResult())
|
||||||
asyncRecord.output.push(result);
|
asyncRecord.output.push(result);
|
||||||
outOfBandRecord.push(asyncRecord);
|
outOfBandRecord.push(asyncRecord);
|
||||||
}
|
} else if (match[3]) {
|
||||||
else if (match[3]) {
|
|
||||||
const streamRecord = {
|
const streamRecord = {
|
||||||
isStream: true,
|
isStream: true,
|
||||||
type: streamRecordType[match[3]],
|
type: streamRecordType[match[3]],
|
||||||
|
|
|
||||||
|
|
@ -42,8 +42,7 @@ function getMemoryRange(range: string) {
|
||||||
if (memoryLocationRegex.exec(length))
|
if (memoryLocationRegex.exec(length))
|
||||||
length = parseInt(length.substr(2), 16).toString();
|
length = parseInt(length.substr(2), 16).toString();
|
||||||
return "from=" + encodeURIComponent(from) + "&length=" + encodeURIComponent(length);
|
return "from=" + encodeURIComponent(from) + "&length=" + encodeURIComponent(length);
|
||||||
}
|
} else if ((index = range.indexOf("-")) != -1) {
|
||||||
else if ((index = range.indexOf("-")) != -1) {
|
|
||||||
const from = range.substr(0, index);
|
const from = range.substr(0, index);
|
||||||
const to = range.substr(index + 1);
|
const to = range.substr(index + 1);
|
||||||
if (!memoryLocationRegex.exec(from))
|
if (!memoryLocationRegex.exec(from))
|
||||||
|
|
@ -51,8 +50,7 @@ function getMemoryRange(range: string) {
|
||||||
if (!memoryLocationRegex.exec(to))
|
if (!memoryLocationRegex.exec(to))
|
||||||
return undefined;
|
return undefined;
|
||||||
return "from=" + encodeURIComponent(from) + "&to=" + encodeURIComponent(to);
|
return "from=" + encodeURIComponent(from) + "&to=" + encodeURIComponent(to);
|
||||||
}
|
} else if (memoryLocationRegex.exec(range))
|
||||||
else if (memoryLocationRegex.exec(range))
|
|
||||||
return "at=" + encodeURIComponent(range);
|
return "at=" + encodeURIComponent(range);
|
||||||
else return undefined;
|
else return undefined;
|
||||||
}
|
}
|
||||||
|
|
@ -100,18 +98,14 @@ class MemoryContentProvider implements vscode.TextDocumentContentProvider {
|
||||||
highlightAt = 64;
|
highlightAt = 64;
|
||||||
from = Math.max(loc - 64, 0);
|
from = Math.max(loc - 64, 0);
|
||||||
to = Math.max(loc + 768, 0);
|
to = Math.max(loc + 768, 0);
|
||||||
}
|
} else if (splits[0].split("=")[0] == "from") {
|
||||||
else if (splits[0].split("=")[0] == "from") {
|
|
||||||
from = parseInt(splits[0].split("=")[1].substr(2), 16);
|
from = parseInt(splits[0].split("=")[1].substr(2), 16);
|
||||||
if (splits[1].split("=")[0] == "to") {
|
if (splits[1].split("=")[0] == "to") {
|
||||||
to = parseInt(splits[1].split("=")[1].substr(2), 16);
|
to = parseInt(splits[1].split("=")[1].substr(2), 16);
|
||||||
}
|
} else if (splits[1].split("=")[0] == "length") {
|
||||||
else if (splits[1].split("=")[0] == "length") {
|
|
||||||
to = from + parseInt(splits[1].split("=")[1]);
|
to = from + parseInt(splits[1].split("=")[1]);
|
||||||
}
|
} else return reject("Invalid Range");
|
||||||
else return reject("Invalid Range");
|
} else return reject("Invalid Range");
|
||||||
}
|
|
||||||
else return reject("Invalid Range");
|
|
||||||
if (to < from)
|
if (to < from)
|
||||||
return reject("Negative Range");
|
return reject("Negative Range");
|
||||||
conn.write("examineMemory " + JSON.stringify([from, to - from + 1]));
|
conn.write("examineMemory " + JSON.stringify([from, to - from + 1]));
|
||||||
|
|
|
||||||
|
|
@ -92,8 +92,7 @@ class GDBDebugSession extends MI2DebugSession {
|
||||||
}, err => {
|
}, err => {
|
||||||
this.sendErrorResponse(response, 102, `Failed to SSH: ${err.toString()}`);
|
this.sendErrorResponse(response, 102, `Failed to SSH: ${err.toString()}`);
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
this.miDebugger.load(args.cwd, args.target, args.arguments, args.terminal).then(() => {
|
this.miDebugger.load(args.cwd, args.target, args.arguments, args.terminal).then(() => {
|
||||||
if (args.autorun)
|
if (args.autorun)
|
||||||
args.autorun.forEach(command => {
|
args.autorun.forEach(command => {
|
||||||
|
|
@ -153,8 +152,7 @@ class GDBDebugSession extends MI2DebugSession {
|
||||||
}, err => {
|
}, err => {
|
||||||
this.sendErrorResponse(response, 102, `Failed to SSH: ${err.toString()}`);
|
this.sendErrorResponse(response, 102, `Failed to SSH: ${err.toString()}`);
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if (args.remote) {
|
if (args.remote) {
|
||||||
this.miDebugger.connect(args.cwd, args.executable, args.target).then(() => {
|
this.miDebugger.connect(args.cwd, args.executable, args.target).then(() => {
|
||||||
if (args.autorun)
|
if (args.autorun)
|
||||||
|
|
@ -165,8 +163,7 @@ class GDBDebugSession extends MI2DebugSession {
|
||||||
}, err => {
|
}, err => {
|
||||||
this.sendErrorResponse(response, 102, `Failed to attach: ${err.toString()}`);
|
this.sendErrorResponse(response, 102, `Failed to attach: ${err.toString()}`);
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
this.miDebugger.attach(args.cwd, args.executable, args.target).then(() => {
|
this.miDebugger.attach(args.cwd, args.executable, args.target).then(() => {
|
||||||
if (args.autorun)
|
if (args.autorun)
|
||||||
args.autorun.forEach(command => {
|
args.autorun.forEach(command => {
|
||||||
|
|
|
||||||
|
|
@ -83,8 +83,7 @@ class LLDBDebugSession extends MI2DebugSession {
|
||||||
this.handlePause(undefined);
|
this.handlePause(undefined);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
this.miDebugger.load(args.cwd, args.target, args.arguments, undefined).then(() => {
|
this.miDebugger.load(args.cwd, args.target, args.arguments, undefined).then(() => {
|
||||||
if (args.autorun)
|
if (args.autorun)
|
||||||
args.autorun.forEach(command => {
|
args.autorun.forEach(command => {
|
||||||
|
|
|
||||||
|
|
@ -179,16 +179,14 @@ export class MI2DebugSession extends DebugSession {
|
||||||
response.body = {
|
response.body = {
|
||||||
value: res.result("value")
|
value: res.result("value")
|
||||||
};
|
};
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
await this.miDebugger.changeVariable(args.name, args.value);
|
await this.miDebugger.changeVariable(args.name, args.value);
|
||||||
response.body = {
|
response.body = {
|
||||||
value: args.value
|
value: args.value
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
this.sendResponse(response);
|
this.sendResponse(response);
|
||||||
}
|
} catch (err) {
|
||||||
catch (err) {
|
|
||||||
this.sendErrorResponse(response, 11, `Could not continue: ${err}`);
|
this.sendErrorResponse(response, 11, `Could not continue: ${err}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -300,8 +298,7 @@ export class MI2DebugSession extends DebugSession {
|
||||||
if (this.isSSH) {
|
if (this.isSSH) {
|
||||||
file = relative(this.switchCWD.replace(/\\/g, "/"), file.replace(/\\/g, "/"));
|
file = relative(this.switchCWD.replace(/\\/g, "/"), file.replace(/\\/g, "/"));
|
||||||
file = systemPath.resolve(this.trimCWD.replace(/\\/g, "/"), file.replace(/\\/g, "/"));
|
file = systemPath.resolve(this.trimCWD.replace(/\\/g, "/"), file.replace(/\\/g, "/"));
|
||||||
}
|
} else if (process.platform === "win32") {
|
||||||
else if (process.platform === "win32") {
|
|
||||||
if (file.startsWith("\\cygdrive\\") || file.startsWith("/cygdrive/")) {
|
if (file.startsWith("\\cygdrive\\") || file.startsWith("/cygdrive/")) {
|
||||||
file = file[10] + ":" + file.substr(11); // replaces /cygdrive/c/foo/bar.txt with c:/foo/bar.txt
|
file = file[10] + ":" + file.substr(11); // replaces /cygdrive/c/foo/bar.txt with c:/foo/bar.txt
|
||||||
}
|
}
|
||||||
|
|
@ -333,8 +330,7 @@ export class MI2DebugSession extends DebugSession {
|
||||||
}, msg => {
|
}, msg => {
|
||||||
this.sendErrorResponse(response, 2, `Could not continue: ${msg}`);
|
this.sendErrorResponse(response, 2, `Could not continue: ${msg}`);
|
||||||
});
|
});
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
this.sendResponse(response);
|
this.sendResponse(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -353,8 +349,7 @@ export class MI2DebugSession extends DebugSession {
|
||||||
let id: number | string | VariableObject | ExtendedVariable;
|
let id: number | string | VariableObject | ExtendedVariable;
|
||||||
if (args.variablesReference < VAR_HANDLES_START) {
|
if (args.variablesReference < VAR_HANDLES_START) {
|
||||||
id = args.variablesReference - STACK_HANDLES_START;
|
id = args.variablesReference - STACK_HANDLES_START;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
id = this.variableHandles.get(args.variablesReference);
|
id = this.variableHandles.get(args.variablesReference);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -369,8 +364,7 @@ export class MI2DebugSession extends DebugSession {
|
||||||
let id: number;
|
let id: number;
|
||||||
if (this.variableHandlesReverse.hasOwnProperty(varObj.name)) {
|
if (this.variableHandlesReverse.hasOwnProperty(varObj.name)) {
|
||||||
id = this.variableHandlesReverse[varObj.name];
|
id = this.variableHandlesReverse[varObj.name];
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
id = createVariable(varObj);
|
id = createVariable(varObj);
|
||||||
this.variableHandlesReverse[varObj.name] = id;
|
this.variableHandlesReverse[varObj.name] = id;
|
||||||
}
|
}
|
||||||
|
|
@ -398,29 +392,25 @@ export class MI2DebugSession extends DebugSession {
|
||||||
});
|
});
|
||||||
const varId = this.variableHandlesReverse[varObjName];
|
const varId = this.variableHandlesReverse[varObjName];
|
||||||
varObj = this.variableHandles.get(varId) as any;
|
varObj = this.variableHandles.get(varId) as any;
|
||||||
}
|
} catch (err) {
|
||||||
catch (err) {
|
|
||||||
if (err instanceof MIError && err.message == "Variable object not found") {
|
if (err instanceof MIError && err.message == "Variable object not found") {
|
||||||
varObj = await this.miDebugger.varCreate(variable.name, varObjName);
|
varObj = await this.miDebugger.varCreate(variable.name, varObjName);
|
||||||
const varId = findOrCreateVariable(varObj);
|
const varId = findOrCreateVariable(varObj);
|
||||||
varObj.exp = variable.name;
|
varObj.exp = variable.name;
|
||||||
varObj.id = varId;
|
varObj.id = varId;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
variables.push(varObj.toProtocolVariable());
|
variables.push(varObj.toProtocolVariable());
|
||||||
}
|
} catch (err) {
|
||||||
catch (err) {
|
|
||||||
variables.push({
|
variables.push({
|
||||||
name: variable.name,
|
name: variable.name,
|
||||||
value: `<${err}>`,
|
value: `<${err}>`,
|
||||||
variablesReference: 0
|
variablesReference: 0
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if (variable.valueStr !== undefined) {
|
if (variable.valueStr !== undefined) {
|
||||||
let expanded = expandValue(createVariable, `{${variable.name}=${variable.valueStr})`, "", variable.raw);
|
let expanded = expandValue(createVariable, `{${variable.name}=${variable.valueStr})`, "", variable.raw);
|
||||||
if (expanded) {
|
if (expanded) {
|
||||||
|
|
@ -447,12 +437,10 @@ export class MI2DebugSession extends DebugSession {
|
||||||
variables: variables
|
variables: variables
|
||||||
};
|
};
|
||||||
this.sendResponse(response);
|
this.sendResponse(response);
|
||||||
}
|
} catch (err) {
|
||||||
catch (err) {
|
|
||||||
this.sendErrorResponse(response, 1, `Could not expand variable: ${err}`);
|
this.sendErrorResponse(response, 1, `Could not expand variable: ${err}`);
|
||||||
}
|
}
|
||||||
}
|
} else if (typeof id == "string") {
|
||||||
else if (typeof id == "string") {
|
|
||||||
// Variable members
|
// Variable members
|
||||||
let variable;
|
let variable;
|
||||||
try {
|
try {
|
||||||
|
|
@ -462,8 +450,7 @@ export class MI2DebugSession extends DebugSession {
|
||||||
let expanded = expandValue(createVariable, variable.result("value"), id, variable);
|
let expanded = expandValue(createVariable, variable.result("value"), id, variable);
|
||||||
if (!expanded) {
|
if (!expanded) {
|
||||||
this.sendErrorResponse(response, 2, `Could not expand variable`);
|
this.sendErrorResponse(response, 2, `Could not expand variable`);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if (typeof expanded[0] == "string")
|
if (typeof expanded[0] == "string")
|
||||||
expanded = [
|
expanded = [
|
||||||
{
|
{
|
||||||
|
|
@ -477,16 +464,13 @@ export class MI2DebugSession extends DebugSession {
|
||||||
};
|
};
|
||||||
this.sendResponse(response);
|
this.sendResponse(response);
|
||||||
}
|
}
|
||||||
}
|
} catch (e) {
|
||||||
catch (e) {
|
|
||||||
this.sendErrorResponse(response, 2, `Could not expand variable: ${e}`);
|
this.sendErrorResponse(response, 2, `Could not expand variable: ${e}`);
|
||||||
}
|
}
|
||||||
}
|
} catch (err) {
|
||||||
catch (err) {
|
|
||||||
this.sendErrorResponse(response, 1, `Could not expand variable: ${err}`);
|
this.sendErrorResponse(response, 1, `Could not expand variable: ${err}`);
|
||||||
}
|
}
|
||||||
}
|
} else if (typeof id == "object") {
|
||||||
else if (typeof id == "object") {
|
|
||||||
if (id instanceof VariableObject) {
|
if (id instanceof VariableObject) {
|
||||||
// Variable members
|
// Variable members
|
||||||
let children: VariableObject[];
|
let children: VariableObject[];
|
||||||
|
|
@ -502,12 +486,10 @@ export class MI2DebugSession extends DebugSession {
|
||||||
variables: vars
|
variables: vars
|
||||||
};
|
};
|
||||||
this.sendResponse(response);
|
this.sendResponse(response);
|
||||||
}
|
} catch (err) {
|
||||||
catch (err) {
|
|
||||||
this.sendErrorResponse(response, 1, `Could not expand variable: ${err}`);
|
this.sendErrorResponse(response, 1, `Could not expand variable: ${err}`);
|
||||||
}
|
}
|
||||||
}
|
} else if (id instanceof ExtendedVariable) {
|
||||||
else if (id instanceof ExtendedVariable) {
|
|
||||||
const varReq = id;
|
const varReq = id;
|
||||||
if (varReq.options.arg) {
|
if (varReq.options.arg) {
|
||||||
const strArr = [];
|
const strArr = [];
|
||||||
|
|
@ -526,16 +508,14 @@ export class MI2DebugSession extends DebugSession {
|
||||||
const expanded = expandValue(createVariable, variable.result("value"), varReq.name, variable);
|
const expanded = expandValue(createVariable, variable.result("value"), varReq.name, variable);
|
||||||
if (!expanded) {
|
if (!expanded) {
|
||||||
this.sendErrorResponse(response, 15, `Could not expand variable`);
|
this.sendErrorResponse(response, 15, `Could not expand variable`);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if (typeof expanded == "string") {
|
if (typeof expanded == "string") {
|
||||||
if (expanded == "<nullptr>") {
|
if (expanded == "<nullptr>") {
|
||||||
if (argsPart)
|
if (argsPart)
|
||||||
argsPart = false;
|
argsPart = false;
|
||||||
else
|
else
|
||||||
return submit();
|
return submit();
|
||||||
}
|
} else if (expanded[0] != '"') {
|
||||||
else if (expanded[0] != '"') {
|
|
||||||
strArr.push({
|
strArr.push({
|
||||||
name: "[err]",
|
name: "[err]",
|
||||||
value: expanded,
|
value: expanded,
|
||||||
|
|
@ -549,8 +529,7 @@ export class MI2DebugSession extends DebugSession {
|
||||||
variablesReference: 0
|
variablesReference: 0
|
||||||
});
|
});
|
||||||
addOne();
|
addOne();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
strArr.push({
|
strArr.push({
|
||||||
name: "[err]",
|
name: "[err]",
|
||||||
value: expanded,
|
value: expanded,
|
||||||
|
|
@ -559,24 +538,20 @@ export class MI2DebugSession extends DebugSession {
|
||||||
submit();
|
submit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} catch (e) {
|
||||||
catch (e) {
|
|
||||||
this.sendErrorResponse(response, 14, `Could not expand variable: ${e}`);
|
this.sendErrorResponse(response, 14, `Could not expand variable: ${e}`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
addOne();
|
addOne();
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
this.sendErrorResponse(response, 13, `Unimplemented variable request options: ${JSON.stringify(varReq.options)}`);
|
this.sendErrorResponse(response, 13, `Unimplemented variable request options: ${JSON.stringify(varReq.options)}`);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
response.body = {
|
response.body = {
|
||||||
variables: id
|
variables: id
|
||||||
};
|
};
|
||||||
this.sendResponse(response);
|
this.sendResponse(response);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
response.body = {
|
response.body = {
|
||||||
variables: variables
|
variables: variables
|
||||||
};
|
};
|
||||||
|
|
@ -678,6 +653,5 @@ function prettyStringArray(strings) {
|
||||||
return strings.join(", ");
|
return strings.join(", ");
|
||||||
else
|
else
|
||||||
return JSON.stringify(strings);
|
return JSON.stringify(strings);
|
||||||
}
|
} else return strings;
|
||||||
else return strings;
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,6 @@
|
||||||
"no-unnecessary-initializer": false,
|
"no-unnecessary-initializer": false,
|
||||||
"object-literal-shorthand": false,
|
"object-literal-shorthand": false,
|
||||||
"object-literal-sort-keys": false,
|
"object-literal-sort-keys": false,
|
||||||
"one-line": false,
|
|
||||||
"one-variable-per-declaration": false,
|
"one-variable-per-declaration": false,
|
||||||
"only-arrow-functions": false,
|
"only-arrow-functions": false,
|
||||||
"ordered-imports": false,
|
"ordered-imports": false,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue