Golang support

I followed Debugging Go Code with LLDB and ran the commands:

go build -gcflags "-N -l" -o helloworld .
lldb ./helloworld
(lldb) b main.main
(lldb) run
(lldb) step

The source code is correctly displayed upon running.
Everything worked up until the point where I print anything. The following 3 commands return nothing:

frame variable
print myvar
print main.out (main = package name)

There is a mention of “lldb golang support”, what’s up with that, do I still need to “compile lldb from source”?

Thanks

Return nothing or give an error?

What’s the steps to get a debuggable “hello world” with Go? I can try it out locally if there’s some specific issues.

I’m not sure of the state of Go support. I don’t remember any specific changes recently so you should be ok with a released version, 3.7 was ages ago.

Yes, print literally returns nothing. A “debuggable hello world” is what I am looking for.

Check first you can debug with GDB: Debugging Go Code with GDB - The Go Programming Language

The answer is: yes I can can print variables with gdb. Also I failed to mention I am on freebsd 13.2 and using the lldb 14.05

Two things you can try:

  • older lldb versions, in case we did remove some necessary support.
  • enabling logging to see what work is being done behind the scenes. log enable <log name>. Anything related to symbols might help.

Sorry for the late reply.
Enabling channel “lldb”, category “all” results in the following log upon trying to print the variable “bruh”:

Processing command: print bruh
lldb             HandleCommand, cmd_obj : 'expression'
lldb             HandleCommand, (revised) command_string: 'expression -- bruh'
lldb             HandleCommand, wants_raw_input:'True'
lldb             HandleCommand, command line after removing command name(s): '-- bruh'
lldb             == [UserExpression::Evaluate] Getting expression: Could not find type system for language go: TypeSystem for language go doesn't exist ==
lldb             HandleCommand, command did not succeed
(lldb) lldb             this = 0x000000083232E8C0, timeout = <infinite>

The only Go reference in lldb is eLanguageTypeGo but that’s only because it’s from a DWARF value, and we just know that “go” is the language name from there.

I’m wondering if you aren’t intended to build lldb from this person’s repo because they refer to https://github.com/ribrdb/lldb/blob/gogogo/source/Plugins/LanguageRuntime/Go/GoLanguageRuntime.cpp, which is not upstream.

lldb             == [UserExpression::Evaluate] Getting expression: Could not find type system for language go: TypeSystem for language go doesn't exist ==

This is a bug, we should report something to the user in this case.

Please open an issue for that Issues · llvm/llvm-project · GitHub

We had almost the same question about Ada here: LLDB Ada support on Apple M2 (Could not find type system for language ada83)

Except they used e to print, I wonder if the print command is incorrectly suppressing the error message in your case. Please try using e / expression if you get the chance.

Also, while researching that I found Anybody using the Go/Java debugger plugins? which states that we did at one point have in tree Go support. It has since been removed.