Never tried, but pygdbmi would probably get you halfway there. It uses python to parse structured data (key/value pairs) from gdb output. Gdbgui uses it on its backend. (Disclaimer: I am the developer)
https://github.com/cs01/pygdbmi
Also for golang: https://github.com/cyrus-and/gdb