LEFT | RIGHT |
(no file at all) | |
1 // Copyright 2014 The Go Authors. All rights reserved. | 1 // Copyright 2014 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 package server | 5 package server |
6 | 6 |
7 // TODO: syscall.PTRACE_O_TRACECLONE shenanigans to trace multi-threaded | 7 // TODO: syscall.PTRACE_O_TRACECLONE shenanigans to trace multi-threaded |
8 // programs. | 8 // programs. |
9 | 9 |
10 import ( | 10 import ( |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 return <-s.ec | 43 return <-s.ec |
44 } | 44 } |
45 | 45 |
46 func (s *Server) ptraceGetRegs(pid int, regsout *syscall.PtraceRegs) (err error)
{ | 46 func (s *Server) ptraceGetRegs(pid int, regsout *syscall.PtraceRegs) (err error)
{ |
47 s.fc <- func() error { | 47 s.fc <- func() error { |
48 return syscall.PtraceGetRegs(pid, regsout) | 48 return syscall.PtraceGetRegs(pid, regsout) |
49 } | 49 } |
50 return <-s.ec | 50 return <-s.ec |
51 } | 51 } |
52 | 52 |
| 53 func (s *Server) ptraceSetRegs(pid int, regs *syscall.PtraceRegs) (err error) { |
| 54 s.fc <- func() error { |
| 55 return syscall.PtraceSetRegs(pid, regs) |
| 56 } |
| 57 return <-s.ec |
| 58 } |
| 59 |
53 func (s *Server) ptracePeek(pid int, addr uintptr, out []byte) (err error) { | 60 func (s *Server) ptracePeek(pid int, addr uintptr, out []byte) (err error) { |
54 s.fc <- func() error { | 61 s.fc <- func() error { |
55 n, err := syscall.PtracePeekText(pid, addr, out) | 62 n, err := syscall.PtracePeekText(pid, addr, out) |
56 if err != nil { | 63 if err != nil { |
57 return err | 64 return err |
58 } | 65 } |
59 if n != len(out) { | 66 if n != len(out) { |
60 return fmt.Errorf("ptracePeek: peeked %d bytes, want %d"
, n, len(out)) | 67 return fmt.Errorf("ptracePeek: peeked %d bytes, want %d"
, n, len(out)) |
61 } | 68 } |
62 return nil | 69 return nil |
(...skipping 24 matching lines...) Expand all Loading... |
87 | 94 |
88 func (s *Server) wait() (err error) { | 95 func (s *Server) wait() (err error) { |
89 var status syscall.WaitStatus | 96 var status syscall.WaitStatus |
90 s.fc <- func() error { | 97 s.fc <- func() error { |
91 _, err1 := syscall.Wait4(-1, &status, 0, nil) | 98 _, err1 := syscall.Wait4(-1, &status, 0, nil) |
92 return err1 | 99 return err1 |
93 } | 100 } |
94 // TODO: do something with status. | 101 // TODO: do something with status. |
95 return <-s.ec | 102 return <-s.ec |
96 } | 103 } |
LEFT | RIGHT |