Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug nodejs addon by gdb

Tags:

c++

node.js

macos

Heading

I am writing a Node.Js C++ addon,When I try to debug my c++ add by the way i searched on internet,it just cannt work at all.

what i get from internet is gdb node set args app.js run

i get this /usr/local/bin/node": not in executable format: File format not recognized

after type file /usr/local/bin/node

i get this /usr/local/bin/node: Mach-O universal binary with 2 architectures /usr/local/bin/node (for architecture i386): Mach-O executable i386 /usr/local/bin/node (for architecture x86_64): Mach-O 64-bit executable x86_64

i dont konw why my gdb told me the node is not a executeable fomat

like image 934
turing.huang Avatar asked Mar 11 '14 11:03

turing.huang


1 Answers

Did you build node.js with debugging enabled? It looks like you are on a mac, if you used homebrew to install mode, try the following:

brew install nodejs --with-debug

Then try:

gdb --args /usr/local/bin/node app.js

Also gdb on the mac has been deprecated in favor of lldb so you might try lldb as well:

lldb -- /usr/local/bin/node app.js
like image 57
Ricky Nelson Avatar answered Sep 28 '22 02:09

Ricky Nelson