diff --git a/pkg/proc/native/proc_windows.go b/pkg/proc/native/proc_windows.go index 2f14ff966ccdfce02209aa8f5179d15c063a64f3..b6f8a2ca5489b79b1ea77488793f7cf727b69a61 100644 --- a/pkg/proc/native/proc_windows.go +++ b/pkg/proc/native/proc_windows.go @@ -57,6 +57,7 @@ func Launch(cmd []string, wd string, foreground bool) (*Process, error) { var p *os.Process dbp := New(0) + dbp.common = proc.NewCommonProcess(true) dbp.execPtraceFunc(func() { attr := &os.ProcAttr{ Dir: wd, diff --git a/pkg/proc/native/registers_linux_amd64.go b/pkg/proc/native/registers_linux_amd64.go index 0467444c3680d9e963931b7a660687d4056bccb9..6a3014f770188d545ba612270ec021a0b36c72b3 100644 --- a/pkg/proc/native/registers_linux_amd64.go +++ b/pkg/proc/native/registers_linux_amd64.go @@ -325,5 +325,16 @@ func (thread *Thread) fpRegisters() (regs []proc.Register, fpregs proc.LinuxX86X } func (r *Regs) Copy() proc.Registers { - return r + var rr Regs + rr.regs = &sys.PtraceRegs{} + rr.fpregset = &proc.LinuxX86Xstate{} + *(rr.regs) = *(r.regs) + if r.fpregset != nil { + *(rr.fpregset) = *(r.fpregset) + } + if r.fpregs != nil { + rr.fpregs = make([]proc.Register, len(r.fpregs)) + copy(rr.fpregs, r.fpregs) + } + return &rr } diff --git a/pkg/proc/native/registers_windows_amd64.go b/pkg/proc/native/registers_windows_amd64.go index a50ad6e6782ca30c0a0e0d6b8eb48e419f25aa71..099a18290fb45c3ea1f4e207e5aa057d3b31e5a7 100644 --- a/pkg/proc/native/registers_windows_amd64.go +++ b/pkg/proc/native/registers_windows_amd64.go @@ -33,6 +33,7 @@ type Regs struct { fs uint64 gs uint64 tls uint64 + context *_CONTEXT fltSave *_XMM_SAVE_AREA32 } @@ -374,11 +375,16 @@ func registers(thread *Thread, floatingPoint bool) (proc.Registers, error) { if floatingPoint { regs.fltSave = &context.FltSave } + regs.context = context return regs, nil } func (r *Regs) Copy() proc.Registers { - //TODO(aarzilli): implement this to support function calls - return nil + var rr Regs + rr = *r + rr.context = newCONTEXT() + *(rr.context) = *(r.context) + rr.fltSave = &rr.context.FltSave + return &rr } diff --git a/pkg/proc/native/threads_windows.go b/pkg/proc/native/threads_windows.go index 9ba6a15d93fdfaa371707d1f9597541d3fa8122a..3420aafba25e992309fb66268e2a884fe06341b3 100644 --- a/pkg/proc/native/threads_windows.go +++ b/pkg/proc/native/threads_windows.go @@ -125,6 +125,9 @@ func (t *Thread) WriteMemory(addr uintptr, data []byte) (int, error) { if t.dbp.exited { return 0, proc.ProcessExitedError{Pid: t.dbp.pid} } + if len(data) == 0 { + return 0, nil + } var count uintptr err := _WriteProcessMemory(t.dbp.os.hProcess, addr, &data[0], uintptr(len(data)), &count) if err != nil { @@ -151,5 +154,5 @@ func (t *Thread) ReadMemory(buf []byte, addr uintptr) (int, error) { } func (t *Thread) restoreRegisters(savedRegs proc.Registers) error { - return errors.New("not implemented") + return _SetThreadContext(t.os.hThread, savedRegs.(*Regs).context) } diff --git a/pkg/proc/registers.go b/pkg/proc/registers.go index f13eea78c2eb8b79753c1050bac27bf5adb2e656..4c3f8fe1423e1a157436c48fb7f8eb79a1dc49b4 100644 --- a/pkg/proc/registers.go +++ b/pkg/proc/registers.go @@ -24,7 +24,7 @@ type Registers interface { GAddr() (uint64, bool) Get(int) (uint64, error) Slice() []Register - // Copy returns a copy of this registers that is guaranteed not to change + // Copy returns a copy of the registers that is guaranteed not to change // when the registers of the associated thread change. Copy() Registers } diff --git a/pkg/proc/test/support.go b/pkg/proc/test/support.go index 62de03b54f57c4892173cd9b1717d381a9f1b733..53b8c36a8d9975e8df0c29dd179721a9a1729719 100644 --- a/pkg/proc/test/support.go +++ b/pkg/proc/test/support.go @@ -251,18 +251,7 @@ func MustSupportFunctionCalls(t *testing.T, testBackend string) { t.Skip("this version of Go does not support function calls") } - const unsupported = "this backend does not support function calls" - - if testBackend == "rr" { - t.Skip(unsupported) - } - - switch runtime.GOOS { - case "darwin": - if testBackend == "native" { - t.Skip(unsupported) - } - case "windows": - t.Skip(unsupported) + if testBackend == "rr" || (runtime.GOOS == "darwin" && testBackend == "native") { + t.Skip("this backend does not support function calls") } }