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

Function startInspect

lib/internal/debugger/inspect.js:320–365  ·  view source on GitHub ↗
(argv = ArrayPrototypeSlice(process.argv, 2),
                      stdin = process.stdin,
                      stdout = process.stdout)

Source from the content-addressed store, hash-verified

318}
319
320function startInspect(argv = ArrayPrototypeSlice(process.argv, 2),
321 stdin = process.stdin,
322 stdout = process.stdout) {
323 const invokedAs = `${process.argv0} ${process.argv[1]}`;
324
325 if (argv.length < 1) {
326 writeInspectUsageAndExit(invokedAs, undefined, kInvalidCommandLineArgument);
327 }
328
329 const parsed = parseInspectMode(argv);
330
331 if (parsed.mode === 'help') {
332 writeInspectUsageAndExit(invokedAs);
333 }
334
335 if (parsed.mode === 'probe') {
336 let probeOptions;
337 try {
338 probeOptions = parseProbeTokens(parsed.tokens, parsed.args);
339 } catch (error) {
340 writeInspectUsageAndExit(invokedAs, error.message, kInvalidCommandLineArgument);
341 }
342 runProbeMode(stdout, probeOptions);
343 return;
344 }
345
346 const options = parseInteractiveArgs(argv);
347 const inspector = new NodeInspector(options, stdin, stdout);
348
349 stdin.resume();
350
351 function handleUnexpectedError(e) {
352 if (e.code !== 'ERR_DEBUGGER_STARTUP_ERROR') {
353 process.stderr.write('There was an internal error in Node.js. ' +
354 'Please report this bug.\n' +
355 `${e.message}\n${e.stack}\n`);
356 } else {
357 process.stderr.write(e.message);
358 process.stderr.write('\n');
359 }
360 if (inspector.child) inspector.child.kill();
361 process.exit(kGenericUserError);
362 }
363
364 process.on('uncaughtException', handleUnexpectedError);
365}
366exports.start = startInspect;

Callers

nothing calls this directly

Calls 7

writeInspectUsageAndExitFunction · 0.85
parseInspectModeFunction · 0.85
parseProbeTokensFunction · 0.85
runProbeModeFunction · 0.85
parseInteractiveArgsFunction · 0.85
resumeMethod · 0.65
onMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…