Imports #
"bytes"
"encoding/binary"
"fmt"
"os"
"regexp"
"strings"
"internal/trace"
"internal/trace/event"
"internal/trace/event/go122"
"internal/trace/raw"
"internal/trace/version"
"internal/txtar"
"bytes"
"encoding/binary"
"fmt"
"os"
"regexp"
"strings"
"internal/trace"
"internal/trace/event"
"internal/trace/event/go122"
"internal/trace/raw"
"internal/trace/version"
"internal/txtar"
var NoStack = []trace.StackFrame{...}
var NoString = ""
Seq represents a sequence counter.
type Seq uint64
Time represents a low-level trace timestamp (which does not necessarily correspond to nanoseconds, like trace.Time does).
type Time uint64
Batch represents an event batch.
type Batch struct {
gen *Generation
thread trace.ThreadID
timestamp Time
size uint64
events []raw.Event
}
Generation represents a single generation in the trace.
type Generation struct {
trace *Trace
gen uint64
batches []*Batch
strings map[string]uint64
stacks map[stack]uint64
ignoreStringBatchSizeLimit bool
ignoreStackBatchSizeLimit bool
}
Trace represents an execution trace for testing. It does a little bit of work to ensure that the produced trace is valid, just for convenience. It mainly tracks batches and batch sizes (so they're trivially correct), tracks strings and stacks, and makes sure emitted string and stack batches are valid. That last part can be controlled by a few options. Otherwise, it performs no validation on the trace at all.
type Trace struct {
ver version.Version
names map[string]event.Type
specs []event.Spec
events []raw.Event
gens []*Generation
validTimestamps bool
bad bool
badMatch *regexp.Regexp
}
type stack struct {
stk [32]trace.StackFrame
len int
}
Batch starts a new event batch in the trace data. This is convenience function for generating correct batches.
func (g *Generation) Batch(thread trace.ThreadID, time Time) *Batch
DisableTimestamps makes the timestamps for all events generated after this call zero. Raw events are exempted from this because the caller has to pass their own timestamp into those events anyway.
func (t *Trace) DisableTimestamps()
Event emits an event into a batch. name must correspond to one of the names in Specs() result for the version that was passed to this trace. Callers must omit the timestamp delta.
func (b *Batch) Event(name string, args ...any)
ExpectFailure writes down that the trace should be broken. The caller must provide a pattern matching the expected error produced by the parser.
func (t *Trace) ExpectFailure(pattern string)
ExpectSuccess writes down that the trace should successfully parse.
func (t *Trace) ExpectSuccess()
Generate creates a test file for the trace.
func (t *Trace) Generate() []byte
Generation creates a new trace generation. This provides more structure than Event to allow for more easily creating complex traces that are mostly or completely correct.
func (t *Trace) Generation(gen uint64) *Generation
func Main(f func(*Trace))
NewTrace creates a new trace.
func NewTrace() *Trace
RawEvent emits an event into the trace. name must correspond to one of the names in Specs() result for the version that was passed to this trace.
func (t *Trace) RawEvent(typ event.Type, data []byte, args ...uint64)
RawEvent emits an event into a batch. name must correspond to one of the names in Specs() result for the version that was passed to this trace.
func (b *Batch) RawEvent(typ event.Type, data []byte, args ...uint64)
Stack registers a stack with the trace. This is a convenience function for easily adding correct stacks to traces.
func (g *Generation) Stack(stk []trace.StackFrame) uint64
String registers a string with the trace. This is a convenience function for easily adding correct strings to traces.
func (g *Generation) String(s string) uint64
func (t *Trace) createEvent(ev event.Type, data []byte, args ...uint64) raw.Event
func (g *Generation) newStructuralBatch() *Batch
func (b *Batch) uintArgFor(arg any, argSpec string) uint64
writeEventsTo emits event batches in the generation to tw.
func (g *Generation) writeEventsTo(tw *raw.TextWriter)
writeEventsTo emits events in the batch, including the batch header, to tw.
func (b *Batch) writeEventsTo(tw *raw.TextWriter)
Generated with Arrow