Attach to process on a local machine does not display running Go process

Until recently I worked in an Intel Mac Book Pro Sonoma 14.7.3 with Goland 2024.3.2.1
I followed this guide https://www.jetbrains.com/help/go/attach-to-running-go-processes-with-debugger.html#attach-to-a-process-on-a-local-machine, in order to debug a locally running Go application and it worked perfectly. 
Go version: 1.22.1 

Now I switched to an M4 MBP, Sequoia 15.3,  with the same  Goland and Go versions.
When I am following the same procedure:

go build -gcflags="all=-N -l" -o myapp
./myapp
I am getting:
[1]    61177 killed     ./myapp

The killing should be related to the signature requirements that exist in ARM Macs.
Then I manually sign the binary:
codesign -s - --force --timestamp=none myapp
 

Then I execute it again: ./myapp
And the application starts properly.

When I am selecting from Goland, Run → Attach to process, the pop up window says:
No processes to attach to.

If I have a running python process running, then it is displayed in the available processes to attach.
In both laptops the gops are properly installed as it is described in the guide and there is no delve external installation.
In Intel MBP, after attaching the process, Goland connects using the embedded dlv.
 

In M4, I also tried to run with delve manually:
/Applications/GoLand.app/Contents/plugins/go-plugin/lib/dlv/mac/dlv --listen=127.0.0.1:58842 --headless=true --api-version=2 --accept-multiclient exec ./myapp

Result:

API server listening at: 127.0.0.1:58842
debugserver-@(#)PROGRAM:LLDB  PROJECT:lldb-1600.0.39.109
for arm64.
Got a connection, launched process /myapp (pid = 6047).
Warning: no debug info found, some functionality will be missing such as stack traces and variable evaluation.
Exiting.
could not launch process: could not read debug info (decoding dwarf section info at offset 0x0: too short) and could not read go symbol table (could not find rodata struct member)

I solved the above error, by installing the latest delve and replacing the Goland's delve executable:
go install github.com/go-delve/delve/cmd/dlv@master
cp $(which dlv) /Applications/GoLand.app/Contents/plugins/go-plugin/lib/dlv/mac/dlv
Now the command:
/Applications/GoLand.app/Contents/plugins/go-plugin/lib/dlv/mac/dlv --listen=127.0.0.1:58842 --headless=true --api-version=2 --accept-multiclient exec ./myapp

Launches the application successfully and then I am able to debug by creating a Go remote configuration and connect to locahost:58842.

But I still do not understand why the Attach to the process displays no running Go process.


Any idea why the Attach to Process in the M4 MBP displays no running processes?

Thank you in advance.
 

0
3 comments
Hi there, 

Can I ask you to do this: after you codesign the app and perform steps 1 and 2 from the guide, if you notice that GoLand shows no processes to attach, please open your terminal and run the gops command to check if it produces any output. This will help us troubleshoot further.
0

Hi Svetlana.

You question helped my to identify the problem.
The gops command got killed. 
The which gops returned gops not found, because it was installed in go1.22.1 which was not in the GOPATH, as I had switched to go1.23.1.


So, I installed it again using:
go install github.com/google/gops@latest
and this time, it was added under  the GOPATH/bin/gops.
After this, the Go processes were listed properly in the Attach to process window and I was able to debug smoothly.

Thanks for your help!

 

0
Awesome! Glad I could help!
0

Please sign in to leave a comment.