Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proc/gdbserial: Added support for darwin/arm64 using gdbserver #2285

Merged
merged 3 commits into from
Jan 4, 2021

Conversation

oxisto
Copy link
Contributor

@oxisto oxisto commented Dec 31, 2020

This is an alternative fix for #2246 and one that might be easier to merge in than fixing the native darwin backend (see #2254).

Tests almost succeed, and it looks like those that do not, i.e. cgo-related ones, might be related to some Go 1.16 problems. I can provide a complete log of make test (it is currently running).

Fixes #2246

@oxisto
Copy link
Contributor Author

oxisto commented Dec 31, 2020

Here is the log of running the tests on my M1 machine: test.log

But, somehow it looks like I broke darwin/amd64, meh.

package gdbserial

const (
regnamePC = "pc"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would probably be a good idea to define those constants somewhere else, since multiple backends might need to refer to them.

@oxisto
Copy link
Contributor Author

oxisto commented Dec 31, 2020

Existing tests on amd64 should now all run flawlessly. Ready to review and open for suggestions how to improve it :)

@oxisto oxisto changed the title proc/*: Added support for darwin/arm64 using gdbserver proc/gdbserial: Added support for darwin/arm64 using gdbserver Dec 31, 2020
Copy link
Member

@aarzilli aarzilli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM, just a couple of minor things, glad to see you made it work!

pkg/proc/native/support_sentinel.go Outdated Show resolved Hide resolved
pkg/proc/gdbserial/gdbserver.go Outdated Show resolved Hide resolved
Copy link
Member

@aarzilli aarzilli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ebilling
Copy link

ebilling commented Jan 2, 2021

I hate to ask, and I know this isn't the right place, but @oxisto, I can't get this to work on my setup. I've been pulling down every version you push to try them out.

Darwin_arm64 laptop,
go version devel +a508840c67 Tue Dec 15 16:31:07 2020 +0000 darwin/amd64
% dlv version
Delve Debugger
Version: 1.5.1
Build: 15456ea

When I try to debug something using Microsoft Code, I get:

could not launch process: stub exited while waiting for connection: exit status 0

This works on my old laptop just fine, so has to be part of the arm move. Have you run into this? Are there additional instructions required in the Readme.md?

@aarzilli
Copy link
Member

aarzilli commented Jan 2, 2021

Could be that you are using a version of go compiled for amd64.

@oxisto
Copy link
Contributor Author

oxisto commented Jan 2, 2021

Could be that you are using a version of go compiled for amd64.

Yes, exactly. This PR adds support for darwin/arm64 binaries using a darwin/arm64 version of Go. All other combinations, such as using a amd64 go binary or to debug a amd64 binary using Rosetta 2 is not supported. Once this PR is done, I will have a look at what other options delve can support.

To test it, you can get the Go 1.16 beta that supports darwin/am64 from the Go downloads page: https://golang.org/dl/go1.16beta1.darwin-arm64.pkg. You should then be able to make install delve using this fork/branch. Afterwards, using dlv debug path-to-your-program.go should be able to debug your program.

You can even test it in Visual Studio code, but you probably need to download the very experimental arm64 builds of VSCode for that (https://code.visualstudio.com/insiders/# / https://code.visualstudio.com/sha/download?build=insider&os=darwin-arm64). I would not recommend this for any productive workflow yet.

@ebilling
Copy link

ebilling commented Jan 2, 2021

Thank you both. I had built the darwin/arm64 version of go, but vs code was still pointing to a different version, and not paying attention to my PATH. I appreciate the pointers @oxisto and @aarzilli. Thank you.

I tried out the experimental VSCode and it's working.

@gitslav
Copy link

gitslav commented Jan 2, 2021

@aarzilli
Copy link
Member

aarzilli commented Jan 3, 2021

@oxisto I think you forgot to bump up the version number in compat.go
https://github.com/oxisto/delve/blob/15456ea98f1ca3fb8379730ff46ae8e08a054ef2/pkg/goversion/compat.go#L11

That's going to be done by #2214

@artspb
Copy link
Contributor

artspb commented Jan 4, 2021

If you want to try it in GoLand, you can specify -Ddlv.path=/Users/artspb/path/to/arm64/dlv under Help | Edit Custom VM Options...

mask8 = 0x000f
mask16 = 0x00ff
mask32 = 0xffff
mask8 = 0xff
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been fixed elsewhere, but we really should export these somewhere for consistency.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be clear, I don't think this should happen in this patch, just making a note.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It makes more sense to do it after the compositeMemory.WriteMemory PR, since that changes some other things about registers, we should just go through op.DwarfRegisters.

Copy link
Member

@derekparker derekparker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@derekparker derekparker merged commit 57f033e into go-delve:master Jan 4, 2021
@zsyu9779
Copy link

zsyu9779 commented Jan 9, 2021

when I try to debug
it's still display that

# runtime/cgo gcc_arm64.S:28:16: error: brackets expression not supported on this target stp x29, x30, [sp, #-96]! ^ gcc_arm64.S:32:2: error: unknown use of instruction mnemonic without a size suffix mov x29, sp ^ gcc_arm64.S:34:16: error: brackets expression not supported on this target stp x19, x20, [sp, #80] ^ gcc_arm64.S:37:16: error: brackets expression not supported on this target stp x21, x22, [sp, #64] ^ gcc_arm64.S:40:16: error: brackets expression not supported on this target stp x23, x24, [sp, #48] ^ gcc_arm64.S:43:16: error: brackets expression not supported on this target stp x25, x26, [sp, #32] ^ gcc_arm64.S:46:16: error: brackets expression not supported on this target stp x27, x28, [sp, #16] ^ gcc_arm64.S:50:2: error: unknown use of instruction mnemonic without a size suffix mov x19, x0 ^ gcc_arm64.S:51:2: error: unknown use of instruction mnemonic without a size suffix mov x20, x1 ^ gcc_arm64.S:52:2: error: unknown use of instruction mnemonic without a size suffix mov x0, x2 ^ gcc_arm64.S:54:2: error: invalid instruction mnemonic 'blr' blr x20 ^~~ gcc_arm64.S:55:2: error: invalid instruction mnemonic 'blr' blr x19 ^~~ gcc_arm64.S:57:16: error: brackets expression not supported on this target ldp x27, x28, [sp, #16] ^ gcc_arm64.S:60:16: error: brackets expression not supported on this target ldp x25, x26, [sp, #32] ^ gcc_arm64.S:63:16: error: brackets expression not supported on this target ldp x23, x24, [sp, #48] ^ gcc_arm64.S:66:16: error: brackets expression not supported on this target ldp x21, x22, [sp, #64] ^ gcc_arm64.S:69:16: error: brackets expression not supported on this target ldp x19, x20, [sp, #80] ^ gcc_arm64.S:72:16: error: brackets expression not supported on this target ldp x29, x30, [sp], #96

@shortcircuit3
Copy link

I get this error when debugging

Failed to continue - runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation]
Unable to propogate EXC_BAD_ACCESS signal to target process and panic (see https://github.com/go-delve/delve/issues/852)
Last known immediate stacktrace (goroutine id 0):
	?:-1
		<unknown>
	:0
		<unknown>

@xibolun
Copy link

xibolun commented Jan 18, 2021

runtime/cgo gcc_arm64.S

check your go IDE is arm version? or you use another go version to run code?

@dragonly
Copy link

dragonly commented Mar 9, 2021

I still run into trouble debugging TiDB.

#2246 (comment)

abner-chenc pushed a commit to loongson/delve that referenced this pull request Mar 1, 2024
…lve#2285)

* Added support for reading darwin/arm64 using gdbserver

* Trying to fix test failures

* Addressing review comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Apple M1 ARM support
10 participants