stackdeltatypes

package
v0.0.0-...-319d980 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package stackdeltatypes provides types used to represent stack delta information as constructed by `nativeunwind.GetIntervalStructures` This information is a post-processed form of the stack delta information that is used in all relevant packages.

Index

Constants

View Source
const (
	// ABI is the current binary compatibility version. It is incremented
	// if struct IntervalData, struct StackDelta or the meaning of their contents
	// changes, and can be used to determine if the data is compatible
	ABI = 15

	// MinimumGap determines the minimum number of alignment bytes needed
	// in order to keep the created STOP stack delta between functions
	MinimumGap = 15

	// UnwindOpcodes from the C header file
	UnwindOpcodeCommand   uint8 = C.UNWIND_OPCODE_COMMAND
	UnwindOpcodeBaseCFA   uint8 = C.UNWIND_OPCODE_BASE_CFA
	UnwindOpcodeBaseSP    uint8 = C.UNWIND_OPCODE_BASE_SP
	UnwindOpcodeBaseFP    uint8 = C.UNWIND_OPCODE_BASE_FP
	UnwindOpcodeBaseLR    uint8 = C.UNWIND_OPCODE_BASE_LR
	UnwindOpcodeFlagDeref uint8 = C.UNWIND_OPCODEF_DEREF

	// UnwindCommands from the C header file
	UnwindCommandInvalid int32 = C.UNWIND_COMMAND_INVALID
	UnwindCommandStop    int32 = C.UNWIND_COMMAND_STOP
	UnwindCommandPLT     int32 = C.UNWIND_COMMAND_PLT
	UnwindCommandSignal  int32 = C.UNWIND_COMMAND_SIGNAL

	// UnwindDeref handling from the C header file
	UnwindDerefMask       int32 = C.UNWIND_DEREF_MASK
	UnwindDerefMultiplier int32 = C.UNWIND_DEREF_MULTIPLIER

	// UnwindHintNone indicates that no flags are set.
	UnwindHintNone uint8 = 0
	// UnwindHintKeep flags important intervals that should not be removed
	// (e.g. has CALL/SYSCALL assembly opcode, or is part of function prologue)
	UnwindHintKeep uint8 = 1
	// UnwindHintGap indicates that the delta marks function end
	UnwindHintGap uint8 = 4
)

Variables

View Source
var UnwindInfoFramePointer = UnwindInfo{
	Opcode:   UnwindOpcodeBaseFP,
	Param:    16,
	FPOpcode: UnwindOpcodeBaseCFA,
	FPParam:  -16,
}

UnwindInfoFramePointer contains the description to unwind a frame with valid frame pointer.

View Source
var UnwindInfoInvalid = UnwindInfo{Opcode: UnwindOpcodeCommand, Param: UnwindCommandInvalid}

UnwindInfoInvalid is the stack delta info indicating invalid or unsupported PC.

View Source
var UnwindInfoSignal = UnwindInfo{Opcode: UnwindOpcodeCommand, Param: UnwindCommandSignal}

UnwindInfoSignal is the stack delta info indicating signal return frame.

View Source
var UnwindInfoStop = UnwindInfo{Opcode: UnwindOpcodeCommand, Param: UnwindCommandStop}

UnwindInfoStop is the stack delta info indicating root function of a stack.

Functions

func PackDerefParam

func PackDerefParam(preDeref, postDeref int32) (int32, bool)

PackDerefParam compresses pre- and post-dereference parameters to single value

func UnpackDerefParam

func UnpackDerefParam(param int32) (preDeref, postDeref int32)

UnpackDerefParam splits the pre- and post-dereference parameters from single value

Types

type IntervalData

type IntervalData struct {
	// Deltas contains all stack deltas for a single binary.
	// Two consecutive entries describe an interval.
	Deltas StackDeltaArray
}

IntervalData contains everything that a userspace agent needs to have to populate eBPF maps for the kernel-space native unwinder to do its job:

type StackDelta

type StackDelta struct {
	Address uint64
	Hints   uint8
	Info    UnwindInfo
}

StackDelta defines the start address for the delta interval, along with the unwind information.

type StackDeltaArray

type StackDeltaArray []StackDelta

StackDeltaArray defines an address space where consecutive entries establish intervals for the stack deltas

func (*StackDeltaArray) Add

func (deltas *StackDeltaArray) Add(delta StackDelta)

Add adds a new stack delta from a sorted source.

func (*StackDeltaArray) AddEx

func (deltas *StackDeltaArray) AddEx(delta StackDelta, sorted bool)

AddEx adds a new stack delta to the array.

type UnwindInfo

type UnwindInfo struct {
	Opcode, FPOpcode, MergeOpcode uint8

	Param, FPParam int32
}

UnwindInfo contains the data needed to unwind PC, SP and FP

Jump to

Keyboard shortcuts

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