From 44286b17c5ca6673648ba57b4a9d49ab8dffedf6 Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Fri, 1 Dec 2017 16:13:08 -0500 Subject: runtime: replace system goroutine whitelist with symbol test Currently isSystemGoroutine has a hard-coded list of known entry points into system goroutines. This list is annoying to maintain. For example, it's missing the ensureSigM goroutine. Replace it with a check that simply looks for any goroutine with runtime function as its entry point, with a few exceptions. This also matches the definition recently added to the trace viewer (CL 81315). Change-Id: Iaed723d4a6e8c2ffb7c0c48fbac1688b00b30f01 Reviewed-on: https://go-review.googlesource.com/81655 Run-TryBot: Austin Clements TryBot-Result: Gobot Gobot Reviewed-by: Keith Randall --- src/cmd/trace/trace.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/cmd/trace') diff --git a/src/cmd/trace/trace.go b/src/cmd/trace/trace.go index 7a61d5b412..fcba0cbc3f 100644 --- a/src/cmd/trace/trace.go +++ b/src/cmd/trace/trace.go @@ -576,7 +576,7 @@ func generateTrace(params *traceParams, consumer traceConsumer) error { fname := stk[0].Fn info.name = fmt.Sprintf("G%v %s", newG, fname) - info.isSystemG = strings.HasPrefix(fname, "runtime.") && fname != "runtime.main" + info.isSystemG = isSystemGoroutine(fname) ctx.gcount++ setGState(ev, newG, gDead, gRunnable) @@ -1125,6 +1125,12 @@ func (ctx *traceContext) buildBranch(parent frameNode, stk []*trace.Frame) int { return ctx.buildBranch(node, stk) } +func isSystemGoroutine(entryFn string) bool { + // This mimics runtime.isSystemGoroutine as closely as + // possible. + return entryFn != "runtime.main" && strings.HasPrefix(entryFn, "runtime.") +} + // firstTimestamp returns the timestamp of the first event record. func firstTimestamp() int64 { res, _ := parseTrace() -- cgit v1.3-6-g1900