title: GDB can't find source file
body: <p>I am trying to <strong>debug into OpenCV code</strong> but <strong>gdb</strong> fails to load the OpenCV source file.</p>
  
  <p>Checking for the source file existence:</p>
  
  <pre><code>$ls -l /home/rui/DriveSo/opencv/modules/core/src/matrix.cpp
  -rw-r--r-- 1 rui rui 156046 May 11 21:46 /home/rui/DriveSo/opencv/modules/core/src/matrix.cpp
  </code></pre>
  
  <p>After linking with OpenCV Debug mode libraries I start <strong>dbg</strong> and add this to the list of <strong>source directories</strong>:</p>
  
  <pre><code>$gdb DriveSo
  GNU gdb (Debian 7.7.1+dfsg-5) 7.7.1
  ....
  Reading symbols from DriveSo...done.
  (gdb) directory /home/rui/DriveSo/opencv/modules/core/src
  Source directories searched: /home/rui/DriveSo/opencv/modules/core/src:$cdir:$cwd
  (gdb) break matrix.cpp:2349
  No source file named matrix.cpp.
  Make breakpoint pending on future shared library load? (y or [n]) y
  Breakpoint 1 (matrix.cpp:2349) pending.
  </code></pre>
  
  <p>Even after starting the session gdb still does not find the source file:</p>
  
  <pre><code>(gdb) start
  Temporary breakpoint 2 at 0x41d2cf: file ../../DriveSo.dkt/main.cpp, line 11.
  Starting program: /home/rui/DriveSo/repositories/trunk/builds/build-DriveSo-Desktop_Qt_5_5_0_GCC_64bit-Debug/DriveSo
  ....
  Temporary breakpoint 2, main (argc=1, argv=0x7fffffffe5a8) at ../../DriveSo.dkt/main.cpp:11
  11 QCoreApplication::setApplicationName(QString("DriveSo"));
  (gdb)
  </code></pre>
  
  <p>What can be causing this (to me) unexpected behavior?</p>
  
  <p>Following up on the suggestion by iksajotien, as far as I see the executable has debug information...</p>
  
  <pre><code>$ objdump --syms DriveSo | grep debug
  0000000000000000 l    d  .debug_aranges 0000000000000000              .debug_aranges
  0000000000000000 l    d  .debug_info    0000000000000000              .debug_info
  0000000000000000 l    d  .debug_abbrev  0000000000000000              .debug_abbrev
  0000000000000000 l    d  .debug_line    0000000000000000              .debug_line
  0000000000000000 l    d  .debug_str 0000000000000000              .debug_str
  0000000000000000 l    d  .debug_ranges  0000000000000000              .debug_ranges
  </code></pre>
  
  <p>...and the shared libraries opened by it...</p>
  
  <pre><code>$ lsof -p 12159 
  COMMAND   PID USER   FD      TYPE             DEVICE   SIZE/OFF      NODE NAME
  ...
  DriveSo 12159  rui  mem       REG                8,6   20289800  26740265 /usr/local/lib/libopencv_core.so.3.1.0
  ...
  </code></pre>
  
  <p>... also have debug information.</p>
  
  <pre><code>$ objdump --syms /usr/local/lib/libopencv_core.so.3.1.0 | grep debug
  0000000000000000 l    d  .debug_aranges 0000000000000000              .debug_aranges
  0000000000000000 l    d  .debug_info    0000000000000000              .debug_info
  0000000000000000 l    d  .debug_abbrev  0000000000000000              .debug_abbrev
  0000000000000000 l    d  .debug_line    0000000000000000              .debug_line
  0000000000000000 l    d  .debug_str 0000000000000000              .debug_str
  0000000000000000 l    d  .debug_ranges  0000000000000000              .debug_ranges
  </code></pre>
  
  <p>gdb info shared:</p>
  
  <pre><code>$gdb DriveSo
  GNU gdb (Debian 7.7.1+dfsg-5) 7.7.1
  ...
  Reading symbols from DriveSo...done.
  (gdb) run
  Starting program: /home/rui/DriveSo/repositories/trunk/builds/build-DriveSo-Desktop_Qt_5_5_0_GCC_64bit-Debug/DriveSo 
  ...
  ^C
  Program received signal SIGINT, Interrupt.
  ...
  (gdb) info shared
  From                To                  Syms Read   Shared Object Library
  0x00007ffff7ddcae0  0x00007ffff7df5130  Yes         /lib64/ld-linux-x86-64.so.2
                                          No          linux-vdso.so.1
  0x00007ffff7158860  0x00007ffff794a910  Yes         /usr/local/lib/libopencv_core.so.3.1
  0x00007ffff6e5d880  0x00007ffff6e63a0b  Yes         /usr/local/lib/libopencv_highgui.so.3.1
  0x00007ffff5493840  0x00007ffff690ce00  Yes         /usr/local/lib/libopencv_imgproc.so.3.1
  0x00007ffff50aa6f0  0x00007ffff5158bd1  Yes         /usr/local/lib/libopencv_features2d.so.3.1
  0x00007ffff4db8640  0x00007ffff4e3de75  Yes         /usr/local/lib/libopencv_imgcodecs.so.3.1
  0x00007ffff4b72a80  0x00007ffff4b931b0  Yes         /usr/local/lib/libopencv_videoio.so.3.1
  0x00007ffff47b7d40  0x00007ffff4920f80  Yes         /usr/local/lib/libopencv_calib3d.so.3.1
  ...
  ---Type &lt;return&gt; to continue, or q &lt;return&gt; to quit---
  </code></pre>
  
  <p>Looking at <strong>gdb source code</strong> solib.c has the following at line 1053:</p>
  
  <pre><code>   if (! ui_out_is_mi_like_p (interp_ui_out (top_level_interpreter ()))
            &amp;&amp; so-&gt;symbols_loaded
            &amp;&amp; !objfile_has_symbols (so-&gt;objfile))
          {
            so_missing_debug_info = 1;
            ui_out_field_string (uiout, "syms-read", "Yes (*)");
          }
        else
          ui_out_field_string (uiout, "syms-read",
                               so-&gt;symbols_loaded ? "Yes" : "No");
  </code></pre>
  
  <p>I therefore assume symbols are loaded and debug info exists otherwise libraries would be listed with <strong>Yes (*)</strong> or <strong>No</strong></p>