defers

package
v0.1.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package defers implements an analysis that determines which set of defer instructions can reach each program point. For now, everything except whether the result is bounded is thrown away.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnalyzeProgram

func AnalyzeProgram(program *ssa.Program, l *config.LogGroup)

AnalyzeProgram runs the analysis on an entire program, and report the results to stdout.

Types

type InstrIndices

type InstrIndices struct {
	Block int // index of block in function
	Ins   int // index of instruction in block
}

InstrIndices represents instructions so that we can compare them (instructions do not know their own index).

type Results

type Results struct {
	DeferStackBounded bool // unbounded == "bad" == false
	RunDeferSets      map[*ssa.RunDefers]StackSet
}

Results represents the results of the analysis. The analysis could be easily extended to save the results at e.g. each RunDefers or each panic point.

func AnalyzeFunction

func AnalyzeFunction(fn *ssa.Function, l *config.LogGroup) Results

AnalyzeFunction analyzes defers for a single function using a fixpoint loop.

type Stack

type Stack []InstrIndices

Stack is a representation of the runtime stack of deferred expressions (represented by a slice of the indices of instructions that generated each deferred function).

type StackSet

type StackSet []Stack

StackSet is a set of stacks, represented as a sorted slice.

Jump to

Keyboard shortcuts

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