Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debugging Node #3016

Closed
RaisinTen opened this issue Oct 11, 2020 · 5 comments
Closed

Debugging Node #3016

RaisinTen opened this issue Oct 11, 2020 · 5 comments

Comments

@RaisinTen
Copy link
Contributor

How do I generate a stack trace like this for Node.js?

@addaleax
Copy link
Member

@RaisinTen That stack trace comes from gdb, a popular debugger for C/C++ code. lldb would also be able to generate similar stack traces.

@RaisinTen
Copy link
Contributor Author

@addaleax thanks for the response. I did use gdb for debugging some C/C++ codes but I'm not quite sure how I'm supposed to use it for node.

@Srinivasa314
Copy link

Run gdb --args node file.js

@addaleax
Copy link
Member

@RaisinTen In a case like the one you linked, you could either:

  • Run gdb --args node test.js, then run to start the program and use bt for the backtrace once it crashes
  • Run node test.js (in a way that would generate a coredump, i.e. with ulimit -c unlimited), then use gdb node core to load the core file and then run bt once that is loaded.

You can also always run gdb --args node ..., use run, and then press Ctrl+C to interrupt the process and then generate a backtrace.

@RaisinTen
Copy link
Contributor Author

Thank you so much! 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants