3

There is a golang application that loads the plugin at runtime. I am developing this plugin and I would like to ask if there is an opportunity to debug the code of my plugin?

I tried to run delve by compiling both the application and the plugin with --gcflags="all=-N -l", but running the application in the debugger I got an error the executable file does not contain debugging information for the plugin

Are there ways to debug golang plugin?

  • 2
    _"the executable file does not contain debugging information for the plugin"_ that's because plugins are not compiled / bundled into the executable binary. That's the whole point of Go plugins. If you want to debug it, call it directly and not as a plugin. – icza Feb 07 '22 at 13:22

1 Answers1

2

Solution: put breakpoint via runtime.Breakpoint(), then run application with delve. It will stop on breakpoint at the plugin code.

Don't forget to build plugin and application with flags: go build -trimpath -gcflags "all=-N -l"