Delve: Add support for FreeBSD

Created on 19 Aug 2015  路  15Comments  路  Source: go-delve/delve

go get -u github.com/derekparker/delve/cmd/dlv
# github.com/derekparker/delve/proc
../../../github.com/derekparker/delve/proc/proc.go:43: undefined: OSProcessDetails
help wanted kinenhancement oFreeBSD

All 15 comments

Unfortunately FreeBSD is not a supported platform at the moment.

Actually, let me rename and reopen for adding FreeBSD support.

For completeness sake, retrieving the dependencies fails like this:

% go get -v -u github.com/peterh/liner github.com/derekparker/delve/cmd/dlv
github.com/peterh/liner (download)
github.com/derekparker/delve (download)
Fetching https://gopkg.in/yaml.v2?go-get=1
Parsing meta tags from https://gopkg.in/yaml.v2?go-get=1 (status code 200)
get "gopkg.in/yaml.v2": found meta tag main.metaImport{Prefix:"gopkg.in/yaml.v2", VCS:"git", RepoRoot:"https://gopkg.in/yaml.v2"} at https://gopkg.in/yaml.v2?go-get=1
gopkg.in/yaml.v2 (download)
Fetching https://golang.org/x/debug/dwarf?go-get=1
Parsing meta tags from https://golang.org/x/debug/dwarf?go-get=1 (status code 200)
get "golang.org/x/debug/dwarf": found meta tag main.metaImport{Prefix:"golang.org/x/debug", VCS:"git", RepoRoot:"https://go.googlesource.com/debug"} at https://golang.org/x/debug/dwarf?go-get=1
get "golang.org/x/debug/dwarf": verifying non-authoritative meta tag
Fetching https://golang.org/x/debug?go-get=1
Parsing meta tags from https://golang.org/x/debug?go-get=1 (status code 200)
golang.org/x/debug (download)
Fetching https://rsc.io/x86/x86asm?go-get=1
Parsing meta tags from https://rsc.io/x86/x86asm?go-get=1 (status code 200)
get "rsc.io/x86/x86asm": found meta tag main.metaImport{Prefix:"rsc.io/x86", VCS:"git", RepoRoot:"https://github.com/rsc/x86"} at https://rsc.io/x86/x86asm?go-get=1
get "rsc.io/x86/x86asm": verifying non-authoritative meta tag
Fetching https://rsc.io/x86?go-get=1
Parsing meta tags from https://rsc.io/x86?go-get=1 (status code 200)
rsc.io/x86 (download)
github.com/spf13/cobra (download)
github.com/spf13/pflag (download)
gopkg.in/yaml.v2
github.com/peterh/liner
github.com/derekparker/delve/dwarf/util
github.com/derekparker/delve/dwarf/frame
github.com/derekparker/delve/dwarf/line
github.com/derekparker/delve/dwarf/op
golang.org/x/debug/dwarf
github.com/derekparker/delve/config
rsc.io/x86/x86asm
github.com/derekparker/delve/dwarf/reader
github.com/spf13/pflag
github.com/derekparker/delve/proc
# github.com/derekparker/delve/proc
../../go/src/github.com/derekparker/delve/proc/proc.go:54: undefined: OSProcessDetails
../../go/src/github.com/derekparker/delve/proc/threads.go:23: undefined: WaitStatus
github.com/spf13/cobra

The issue seems to be:

# github.com/derekparker/delve/proc
../../go/src/github.com/derekparker/delve/proc/proc.go:54: undefined: OSProcessDetails
../../go/src/github.com/derekparker/delve/proc/threads.go:23: undefined: WaitStatus

Cheers,
tpltnt

@aarzilli : It seems only need to extend content in /proc directory of delve to support FreeBSD. Is it right?

@NanXiao yes.

Can we also throw in a request for OpenBSD since I'm seeing a similar issue?

$ go get -v -u github.com/peterh/liner github.com/derekparker/delve/cmd/dlv 
github.com/peterh/liner (download)
github.com/derekparker/delve (download)
github.com/derekparker/delve/vendor/gopkg.in/yaml.v2
github.com/derekparker/delve/pkg/goversion
github.com/derekparker/delve/pkg/dwarf/util
github.com/derekparker/delve/pkg/dwarf/op
github.com/derekparker/delve/pkg/dwarf/godwarf
github.com/derekparker/delve/pkg/dwarf/frame
github.com/derekparker/delve/pkg/dwarf/line
github.com/derekparker/delve/pkg/dwarf/reader
github.com/derekparker/delve/vendor/golang.org/x/arch/x86/x86asm
github.com/derekparker/delve/pkg/config
github.com/derekparker/delve/vendor/github.com/peterh/liner
github.com/derekparker/delve/pkg/version
github.com/derekparker/delve/vendor/github.com/spf13/pflag
github.com/derekparker/delve/pkg/proc
github.com/derekparker/delve/vendor/github.com/spf13/cobra
github.com/derekparker/delve/service/api
github.com/derekparker/delve/pkg/proc/core
github.com/derekparker/delve/service
github.com/derekparker/delve/pkg/proc/gdbserial
github.com/derekparker/delve/pkg/proc/native
# github.com/derekparker/delve/pkg/proc/native
src/github.com/derekparker/delve/pkg/proc/native/threads.go:16:28: undefined: WaitStatus
src/github.com/derekparker/delve/pkg/proc/native/threads.go:24:18: undefined: OSSpecificDetails
# github.com/derekparker/delve/pkg/proc/gdbserial
src/github.com/derekparker/delve/pkg/proc/gdbserial/gdbserver.go:418:21: undefined: backgroundSysProcAttr
src/github.com/derekparker/delve/pkg/proc/gdbserial/gdbserver.go:468:21: undefined: backgroundSysProcAttr
src/github.com/derekparker/delve/pkg/proc/gdbserial/rr.go:58:22: undefined: backgroundSysProcAttr

It's actually worse than just /proc stuff. None of the ptrace definitions are in place for FreeBSD. I'll take a stab at adding them.

I might help with NetBSD, but currently we are in the process of improving our debugging interfaces and this must wait.

Status update: my patched delve compiles on FreeBSD. I can start it and run a few commands before it aborts due to an array overflow in Go. I'll keep working as time permits.

@asomers that's pretty cool.

@asomers where is your repository?

Sorry to say that I'm out of time to work on this. Perhaps somebody else can continue where I left off. My main repository is at [email protected]:asomers/delve.git and I'm working in the fbsd branch. I also had to make a few changes to golang. Those are in [email protected]:asomers/sys in the ptrace_fbsd branch. They're also already imported into the vendor area of my delve branch.

The biggest challenge to porting Delve to FreeBSD is in the different threading model. On Linux a thread is just a weird process, and ptrace works more or less identically on threads and processes. However, on FreeBSD threads are a first-class concept and ptrace works primarily on processes, using a set of special requests to for thread-related stuff. That difference has exposed some Linuxisms that got accidentally assumed in Delve. I expect that there are more to follow.

I apologize in advance for any problems with my code. This is both my first experience with Go and my first experience with ptrace, so it's a little rough. Good luck to all.

I have got slides (bit dated, but good as a reference) of mine explaining a bit the differences between BSD's ptrace(2) and the Linux's one.
http://netbsd.org/~kamil/ptrace-netbsd/presentation.html

Oh fantastic. Can likely change back to a decent OS for developing on. :wink:

Was this page helpful?
0 / 5 - 0 ratings