Skip to content

Debugging Tips

Chris Campbell edited this page Apr 4, 2023 · 2 revisions

NOTE: This page was migrated from the old README and may not be accurate. Edits are welcome!

If you are using Atom, you can run the Chrome debugger inside Atom using the Atom IDE.

To run in the Chrome debugger, start Node with the --inspect-brk flag. Use node main.js from the packages/cli/src directory.

Debugging Node.js with Chrome DevTools

Place a debugger statement in the code to set a breakpoint. Only one source file is available when the debugger starts. Others will become available as you step through code or examine the call stack. You can set additional breakpoints in the debugger once the source file is loaded.

When running in the Chrome debugger, enter ctx.getText() in the console when in a visitor method to see the text of the parser node.

An exception of "code generator exception: Cannot read property 'name' of undefined" is generated when a subscript is not able to be resolved by the subs() function in normalizeSubscripts().

To print a stack trace to the console, use console.error(e.stack) in an exception handler and console.trace() elsewhere.

In the C input parsing code, show a changed value:

if (*inputVarPtrs[modelVarIndex] != value) {
  fprintf(stderr, "input %d changed from %g to %g\n", modelVarIndex, *inputVarPtrs[modelVarIndex], value);
}
Clone this wiki locally