delve icon indicating copy to clipboard operation
delve copied to clipboard

Fixing darwin native backend [WIP]

Open oxisto opened this issue 4 years ago • 11 comments

Added correct entitlements and replaced the fork_exec mechanism to a POSIX spawn. This now enables the launch of the inferior and successfully calls task_for_pid().

The following functionality has been tested:

  • Setting breakpoints
  • Thread continue
  • Thread cpu instruction step
  • Reading go routine
  • Printing stracktrace
  • Reading variables / locals

If finished, this fixes #2246 and it fixes #1112. The reason, I chose to fix #2246 this way is because I am running into more blocking issues using Apple's debugserver and the gdbserver approach. Generally, I would be fine with the gdbserver as default backend on darwin amd64 and the native approach on darwin arm64.

oxisto avatar Dec 07 '20 14:12 oxisto

How should I proceed with these issues from DeepSource? They all seem not to be related to this PR, not sure why they creep up now.

Is there a way to re-trigger the Travis CI tests? I guess cirrus only checks Linux, right?

oxisto avatar Dec 09 '20 15:12 oxisto

How should I proceed with these issues from DeepSource?

Ignore them if it's not something you added.

Is there a way to re-trigger the Travis CI tests?

No, Travis CI recently changed their plan for open source software and now we run out of credits in a couple of days. This is an ongoing problem at the moment.

I guess cirrus only checks Linux, right?

Freebsd, actually.

aarzilli avatar Dec 09 '20 15:12 aarzilli

Unfortunately, I am running into some issues with implementing trace functionality, i.e. attaching to an existing PID under darwin/arm64.

As you can see here, Go forces PIE under darwin/arm64: https://github.com/golang/go/blob/cb84d831c956026f477b52c9f8a7c1ed2b2724ad/src/cmd/link/internal/ld/config.go#L39-L40

While launching an executable, we can disable ASLR, but when attaching to existing processes, we can not :(

oxisto avatar Dec 29 '20 20:12 oxisto

Unfortunately, I am running into some issues with implementing trace functionality, i.e. attaching to an existing PID under darwin/arm64.

As you can see here, Go forces PIE under darwin/arm64: https://github.com/golang/go/blob/cb84d831c956026f477b52c9f8a7c1ed2b2724ad/src/cmd/link/internal/ld/config.go#L39-L40

While launching an executable, we can disable ASLR, but when attaching to existing processes, we can not :(

Good news, I managed to retrieve the start of the __TEXT section using mach_vm_region, so debugging with ASLR enabled works now!

oxisto avatar Dec 30 '20 22:12 oxisto

Looks like CI is passing with this patch! I've been off for the holidays the last 2 weeks so I'm in catch up mode, but I will review this patch this week.

My current line of thinking is to cut the initial v1.6 release with lldb-server based darwin/arm64 support and then review & merge this, let it simmer for a while, let folks test it, and then include it when we do a v1.6.x release.

derekparker avatar Jan 05 '21 19:01 derekparker

Looks like CI is passing with this patch! I've been off for the holidays the last 2 weeks so I'm in catch up mode, but I will review this patch this week.

My current line of thinking is to cut the initial v1.6 release with lldb-server based darwin/arm64 support and then review & merge this, let it simmer for a while, let folks test it, and then include it when we do a v1.6.x release.

Sounds like a good idea! In the long run you might want to decide whether to keep the native backend or not. Now at least there is Darwin/amd64 support through the lldb server.

oxisto avatar Jan 06 '21 11:01 oxisto

After a long absence on my part, I have decided the rebase this against the current master. I have also reverted some changes that made this the default since we now have support using LLDB on darwin/arm64 now.

How should we proceed with this @derekparker? I did not have have time yet to check what has changed in the last couple of months. What is your future plan with regards to this?

oxisto avatar Apr 18 '21 17:04 oxisto

@derekparker Just a quick question. Is this something still to be considered? Then I would try to find the time to resolve the merge conflicts. Or should we just abandon the native Mac backend alltogether?

oxisto avatar Oct 13 '21 06:10 oxisto

@oxisto I would very much like to continue supporting the native Mac backend. If you can find the time to address the conflicts and continue hacking on this it would be greatly appreciated!

derekparker avatar Oct 13 '21 07:10 derekparker

@oxisto Also, I apologize for not responding to your previous comment, I do not want to give you the impression that this is not important or appreciated work, sometimes I have every intention to reply and follow up but things fall through the cracks. If you rebase this and ping me I will make sure to provide prompt reviews and feedback.

derekparker avatar Oct 13 '21 07:10 derekparker

@oxisto Also, I apologize for not responding to your previous comment, I do not want to give you the impression that this is not important or appreciated work, sometimes I have every intention to reply and follow up but things fall through the cracks. If you rebase this and ping me I will make sure to provide prompt reviews and feedback.

No worries :) I just wanted to make sure that this is still on the roadmap before I put more effort in.

oxisto avatar Oct 13 '21 08:10 oxisto

Closing stale PR, however @oxisto I'm still very interested in seeing this land. If you don't have the time I can try taking this over myself.

derekparker avatar Nov 16 '22 17:11 derekparker

@oxisto if you are still open to completing this work, feel free to rebase this PR and reopen it and I will make it a priority to review and give feedback.

derekparker avatar Nov 16 '22 17:11 derekparker

@oxisto if you are still open to completing this work, feel free to rebase this PR and reopen it and I will make it a priority to review and give feedback.

Unfortunately I do not see any free time this year to tackle this :( Maybe next year.

oxisto avatar Nov 17 '22 10:11 oxisto