From 76ce11cffb812c1951d7807665c6e40d269bd9c7 Mon Sep 17 00:00:00 2001 From: Alessandro Arzilli Date: Thu, 4 May 2017 19:43:53 +0200 Subject: [PATCH] proc/gdbserial: disable lldb backend on windows (#819) Lldb-server does not currently support windows/amd64 (it's in development). And delve's native backend seems to work well on windows. Disable the lldb backend on windows for now. Fixes #817 --- pkg/proc/gdbserial/gdbserver.go | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/pkg/proc/gdbserial/gdbserver.go b/pkg/proc/gdbserial/gdbserver.go index c9c7ad16..12681e46 100644 --- a/pkg/proc/gdbserial/gdbserver.go +++ b/pkg/proc/gdbserial/gdbserver.go @@ -292,13 +292,20 @@ func unusedPort() string { const debugserverExecutable = "/Library/Developer/CommandLineTools/Library/PrivateFrameworks/LLDB.framework/Versions/A/Resources/debugserver" +var ErrUnsupportedOS = errors.New("lldb backend not supported on windows") + // LLDBLaunch starts an instance of lldb-server and connects to it, asking // it to launch the specified target program with the specified arguments // (cmd) on the specified directory wd. func LLDBLaunch(cmd []string, wd string) (*Process, error) { - // check that the argument to Launch is an executable file - if fi, staterr := os.Stat(cmd[0]); staterr == nil && (fi.Mode()&0111) == 0 { - return nil, proc.NotExecutableErr + switch runtime.GOOS { + case "windows": + return nil, ErrUnsupportedOS + default: + // check that the argument to Launch is an executable file + if fi, staterr := os.Stat(cmd[0]); staterr == nil && (fi.Mode()&0111) == 0 { + return nil, proc.NotExecutableErr + } } port := unusedPort() @@ -354,6 +361,10 @@ func LLDBLaunch(cmd []string, wd string) (*Process, error) { // for some stubs that do not provide an automated way of determining it // (for example debugserver). func LLDBAttach(pid int, path string) (*Process, error) { + if runtime.GOOS == "windows" { + return nil, ErrUnsupportedOS + } + port := unusedPort() isDebugserver := false var proc *exec.Cmd @@ -921,8 +932,8 @@ func (t *Thread) Blocked() bool { func (p *Process) loadGInstr() []byte { switch p.bi.GOOS { case "windows": - //TODO(aarzilli): implement - panic("not implemented") + // mov rcx, QWORD PTR gs:0x28 + return []byte{0x65, 0x48, 0x8b, 0x0c, 0x25, 0x28, 0x00, 0x00, 0x00} case "linux": switch p.bi.Arch.GStructOffset() { case 0xfffffffffffffff8, 0x0: