MCPcopy Create free account
hub / github.com/WebFreak001/code-debug / initDebugger

Method initDebugger

src/mibase.ts:51–93  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

49 }
50
51 protected initDebugger() {
52 this.miDebugger.on("launcherror", this.launchError.bind(this));
53 this.miDebugger.on("quit", this.quitEvent.bind(this));
54 this.miDebugger.on("exited-normally", this.quitEvent.bind(this));
55 this.miDebugger.on("stopped", this.stopEvent.bind(this));
56 this.miDebugger.on("msg", this.handleMsg.bind(this));
57 this.miDebugger.on("breakpoint", this.handleBreakpoint.bind(this));
58 this.miDebugger.on("watchpoint", this.handleBreak.bind(this)); // consider to parse old/new, too (otherwise it is in the console only)
59 this.miDebugger.on("step-end", this.handleBreak.bind(this));
60 //this.miDebugger.on("step-out-end", this.handleBreak.bind(this)); // was combined into step-end
61 this.miDebugger.on("step-other", this.handleBreak.bind(this));
62 this.miDebugger.on("signal-stop", this.handlePause.bind(this));
63 this.miDebugger.on("thread-created", this.threadCreatedEvent.bind(this));
64 this.miDebugger.on("thread-exited", this.threadExitedEvent.bind(this));
65 this.miDebugger.once("debug-ready", (() => this.sendEvent(new InitializedEvent())));
66 try {
67 this.commandServer = net.createServer(c => {
68 c.on("data", data => {
69 const rawCmd = data.toString();
70 const spaceIndex = rawCmd.indexOf(" ");
71 let func = rawCmd;
72 let args = [];
73 if (spaceIndex != -1) {
74 func = rawCmd.substring(0, spaceIndex);
75 args = JSON.parse(rawCmd.substring(spaceIndex + 1));
76 }
77 Promise.resolve(this.miDebugger[func].apply(this.miDebugger, args)).then(data => {
78 c.write(data.toString());
79 });
80 });
81 });
82 this.commandServer.on("error", err => {
83 if (process.platform != "win32")
84 this.handleMsg("stderr", "Code-Debug WARNING: Utility Command Server: Error in command socket " + err.toString() + "\nCode-Debug WARNING: The examine memory location command won't work");
85 });
86 if (!fs.existsSync(systemPath.join(os.tmpdir(), "code-debug-sockets")))
87 fs.mkdirSync(systemPath.join(os.tmpdir(), "code-debug-sockets"));
88 this.commandServer.listen(this.serverPath = systemPath.join(os.tmpdir(), "code-debug-sockets", ("Debug-Instance-" + Math.floor(Math.random() * 36 * 36 * 36 * 36).toString(36)).toLowerCase()));
89 } catch (e) {
90 if (process.platform != "win32")
91 this.handleMsg("stderr", "Code-Debug WARNING: Utility Command Server: Failed to start " + e.toString() + "\nCode-Debug WARNING: The examine memory location command won't work");
92 }
93 }
94
95 protected setValuesFormattingMode(mode: ValuesFormattingMode) {
96 switch (mode) {

Callers 6

launchRequestMethod · 0.80
attachRequestMethod · 0.80
launchRequestMethod · 0.80
attachRequestMethod · 0.80
launchRequestMethod · 0.80
attachRequestMethod · 0.80

Calls 2

handleMsgMethod · 0.95
toStringMethod · 0.80

Tested by

no test coverage detected