]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/trace: display goroutines (PC=0) with clearer description
authorhitzhangjie <hit.zhangjie@gmail.com>
Thu, 25 Aug 2022 09:34:49 +0000 (09:34 +0000)
committerMichael Pratt <mpratt@google.com>
Thu, 25 Aug 2022 20:44:19 +0000 (20:44 +0000)
This PR fixes: #54425 #49994

Change-Id: Id60a3ba6930f8e29b12b6d8f80945decd2ce31bc
GitHub-Last-Rev: 60a040aa2f111f64f571597799ce7ca317e1d281
GitHub-Pull-Request: golang/go#54575
Reviewed-on: https://go-review.googlesource.com/c/go/+/425042
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
src/cmd/trace/goroutines.go

index 74d1b0a11dfc4ec000104954c046c1c1b434ce02..7850fc0ff189d71c794238a9c4cbab19fa2b58b3 100644 (file)
@@ -64,6 +64,11 @@ func httpGoroutines(w http.ResponseWriter, r *http.Request) {
        var glist []gtype
        for k, v := range gss {
                v.ID = k
+               // If goroutine didn't run during the trace (no sampled PC),
+               // the v.ID and v.Name will be zero value.
+               if v.ID == 0 && v.Name == "" {
+                       v.Name = "(Inactive, no stack trace sampled)"
+               }
                glist = append(glist, v)
        }
        sort.Slice(glist, func(i, j int) bool { return glist[i].ExecTime > glist[j].ExecTime })