0

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.

Jiseong
  • 89
  • 6
  • nm should work whether debug symbols are present or not, since the dynamic linker needs to see the symbol names to be able to do any linking... So try starting with ldd on your executable to see which libgomp.so is being used, then use that full filename with nm. You could also look at the LLVM OpenMP runtime, of course... – Jim Cownie Aug 07 '19 at 15:15
  • @JimCownie Thank you for answering. I'll take a look at LLVM. – Jiseong Aug 09 '19 at 05:51

1 Answers1

1

(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 -s instead 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 its sudo 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.

Gregor Budweiser
  • 218
  • 3
  • 10
  • Thank you for your advice. I've just started using `readelf` ann `objdump` and understood the inner structure a little bit. – Jiseong Aug 09 '19 at 05:53