title: How to debug binary module of nodejs?
body: <p>I have a node.js module written in C++ that provides some bindings for a C++ library. The library crashes with SIGSEGV, so I need to debug it with GDB and find out what goes wrong.</p>
  
  <p>I already have the source for the module in <code>./node_modules/somelib/</code> and if I go to that folder and type <code>npm install</code> the library is compiled and can be used through a require('somelib') from node.js. I can attach gdb to node and reproduce the error, but in the stacktrace I just see <code>node_modules/somelib/Release/somelib.node</code>. </p>
  
  <p>I'm not sure if this is important but the library is compiled using <code>node-gyp</code>.</p>
  
  <ul>
  <li><strong>Question 1:</strong> How do I load the source code or point gdb to the source code?</li>
  <li><strong>Question 2:</strong> How do I configure <code>node-gyp</code> to produce debug symbols?</li>
  </ul>