Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return __awaiter(this, void 0, void 0, function* () {
vscode_debugadapter_1.logger.init(core_utils_1.noop, path.join(__dirname, '..', '..', '..', 'experimental_debug.log'));
const serviceContainer = serviceRegistry_1.initializeIoc();
const protocolMessageWriter = serviceContainer.get(types_2.IProtocolMessageWriter);
try {
// debugger;
const debugManager = new DebugManager(serviceContainer);
yield debugManager.start();
}
catch (err) {
const message = `Debugger Error: ${err && err.message ? err.message : err.toString()}`;
const details = [message, err && err.name ? err.name : '', err && err.stack ? err.stack : ''].join(os_1.EOL);
vscode_debugadapter_1.logger.error(`${message}${os_1.EOL}${details}`);
// Notify the user.
protocolMessageWriter.write(process.stdout, new messages_1.Event('error', message));
protocolMessageWriter.write(process.stdout, new vscode_debugadapter_1.OutputEvent(`${message}${os_1.EOL}${details}`, 'stderr'));
}
});
}
fn().catch(error => {
const errorMessage = error.stack || error.message || String(error);
if (response != null) {
response.success = false;
// $FlowIgnore: returning an ErrorResponse.
response.body = {
error: {
id: -1,
format: errorMessage,
},
};
this.sendResponse(response);
}
this.sendEvent(
new OutputEvent(
`OCaml Debugger ran into an error:\n\`${errorMessage}\``,
'nuclide_notification',
{type: 'error'},
),
);
this.sendEvent(new TerminatedEvent());
});
}
terminal.registerOnDataReceived((data: string) => {
this._inputBuffer += data;
if (this._inputBuffer.indexOf("\n") >= 0) {
let out = this._inputBuffer.split(/\r?\n/);
for (let i: number = 0; i < out.length - 1; i++) {
this.sendEvent(new OutputEvent(out[i]));
}
this._inputBuffer = out[out.length-1];
}
else if (this._inputBuffer.length > 120) {
this.sendEvent(new OutputEvent(this._inputBuffer));
this._inputBuffer = "";
}
});
onPythonException(pyThread, ex) {
this.lastException = ex;
this.sendEvent(new vscode_debugadapter_1.StoppedEvent("exception", pyThread.Int32Id, `${ex.TypeName}, ${ex.Description}`));
this.sendEvent(new vscode_debugadapter_1.OutputEvent(`${ex.TypeName}, ${ex.Description}\n`, "stderr"));
}
onPythonThreadExited(pyThread) {
process.stderr.on("data", (data) => {
this.sendEvent(new OutputEvent(data.toString(), "stderr"));
});
process.on("error", (error) => {
let onceSocketListened = (message: string) => {
if (once) return;
once = true;
if (this._remoteMode) {
this.sendEvent(new OutputEvent(message));
} else {
launchDebuggee();
}
};
private debugConsole(message: string): void {
this.sendEvent(new OutputEvent(message + '\n', 'console'));
}
public sendOutput(params: IOutputParameters): void {
const event = new OutputEvent(params.output, params.category) as DebugProtocol.OutputEvent;
if (params.variablesReference) {
event.body.variablesReference = params.variablesReference;
}
if (params.location) {
this._locationInSourceToClientConverter.toLocationInSource(params.location, event.body);
}
this._session.sendEvent(event);
}
nodeProcess.stdout.on('data', (data) => {
if (noDebugMode || this._captureFromStd) {
let msg = data.toString();
this._session.sendEvent(new vscode_debugadapter_1.OutputEvent(msg, 'stdout'));
}
});
resolve();
outputCallback: (data: Buffer) => {
let outputEvent = new OutputEvent(data.toString(), "stdout");
this.sendEvent(outputEvent);
},
exitCallback: () => {