-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added resume and suspend actions #1971
Added resume and suspend actions #1971
Conversation
|
||
export namespace DebugSessionContextMenu { | ||
export const STOP = [...DEBUG_SESSION_CONTEXT_MENU, '1_stop']; | ||
export const RESUME_ALL_THREADS = [...DEBUG_SESSION_CONTEXT_MENU, '3_resume_all_threads']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These actions should be represented by buttons.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where should the buttons be displayed? Still here? Or just registered to the top debug menu? I figured the context menu should be a good place to have these because it covers the entire session.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Top debug menu will be ok for now.
|
||
export const SUSPEND_ALL_THREADS = { | ||
id: 'debug.thread.suspend.all', | ||
label: 'Suspend all threads' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just Suspend
|
||
export const RESUME_ALL_THREADS = { | ||
id: 'debug.thread.resume.all', | ||
label: 'Resume all threads' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just Resume
@@ -60,6 +90,8 @@ export class DebugCommandHandlers implements MenuContribution, CommandContributi | |||
protected readonly debugSessionManager: DebugSessionManager; | |||
@inject(DebugConfigurationManager) | |||
protected readonly debugConfigurationManager: DebugConfigurationManager; | |||
@inject(DebugThreadSelectionService) | |||
protected readonly selectionService: DebugThreadSelectionService; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have to get rid of DebugThreadSelectionService
execute: () => { | ||
const debugSession = this.debugSessionManager.getActiveDebugSession(); | ||
if (debugSession) { | ||
debugSession.threads().then(response => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would move these code to DebugSession in function suspend(threadId?: number)
The same for resume command.;
debugSession.threads().then(response => { | ||
const threads: DebugProtocol.Thread[] = response.body.threads; | ||
// tslint:disable-next-line:forin | ||
for (const thread in threads) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is better to use
for (const thread of threads)
return Promise.all(requests); | ||
}); | ||
} | ||
this.emit('changeStatus', threadId, false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
StoppedEvent
is fired when thread is stopped. You don't have emit changeStatus
event.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean I should resolve the promise and then emit the changeStatus event or that I should emit changeStatus event here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't emit any events here.
Just rely on DebugState
https://github.com/theia-ide/theia/blob/vscode-debug-protocol/packages/debug/src/browser/debug-session.ts#L27
Let me know if you need something else.
faf8a36
to
0eff22d
Compare
3734923
to
33fa65d
Compare
const requests = []; | ||
for (const thread of threads) { | ||
const currentThreadID = thread.id; | ||
const pauseResponse = this.proceedRequest("pause", { currentThreadID }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
currentThreadID -> threadId: thread.id
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happened if thread already stopped?
const requests = []; | ||
for (const thread of threads) { | ||
const currentThreadID = thread.id; | ||
const continueResponse = this.proceedRequest("continue", { currentThreadID }) as Promise<DebugProtocol.ContinueResponse>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
currentThreadID -> threadId: thread.id
@@ -23,10 +24,13 @@ import { injectable, inject } from "inversify"; | |||
export class DebugThreadsWidget extends VirtualWidget { | |||
private _threads: DebugProtocol.Thread[] = []; | |||
private _threadId?: number; | |||
private _threadStatus: Map<number, boolean> = new Map(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Get rid of _threadStatus
field. Rely on debugSession.debugSessionState
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My only problems is that inside of the onContinuedEvent it assumes that to remove the thread you need to have the event but the debug adapter protocol suggests that the continued event is optional after a continue:
/** Event message for 'continued' event type.
The event indicates that the execution of the debuggee has continued.
Please note: a debug adapter is not expected to send this event in response to a request that implies that execution continues, e.g. 'launch' or 'continue'.
It is only necessary to send a ContinuedEvent if there was no previous request that implied this.
*/
If the onContinuedEvent state is not triggered then we won't accurately know the state of all the threads
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see.
Let's emit continued
event ourselves after continue response. In this case DebugSessionState
will be consistent.
const event: DebugProtocol.ContinuedEvent = {
type: 'event',
seq: -1,
event: 'continued',
body: {
threadId,
allThreadsContinued: false
}
};
this.proceedEvent(event);
} | ||
} | ||
}, | ||
isEnabled: () => !this.debugSession.debugSessionState.allThreadsContinued, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be enabled if at least one thread is stopped
} | ||
} | ||
}, | ||
isEnabled: () => !this.debugSession.debugSessionState.allThreadsStopped, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be enabled if at least one thread is run
return this.proceedRequest("pause", { threadId }); | ||
} | ||
|
||
resume(threadId?: number): Promise<DebugProtocol.ContinueResponse> | Promise<DebugProtocol.ContinueResponse[]> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is better not to duplicate the code.
Let's do it in a simpler way:
resume(threadId?: number): Promise<DebugProtocol.ContinueResponse | DebugProtocol.ContinueResponse[]> {
if (threadId) {
return this.doResume(threadId);
} else {
return this.threads().then(response => Promise.all(response.body.threads.map(thread => this.doResume(thread.id))));
}
}
private doResume(threadId: number): Promise<DebugProtocol.ContinueResponse> {
return this.proceedRequest("continue", { threadId: threadId }).then(response => {
const event: DebugProtocol.ContinuedEvent = {
type: 'event',
seq: -1,
event: 'continued',
body: {
threadId: threadId,
allThreadsContinued: false
}
};
this.proceedEvent(event);
return response as DebugProtocol.ContinueResponse;
});
}
@@ -124,10 +125,56 @@ export class DebugSessionImpl extends EventEmitter implements DebugSession { | |||
return this.proceedRequest("threads"); | |||
} | |||
|
|||
pause(threadId: number): Promise<DebugProtocol.PauseResponse> { | |||
pause(threadId?: number): Promise<DebugProtocol.PauseResponse> | Promise<DebugProtocol.PauseResponse[]> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's do it in a simple way
pause(threadId?: number): Promise<DebugProtocol.PauseResponse> | Promise<DebugProtocol.PauseResponse[]> {
if (threadId) {
return this.doPause(threadId);
} else {
return this.threads().then(response => Promise.all(response.body.threads.map(thread => this.doPause(thread.id))));
}
}
doPause(threadId: number): Promise<DebugProtocol.PauseResponse> {
return this.proceedRequest("pause", { threadId });
}
4d0d992
to
9e02925
Compare
Signed-off-by: jpinkney <josh.pinkney@mail.utoronto.ca>
9e02925
to
606b052
Compare
Signed-off-by: jpinkney josh.pinkney@mail.utoronto.ca
This PR adds the resume and suspend actions for DAP.