I'm studying the implementation detail of OpenMP. I'm trying to look inside the source code of libgomp.so. I have source code of gcc and I know how to build it. But I want to add debugging symbol to libgomp.so, such that, command below has effect.
nm libgomp.so
So I've just generated Makefile to build gcc with configure. I think adding debugging symbol to libgomp.so is related to Makefile.in, Makefile.am inside the libgomp directory (subdirectory of gcc). But the text is too long and there are so many flags. I want to know where to modify. Please help me to figure it out.
Actually I'm quite newbie to this system. I studied Makefile several times, but Makefile.in, Makefile.am, configure, etc. are what I first met this time.
I've just found candidate in libgomp.info, there are explanation of some environment variables. There is
* GOMP_DEBUG:: Enable Debugging output
But I'm not sure how to use it.
(I don't have enough reputation to leave a comment so I have to write it as an answer.)
I'm not an expert on this topic but according to the docs of nm its meant for object files. libgomp.so is an elf file. You could use
readelf -sinstead to list the symbols. Also you don't necessarily have to compile gcc yourself. You can install debugging symbols for libgomp on most linux distibutions (on ubuntu based systems itssudo apt-get install libgomp1-dbg).A big part of understanding openmp is to understand what the compiler does with your omp pragmas, so you might want to enable source-debugging for openmp inside your project. You can do this by pointing gdb to the openmp source or put the openmp source relative to your project such that the debugger can find the needed sources. In my case gdb looked for the source in
../../../src/libgomp/parallel.c. Putting the source relative to my executable actually worked and let me step through the openmp source while debugging in my IDE.