title: How to use gdb on c++ header files?
body: <p>I tried to search this question online, but it seems that I can't find a good solution for my problem. Well, I'm trying to use gdb to debug my c++ program. And the program is made up of a simple main.cpp and a model.h. And the compiling command is</p>
  
  <pre><code>g++ -Wall -g -c main.cpp
  g++ -Wall -g main.o -o OUTPUT
  </code></pre>
  
  <p>As almost all the algorithm is stored in model.h, I need to debug that header file rather than the cpp file. However, whenever I tried to place a break point on the header like</p>
  
  <pre><code>tbreak model.h:163
  </code></pre>
  
  <p>gdb always give me a message that"No source file named TNFmodel.h".</p>
  
  <p>In another question <a href="https://stackoverflow.com/questions/1810415/breakpoints-in-gdb">breakpoints in GDB</a>, I saw a solution by adding the folder that containing the header into the library by "dir". But my header file is already in source folder, and after trying</p>
  
  <pre><code>dir ./
  </code></pre>
  
  <p>The problem maintains.</p>
  
  <p>So anybody know what's wrong? How to use gdb to debug a header file?</p>