Documentation ¶
Overview ¶
Package ptrace provides a ptrace-based implementation of the platform interface. This is useful for development and testing purposes primarily, and runs on stock kernels without special permissions.
In a nutshell, it works as follows:
The creation of a new address space creates a new child process with a single thread which is traced by a single goroutine.
A context is just a collection of temporary variables. Calling Switch on a context does the following:
Locks the runtime thread. Looks up a traced subprocess thread for the current runtime thread. If none exists, the dedicated goroutine is asked to create a new stopped thread in the subprocess. This stopped subprocess thread is then traced by the current thread and this information is stored for subsequent switches. The context is then bound with information about the subprocess thread so that the context may be appropriately interrupted via a signal. The requested operation is performed in the traced subprocess thread (e.g. set registers, execute, return).
Lock order:
subprocess.mu context.mu
Index ¶
- Constants
- type PTrace
- func (*PTrace) CooperativelySchedulesAddressSpace() bool
- func (*PTrace) MapUnit() uint64
- func (*PTrace) MaxUserAddress() hostarch.Addr
- func (p *PTrace) NewAddressSpace(any) (platform.AddressSpace, <-chan struct{}, error)
- func (*PTrace) NewContext(ctx pkgcontext.Context) platform.Context
- func (*PTrace) SupportsAddressSpaceIO() bool
- func (*PTrace) SyscallFilters() seccomp.SyscallRules
Constants ¶
const ( ERESTARTSYS = unix.Errno(512) ERESTARTNOINTR = unix.Errno(513) ERESTARTNOHAND = unix.Errno(514) )
Linux kernel errnos which "should never be seen by user programs", but will be revealed to ptrace syscall exit tracing.
These constants are only used in subprocess.go.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PTrace ¶
type PTrace struct { platform.MMapMinAddr platform.NoCPUPreemptionDetection platform.UseHostGlobalMemoryBarrier }
PTrace represents a collection of ptrace subprocesses.
func (*PTrace) CooperativelySchedulesAddressSpace ¶
CooperativelySchedulesAddressSpace implements platform.Platform.CooperativelySchedulesAddressSpace.
func (*PTrace) MaxUserAddress ¶
MaxUserAddress returns the first address that may not be used by user applications.
func (*PTrace) NewAddressSpace ¶
func (p *PTrace) NewAddressSpace(any) (platform.AddressSpace, <-chan struct{}, error)
NewAddressSpace returns a new subprocess.
func (*PTrace) NewContext ¶
func (*PTrace) NewContext(ctx pkgcontext.Context) platform.Context
NewContext implements platform.Platform.NewContext.
func (*PTrace) SupportsAddressSpaceIO ¶
SupportsAddressSpaceIO implements platform.Platform.SupportsAddressSpaceIO.
func (*PTrace) SyscallFilters ¶
func (*PTrace) SyscallFilters() seccomp.SyscallRules
SyscallFilters returns syscalls made exclusively by the ptrace platform.
Source Files ¶
- filters.go
- ptrace.go
- ptrace_amd64.go
- ptrace_amd64_state_autogen.go
- ptrace_linux_state_autogen.go
- ptrace_linux_unsafe_state_autogen.go
- ptrace_state_autogen.go
- ptrace_unsafe.go
- ptrace_unsafe_state_autogen.go
- stub_unsafe.go
- subprocess.go
- subprocess_amd64.go
- subprocess_linux.go
- subprocess_linux_unsafe.go
- subprocess_unsafe.go