proc/native: implement Copy/RestoreRegisters on windows
This commit is contained in:
parent
438e51f330
commit
b8e80746e5
@ -57,6 +57,7 @@ func Launch(cmd []string, wd string, foreground bool) (*Process, error) {
|
|||||||
|
|
||||||
var p *os.Process
|
var p *os.Process
|
||||||
dbp := New(0)
|
dbp := New(0)
|
||||||
|
dbp.common = proc.NewCommonProcess(true)
|
||||||
dbp.execPtraceFunc(func() {
|
dbp.execPtraceFunc(func() {
|
||||||
attr := &os.ProcAttr{
|
attr := &os.ProcAttr{
|
||||||
Dir: wd,
|
Dir: wd,
|
||||||
|
|||||||
@ -325,5 +325,16 @@ func (thread *Thread) fpRegisters() (regs []proc.Register, fpregs proc.LinuxX86X
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r *Regs) Copy() proc.Registers {
|
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
|
fs uint64
|
||||||
gs uint64
|
gs uint64
|
||||||
tls uint64
|
tls uint64
|
||||||
|
context *_CONTEXT
|
||||||
fltSave *_XMM_SAVE_AREA32
|
fltSave *_XMM_SAVE_AREA32
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -374,11 +375,16 @@ func registers(thread *Thread, floatingPoint bool) (proc.Registers, error) {
|
|||||||
if floatingPoint {
|
if floatingPoint {
|
||||||
regs.fltSave = &context.FltSave
|
regs.fltSave = &context.FltSave
|
||||||
}
|
}
|
||||||
|
regs.context = context
|
||||||
|
|
||||||
return regs, nil
|
return regs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Regs) Copy() proc.Registers {
|
func (r *Regs) Copy() proc.Registers {
|
||||||
//TODO(aarzilli): implement this to support function calls
|
var rr Regs
|
||||||
return nil
|
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 {
|
if t.dbp.exited {
|
||||||
return 0, proc.ProcessExitedError{Pid: t.dbp.pid}
|
return 0, proc.ProcessExitedError{Pid: t.dbp.pid}
|
||||||
}
|
}
|
||||||
|
if len(data) == 0 {
|
||||||
|
return 0, nil
|
||||||
|
}
|
||||||
var count uintptr
|
var count uintptr
|
||||||
err := _WriteProcessMemory(t.dbp.os.hProcess, addr, &data[0], uintptr(len(data)), &count)
|
err := _WriteProcessMemory(t.dbp.os.hProcess, addr, &data[0], uintptr(len(data)), &count)
|
||||||
if err != nil {
|
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 {
|
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)
|
GAddr() (uint64, bool)
|
||||||
Get(int) (uint64, error)
|
Get(int) (uint64, error)
|
||||||
Slice() []Register
|
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.
|
// when the registers of the associated thread change.
|
||||||
Copy() Registers
|
Copy() Registers
|
||||||
}
|
}
|
||||||
|
|||||||
@ -251,18 +251,7 @@ func MustSupportFunctionCalls(t *testing.T, testBackend string) {
|
|||||||
t.Skip("this version of Go does not support function calls")
|
t.Skip("this version of Go does not support function calls")
|
||||||
}
|
}
|
||||||
|
|
||||||
const unsupported = "this backend does not support function calls"
|
if testBackend == "rr" || (runtime.GOOS == "darwin" && testBackend == "native") {
|
||||||
|
t.Skip("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)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user