github.com/criyle/go-sandbox@v0.10.3/ptracer/context_linux_arm.go (about)

     1  package ptracer
     2  
     3  import (
     4  	"syscall"
     5  
     6  	unix "golang.org/x/sys/unix"
     7  )
     8  
     9  // SyscallNo get current syscall no
    10  func (c *Context) SyscallNo() uint {
    11  	return uint(c.regs.Uregs[7]) // R7
    12  }
    13  
    14  // Arg0 gets the arg0 for the current syscall
    15  func (c *Context) Arg0() uint {
    16  	return uint(c.regs.Uregs[17]) //Orig_R0
    17  }
    18  
    19  // Arg1 gets the arg1 for the current syscall
    20  func (c *Context) Arg1() uint {
    21  	return uint(c.regs.Uregs[1]) // R1
    22  }
    23  
    24  // Arg2 gets the arg2 for the current syscall
    25  func (c *Context) Arg2() uint {
    26  	return uint(c.regs.Uregs[2]) // R2
    27  }
    28  
    29  // Arg3 gets the arg3 for the current syscall
    30  func (c *Context) Arg3() uint {
    31  	return uint(c.regs.Uregs[3]) // R3
    32  }
    33  
    34  // Arg4 gets the arg4 for the current syscall
    35  func (c *Context) Arg4() uint {
    36  	return uint(c.regs.Uregs[4]) // R4
    37  }
    38  
    39  // Arg5 gets the arg5 for the current syscall
    40  func (c *Context) Arg5() uint {
    41  	return uint(c.regs.Uregs[5]) //R5
    42  }
    43  
    44  // SetReturnValue set the return value if skip the syscall
    45  func (c *Context) SetReturnValue(retval int) {
    46  	c.regs.Uregs[0] = uint32(retval) // R0
    47  }
    48  
    49  func (c *Context) skipSyscall() error {
    50  	err := syscall.PtraceSetRegs(c.Pid, &c.regs)
    51  	if err != nil {
    52  		return err
    53  	}
    54  	return ptraceArmSetSyscall(c.Pid, -1)
    55  }
    56  
    57  func getIovec(base *byte, l int) unix.Iovec {
    58  	return unix.Iovec{
    59  		Base: base,
    60  		Len:  uint32(l),
    61  	}
    62  }