mirror of
https://github.com/facebookarchive/prepack.git
synced 2024-10-26 15:20:18 +03:00
Add threads request to debugger
Summary: Release note: none - let UI send threads request - adapter returns information about the one thread Closes https://github.com/facebook/prepack/pull/1130 Differential Revision: D6227708 Pulled By: JWZ2018 fbshipit-source-id: 40a14f786842dec01491c03eee49a41a15af98cd
This commit is contained in:
parent
e63daa5585
commit
bd9d49d618
@ -197,6 +197,18 @@ class PrepackDebugSession extends LoggingDebugSession {
|
||||
this.sendResponse(response);
|
||||
});
|
||||
}
|
||||
|
||||
threadsRequest(response: DebugProtocol.ThreadsResponse): void {
|
||||
// There will only be 1 thread, so respond immediately
|
||||
let thread: DebugProtocol.Thread = {
|
||||
id: DebuggerConstants.PREPACK_THREAD_ID,
|
||||
name: "main",
|
||||
};
|
||||
response.body = {
|
||||
threads: [thread],
|
||||
};
|
||||
this.sendResponse(response);
|
||||
}
|
||||
}
|
||||
|
||||
DebugSession.run(PrepackDebugSession);
|
||||
|
@ -129,8 +129,15 @@ export class UISession {
|
||||
}
|
||||
|
||||
_processResponse(response: DebugProtocol.Response) {
|
||||
// to be implemented
|
||||
console.log(response);
|
||||
if (response.command === "threads") {
|
||||
this._processThreadsResponse(((response: any): DebugProtocol.ThreadsResponse));
|
||||
}
|
||||
}
|
||||
|
||||
_processThreadsResponse(response: DebugProtocol.ThreadsResponse) {
|
||||
for (const thread of response.body.threads) {
|
||||
this._uiOutput(`${thread.id}: ${thread.name}`);
|
||||
}
|
||||
}
|
||||
|
||||
// execute a command if it is valid
|
||||
@ -167,6 +174,10 @@ export class UISession {
|
||||
this._sendBreakpointRequest(filePath, line, column);
|
||||
}
|
||||
break;
|
||||
case "threads":
|
||||
if (parts.length !== 1) return false;
|
||||
this._sendThreadsRequest();
|
||||
break;
|
||||
default:
|
||||
// invalid command
|
||||
return false;
|
||||
@ -256,6 +267,16 @@ export class UISession {
|
||||
this._packageAndSend(json);
|
||||
}
|
||||
|
||||
_sendThreadsRequest() {
|
||||
let message = {
|
||||
type: "request",
|
||||
seq: this._sequenceNum,
|
||||
command: "threads",
|
||||
};
|
||||
let json = JSON.stringify(message);
|
||||
this._packageAndSend(json);
|
||||
}
|
||||
|
||||
// write out a message to the adapter on stdout
|
||||
_packageAndSend(message: string) {
|
||||
// format: Content-Length: <length> separator <message>
|
||||
|
Loading…
Reference in New Issue
Block a user