0

I am trying to debug my application which use one static builded library.

I want to set break points in my library so i tried to set it using below command :

break TS.cpp:600(FIle name:line no)

but it says

No source file named TS.cpp.

Make breakpoint pending on future shared library load?(y or [n])

so I presses y here (I came to know after browsing internet) but after pressing y gdb is not stopping at my break point and it completed executing program.

Why GDB is not stopped at my break point??

Any input is highly appreciated.

Community
  • 1
  • 1
user3706789
  • 87
  • 1
  • 7
  • please cross-check whether really your file name is `TS.cpp` and it is included in compilation or not. – Sourav Ghosh Nov 27 '14 at 12:38
  • Yes i checked it file name is correct and apparently it's included in compilation of library.. – user3706789 Nov 27 '14 at 12:41
  • I am debugging a stand alone application which uses static builded library here.. – user3706789 Nov 27 '14 at 12:42
  • If I enable some prints in TS.cpp then i am getting those prints while GDB executes.. but the problem is GDB is not stopping at breakpoint in the same file.. – user3706789 Nov 27 '14 at 12:45
  • Have you built your app with `-g` option passed to `gcc` ? – Santosh A Nov 27 '14 at 12:59
  • Yes.. I am getting all prints(I enabled for debugging) while gdb executes so it does mean gdb has all symbols loaded .. – user3706789 Nov 27 '14 at 13:06
  • the problem is gdb is not able to locate the file properly. check whether after getting the binary, the debug info is being stripped down or not. – Sourav Ghosh Nov 27 '14 at 13:15
  • How to check debug info is being stripped down or not.?? – user3706789 Nov 27 '14 at 13:28
  • @user3706789 when you start gdb it either prints `Reading symbols from XXXX...done.` or `Reading symbols from XXXX...(no debugging symbols found)...done.`. Make sure your library, and not only the application is compiled with the `-g` flag.. Try also the [info sources](http://stackoverflow.com/questions/22821344/gdb-how-to-list-all-source-files-used-for-compilation) gdb command, to list which source files gdb knows about. – nos Nov 27 '14 at 14:08
  • the library, it self, probably was not compiled with the -g option or 'strip' was used on the library. or your execution path is not executing line 6000 (sounds like time to be dividing that TI.cpp file down into a set of functions, located in separate files. – user3629249 Nov 27 '14 at 17:04
  • @nos info sources command shows only my application.c and not the files of my library where i want to set a breakpoint.. – user3706789 Nov 28 '14 at 06:13
  • @user3706789 Many have asked if the source files in your static library is compiled with the -g flag. Have you found out the answer to that ? – nos Nov 28 '14 at 09:03

2 Answers2

2

No source file named TS.cpp

This means one of two things:

  1. either the file TS.cpp was not compiled with -g (or equivalently TS.o has been stripped), or
  2. the file TS.o was not linked into the application.

Since you are seeing prints from that source, it's a safe bet that #1 is the actual root cause.

info sources command shows only my application.c and not the files of my library

That is another confirmation that #1 is the root cause.

Employed Russian
  • 199,314
  • 34
  • 295
  • 362
0

The problem in your case is with source mapping. It normally happens when application is compiled at some other machine and you are debugging it on some other machine where source location is different.

You can specify source path using directory command of gdb. e.g. if your sources are in /home/taimoor/testApp/src, you can do following:

(gdb) directory /home/taimoor/testApp/src

Taimoor
  • 43
  • 5
  • I executed directory command as /home/user3706789/library where all my sorce files are available after executing command GDB shows me : Source directories searched: /home/user3706789/library:$cdir:$cwd .. – user3706789 Nov 28 '14 at 06:30