Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Go plugin debugging

Tags:

plugins

go

delve

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?

like image 216
Андрей Крюков Avatar asked Nov 17 '25 12:11

Андрей Крюков


1 Answers

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"

like image 84
Андрей Крюков Avatar answered Nov 20 '25 13:11

Андрей Крюков



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!