m.Name = "/gc/heap/goal:bytes"
m.Value = Value{kind: ValueUint64, scalar: e.base.args[0]}
default:
- panic(fmt.Sprintf("internal error: unexpected event type for Metric kind: %s", tracev2.EventString(e.base.typ)))
+ panic(fmt.Sprintf("internal error: unexpected wire-format event type for Metric kind: %d", e.base.typ))
}
return m
}
panic("Label called on non-Label event")
}
if e.base.typ != tracev2.EvGoLabel {
- panic(fmt.Sprintf("internal error: unexpected event type for Label kind: %s", tracev2.EventString(e.base.typ)))
+ panic(fmt.Sprintf("internal error: unexpected wire-format event type for Label kind: %d", e.base.typ))
}
return Label{
Label: e.table.strings.mustGet(stringID(e.base.args[0])),
r.Scope.id = int64(e.Goroutine())
}
default:
- panic(fmt.Sprintf("internal error: unexpected event type for Range kind: %s", tracev2.EventString(e.base.typ)))
+ panic(fmt.Sprintf("internal error: unexpected wire-event type for Range kind: %d", e.base.typ))
}
return r
}
parentID = TaskID(e.base.extra(version.Go122)[0])
typ = e.table.getExtraString(extraStringID(e.base.extra(version.Go122)[1]))
default:
- panic(fmt.Sprintf("internal error: unexpected event type for Task kind: %s", tracev2.EventString(e.base.typ)))
+ panic(fmt.Sprintf("internal error: unexpected wire-format event type for Task kind: %d", e.base.typ))
}
return Task{
ID: TaskID(e.base.args[0]),
panic("Region called on non-Region event")
}
if e.base.typ != tracev2.EvUserRegionBegin && e.base.typ != tracev2.EvUserRegionEnd {
- panic(fmt.Sprintf("internal error: unexpected event type for Region kind: %s", tracev2.EventString(e.base.typ)))
+ panic(fmt.Sprintf("internal error: unexpected wire-format event type for Region kind: %d", e.base.typ))
}
return Region{
Task: TaskID(e.base.args[0]),
panic("Log called on non-Log event")
}
if e.base.typ != tracev2.EvUserLog {
- panic(fmt.Sprintf("internal error: unexpected event type for Log kind: %s", tracev2.EventString(e.base.typ)))
+ panic(fmt.Sprintf("internal error: unexpected wire-format event type for Log kind: %d", e.base.typ))
}
return Log{
Task: TaskID(e.base.args[0]),
from, to := packedStatus>>32, packedStatus&((1<<32)-1)
s = goStateTransition(GoID(e.base.args[0]), GoState(from), tracev2GoStatus2GoState[to])
default:
- panic(fmt.Sprintf("internal error: unexpected event type for StateTransition kind: %s", tracev2.EventString(e.base.typ)))
+ panic(fmt.Sprintf("internal error: unexpected wire-format event type for StateTransition kind: %d", e.base.typ))
}
return s
}
// add completed events to the ordering. Next is used to pick
// off events in the ordering.
type ordering struct {
+ traceVer version.Version
gStates map[GoID]*gState
pStates map[ProcID]*pState // TODO: The keys are dense, so this can be a slice.
mStates map[ThreadID]*mState
return ok, err
}
+func (o *ordering) evName(typ event.Type) string {
+ return o.traceVer.EventName(typ)
+}
+
type orderingHandleFunc func(o *ordering, ev *baseEvent, evt *evTable, m ThreadID, gen uint64, curCtx schedCtx) (schedCtx, bool, error)
var orderingDispatch = [256]orderingHandleFunc{
// ProcStop doesn't need a sequence number.
state, ok := o.pStates[curCtx.P]
if !ok {
- return curCtx, false, fmt.Errorf("event %s for proc (%v) that doesn't exist", tracev2.EventString(ev.typ), curCtx.P)
+ return curCtx, false, fmt.Errorf("event %s for proc (%v) that doesn't exist", o.evName(ev.typ), curCtx.P)
}
if state.status != tracev2.ProcRunning && state.status != tracev2.ProcSyscall {
- return curCtx, false, fmt.Errorf("%s event for proc that's not %s or %s", tracev2.EventString(ev.typ), tracev2.ProcRunning, tracev2.ProcSyscall)
+ return curCtx, false, fmt.Errorf("%s event for proc that's not %s or %s", o.evName(ev.typ), tracev2.ProcRunning, tracev2.ProcSyscall)
}
reqs := schedReqs{M: mustHave, P: mustHave, G: mayHave}
if err := validateCtx(curCtx, reqs); err != nil {
}
// If we have a goroutine, it must be running.
if state, ok := o.gStates[curCtx.G]; ok && state.status != tracev2.GoRunning {
- return curCtx, false, fmt.Errorf("%s event for goroutine that's not %s", tracev2.EventString(ev.typ), GoRunning)
+ return curCtx, false, fmt.Errorf("%s event for goroutine that's not %s", o.evName(ev.typ), GoRunning)
}
// This goroutine created another. Add a state for it.
newgid := GoID(ev.args[0])
}
state, ok := o.gStates[curCtx.G]
if !ok {
- return curCtx, false, fmt.Errorf("event %s for goroutine (%v) that doesn't exist", tracev2.EventString(ev.typ), curCtx.G)
+ return curCtx, false, fmt.Errorf("event %s for goroutine (%v) that doesn't exist", o.evName(ev.typ), curCtx.G)
}
if state.status != tracev2.GoRunning {
- return curCtx, false, fmt.Errorf("%s event for goroutine that's not %s", tracev2.EventString(ev.typ), GoRunning)
+ return curCtx, false, fmt.Errorf("%s event for goroutine that's not %s", o.evName(ev.typ), GoRunning)
}
// Handle each case slightly differently; we just group them together
// because they have shared preconditions.
}
curGState, ok := o.gStates[curCtx.G]
if !ok {
- return curCtx, false, fmt.Errorf("event %s for goroutine (%v) that doesn't exist", tracev2.EventString(ev.typ), curCtx.G)
+ return curCtx, false, fmt.Errorf("event %s for goroutine (%v) that doesn't exist", o.evName(ev.typ), curCtx.G)
}
if curGState.status != tracev2.GoRunning {
- return curCtx, false, fmt.Errorf("%s event for goroutine that's not %s", tracev2.EventString(ev.typ), GoRunning)
+ return curCtx, false, fmt.Errorf("%s event for goroutine that's not %s", o.evName(ev.typ), GoRunning)
}
nextg := GoID(ev.args[0])
seq := makeSeq(gen, ev.args[1]) // seq is for nextg, not curCtx.G.
}
state, ok := o.gStates[curCtx.G]
if !ok {
- return curCtx, false, fmt.Errorf("event %s for goroutine (%v) that doesn't exist", tracev2.EventString(ev.typ), curCtx.G)
+ return curCtx, false, fmt.Errorf("event %s for goroutine (%v) that doesn't exist", o.evName(ev.typ), curCtx.G)
}
if state.status != tracev2.GoRunning {
- return curCtx, false, fmt.Errorf("%s event for goroutine that's not %s", tracev2.EventString(ev.typ), GoRunning)
+ return curCtx, false, fmt.Errorf("%s event for goroutine that's not %s", o.evName(ev.typ), GoRunning)
}
// Goroutine entered a syscall. It's still running on this P and M.
state.status = tracev2.GoSyscall
pState, ok := o.pStates[curCtx.P]
if !ok {
- return curCtx, false, fmt.Errorf("uninitialized proc %d found during %s", curCtx.P, tracev2.EventString(ev.typ))
+ return curCtx, false, fmt.Errorf("uninitialized proc %d found during %s", curCtx.P, o.evName(ev.typ))
}
pState.status = tracev2.ProcSyscall
// Validate the P sequence number on the event and advance it.
// to back off and see if any other events will advance. This is a running P.
pSeq := makeSeq(gen, ev.args[0])
if !pSeq.succeeds(pState.seq) {
- return curCtx, false, fmt.Errorf("failed to advance %s: can't make sequence: %s -> %s", tracev2.EventString(ev.typ), pState.seq, pSeq)
+ return curCtx, false, fmt.Errorf("failed to advance %s: can't make sequence: %s -> %s", o.evName(ev.typ), pState.seq, pSeq)
}
pState.seq = pSeq
o.queue.push(Event{table: evt, ctx: curCtx, base: *ev})
}
state, ok := o.gStates[curCtx.G]
if !ok {
- return curCtx, false, fmt.Errorf("event %s for goroutine (%v) that doesn't exist", tracev2.EventString(ev.typ), curCtx.G)
+ return curCtx, false, fmt.Errorf("event %s for goroutine (%v) that doesn't exist", o.evName(ev.typ), curCtx.G)
}
if state.status != tracev2.GoSyscall {
- return curCtx, false, fmt.Errorf("%s event for goroutine that's not %s", tracev2.EventString(ev.typ), GoRunning)
+ return curCtx, false, fmt.Errorf("%s event for goroutine that's not %s", o.evName(ev.typ), GoRunning)
}
state.status = tracev2.GoRunning
// Transfer the P back to running from syscall.
pState, ok := o.pStates[curCtx.P]
if !ok {
- return curCtx, false, fmt.Errorf("uninitialized proc %d found during %s", curCtx.P, tracev2.EventString(ev.typ))
+ return curCtx, false, fmt.Errorf("uninitialized proc %d found during %s", curCtx.P, o.evName(ev.typ))
}
if pState.status != tracev2.ProcSyscall {
return curCtx, false, fmt.Errorf("expected proc %d in state %v, but got %v instead", curCtx.P, tracev2.ProcSyscall, pState.status)
if curCtx.P != NoProc {
pState, ok := o.pStates[curCtx.P]
if !ok {
- return curCtx, false, fmt.Errorf("uninitialized proc %d found during %s", curCtx.P, tracev2.EventString(ev.typ))
+ return curCtx, false, fmt.Errorf("uninitialized proc %d found during %s", curCtx.P, o.evName(ev.typ))
}
if pState.status == tracev2.ProcSyscall {
return curCtx, false, nil
}
state, ok := o.gStates[curCtx.G]
if !ok {
- return curCtx, false, fmt.Errorf("event %s for goroutine (%v) that doesn't exist", tracev2.EventString(ev.typ), curCtx.G)
+ return curCtx, false, fmt.Errorf("event %s for goroutine (%v) that doesn't exist", o.evName(ev.typ), curCtx.G)
}
if state.status != tracev2.GoSyscall {
- return curCtx, false, fmt.Errorf("%s event for goroutine that's not %s", tracev2.EventString(ev.typ), GoRunning)
+ return curCtx, false, fmt.Errorf("%s event for goroutine that's not %s", o.evName(ev.typ), GoRunning)
}
newCtx := curCtx
newCtx.G = NoGoroutine
// Check to make sure the goroutine exists in the right state.
state, ok := o.gStates[curCtx.G]
if !ok {
- return curCtx, false, fmt.Errorf("event %s for goroutine (%v) that doesn't exist", tracev2.EventString(ev.typ), curCtx.G)
+ return curCtx, false, fmt.Errorf("event %s for goroutine (%v) that doesn't exist", o.evName(ev.typ), curCtx.G)
}
if state.status != tracev2.GoSyscall {
- return curCtx, false, fmt.Errorf("%s event for goroutine that's not %v", tracev2.EventString(ev.typ), GoSyscall)
+ return curCtx, false, fmt.Errorf("%s event for goroutine that's not %v", o.evName(ev.typ), GoSyscall)
}
// This goroutine is exiting itself.
delete(o.gStates, curCtx.G)
if curCtx.P != NoProc {
pState, ok := o.pStates[curCtx.P]
if !ok {
- return curCtx, false, fmt.Errorf("found invalid proc %d during %s", curCtx.P, tracev2.EventString(ev.typ))
+ return curCtx, false, fmt.Errorf("found invalid proc %d during %s", curCtx.P, o.evName(ev.typ))
}
if pState.status != tracev2.ProcSyscall {
- return curCtx, false, fmt.Errorf("proc %d in unexpected state %s during %s", curCtx.P, pState.status, tracev2.EventString(ev.typ))
+ return curCtx, false, fmt.Errorf("proc %d in unexpected state %s during %s", curCtx.P, pState.status, o.evName(ev.typ))
}
// See the go122-create-syscall-reuse-thread-id test case for more details.
pState.status = tracev2.ProcSyscallAbandoned
// current scheduler context.
gState, ok := o.gStates[gid]
if !ok {
- return curCtx, false, fmt.Errorf("uninitialized goroutine %d found during %s", gid, tracev2.EventString(ev.typ))
+ return curCtx, false, fmt.Errorf("uninitialized goroutine %d found during %s", gid, o.evName(ev.typ))
}
if err := gState.activeRange(makeRangeType(ev.typ, 0), gen == o.initialGen); err != nil {
return curCtx, false, err