commit
606a25b38c
15 changed files with 143 additions and 225 deletions
|
|
@ -84,7 +84,7 @@ export class VariableObject {
|
|||
frozen: boolean;
|
||||
dynamic: boolean;
|
||||
displayhint: string;
|
||||
has_more: boolean;
|
||||
hasMore: boolean;
|
||||
id: number;
|
||||
constructor(node: any) {
|
||||
this.name = MINode.valueOf(node, "name");
|
||||
|
|
@ -97,7 +97,7 @@ export class VariableObject {
|
|||
this.dynamic = !!MINode.valueOf(node, "dynamic");
|
||||
this.displayhint = MINode.valueOf(node, "displayhint");
|
||||
// TODO: use has_more when it's > 0
|
||||
this.has_more = !!MINode.valueOf(node, "has_more");
|
||||
this.hasMore = !!MINode.valueOf(node, "has_more");
|
||||
}
|
||||
|
||||
public applyChanges(node: MINode) {
|
||||
|
|
@ -107,7 +107,7 @@ export class VariableObject {
|
|||
}
|
||||
this.dynamic = !!MINode.valueOf(node, "dynamic");
|
||||
this.displayhint = MINode.valueOf(node, "displayhint");
|
||||
this.has_more = !!MINode.valueOf(node, "has_more");
|
||||
this.hasMore = !!MINode.valueOf(node, "has_more");
|
||||
}
|
||||
|
||||
public isCompound(): boolean {
|
||||
|
|
@ -133,7 +133,7 @@ export interface MIError extends Error {
|
|||
readonly name: string;
|
||||
readonly message: string;
|
||||
readonly source: string;
|
||||
};
|
||||
}
|
||||
export interface MIErrorConstructor {
|
||||
new (message: string, source: string): MIError;
|
||||
readonly prototype: MIError;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { MINode } from "./mi_parse"
|
||||
import { MINode } from "./mi_parse";
|
||||
|
||||
const resultRegex = /^([a-zA-Z_\-][a-zA-Z0-9_\-]*|\[\d+\])\s*=\s*/;
|
||||
const variableRegex = /^[a-zA-Z_\-][a-zA-Z0-9_\-]*/;
|
||||
|
|
@ -75,8 +75,7 @@ export function expandValue(variableCreate: Function, value: string, root: strin
|
|||
name = name.substr(1);
|
||||
}
|
||||
namespace = namespace + pointerCombineChar + name;
|
||||
}
|
||||
else
|
||||
} else
|
||||
namespace = name;
|
||||
}
|
||||
}
|
||||
|
|
@ -151,45 +150,35 @@ export function expandValue(variableCreate: Function, value: string, root: strin
|
|||
else if (value.startsWith("true")) {
|
||||
primitive = "true";
|
||||
value = value.substr(4).trim();
|
||||
}
|
||||
else if (value.startsWith("false")) {
|
||||
} else if (value.startsWith("false")) {
|
||||
primitive = "false";
|
||||
value = value.substr(5).trim();
|
||||
}
|
||||
else if (match = nullpointerRegex.exec(value)) {
|
||||
} else if (match = nullpointerRegex.exec(value)) {
|
||||
primitive = "<nullptr>";
|
||||
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();
|
||||
primitive = parseCString();
|
||||
}
|
||||
else if (match = referenceRegex.exec(value)) {
|
||||
} else if (match = referenceRegex.exec(value)) {
|
||||
primitive = "*" + match[0];
|
||||
value = value.substr(match[0].length).trim();
|
||||
}
|
||||
else if (match = cppReferenceRegex.exec(value)) {
|
||||
} else if (match = cppReferenceRegex.exec(value)) {
|
||||
primitive = match[0];
|
||||
value = value.substr(match[0].length).trim();
|
||||
}
|
||||
else if (match = charRegex.exec(value)) {
|
||||
} else if (match = charRegex.exec(value)) {
|
||||
primitive = match[1];
|
||||
value = value.substr(match[0].length - 1);
|
||||
primitive += " " + parseCString();
|
||||
}
|
||||
else if (match = numberRegex.exec(value)) {
|
||||
} else if (match = numberRegex.exec(value)) {
|
||||
primitive = match[0];
|
||||
value = value.substr(match[0].length).trim();
|
||||
}
|
||||
else if (match = variableRegex.exec(value)) {
|
||||
} else if (match = variableRegex.exec(value)) {
|
||||
primitive = match[0];
|
||||
value = value.substr(match[0].length).trim();
|
||||
}
|
||||
else if (match = errorRegex.exec(value)) {
|
||||
} else if (match = errorRegex.exec(value)) {
|
||||
primitive = match[0];
|
||||
value = value.substr(match[0].length).trim();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
primitive = value;
|
||||
}
|
||||
return primitive;
|
||||
|
|
@ -225,22 +214,18 @@ export function expandValue(variableCreate: Function, value: string, root: strin
|
|||
if (typeof val == "object") {
|
||||
ref = variableCreate(val);
|
||||
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") {
|
||||
ref = variableCreate(getNamespace("*(" + name), { arg: true });
|
||||
val = "<args>";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
ref = variableCreate(getNamespace("*" + name));
|
||||
val = "Object@" + val;
|
||||
}
|
||||
}
|
||||
else if (typeof val == "string" && val.startsWith("@0x")) {
|
||||
} else if (typeof val == "string" && val.startsWith("@0x")) {
|
||||
ref = variableCreate(getNamespace("*&" + name.substr));
|
||||
val = "Ref" + val;
|
||||
}
|
||||
else if (typeof val == "string" && val.startsWith("<...>")) {
|
||||
} else if (typeof val == "string" && val.startsWith("<...>")) {
|
||||
ref = variableCreate(getNamespace(name));
|
||||
val = "...";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import * as ChildProcess from "child_process"
|
||||
import * as fs from "fs"
|
||||
import * as ChildProcess from "child_process";
|
||||
import * as fs from "fs";
|
||||
|
||||
export function spawnTerminalEmulator(preferedEmulator: string): Thenable<string> {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
import { Breakpoint, IBackend, Thread, Stack, SSHArguments, Variable, VariableObject, MIError } from "../backend"
|
||||
import * as ChildProcess from "child_process"
|
||||
import { EventEmitter } from "events"
|
||||
import { Breakpoint, IBackend, Thread, Stack, SSHArguments, Variable, VariableObject, MIError } from "../backend";
|
||||
import * as ChildProcess from "child_process";
|
||||
import { EventEmitter } from "events";
|
||||
import { parseMI, MINode } from '../mi_parse';
|
||||
import * as linuxTerm from '../linux/console';
|
||||
import * as net from "net"
|
||||
import * as fs from "fs"
|
||||
import { posix } from "path"
|
||||
import * as nativePath from "path"
|
||||
import * as net from "net";
|
||||
import * as fs from "fs";
|
||||
import { posix } from "path";
|
||||
import * as nativePath from "path";
|
||||
const path = posix;
|
||||
const Client = require("ssh2").Client;
|
||||
import { Client } from "ssh2";
|
||||
|
||||
export function escape(str: string) {
|
||||
return str.replace(/\\/g, "\\\\").replace(/"/g, "\\\"");
|
||||
|
|
@ -66,13 +66,12 @@ export class MI2 extends EventEmitter implements IBackend {
|
|||
promises.push(this.sendCommand("exec-arguments " + procArgs));
|
||||
if (process.platform == "win32") {
|
||||
if (separateConsole !== undefined)
|
||||
promises.push(this.sendCommand("gdb-set new-console on"))
|
||||
promises.push(this.sendCommand("gdb-set new-console on"));
|
||||
Promise.all(promises).then(() => {
|
||||
this.emit("debug-ready");
|
||||
resolve();
|
||||
}, reject);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (separateConsole !== undefined) {
|
||||
linuxTerm.spawnTerminalEmulator(separateConsole).then(tty => {
|
||||
promises.push(this.sendCommand("inferior-tty-set " + tty));
|
||||
|
|
@ -81,8 +80,7 @@ export class MI2 extends EventEmitter implements IBackend {
|
|||
resolve();
|
||||
}, reject);
|
||||
});
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
Promise.all(promises).then(() => {
|
||||
this.emit("debug-ready");
|
||||
resolve();
|
||||
|
|
@ -170,7 +168,7 @@ export class MI2 extends EventEmitter implements IBackend {
|
|||
if (procArgs && procArgs.length && !attach)
|
||||
promises.push(this.sendCommand("exec-arguments " + procArgs));
|
||||
Promise.all(promises).then(() => {
|
||||
this.emit("debug-ready")
|
||||
this.emit("debug-ready");
|
||||
resolve();
|
||||
}, reject);
|
||||
});
|
||||
|
|
@ -187,8 +185,7 @@ export class MI2 extends EventEmitter implements IBackend {
|
|||
if (ssh) {
|
||||
if (!path.isAbsolute(target))
|
||||
target = path.join(cwd, target);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (!nativePath.isAbsolute(target))
|
||||
target = nativePath.join(cwd, target);
|
||||
}
|
||||
|
|
@ -231,7 +228,7 @@ export class MI2 extends EventEmitter implements IBackend {
|
|||
commands.push(this.sendCommand("file-symbol-file \"" + escape(executable) + "\""));
|
||||
}
|
||||
Promise.all(commands).then(() => {
|
||||
this.emit("debug-ready")
|
||||
this.emit("debug-ready");
|
||||
resolve();
|
||||
}, reject);
|
||||
});
|
||||
|
|
@ -256,7 +253,7 @@ export class MI2 extends EventEmitter implements IBackend {
|
|||
this.sendCommand("environment-directory \"" + escape(cwd) + "\""),
|
||||
this.sendCommand("target-select remote " + target)
|
||||
]).then(() => {
|
||||
this.emit("debug-ready")
|
||||
this.emit("debug-ready");
|
||||
resolve();
|
||||
}, reject);
|
||||
});
|
||||
|
|
@ -318,8 +315,7 @@ export class MI2 extends EventEmitter implements IBackend {
|
|||
if (couldBeOutput(line)) {
|
||||
if (!gdbMatch.exec(line))
|
||||
this.log("stdout", line);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
const parsed = parseMI(line);
|
||||
if (this.debugOutput)
|
||||
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
|
||||
this.log("stderr", "Program exited with code " + parsed.record("exit-code"));
|
||||
this.emit("exited-normally", parsed);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
this.log("console", "Not implemented stop reason (assuming exception): " + reason);
|
||||
this.emit("stopped", parsed);
|
||||
}
|
||||
|
|
@ -408,10 +403,9 @@ export class MI2 extends EventEmitter implements IBackend {
|
|||
}, 1000);
|
||||
this.stream.on("exit", function (code) {
|
||||
clearTimeout(to);
|
||||
})
|
||||
});
|
||||
this.sendRaw("-gdb-exit");
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
const proc = this.process;
|
||||
const to = setTimeout(() => {
|
||||
process.kill(-proc.pid);
|
||||
|
|
@ -521,8 +515,7 @@ export class MI2 extends EventEmitter implements IBackend {
|
|||
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");
|
||||
location += "-t ";
|
||||
}
|
||||
else if (parseInt(match) != 0)
|
||||
} else if (parseInt(match) != 0)
|
||||
location += "-t -i " + parseInt(match) + " ";
|
||||
}
|
||||
}
|
||||
|
|
@ -547,13 +540,11 @@ export class MI2 extends EventEmitter implements IBackend {
|
|||
resolve([false, undefined]);
|
||||
}
|
||||
}, reject);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
this.breakpoints.set(newBrk, bkptNum);
|
||||
resolve([true, newBrk]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
reject(result);
|
||||
}
|
||||
}, reject);
|
||||
|
|
@ -570,8 +561,7 @@ export class MI2 extends EventEmitter implements IBackend {
|
|||
if (result.resultRecords.resultClass == "done") {
|
||||
this.breakpoints.delete(breakpoint);
|
||||
resolve(true);
|
||||
}
|
||||
else resolve(false);
|
||||
} else resolve(false);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
@ -584,8 +574,7 @@ export class MI2 extends EventEmitter implements IBackend {
|
|||
if (result.resultRecords.resultClass == "done") {
|
||||
this.breakpoints.clear();
|
||||
resolve(true);
|
||||
}
|
||||
else resolve(false);
|
||||
} else resolve(false);
|
||||
}, () => {
|
||||
resolve(false);
|
||||
});
|
||||
|
|
@ -719,7 +708,7 @@ export class MI2 extends EventEmitter implements IBackend {
|
|||
async varUpdate(name: string = "*"): Promise<MINode> {
|
||||
if (trace)
|
||||
this.log("stderr", "varUpdate");
|
||||
return this.sendCommand(`var-update --all-values ${name}`)
|
||||
return this.sendCommand(`var-update --all-values ${name}`);
|
||||
}
|
||||
|
||||
async varAssign(name: string, rawValue: string): Promise<MINode> {
|
||||
|
|
@ -739,8 +728,7 @@ export class MI2 extends EventEmitter implements IBackend {
|
|||
sendUserInput(command: string, threadId: number = 0, frameLevel: number = 0): Thenable<any> {
|
||||
if (command.startsWith("-")) {
|
||||
return this.sendCommand(command.substr(1));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return this.sendCliCommand(command, threadId, frameLevel);
|
||||
}
|
||||
}
|
||||
|
|
@ -755,12 +743,12 @@ export class MI2 extends EventEmitter implements IBackend {
|
|||
}
|
||||
|
||||
async sendCliCommand(command: string, threadId: number = 0, frameLevel: number = 0) {
|
||||
let mi_command = "interpreter-exec ";
|
||||
let miCommand = "interpreter-exec ";
|
||||
if (threadId != 0) {
|
||||
mi_command += `--thread ${threadId} --frame ${frameLevel} `;
|
||||
miCommand += `--thread ${threadId} --frame ${frameLevel} `;
|
||||
}
|
||||
mi_command += `console "${command.replace(/[\\"']/g, '\\$&')}"`;
|
||||
await this.sendCommand(mi_command);
|
||||
miCommand += `console "${command.replace(/[\\"']/g, '\\$&')}"`;
|
||||
await this.sendCommand(miCommand);
|
||||
}
|
||||
|
||||
sendCommand(command: string, suppressFailure: boolean = false): Thenable<MINode> {
|
||||
|
|
@ -771,11 +759,9 @@ export class MI2 extends EventEmitter implements IBackend {
|
|||
if (suppressFailure) {
|
||||
this.log("stderr", `WARNING: Error executing command '${command}'`);
|
||||
resolve(node);
|
||||
}
|
||||
else
|
||||
} else
|
||||
reject(new MIError(node.result("msg") || "Internal error", command));
|
||||
}
|
||||
else
|
||||
} else
|
||||
resolve(node);
|
||||
};
|
||||
this.sendRaw(sel + "-" + command);
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import { MI2, escape } from "./mi2"
|
||||
import { Breakpoint } from "../backend"
|
||||
import * as ChildProcess from "child_process"
|
||||
import { posix } from "path"
|
||||
import * as nativePath from "path"
|
||||
import { MI2, escape } from "./mi2";
|
||||
import { Breakpoint } from "../backend";
|
||||
import * as ChildProcess from "child_process";
|
||||
import { posix } from "path";
|
||||
import * as nativePath from "path";
|
||||
const path = posix;
|
||||
|
||||
export class MI2_LLDB extends MI2 {
|
||||
|
|
@ -10,8 +10,7 @@ export class MI2_LLDB extends MI2 {
|
|||
if (ssh) {
|
||||
if (!path.isAbsolute(target))
|
||||
target = path.join(cwd, target);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (!nativePath.isAbsolute(target))
|
||||
target = nativePath.join(cwd, target);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { MI2_LLDB } from "./mi2lldb"
|
||||
import { Stack } from "../backend"
|
||||
import { MINode } from "../mi_parse"
|
||||
import { MI2_LLDB } from "./mi2lldb";
|
||||
import { Stack } from "../backend";
|
||||
import { MINode } from "../mi_parse";
|
||||
|
||||
export class MI2_Mago extends MI2_LLDB {
|
||||
getStack(maxLevels: number, thread: number): Promise<Stack[]> {
|
||||
|
|
@ -29,7 +29,7 @@ export class MI2_Mago extends MI2_LLDB {
|
|||
level: level,
|
||||
line: line
|
||||
});
|
||||
}
|
||||
};
|
||||
stack.forEach(element => {
|
||||
if (element)
|
||||
if (element[0] == "stack") {
|
||||
|
|
|
|||
|
|
@ -39,8 +39,7 @@ function parseString(str: string): string {
|
|||
else if (m = octalMatch.exec(str.substr(i))) {
|
||||
ret.writeUInt8(parseInt(m[0], 8), bufIndex++);
|
||||
i += 2;
|
||||
}
|
||||
else
|
||||
} else
|
||||
bufIndex += ret.write(str[i], bufIndex);
|
||||
escaped = false;
|
||||
} else {
|
||||
|
|
@ -93,8 +92,7 @@ export class MINode implements MIInfo {
|
|||
path = path.substr(target[0].length);
|
||||
if (current.length && typeof current != "string") {
|
||||
const found = [];
|
||||
for (let i = 0; i < current.length; i++) {
|
||||
const element = current[i];
|
||||
for (const element of current) {
|
||||
if (element[0] == target[1]) {
|
||||
found.push(element[1]);
|
||||
}
|
||||
|
|
@ -105,12 +103,10 @@ export class MINode implements MIInfo {
|
|||
current = found[0];
|
||||
} else return undefined;
|
||||
} else return undefined;
|
||||
}
|
||||
else if (path[0] == '@') {
|
||||
} else if (path[0] == '@') {
|
||||
current = [current];
|
||||
path = path.substr(1);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
target = indexRegex.exec(path);
|
||||
if (target) {
|
||||
path = path.substr(target[0].length);
|
||||
|
|
@ -119,8 +115,7 @@ export class MINode implements MIInfo {
|
|||
current = current[i];
|
||||
} else if (i == 0) {
|
||||
} else return undefined;
|
||||
}
|
||||
else return undefined;
|
||||
} else return undefined;
|
||||
}
|
||||
path = path.trim();
|
||||
} while (path);
|
||||
|
|
@ -189,8 +184,7 @@ export function parseMI(output: string): MINode {
|
|||
let str;
|
||||
try {
|
||||
str = parseString(output.substr(0, stringEnd));
|
||||
}
|
||||
catch (e) {
|
||||
} catch (e) {
|
||||
str = output.substr(0, stringEnd);
|
||||
}
|
||||
output = output.substr(stringEnd);
|
||||
|
|
@ -287,8 +281,7 @@ export function parseMI(output: string): MINode {
|
|||
while (result = parseCommaResult())
|
||||
asyncRecord.output.push(result);
|
||||
outOfBandRecord.push(asyncRecord);
|
||||
}
|
||||
else if (match[3]) {
|
||||
} else if (match[3]) {
|
||||
const streamRecord = {
|
||||
isStream: true,
|
||||
type: streamRecordType[match[3]],
|
||||
|
|
|
|||
|
|
@ -42,8 +42,7 @@ function getMemoryRange(range: string) {
|
|||
if (memoryLocationRegex.exec(length))
|
||||
length = parseInt(length.substr(2), 16).toString();
|
||||
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 to = range.substr(index + 1);
|
||||
if (!memoryLocationRegex.exec(from))
|
||||
|
|
@ -51,8 +50,7 @@ function getMemoryRange(range: string) {
|
|||
if (!memoryLocationRegex.exec(to))
|
||||
return undefined;
|
||||
return "from=" + encodeURIComponent(from) + "&to=" + encodeURIComponent(to);
|
||||
}
|
||||
else if (memoryLocationRegex.exec(range))
|
||||
} else if (memoryLocationRegex.exec(range))
|
||||
return "at=" + encodeURIComponent(range);
|
||||
else return undefined;
|
||||
}
|
||||
|
|
@ -100,18 +98,14 @@ class MemoryContentProvider implements vscode.TextDocumentContentProvider {
|
|||
highlightAt = 64;
|
||||
from = Math.max(loc - 64, 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);
|
||||
if (splits[1].split("=")[0] == "to") {
|
||||
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]);
|
||||
}
|
||||
else return reject("Invalid Range");
|
||||
}
|
||||
else return reject("Invalid Range");
|
||||
} else return reject("Invalid Range");
|
||||
} else return reject("Invalid Range");
|
||||
if (to < from)
|
||||
return reject("Negative Range");
|
||||
conn.write("examineMemory " + JSON.stringify([from, to - from + 1]));
|
||||
|
|
|
|||
23
src/gdb.ts
23
src/gdb.ts
|
|
@ -87,13 +87,12 @@ class GDBDebugSession extends MI2DebugSession {
|
|||
if (this.crashed)
|
||||
this.handlePause(undefined);
|
||||
}, err => {
|
||||
this.sendErrorResponse(response, 100, `Failed to start MI Debugger: ${err.toString()}`)
|
||||
this.sendErrorResponse(response, 100, `Failed to start MI Debugger: ${err.toString()}`);
|
||||
});
|
||||
}, 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(() => {
|
||||
if (args.autorun)
|
||||
args.autorun.forEach(command => {
|
||||
|
|
@ -108,10 +107,10 @@ class GDBDebugSession extends MI2DebugSession {
|
|||
if (this.crashed)
|
||||
this.handlePause(undefined);
|
||||
}, err => {
|
||||
this.sendErrorResponse(response, 100, `Failed to Start MI Debugger: ${err.toString()}`)
|
||||
this.sendErrorResponse(response, 100, `Failed to Start MI Debugger: ${err.toString()}`);
|
||||
});
|
||||
}, err => {
|
||||
this.sendErrorResponse(response, 103, `Failed to load MI Debugger: ${err.toString()}`)
|
||||
this.sendErrorResponse(response, 103, `Failed to load MI Debugger: ${err.toString()}`);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -151,10 +150,9 @@ class GDBDebugSession extends MI2DebugSession {
|
|||
}, 50);
|
||||
this.sendResponse(response);
|
||||
}, err => {
|
||||
this.sendErrorResponse(response, 102, `Failed to SSH: ${err.toString()}`)
|
||||
this.sendErrorResponse(response, 102, `Failed to SSH: ${err.toString()}`);
|
||||
});
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (args.remote) {
|
||||
this.miDebugger.connect(args.cwd, args.executable, args.target).then(() => {
|
||||
if (args.autorun)
|
||||
|
|
@ -163,10 +161,9 @@ class GDBDebugSession extends MI2DebugSession {
|
|||
});
|
||||
this.sendResponse(response);
|
||||
}, 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(() => {
|
||||
if (args.autorun)
|
||||
args.autorun.forEach(command => {
|
||||
|
|
@ -174,7 +171,7 @@ class GDBDebugSession extends MI2DebugSession {
|
|||
});
|
||||
this.sendResponse(response);
|
||||
}, err => {
|
||||
this.sendErrorResponse(response, 101, `Failed to attach: ${err.toString()}`)
|
||||
this.sendErrorResponse(response, 101, `Failed to attach: ${err.toString()}`);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,8 +83,7 @@ class LLDBDebugSession extends MI2DebugSession {
|
|||
this.handlePause(undefined);
|
||||
});
|
||||
});
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
this.miDebugger.load(args.cwd, args.target, args.arguments, undefined).then(() => {
|
||||
if (args.autorun)
|
||||
args.autorun.forEach(command => {
|
||||
|
|
|
|||
|
|
@ -179,18 +179,16 @@ export class MI2DebugSession extends DebugSession {
|
|||
response.body = {
|
||||
value: res.result("value")
|
||||
};
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
await this.miDebugger.changeVariable(args.name, args.value);
|
||||
response.body = {
|
||||
value: args.value
|
||||
};
|
||||
}
|
||||
this.sendResponse(response);
|
||||
}
|
||||
catch (err) {
|
||||
} catch (err) {
|
||||
this.sendErrorResponse(response, 11, `Could not continue: ${err}`);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
protected setFunctionBreakPointsRequest(response: DebugProtocol.SetFunctionBreakpointsResponse, args: DebugProtocol.SetFunctionBreakpointsArguments): void {
|
||||
|
|
@ -300,8 +298,7 @@ export class MI2DebugSession extends DebugSession {
|
|||
if (this.isSSH) {
|
||||
file = relative(this.switchCWD.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/")) {
|
||||
file = file[10] + ":" + file.substr(11); // replaces /cygdrive/c/foo/bar.txt with c:/foo/bar.txt
|
||||
}
|
||||
|
|
@ -321,7 +318,7 @@ export class MI2DebugSession extends DebugSession {
|
|||
};
|
||||
this.sendResponse(response);
|
||||
}, err => {
|
||||
this.sendErrorResponse(response, 12, `Failed to get Stack Trace: ${err.toString()}`)
|
||||
this.sendErrorResponse(response, 12, `Failed to get Stack Trace: ${err.toString()}`);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -333,8 +330,7 @@ export class MI2DebugSession extends DebugSession {
|
|||
}, msg => {
|
||||
this.sendErrorResponse(response, 2, `Could not continue: ${msg}`);
|
||||
});
|
||||
}
|
||||
else
|
||||
} else
|
||||
this.sendResponse(response);
|
||||
}
|
||||
|
||||
|
|
@ -353,8 +349,7 @@ export class MI2DebugSession extends DebugSession {
|
|||
let id: number | string | VariableObject | ExtendedVariable;
|
||||
if (args.variablesReference < VAR_HANDLES_START) {
|
||||
id = args.variablesReference - STACK_HANDLES_START;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
id = this.variableHandles.get(args.variablesReference);
|
||||
}
|
||||
|
||||
|
|
@ -369,8 +364,7 @@ export class MI2DebugSession extends DebugSession {
|
|||
let id: number;
|
||||
if (this.variableHandlesReverse.hasOwnProperty(varObj.name)) {
|
||||
id = this.variableHandlesReverse[varObj.name];
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
id = createVariable(varObj);
|
||||
this.variableHandlesReverse[varObj.name] = id;
|
||||
}
|
||||
|
|
@ -398,29 +392,25 @@ export class MI2DebugSession extends DebugSession {
|
|||
});
|
||||
const varId = this.variableHandlesReverse[varObjName];
|
||||
varObj = this.variableHandles.get(varId) as any;
|
||||
}
|
||||
catch (err) {
|
||||
} catch (err) {
|
||||
if (err instanceof MIError && err.message == "Variable object not found") {
|
||||
varObj = await this.miDebugger.varCreate(variable.name, varObjName);
|
||||
const varId = findOrCreateVariable(varObj);
|
||||
varObj.exp = variable.name;
|
||||
varObj.id = varId;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
variables.push(varObj.toProtocolVariable());
|
||||
}
|
||||
catch (err) {
|
||||
} catch (err) {
|
||||
variables.push({
|
||||
name: variable.name,
|
||||
value: `<${err}>`,
|
||||
variablesReference: 0
|
||||
});
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (variable.valueStr !== undefined) {
|
||||
let expanded = expandValue(createVariable, `{${variable.name}=${variable.valueStr})`, "", variable.raw);
|
||||
if (expanded) {
|
||||
|
|
@ -447,12 +437,10 @@ export class MI2DebugSession extends DebugSession {
|
|||
variables: variables
|
||||
};
|
||||
this.sendResponse(response);
|
||||
}
|
||||
catch (err) {
|
||||
} catch (err) {
|
||||
this.sendErrorResponse(response, 1, `Could not expand variable: ${err}`);
|
||||
}
|
||||
}
|
||||
else if (typeof id == "string") {
|
||||
} else if (typeof id == "string") {
|
||||
// Variable members
|
||||
let variable;
|
||||
try {
|
||||
|
|
@ -462,8 +450,7 @@ export class MI2DebugSession extends DebugSession {
|
|||
let expanded = expandValue(createVariable, variable.result("value"), id, variable);
|
||||
if (!expanded) {
|
||||
this.sendErrorResponse(response, 2, `Could not expand variable`);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (typeof expanded[0] == "string")
|
||||
expanded = [
|
||||
{
|
||||
|
|
@ -477,16 +464,13 @@ export class MI2DebugSession extends DebugSession {
|
|||
};
|
||||
this.sendResponse(response);
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
} catch (e) {
|
||||
this.sendErrorResponse(response, 2, `Could not expand variable: ${e}`);
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
} catch (err) {
|
||||
this.sendErrorResponse(response, 1, `Could not expand variable: ${err}`);
|
||||
}
|
||||
}
|
||||
else if (typeof id == "object") {
|
||||
} else if (typeof id == "object") {
|
||||
if (id instanceof VariableObject) {
|
||||
// Variable members
|
||||
let children: VariableObject[];
|
||||
|
|
@ -500,14 +484,12 @@ export class MI2DebugSession extends DebugSession {
|
|||
|
||||
response.body = {
|
||||
variables: vars
|
||||
}
|
||||
};
|
||||
this.sendResponse(response);
|
||||
}
|
||||
catch (err) {
|
||||
} catch (err) {
|
||||
this.sendErrorResponse(response, 1, `Could not expand variable: ${err}`);
|
||||
}
|
||||
}
|
||||
else if (id instanceof ExtendedVariable) {
|
||||
} else if (id instanceof ExtendedVariable) {
|
||||
const varReq = id;
|
||||
if (varReq.options.arg) {
|
||||
const strArr = [];
|
||||
|
|
@ -526,16 +508,14 @@ export class MI2DebugSession extends DebugSession {
|
|||
const expanded = expandValue(createVariable, variable.result("value"), varReq.name, variable);
|
||||
if (!expanded) {
|
||||
this.sendErrorResponse(response, 15, `Could not expand variable`);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (typeof expanded == "string") {
|
||||
if (expanded == "<nullptr>") {
|
||||
if (argsPart)
|
||||
argsPart = false;
|
||||
else
|
||||
return submit();
|
||||
}
|
||||
else if (expanded[0] != '"') {
|
||||
} else if (expanded[0] != '"') {
|
||||
strArr.push({
|
||||
name: "[err]",
|
||||
value: expanded,
|
||||
|
|
@ -549,8 +529,7 @@ export class MI2DebugSession extends DebugSession {
|
|||
variablesReference: 0
|
||||
});
|
||||
addOne();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
strArr.push({
|
||||
name: "[err]",
|
||||
value: expanded,
|
||||
|
|
@ -559,24 +538,20 @@ export class MI2DebugSession extends DebugSession {
|
|||
submit();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
} catch (e) {
|
||||
this.sendErrorResponse(response, 14, `Could not expand variable: ${e}`);
|
||||
}
|
||||
};
|
||||
addOne();
|
||||
}
|
||||
else
|
||||
} else
|
||||
this.sendErrorResponse(response, 13, `Unimplemented variable request options: ${JSON.stringify(varReq.options)}`);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
response.body = {
|
||||
variables: id
|
||||
};
|
||||
this.sendResponse(response);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
response.body = {
|
||||
variables: variables
|
||||
};
|
||||
|
|
@ -647,7 +622,7 @@ export class MI2DebugSession extends DebugSession {
|
|||
response.body = {
|
||||
variablesReference: 0,
|
||||
result: res.result("value")
|
||||
}
|
||||
};
|
||||
this.sendResponse(response);
|
||||
}, msg => {
|
||||
this.sendErrorResponse(response, 7, msg.toString());
|
||||
|
|
@ -678,6 +653,5 @@ function prettyStringArray(strings) {
|
|||
return strings.join(", ");
|
||||
else
|
||||
return JSON.stringify(strings);
|
||||
}
|
||||
else return strings;
|
||||
} else return strings;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
// to report the results back to the caller. When the tests are finished, return
|
||||
// a possible error to the callback or null if none.
|
||||
|
||||
const testRunner = require('vscode/lib/testrunner');
|
||||
import * as testRunner from "vscode/lib/testrunner";
|
||||
|
||||
// You can directly control Mocha options by uncommenting the following lines
|
||||
// See https://github.com/mochajs/mocha/wiki/Using-mocha-programmatically#set-options for more info
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ suite("MI Parse", () => {
|
|||
assert.notEqual(parsed.resultRecords, undefined);
|
||||
assert.equal(parsed.resultRecords.resultClass, "done");
|
||||
assert.equal(parsed.resultRecords.results.length, 1);
|
||||
const asm_insns = [
|
||||
const asmInsns = [
|
||||
"asm_insns",
|
||||
[
|
||||
[
|
||||
|
|
@ -125,7 +125,7 @@ suite("MI Parse", () => {
|
|||
]
|
||||
]
|
||||
];
|
||||
assert.deepEqual(parsed.resultRecords.results[0], asm_insns);
|
||||
assert.deepEqual(parsed.resultRecords.results[0], asmInsns);
|
||||
assert.equal(parsed.result("asm_insns.src_and_asm_line.line_asm_insn[1].address"), "0x00000000004e7da5");
|
||||
});
|
||||
test("valueof children", () => {
|
||||
|
|
|
|||
13
tslint.json
13
tslint.json
|
|
@ -3,6 +3,7 @@
|
|||
"extends": "tslint:recommended",
|
||||
"rules": {
|
||||
"no-null-keyword": true,
|
||||
"indent": [true, "tabs"],
|
||||
/* Rules in tslint:recommended that we don't follow yet. */
|
||||
"array-type": false,
|
||||
"arrow-parens": false,
|
||||
|
|
@ -11,8 +12,6 @@
|
|||
"class-name": false,
|
||||
"comment-format": false,
|
||||
"curly": false,
|
||||
"eofline": false,
|
||||
"indent": false,
|
||||
"interface-name": false,
|
||||
"max-classes-per-file": false,
|
||||
"max-line-length": false,
|
||||
|
|
@ -24,24 +23,16 @@
|
|||
"no-consecutive-blank-lines": false,
|
||||
"no-empty": false,
|
||||
"no-shadowed-variable": false,
|
||||
"no-trailing-whitespace": false,
|
||||
"no-unnecessary-initializer": false,
|
||||
"no-var-requires": false,
|
||||
"object-literal-shorthand": false,
|
||||
"object-literal-sort-keys": false,
|
||||
"one-line": false,
|
||||
"one-variable-per-declaration": false,
|
||||
"only-arrow-functions": false,
|
||||
"ordered-imports": false,
|
||||
"prefer-for-of": false,
|
||||
"quotemark": false,
|
||||
"radix": false,
|
||||
"semicolon": false,
|
||||
"space-before-function-paren": false,
|
||||
"trailing-comma": false,
|
||||
"triple-equals": false,
|
||||
"typedef-whitespace": false,
|
||||
"variable-name": false,
|
||||
"whitespace": false
|
||||
"triple-equals": false
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue