migrate to go.sys subrepository

As of go version 1.4 the standard library syscall package is "locked
down" and code outside of the standard library is recommended to migrate
to the go.sys subrepository.

Reference: https://golang.org/s/go1.4-syscall
This commit is contained in:
Paul Sbarra
2015-01-25 17:16:18 -06:00
committed by Hashrocket Workstation
parent 0d08380555
commit 58de1f7c85
6 changed files with 37 additions and 35 deletions

View File

@ -6,6 +6,7 @@ import (
"debug/dwarf"
"debug/gosym"
"fmt"
sys "golang.org/x/sys/unix"
"os"
"os/exec"
"path/filepath"
@ -122,8 +123,8 @@ func (dbp *DebuggedProcess) AttachThread(tid int) (*ThreadContext, error) {
return thread, nil
}
err := syscall.PtraceAttach(tid)
if err != nil && err != syscall.EPERM {
err := sys.PtraceAttach(tid)
if err != nil && err != sys.EPERM {
// Do not return err if err == EPERM,
// we may already be tracing this thread due to
// PTRACE_O_TRACECLONE. We will surely blow up later
@ -200,7 +201,7 @@ func (dbp *DebuggedProcess) RequestManualStop() {
if stopped(th.Id) {
continue
}
syscall.Tgkill(dbp.Pid, th.Id, syscall.SIGSTOP)
sys.Tgkill(dbp.Pid, th.Id, sys.SIGSTOP)
}
dbp.running = false
}
@ -234,7 +235,7 @@ func (dbp *DebuggedProcess) ClearByLocation(loc string) (*BreakPoint, error) {
}
// Returns the status of the current main thread context.
func (dbp *DebuggedProcess) Status() *syscall.WaitStatus {
func (dbp *DebuggedProcess) Status() *sys.WaitStatus {
return dbp.CurrentThread.Status
}
@ -313,7 +314,7 @@ func (dbp *DebuggedProcess) Next() error {
}
err := th.Next()
if err != nil && err != syscall.ESRCH {
if err != nil && err != sys.ESRCH {
return err
}
}
@ -389,7 +390,7 @@ func (pe ProcessExitedError) Error() string {
return fmt.Sprintf("process %d has exited", pe.pid)
}
func trapWait(dbp *DebuggedProcess, pid int) (int, *syscall.WaitStatus, error) {
func trapWait(dbp *DebuggedProcess, pid int) (int, *sys.WaitStatus, error) {
for {
wpid, status, err := wait(pid, 0)
if err != nil {
@ -404,17 +405,17 @@ func trapWait(dbp *DebuggedProcess, pid int) (int, *syscall.WaitStatus, error) {
if status.Exited() && wpid == dbp.Pid {
return -1, status, ProcessExitedError{wpid}
}
if status.StopSignal() == syscall.SIGTRAP && status.TrapCause() == syscall.PTRACE_EVENT_CLONE {
if status.StopSignal() == sys.SIGTRAP && status.TrapCause() == sys.PTRACE_EVENT_CLONE {
err = addNewThread(dbp, wpid)
if err != nil {
return -1, nil, err
}
continue
}
if status.StopSignal() == syscall.SIGTRAP {
if status.StopSignal() == sys.SIGTRAP {
return wpid, status, nil
}
if status.StopSignal() == syscall.SIGSTOP && dbp.halt {
if status.StopSignal() == sys.SIGSTOP && dbp.halt {
return -1, nil, ManualStopError{}
}
}
@ -477,11 +478,11 @@ func stopTheWorld(dbp *DebuggedProcess) error {
if stopped(th.Id) {
continue
}
err := syscall.Tgkill(dbp.Pid, th.Id, syscall.SIGSTOP)
err := sys.Tgkill(dbp.Pid, th.Id, sys.SIGSTOP)
if err != nil {
return err
}
pid, _, err := wait(th.Id, syscall.WNOHANG)
pid, _, err := wait(th.Id, sys.WNOHANG)
if err != nil {
return fmt.Errorf("wait err %s %d", err, pid)
}
@ -493,7 +494,7 @@ func stopTheWorld(dbp *DebuggedProcess) error {
func addNewThread(dbp *DebuggedProcess, pid int) error {
// A traced thread has cloned a new thread, grab the pid and
// add it to our list of traced threads.
msg, err := syscall.PtraceGetEventMsg(pid)
msg, err := sys.PtraceGetEventMsg(pid)
if err != nil {
return fmt.Errorf("could not get event message: %s", err)
}
@ -504,12 +505,12 @@ func addNewThread(dbp *DebuggedProcess, pid int) error {
return err
}
err = syscall.PtraceCont(int(msg), 0)
err = sys.PtraceCont(int(msg), 0)
if err != nil {
return fmt.Errorf("could not continue new thread %d %s", msg, err)
}
err = syscall.PtraceCont(pid, 0)
err = sys.PtraceCont(pid, 0)
if err != nil {
return fmt.Errorf("could not continue stopped thread %d %s", pid, err)
}
@ -517,8 +518,8 @@ func addNewThread(dbp *DebuggedProcess, pid int) error {
return nil
}
func wait(pid, options int) (int, *syscall.WaitStatus, error) {
var status syscall.WaitStatus
wpid, err := syscall.Wait4(pid, &status, syscall.WALL|options, nil)
func wait(pid, options int) (int, *sys.WaitStatus, error) {
var status sys.WaitStatus
wpid, err := sys.Wait4(pid, &status, sys.WALL|options, nil)
return wpid, &status, err
}