Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enabling debug symbols in shared library using GCC

I am creating a shared library using gcc and suspect that there may be some memory leaks from the shared library. To debug, I need to enable debug symbols when creating the shared library.

To build, I am using gcc -g ... (-g is for enabling debug information)

But the library (*.so file) size is not changing for both -g, and without -g. Besides, I am not getting any useful information from tools like VALGRIND.

Can anyone point me the mistake?

like image 808
Alphaneo Avatar asked May 15 '09 01:05

Alphaneo


People also ask

How do I enable built in debugging in gcc?

When writing C/C++ code, in order to debug the binary executable the debug option must be enabled on the compiler/linker. In the case of GCC, the option is -g.

How do I add debug symbols?

Enabling debug symbolsChoose Project > Properties > QNX C/C++ Project. In the Build Variants tab, expand the listings for all architectural variants that you want to build. Check the debug boxes for all variants that you want to debug. Click OK to confirm the settings and exit the properties window.

How do I add debug symbols in GDB?

To add additional symbols you might use add-symbol-file . The add-symbol-file command reads additional symbol table information from the file filename. You would use this command when filename has been dynamically loaded (by some other means) into the program that is running.


1 Answers

You need to use -g for all the steps (compiling your source files and linking).

like image 119
lothar Avatar answered Sep 18 '22 17:09

lothar