1

I have forked a C project on Github that use autotools. After having built it with debug options, following William Pursell's post, I cannot step inside some functions. The debugger says: "no debug info".

Here is my build process:

$ ./autogen.sh
$ mkdir Debug
$ cd Debug
$ ../configure --prefix=/Debug CPPFLAGS=-DDEBUG CFLAGS="-O0 -g3 -Wall"
$ make
$ make check

For information, the source tree has two levels of folders: perfo/, src/, src/core/, src/utils/, tests/, etc.

When I debug tests/xxx, I have the symbols for functions in tests/xxx.c, but not the ones inside src/core/global.c for example.

From the information here, I have tried to check the object files, but they look like they have the same debug info properties.

$ readelf -WS tests/reqrep.o | grep debug_info
  [ 6] .debug_info       PROGBITS        0000000000000000 00118a 000735 00      0   0  1
  [ 7] .rela.debug_info  RELA            0000000000000000 00d5d0 000d20 18     25   6  8
$ readelf -WS src/core/global.o | grep debug_info
  [ 6] .debug_info       PROGBITS        0000000000000000 002d87 002360 00      0   0  1
  [ 7] .rela.debug_info  RELA            0000000000000000 01ccb8 003180 18     25   6  8

I am debugging with Eclipse CDT. The debug build profile is identical. For example, if I rebuild from scratch via the console, Eclipse CDT does not rebuild when debugging because it is up to date. Of course, I have tried to debug both from a console build and from an Eclipse build. The Debug configuration looks al-right : application = Debug/tests/.libs/reqrep, use of GDB (DSF) with non stop mode, build configuration is Debug, Source look-up path is default.

Any idea please ?

Community
  • 1
  • 1
lalebarde
  • 1,684
  • 1
  • 21
  • 36
  • Try looking at the build logs. Are there any gcc invocations without `-g3`? – n. m. could be an AI Jan 14 '14 at 16:57
  • Only CC and CCLD appear in the build log. I assume they are defined by the Makefile with the appropriate options. Otherwise, I assume I could not step in any function. – lalebarde Jan 14 '14 at 17:06
  • Verbose build logs: http://stackoverflow.com/questions/3793817/how-to-get-complete-linking-command-instead-of-just-ccld-how-to-disable-silent – n. m. could be an AI Jan 14 '14 at 17:15
  • Every compile command has **-g3** set: `$ grep "gcc -std=gnu99" xxx.build.log | wc -l` 196 `$ grep "gcc -std=gnu99" xxx.build.log | grep g3 | wc -l` 195 `$ grep "gcc -std=gnu99" xxx.build.log | grep -v g3` libtool: link: gcc -std=gnu99 -shared -fPIC -DPIC ...etc... – lalebarde Jan 14 '14 at 17:35
  • Are all sources compiled? Are there any shared libraries produced? – n. m. could be an AI Jan 15 '14 at 04:01
  • yes for both questions. I have identified the problem, but not yet solved it. The project is a library with test programs. Besides the fork to work on it, I have installed it via the system package. When I uninstalled it, the debug executable (one of the tests) cannot load the library. So I have to inform Eclipse somewhere from where it shall load the library. It looks obvious in the interface, in the debug configuration. – lalebarde Jan 15 '14 at 09:57
  • But still it does not work: `/home/laurent/Documents/WorkSpace/xxx/Debug/tests/.libs/test1: error while loading shared libraries: libxxx.so.0: cannot open shared object file: No such file or directory` – lalebarde Jan 15 '14 at 09:58
  • Telling the *linker* where to find the library does not affect runtime *loading*. Your executable still has no idea where to find the right shared library. There are separate linker options for that (`-rpath` and others), but I don't recommend using them to point inside your project tree. Use `LD_LIBRARY_PATH` environment variable instead. Use `-rpath` to point to the final installation folder, if different from the default. – n. m. could be an AI Jan 15 '14 at 10:14
  • Many thanks n.m. You have saved my day. I have added LD_LIBRARY_PATH to my debug configuration environment variables to the path where it is built, and it works. – lalebarde Jan 15 '14 at 10:38

1 Answers1

0

As explained by n.m. , the solution is to add the LD_LIBRARY_PATH environment variable inside the debug configuration, set to the path where the library is built.

enter image description here

lalebarde
  • 1,684
  • 1
  • 21
  • 36