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

Function buildProbeTextReport

lib/internal/debugger/inspect_probe.js:256–313  ·  view source on GitHub ↗
(report)

Source from the content-addressed store, hash-verified

254
255// Built human-readable text output for probe reports.
256function buildProbeTextReport(report) {
257 const lines = [];
258
259 for (const result of report.results) {
260 if (result.event === 'hit') {
261 const probe = report.probes[result.probe];
262 // If Debugger.scriptParsed was missed and the URL is unknown, fall back to the user's
263 // probe target text for readability. This is unlikely unless there's a bug in V8.
264 const locText = (result.location.url !== undefined) ?
265 formatHitLocation(result.location) : formatTargetText(probe.target);
266 ArrayPrototypePush(lines, `Hit ${result.hit} at ${locText}`);
267 if (result.error !== undefined) {
268 ArrayPrototypePush(lines, ` [error] ${probe.expr} = ${result.error.message}`);
269 } else {
270 ArrayPrototypePush(lines,
271 ` ${probe.expr} = ` +
272 `${formatRemoteObject(result.result)}`);
273 }
274 continue;
275 }
276
277 if (result.event === 'completed') {
278 ArrayPrototypePush(lines, 'Completed');
279 continue;
280 }
281
282 if (result.event === 'miss') {
283 ArrayPrototypePush(lines,
284 `Missed probes: ` +
285 `${formatPendingProbeLocations(report.probes, result.pending)}`);
286 continue;
287 }
288
289 if (result.event === 'timeout') {
290 ArrayPrototypePush(lines, result.error.message);
291 continue;
292 }
293
294 if (result.event === 'error') {
295 ArrayPrototypePush(lines, result.error.message);
296 if (result.error.stderr !== undefined) {
297 ArrayPrototypePush(lines, ' [stderr]');
298 const stderrLines = RegExpPrototypeSymbolSplit(
299 /\r\n|\r|\n/g,
300 result.error.stderr,
301 );
302 for (let i = 0; i < stderrLines.length; i++) {
303 if (stderrLines[i] === '' && i === stderrLines.length - 1) {
304 continue;
305 }
306 ArrayPrototypePush(lines, ` ${stderrLines[i]}`);
307 }
308 }
309 }
310 }
311
312 return ensureTrailingNewline(ArrayPrototypeJoin(lines, '\n'));
313}

Callers 1

runProbeModeFunction · 0.85

Calls 5

formatHitLocationFunction · 0.85
formatTargetTextFunction · 0.85
formatRemoteObjectFunction · 0.85
ensureTrailingNewlineFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…