syscall

package
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 22, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const ENOTSUPP = unix.Errno(524)

ENOTSUPP - Operation is not supported

Variables

View Source
var Zero uintptr

Zero single-word zero for use when we need a valid pointer to 0 bytes. See mkunix.pl.

Functions

func Bind

func Bind(s int, addr unsafe.Pointer, addrlen Socklen) (err error)

Bind is a public version of the unix.bind without additional wrappers which allows us to use any value type we want. But does require the usage of unsafe.

func Bpf

func Bpf(cmd int, attr BPFAttribute, size int) (fd uintptr, err error)

Bpf is a wrapper around the BPF syscall, so a very low level function.

func Getsockopt

func Getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *Socklen) (err error)

Getsockopt is a public version of the unix.getsockopt without additional wrappers which allows us to use any value type we want. But does require the usage of unsafe.

func IOCtl

func IOCtl(fd int, req uint, arg uintptr) (err error)

func PerfEventOpen

func PerfEventOpen(attr PerfEventAttr, pid, cpu, groupFD int, flags PerfEventOpenFlags) (uintptr, error)

PerfEventOpen is a wrapper around the perf_event_open syscall.

func Sendto

func Sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen Socklen) (err error)

Sendto is a public version of the unix.sendto without additional wrappers which allows us to use any value type we want. But does require the usage of unsafe.

func Setsockopt

func Setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error)

Setsockopt is a public version of the unix.setsockopt without additional wrappers which allows us to use any value type we want. But does require the usage of unsafe.

Types

type BPFAttribute

type BPFAttribute interface {
	ToPtr() unsafe.Pointer
	Size() uintptr
}

type Error

type Error struct {
	// Context specific error information since the same code can have different
	// meaning depending on context
	Err string
	// The underlaying syscall error number
	Errno unix.Errno
}

Error is an error wrapper for syscall errors

func (*Error) Error

func (e *Error) Error() string

type PerfAttrFlags

type PerfAttrFlags uint64

PerfAttrFlags are used to pass a lot of boolean flags efficiently to the kerenl

const (
	// PerfAttrFlagsDisabled off by default
	PerfAttrFlagsDisabled PerfAttrFlags = 1 << iota
	// PerfAttrFlagsInherit children inherit it
	PerfAttrFlagsInherit
	// PerfAttrFlagsPinned must always be on PMU
	PerfAttrFlagsPinned
	// PerfAttrFlagsExclusive only group on PMU
	PerfAttrFlagsExclusive
	// PerfAttrFlagsExcludeUser don't count user
	PerfAttrFlagsExcludeUser
	// PerfAttrFlagsExcludeKernel ditto kernel
	PerfAttrFlagsExcludeKernel
	// PerfAttrFlagsExcludeHV ditto hypervisor
	PerfAttrFlagsExcludeHV
	// PerfAttrFlagsExcludeIdle don't count when idle
	PerfAttrFlagsExcludeIdle
	// PerfAttrFlagsMmap include mmap data
	PerfAttrFlagsMmap
	// PerfAttrFlagsComm include comm data
	PerfAttrFlagsComm
	// PerfAttrFlagsFreq use freq, not period
	PerfAttrFlagsFreq
	// PerfAttrFlagsInheritStat per task counts
	PerfAttrFlagsInheritStat
	// PerfAttrFlagsEnableOnExec next exec enables
	PerfAttrFlagsEnableOnExec
	// PerfAttrFlagsTask trace fork/exit
	PerfAttrFlagsTask
	// PerfAttrFlagsWatermark wakeup_watermark
	PerfAttrFlagsWatermark
	// PerfAttrFlagsPreciseIPConstantSkid SAMPLE_IP must have constant skid, See also PERF_RECORD_MISC_EXACT_IP
	PerfAttrFlagsPreciseIPConstantSkid PerfAttrFlags = 1 << 15
	// PerfAttrFlagsPreciseIPRequestZeroSkid SAMPLE_IP requested to have 0 skid, See also PERF_RECORD_MISC_EXACT_IP
	PerfAttrFlagsPreciseIPRequestZeroSkid PerfAttrFlags = 1 << 16
	// PerfAttrFlagsPreciseIPRequireZeroSkid SAMPLE_IP must have 0 skid, See also PERF_RECORD_MISC_EXACT_IP
	PerfAttrFlagsPreciseIPRequireZeroSkid PerfAttrFlags = 1<<16 + 1<<15
)

