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

[WIP] Windows support #276

Merged
merged 1 commit into from Jan 24, 2016
Merged

[WIP] Windows support #276

merged 1 commit into from Jan 24, 2016

Conversation

lukehoban
Copy link
Contributor

Initial work on porting Delve to support Windows.

There's a lot more to do before this is ready to be merged, but most of the core infrastructure for Windows support is in place, and some basic Delve scenarios are working in simple scenarios (launching, setting breakpoints, continuing, breaking on breakpoints, inspecting registers, seeing sources, inspecting locals, exiting, etc.).

Fixes #198.

@lukehoban lukehoban mentioned this pull request Oct 16, 2015
@ignatov
Copy link

ignatov commented Oct 27, 2015

Great!

@lukehoban
Copy link
Contributor Author

A quick update on progress:

A few of the known remaining work items:

  • The TestNextNetHTTP test is disabled and needs to be investigated.
  • Attach support is not yet enabled on Windows.
  • Thread information is not displayed nicely for most non-active threads because the PC on those threads is in ntdll or other dynamically loaded code. To address this, we would need to load symbols on Windows and merge that information with the DWARF symbols. This should be possible, but worth discussing before implementing.
  • There are a handful of TODOs to investigate and improve on workarounds in the existing implementation.
  • Effort was made to have minimal impact on the Mac/Linux codebase so far. In the future, it likely will make sense to define a more formal platform abstraction layer that is platform independent.

However, at this point it is worth starting to get more eyes on this code and discussing if/when this should be merged into master.

/cc @derekparker

if err != nil {
return err
}
_, err = t.dbp.trapWait(0)
Copy link
Member

Choose a reason for hiding this comment

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

I think this is a bug, calling trapWait inside singleStep means delve will get stuck on breakpoints set on 1 byte instructions. See #262 and the commit I added today to #259.

Copy link
Member

Choose a reason for hiding this comment

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

That's true. @aarzilli is there a test for that? If not we should add one, because for now let's simply not use trapWait here, but shortly after this and some other PRs land I'd like to look into ensuring that trapWait is safe to call in that situation. Either way I'd like to prevent that as a regression in the future.

Copy link
Member

Choose a reason for hiding this comment

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

#259 has TestIssue262 which does catch this on linux and OS X, however it's highly dependent on what the compiler does.

aarzilli added a commit to aarzilli/delve that referenced this pull request Nov 19, 2015
resume loops in continueOnce moved to a OS specific resume function,
this makes the problem easier to deal with and seems to be more
appropriate to a windows port given what transpired from discussion
of Pull Request go-delve#276
aarzilli added a commit to aarzilli/delve that referenced this pull request Nov 19, 2015
resume loops in continueOnce moved to a OS specific resume function,
this makes the problem easier to deal with and seems to be more
appropriate to a windows port given what transpired from discussion
of Pull Request go-delve#276
aarzilli added a commit to aarzilli/delve that referenced this pull request Nov 20, 2015
resume loops in continueOnce moved to a OS specific resume function,
this makes the problem easier to deal with and seems to be more
appropriate to a windows port given what transpired from discussion
of Pull Request go-delve#276
aarzilli added a commit to aarzilli/delve that referenced this pull request Nov 21, 2015
resume loops in continueOnce moved to a OS specific resume function,
this makes the problem easier to deal with and seems to be more
appropriate to a windows port given what transpired from discussion
of Pull Request go-delve#276
aarzilli added a commit to aarzilli/delve that referenced this pull request Nov 24, 2015
resume loops in continueOnce moved to a OS specific resume function,
this makes the problem easier to deal with and seems to be more
appropriate to a windows port given what transpired from discussion
of Pull Request go-delve#276
@derekparker
Copy link
Member

@lukehoban sorry for the delay, have gotten really busy lately. I will be taking another look tomorrow. How is the work going to finish implementing features and get all tests to pass?

@derekparker
Copy link
Member

@lukehoban do you plan on 100% parity with this PR or to get an initial implementation? Because I'm fine with merging a solid implementation that doesn't have 100% parity, as long as we have issues to track the other features that must be implemented.

@aarzilli
Copy link
Member

My note about the trapWait call can be disregarded given the Continue refactoring we did on the other branch.

aarzilli added a commit to aarzilli/delve that referenced this pull request Dec 15, 2015
resume loops in continueOnce moved to a OS specific resume function,
this makes the problem easier to deal with and seems to be more
appropriate to a windows port given what transpired from discussion
of Pull Request go-delve#276
@lukehoban
Copy link
Contributor Author

