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

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