tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

getOriginalStackFrames.js (1184B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
      4 
      5 "use strict";
      6 
      7 const {
      8  getWasmXScopes,
      9 } = require("resource://devtools/client/shared/source-map-loader/wasm-dwarf/wasmXScopes");
     10 const {
     11  getSourceMap,
     12 } = require("resource://devtools/client/shared/source-map-loader/utils/sourceMapRequests");
     13 const {
     14  generatedToOriginalId,
     15 } = require("resource://devtools/client/shared/source-map-loader/utils/index");
     16 
     17 // Returns expanded stack frames details based on the generated location.
     18 // The function return null if not information was found.
     19 async function getOriginalStackFrames(generatedLocation) {
     20  const wasmXScopes = await getWasmXScopes(generatedLocation.sourceId, {
     21    getSourceMap,
     22    generatedToOriginalId,
     23  });
     24  if (!wasmXScopes) {
     25    return null;
     26  }
     27 
     28  const scopes = wasmXScopes.search(generatedLocation);
     29  if (scopes.length === 0) {
     30    console.warn("Something wrong with debug data: none original frames found");
     31    return null;
     32  }
     33  return scopes;
     34 }
     35 
     36 module.exports = {
     37  getOriginalStackFrames,
     38 };