提交 b8e80746 编写于 作者: A aarzilli 提交者: Derek Parker

proc/native: implement Copy/RestoreRegisters on windows

上级 438e51f3
......@@ -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,
......
......@@ -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
}
......@@ -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
}
......@@ -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)
}
......@@ -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
}
......
......@@ -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")
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册