-
Notifications
You must be signed in to change notification settings - Fork 124
Expand file tree
/
Copy pathmi2lldb.ts
More file actions
63 lines (59 loc) · 2.06 KB
/
mi2lldb.ts
File metadata and controls
63 lines (59 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import { MI2 } from "./mi2"
import { escape } from "../mi_parse"
import { Breakpoint } from "../backend"
import * as ChildProcess from "child_process"
import { posix } from "path"
import * as nativePath from "path"
let path = posix;
export class MI2_LLDB extends MI2 {
protected initCommands(target: string, cwd: string, autorunBeforeCmds: string[], ssh: boolean = false, attach: boolean = false) {
let cmds = [];
if (ssh) {
if (!path.isAbsolute(target))
target = path.join(cwd, target);
}
else {
if (!nativePath.isAbsolute(target))
target = nativePath.join(cwd, target);
}
autorunBeforeCmds.forEach(command => {
cmds.push(this.sendCommand(command));
});
if (!attach)
cmds.push(this.sendCommand("file-exec-and-symbols \"" + escape(target) + "\""));
return cmds;
}
attach(cwd: string, executable: string, target: string, autorunBeforeCmds: string[]): Thenable<any> {
return new Promise((resolve, reject) => {
let cmds = [];
this.process = ChildProcess.spawn(this.application, this.preargs, { cwd: cwd });
this.process.stdout.on("data", this.stdout.bind(this));
this.process.stderr.on("data", this.stderr.bind(this));
this.process.on("exit", (() => { this.emit("quit"); }).bind(this));
autorunBeforeCmds.forEach(command => {
cmds.push(this.sendCommand(command));
});
cmds.push(this.sendCommand("file-exec-and-symbols \"" + escape(executable) + "\""));
Promise.all(cmds).then(() => {
this.emit("debug-ready");
resolve();
}, reject);
});
}
clearBreakPoints(): Thenable<any> {
return new Promise((resolve, reject) => {
let promises = [];
this.breakpoints.forEach((k, index) => {
promises.push(this.sendCommand("break-delete " + k).then((result) => {
if (result.resultRecords.resultClass == "done") resolve(true);
else resolve(false);
}));
});
this.breakpoints.clear();
Promise.all(promises).then(resolve, reject);
});
}
setBreakPointCondition(bkptNum, condition): Thenable<any> {
return this.sendCommand("break-condition " + bkptNum + " \"" + escape(condition) + "\" 1");
}
}