diff --git a/devtools/client/performance-new/@types/perf.d.ts b/devtools/client/performance-new/@types/perf.d.ts index a2ad285fb169..c129ea8695bd 100644 --- a/devtools/client/performance-new/@types/perf.d.ts +++ b/devtools/client/performance-new/@types/perf.d.ts @@ -167,6 +167,7 @@ export type GetSymbolTableCallback = ( export interface SymbolicationService { getSymbolTable: GetSymbolTableCallback; + querySymbolicationApi: (path: string, requestJson: string) => Promise; } export type ReceiveProfile = ( @@ -511,13 +512,10 @@ export type LibInfoMapValue = { debugPath: string; breakpadId: string; arch: string; -} +}; export type SymbolicationWorkerInitialMessage = { - // The debugName of the binary whose symbols should be obtained. - debugName: string; - // The breakpadId for the binary whose symbols should be obtained. - breakpadId: string; + request: SymbolicationWorkerRequest; // A map that allows looking up library info based on debugName + breakpadId. // This is rather redundant at the moment, but it will make more sense once // we can request symbols for multiple different libraries with one worker @@ -530,6 +528,22 @@ export type SymbolicationWorkerInitialMessage = { module: WebAssembly.Module; }; +export type SymbolicationWorkerRequest = + | { + type: "GET_SYMBOL_TABLE"; + // The debugName of the binary whose symbols should be obtained. + debugName: string; + // The breakpadId for the binary whose symbols should be obtained. + breakpadId: string; + } + | { + type: "QUERY_SYMBOLICATION_API"; + // The API entry path, such as "/symbolicate/v5". + path: string; + // The payload JSON, as a string. + requestJson: string; + }; + export type SymbolicationWorkerError = { name: string; message: string; diff --git a/devtools/client/performance-new/symbolication-worker.js b/devtools/client/performance-new/symbolication-worker.js index dca86bfbcaf6..f9d11c74cf5d 100644 --- a/devtools/client/performance-new/symbolication-worker.js +++ b/devtools/client/performance-new/symbolication-worker.js @@ -30,7 +30,7 @@ importScripts( // itself. /* eslint camelcase: 0*/ -const { getCompactSymbolTable } = wasm_bindgen; +const { getCompactSymbolTable, queryAPI } = wasm_bindgen; // Read parts of an open OS.File instance into the Uint8Array dataBuf. // This reads destBuf.byteLength bytes at offset offset. @@ -181,7 +181,7 @@ class FileAndPathHelper { /** @param {MessageEvent} e */ onmessage = async e => { try { - const { debugName, breakpadId, libInfoMap, objdirs, module } = e.data; + const { request, libInfoMap, objdirs, module } = e.data; if (!(module instanceof WebAssembly.Module)) { throw new Error("invalid WebAssembly module"); @@ -191,11 +191,30 @@ onmessage = async e => { await wasm_bindgen(module); const helper = new FileAndPathHelper(libInfoMap, objdirs); - const result = await getCompactSymbolTable(debugName, breakpadId, helper); - postMessage( - { result }, - result.map(r => r.buffer) - ); + + switch (request.type) { + case "GET_SYMBOL_TABLE": { + const { debugName, breakpadId } = request; + const result = await getCompactSymbolTable( + debugName, + breakpadId, + helper + ); + postMessage( + { result }, + result.map(r => r.buffer) + ); + break; + } + case "QUERY_SYMBOLICATION_API": { + const { path, requestJson } = request; + const result = await queryAPI(path, requestJson, helper); + postMessage({ result }); + break; + } + default: + throw new Error(`Unexpected request type ${request.type}`); + } } catch (error) { postMessage({ error: createPlainErrorObject(error) }); } diff --git a/devtools/client/performance-new/symbolication.jsm.js b/devtools/client/performance-new/symbolication.jsm.js index 9f91ce98adb7..57ffbca60c4a 100644 --- a/devtools/client/performance-new/symbolication.jsm.js +++ b/devtools/client/performance-new/symbolication.jsm.js @@ -234,8 +234,35 @@ class LocalSymbolicationService { const module = await getWASMProfilerGetSymbolsModule(); /** @type {SymbolicationWorkerInitialMessage} */ const initialMessage = { - debugName, - breakpadId, + request: { + type: "GET_SYMBOL_TABLE", + debugName, + breakpadId, + }, + libInfoMap: this._libInfoMap, + objdirs: this._objdirs, + module, + }; + return getResultFromWorker( + "resource://devtools/client/performance-new/symbolication-worker.js", + initialMessage + ); + } + + /** + * @param {string} path + * @param {string} requestJson + * @returns {Promise} + */ + async querySymbolicationApi(path, requestJson) { + const module = await getWASMProfilerGetSymbolsModule(); + /** @type {SymbolicationWorkerInitialMessage} */ + const initialMessage = { + request: { + type: "QUERY_SYMBOLICATION_API", + path, + requestJson, + }, libInfoMap: this._libInfoMap, objdirs: this._objdirs, module, @@ -301,6 +328,15 @@ class LocalSymbolicationServiceWithRemoteSymbolTableFallback { return getSymbolTableFromDebuggee(this._perfFront, lib.path, breakpadId); } } + + /** + * @param {string} path + * @param {string} requestJson + * @returns {Promise} + */ + async querySymbolicationApi(path, requestJson) { + return this._symbolicationService.querySymbolicationApi(path, requestJson); + } } /**