type PerfEventAttr

type PerfEventAttr struct {
	Type   PerfType
	Size   uint32
	Config uint64
	// union of sample_period and sample_frequency
	SamplePeriodFreq uint64
	SampleType       uint64
	AttrFlags        PerfAttrFlags
	// union of wakeup_events and wakeup_watermark
	WakeupEventsWatermark uint32
	BPType                uint32
	// union of bp_addr, kprobe_func, uprobe_path, and config1
	BPAddr uintptr
	// union of bp_len, kprobe_addr, probe_offset, and config2
	BPLen uint64
	// Unum of perf_branch_sample_type
	BranchSampleType uint64
	// Defines set of user regs to dump on samples.
	// See asm/perf_regs.h for details.
	SampleRegsUser uint64
	// Defines size of the user stack to dump on samples.
	SampleStackUser uint32
	ClockID         int32
	// Defines set of regs to dump for each sample
	// state captured on:
	//  - precise = 0: PMU interrupt
	//  - precise > 0: sampled instruction
	//
	// See asm/perf_regs.h for details.
	SampleRegsIntr uint64
	// Wakeup watermark for AUX area
	AUXWatermark   uint32
	SampleMaxStack uint16

	AUXSampleSize uint32

	SigData uint64
	// contains filtered or unexported fields
}

PerfEventAttr is the go version of the perf_event_attr struct as defined by the kernel. https://elixir.bootlin.com/linux/v5.14.14/source/include/uapi/linux/perf_event.h#L338

type PerfEventOpenFlags

type PerfEventOpenFlags uintptr
const (
	// PerfEventOpenFDNoGroup This  flag  tells the event to ignore the group_fd parameter ex‐
	// cept for the purpose of setting up output redirection using  the
	// PERF_FLAG_FD_OUTPUT flag.
	PerfEventOpenFDNoGroup PerfEventOpenFlags = 1 << iota

	// PerfEventOpenFDOutput This flag re-routes the event's sampled output to instead be in‐
	// cluded in the mmap buffer of the event specified by group_fd.
	PerfEventOpenFDOutput

	// PerfEventOpenPIDCgroup This  flag  tells the event to ignore the group_fd parameter ex‐
	// cept for the purpose of setting up output redirection using  the
	// PERF_FLAG_FD_OUTPUT flag.
	PerfEventOpenPIDCgroup

	// PerfEventOpenFDCloseOnExit This  flag  enables the close-on-exec flag for the created event
	// file descriptor, so that the file  descriptor  is  automatically
	// closed  on  execve(2).   Setting the close-on-exec flags at cre‐
	// ation time, rather than later with  fcntl(2),  avoids  potential
	// race    conditions    where    the    calling   thread   invokes
	// perf_event_open() and fcntl(2)  at  the  same  time  as  another
	// thread calls fork(2) then execve(2).
	PerfEventOpenFDCloseOnExit
)

type PerfType

type PerfType uint32

PerfType https://elixir.bootlin.com/linux/latest/source/include/uapi/linux/perf_event.h#L32

const (
	// PERF_TYPE_HARDWARE This indicates one of the "generalized"  hardware  events
	// provided  by the kernel.  See the config field definition
	// for more details.
	PERF_TYPE_HARDWARE PerfType = iota

	// PERF_TYPE_SOFTWARE This indicates one of the  software-defined  events  provided
	// by  the  kernel  (even  if  no hardware support is
	// available).
	PERF_TYPE_SOFTWARE

	// PERF_TYPE_TRACEPOINT This indicates a tracepoint provided by the kernel tracepoint infrastructure.
	PERF_TYPE_TRACEPOINT

	// PERF_TYPE_HW_CACHE  This  indicates  a hardware cache event. This has a special encoding,
	// described in the config field definition.
	PERF_TYPE_HW_CACHE

	// PERF_TYPE_RAW This indicates a "raw" implementation-specific  event  in
	// the config field.
	PERF_TYPE_RAW

	// PERF_TYPE_BREAKPOINT This  indicates  a hardware breakpoint as provided by the CPU.
	// Breakpoints can be read/write accesses  to  an  address as well as execution of an instruction address.
	PERF_TYPE_BREAKPOINT
)

type Socklen

type Socklen uint32

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL