title: GDB does not break on some lines of code when using multiple source files
body: <p>I have a program that I'd like to debug by setting a breakpoint in a non-default constructor, but the breakpoint I set is never hit. Below is an example program where this problem comes up. There is no problem hitting breakpoints set in the main function, but any breakpoints set in the Domain.cpp file are ignored:</p>
  
  <p><strong>Main.cpp:</strong></p>
  
  <pre><code>#include &lt;iostream&gt;
  #include "Domain.h"
  
  int main()
  {
    Domain y;
    std::cout &lt;&lt; y.x &lt;&lt; std::endl;  // &lt;- No problem setting breakpoint here
    return 0;
  }
  </code></pre>
  
  <p><strong>Domain.cpp:</strong></p>
  
  <pre><code>#include "Domain.h"
  
  Domain::Domain()
  {
    x = 4;  // &lt;- A breakpoint here is skipped
  }
  </code></pre>
  
  <p><strong>Domain.h:</strong></p>
  
  <pre><code>#ifndef DOMAIN_H_
  #define DOMAIN_H_
  
  class Domain
  {
  public:
    int x;
  public:
    Domain();
  };
  
  #endif /* DOMAIN_H_ */
  </code></pre>
  
  <p>However, the problem does not exist if I put everything into a single file:</p>
  
  <p><strong>Main2.cpp:</strong></p>
  
  <pre><code>#include &lt;iostream&gt;
  
  int main()
  {
  
    class Domain
    {
    public:
      int x;
      Domain()
      {
        x = 4;  // &lt;- No problem setting breakpoint here now!
      };
  
    };
  
    Domain y;
  
    std::cout &lt;&lt; y.x &lt;&lt; std::endl;
  
    return 0;
  }
  </code></pre>
  
  <p>Why is this the case? How can I change this so that I'm able to set breakpoints when I use multiple files?</p>
  
  <p>I can confirm that the breakpoints aren't working both when I run the debugger manually in a terminal and when I run it through Eclipse CDT, where I get the same error discussed in this question which was apparently never answered:</p>
  
  <p><a href="https://stackoverflow.com/questions/204282/why-does-eclipse-cdt-ignore-breakpoints">Why does Eclipse CDT ignore breakpoints?</a></p>
  
  <p>I am using:</p>
  
  <ul>
  <li>Eclipse Kepler</li>
  <li>Mac OSX 10.8.4</li>
  <li>gdb 6.3.5 (Apple version)</li>
  <li>gcc 4.2.1 with <code>-O0</code> and <code>-g3</code> flags</li>
  </ul>
  
  <p>Please be patient with me. I'm still learning the ropes.</p>