title: How to debug a shared library using GDB?
body: <p>I want to debug a <strong>SharedLib</strong> which is called by <strong>Main</strong>. I have the sources of the SharedLib and of Main. I compile and link Main and SharedLib with the option <strong>–g3</strong>. The variables <strong>PATH</strong> and <strong>LD_LIBRARY_PATH</strong> include <strong>/PathToSharedLib</strong>. I set a breakpoint in b <strong>FileOfSharedLib.c</strong> at <strong>NNN</strong>.</p>
  
  <pre><code>(gdb) file /PathToMain/Main
  Reading symbols from /PathToMain/Main...done.
  (gdb) set directories /PathToSourceOfSharedLib
  (gdb) set solib-search-path /PathToSharedLib
  (gdb) sharedlibrary SharedLib
  No loaded shared libraries match the pattern `SharedLib`
  (gdb) b FileOfSharedLib.c:NNN
  No source file named FileOfSharedLib.c.
  Make breakpoint pending on future shared library load? (y or [n]) y
  (gdb) run
  </code></pre>
  
  <p>It never stops at the break point which is called several times by Main. I see it by printf statements in the log of the SharedLib. It looks like that the SharedLib is not considered by gdb. </p>
  
  <p>I checked the SharedLib and the FileOfSharedLib.c:</p>
  
  <pre><code>(gdb) file /PathToSharedLib/SharedLib
  Reading symbols from /PathToSharedLib/SharedLibl...done.
  (gdb) b FileOfSharedLib.c:123
  Breakpoint 1 at 0x43d7f: file FileOfSharedLib.c, line 123.
  (gdb)
  </code></pre>
  
  <p>I am running Ubuntu 14.04.3 LTS (GNU/Linux 3.13.0-66-generic i686) with gcc 4.8.4 and gdb 7.7.1.</p>