MCPcopy Index your code
hub / github.com/nodejs/node / trackScripts

Function trackScripts

deps/v8/test/inspector/debugger/wasm-scripts.js:124–189  ·  view source on GitHub ↗
(debuggerParams)

Source from the content-addressed store, hash-verified

122 .then(() => InspectorTest.completeTest());
123
124function trackScripts(debuggerParams) {
125 let {id: sessionId, Protocol} = contextGroup.connect();
126 let scripts = [];
127
128 Protocol.Debugger.enable(debuggerParams);
129 Protocol.Debugger.onScriptParsed(handleScriptParsed);
130
131 function printDebugSymbols(symbols) {
132 const symbolsLog = symbols.map(symbol => `${symbol.type}:${symbol.externalURL}`);
133 return `debug symbols: [${symbolsLog}]`;
134 }
135
136 async function loadScript({
137 url,
138 scriptId,
139 sourceMapURL,
140 startColumn,
141 endColumn,
142 codeOffset,
143 debugSymbols
144 }) {
145 let stableId = nextStableId(scriptId);
146 InspectorTest.log(`Session #${sessionId}: Script #${
147 scripts.length} parsed. URL: ${url}. Script ID: ${
148 stableId}, Source map URL: ${sourceMapURL}, ${
149 printDebugSymbols(debugSymbols)}. module begin: ${
150 startColumn}, module end: ${endColumn}, code offset: ${codeOffset}`);
151 let {result: {scriptSource, bytecode}} =
152 await Protocol.Debugger.getScriptSource({scriptId});
153 if (bytecode) {
154 if (scriptSource) {
155 InspectorTest.log('Unexpected scriptSource with bytecode: ');
156 InspectorTest.log(scriptSource);
157 }
158 // Binary value is represented as base64 in JSON, decode it.
159 bytecode = InspectorTest.decodeBase64(bytecode);
160 // Check that it can be parsed back to a WebAssembly module.
161 let module = new WebAssembly.Module(bytecode);
162 scriptSource =
163 `
164Raw: ${Array.from(bytecode, b => ('0' + b.toString(16)).slice(-2)).join(' ')}
165Imports: [${
166 WebAssembly.Module.imports(module)
167 .map(i => `${i.name}: ${i.kind} from "${i.module}"`)
168 .join(', ')}]
169Exports: [${
170 WebAssembly.Module.exports(module)
171 .map(e => `${e.name}: ${e.kind}`)
172 .join(', ')}]
173 `.trim();
174 }
175 InspectorTest.log(`Session #${sessionId}: Source for ${url}:`);
176 InspectorTest.log(scriptSource);
177 }
178
179 function handleScriptParsed({params}) {
180 if (params.url.startsWith('wasm://')) {
181 scripts.push(loadScript(params));

Callers 1

wasm-scripts.jsFile · 0.70

Calls 4

onScriptParsedMethod · 0.80
allMethod · 0.80
connectMethod · 0.65
enableMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…