Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
updateGoroutinesList(goroutines) {
// Assume we need to stop all the threads we saw before...
const needsToBeStopped = new Set();
this.goroutines.forEach((id) => needsToBeStopped.add(id));
for (const goroutine of goroutines) {
// ...but delete from list of threads to stop if we still see it
needsToBeStopped.delete(goroutine.id);
if (!this.goroutines.has(goroutine.id)) {
// Send started event if it's new
this.sendEvent(new vscode_debugadapter_1.ThreadEvent('started', goroutine.id));
}
this.goroutines.add(goroutine.id);
}
// Send existed event if it's no longer there
needsToBeStopped.forEach((id) => {
this.sendEvent(new vscode_debugadapter_1.ThreadEvent('exited', id));
this.goroutines.delete(id);
});
}
setBreakPoints(response, args) {
public async registerThread(ref: VMIsolateRef, eventKind: string): Promise {
let thread = this.getThreadInfoFromRef(ref);
if (!thread) {
thread = new ThreadInfo(this, ref, this.nextThreadId);
this.nextThreadId++;
this.threads.push(thread);
// If this is the first time we've seen it, fire an event
this.debugSession.sendEvent(new ThreadEvent("started", thread.num));
if (this.hasConfigurationDone)
thread.receivedConfigurationDone();
}
// If it's just become runnable (IsolateRunnable), then set breakpoints.
if (eventKind === "IsolateRunnable" && !thread.runnable) {
thread.runnable = true;
if (this.debugSession.observatory) {
await Promise.all([
this.debugSession.observatory.setExceptionPauseMode(thread.ref.id, this.exceptionMode),
this.setLibrariesDebuggable(thread.ref),
this.resetBreakpoints(),
]);
thread.setInitialBreakpoints();
private _checkStatus(response: xdebug.StatusResponse): void {
const connection = response.connection;
if (response.status === 'stopping') {
connection.sendStopCommand().then(response => this._checkStatus(response));
} else if (response.status === 'stopped') {
this._connections.delete(connection.id);
this.sendEvent(new vscode.ThreadEvent('exited', connection.id));
connection.close();
} else if (response.status === 'break') {
// StoppedEvent reason can be 'step', 'breakpoint', 'exception' or 'pause'
let stoppedEventReason: string;
let exceptionText: string;
if (response.exception) {
stoppedEventReason = 'exception';
exceptionText = response.exception.name + ': ' + response.exception.message; // this seems to be ignored currently by VS Code
} else if (response.command.indexOf('step') === 0) {
stoppedEventReason = 'step';
} else {
stoppedEventReason = 'breakpoint';
}
this.sendEvent(new vscode.StoppedEvent(stoppedEventReason, connection.id, exceptionText));
}
}
private handleRequestFinished(message: DebuggerMessage): void {
const threadId = this.getThreadIdFromRequestId(message.sobject.RequestId);
if (threadId !== undefined) {
this.logEvent(message);
this.requestThreads.delete(threadId);
this.sendEvent(new ThreadEvent('exited', threadId));
// cleanup everything that's no longer necessary after all request finished
if (this.requestThreads.size === 0) {
this.log(
TRACE_CATEGORY_VARIABLES,
'handleRequestFinished: clearing variable cache'
);
this.stackFrameInfos.reset();
this.variableHandles.reset();
this.variableContainerReferenceByApexId.clear();
}
}
}
public handleIsolateExit(ref: VMIsolateRef) {
const threadInfo = this.getThreadInfoFromRef(ref);
if (threadInfo) {
this.debugSession.sendEvent(new ThreadEvent("exited", threadInfo.num));
this.threads.splice(this.threads.indexOf(threadInfo), 1);
this.removeStoredData(threadInfo);
}
}
}
protected handleThreadCreated(info: { threadId: number, threadGroupId: string }) {
if (!this.activeThreadIds.has(info.threadId)) {
if (traceThreads) {
this.handleMsg('log', `**** Thread created ${info.threadId}\n`);
}
this.activeThreadIds.add(info.threadId);
this.sendEvent(new ThreadEvent('started', info.threadId));
} else {
this.handleMsg('log', `Thread Error: GDB trying to create thread '${info.threadId}' that already exists`);
}
}
activeThreads.forEach(activeThread => {
if (this.threadsArray.indexOf(activeThread.id) === -1) {
this.sendEvent(new vscode_debugadapter_1.ThreadEvent('started', activeThread.id));
this.sendEvent(new vscode_debugadapter_1.StoppedEvent('breakpoint', activeThread.id));
this.threadsArray.push(activeThread.id);
}
});
}
.then((threadinfos) => {
var ti = threadinfos[0], t = this.getThread(ti.threadid), event = new ThreadEvent();
t.name = ti.name;
event.body = { reason:'started', threadId: t.vscode_threadid };
this.sendEvent(event);
})
.always(() => this.dbgr.resumethread(e.threadid));
private onPythonThreadCreated(pyThread: IPythonThread) {
this.sendEvent(new ThreadEvent("started", pyThread.Int32Id));
}
private onStepCompleted(pyThread: IPythonThread) {