Debugging a gcc plugin

475 views Asked by At

I'm currently writing a plugin for gcc (9.2) and am looking for a way to debug said plugin. For this purpose I have built gcc using these instructions to enable debug symbols for gcc. I then try to debug the plugin by invoking gcc within gdb with the following command:

./xg++ -wrapper gdb,--args -fplugin=plugin_name.so

This results in me being able to step through gcc itself, seeing its symbols. However, I am not able to access the plugins symbols. The plugin is compiled with the -g flag.

What do I need to do to also step through the plugin's code?

1

There are 1 answers

2
CookieCutter43 On BEST ANSWER

I have found a solution:

g++ (or xg++ in this case) is just a driver that calls several compiling tools including the actual compiler cc1plus process. So to make sure that gdb attaches to this process, one has to set the following setting in gdb:

set follow-fork-mode child

Afterwards (you might have to just let it run for once) loading the symbols and stepping through the plugin works without problem.