@derekparker Apologies for the delay getting back to you.

I do think this is close to ready to merge in with a discrete set of known issues we can track in the issue tracker.

There is only one truly "incorrect" thing I am aware of in the current implementation, which is the issue mentioned in https://github.com/derekparker/delve/pull/276#discussion_r45100529.

Other than that, the remaining points from https://github.com/derekparker/delve/pull/276#issuecomment-155274585 are places where there is not yet 100% parity, but what does work works correctly. I'm happy to work on these as issues after merging this PR.

Certainly, merging this in with the CI turned on will help to make sure the Windows support doesn't regress going forward.

On the singleStep issue, I'll try to find some time to look at that in the next few days, and to bring this branch up to date with master. Once I have an update on that, we can decide whether to merge this in.

@dprime
Copy link

dprime commented Dec 18, 2015

Hey,

I'm just trying to build this to test it out on my windows setup. Having a few problems getting things running. Should I be building on windows or cross compiling from linux to windows? When attempting to build on windows, it moans about lacking a gcc install and when on linux, it complains about ../../service/api/conversions.go:9:2: C source files not allowed when not using cgo or SWIG: threads_windows.c
Any thoughts?

@lukehoban
Copy link
Contributor Author

Yeah - Delve uses cgo heavily, and cgo on Windows requires a GCC toolchain. I've been compiling on Windows with the MinGW64 tools.

The appveyor.yml has one particular toolchain configuration that works and is being used in the CI toolchain: x86_64-4.9.2-release-win32-seh-rt_v4-rev3.

Locally I've used a slightly different MinGW version: x86_64-5.2.0-posix-seh-rt_v4-rev0.


// Attach to an existing process with the given PID.
func Attach(pid int) (*Process, error) {
fmt.Println("Attach")
Copy link
Member

Choose a reason for hiding this comment

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

Let's remove this and just return the error.

@ignatov
Copy link

ignatov commented Jan 20, 2016

@lukehoban Could you ping me directly when the PR will be merged, please.

// in this case, one for each thread, so we should only handle the BP hit
// on the thread that the debugger was evented on.

err := trapthread.SetCurrentBreakpoint()
Copy link
Member

Choose a reason for hiding this comment

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

nit: rewrite as return trapthread.SetCurrentBreakpoint()

@derekparker
Copy link
Member

@lukehoban https://github.com/derekparker/delve/pull/351 has landed, fixing the single step behavior.

return false
}
switch fn.Name {
case "runtime.kevent", "runtime.mach_semaphore_wait", "runtime.usleep":
Copy link
Member

Choose a reason for hiding this comment

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

We can definitely remove "runtime.mach_semaphore_wait" from this list.

@derekparker
Copy link
Member

@lukehoban also, let's just go ahead and add the Appveyor badge to the README in the PR, since CI is already setup there it seems. That way it'll just be there when this lands.

@lukehoban
Copy link
Contributor Author

I've addressed all the code review feedback in the latest commits.

#351 has landed, fixing the single step behavior.

Great. I've updated the windows branch to align with this (actually just removing some code).

let's just go ahead and add the Appveyor badge to the README in the PR, since CI is already setup there it seems.

I think you'll need to set up an AppVeyor project to track derekparker/delve. The one I have at https://ci.appveyor.com/project/lukehoban/delve is pointing at lukehoban/delve.

@derekparker derekparker merged commit bddb712 into go-delve:master Jan 24, 2016
@derekparker
Copy link
Member

Just merged this branch, will now start creating issues to track outstanding work that needs to be done, and I will get AppVeyor setup as well. Thank you @lukehoban for all your work on this!

@lukehoban
Copy link
Contributor Author

@kolkov
Copy link

kolkov commented Jan 24, 2016

This is very cool!
@ignatov as you asked!

@ahmetb
Copy link

ahmetb commented Jan 24, 2016

congrats!

@techtonik
Copy link

@derekparker looks like this article https://blog.gopheracademy.com/advent-2015/debugging-with-delve/ should be updated with new info about Windows support. )

abner-chenc pushed a commit to loongson/delve that referenced this pull request Mar 1, 2024
resume loops in continueOnce moved to a OS specific resume function,
this makes the problem easier to deal with and seems to be more
appropriate to a windows port given what transpired from discussion
of Pull Request go-delve#276
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.

None yet