Commit c6228ef7 authored by Raul Silvera's avatar Raul Silvera Committed by Michael Matloob

runtime/pprof: track locations for goroutine profiles

Must add locations to the profile when generating a profile.proto.
This fixes #18229

Change-Id: I49cd63a30759d3fe8960d7b7c8bd5a554907f8d1
Reviewed-on: https://go-review.googlesource.com/34028Reviewed-by: 's avatarMichael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 3a067cc8
......@@ -386,12 +386,22 @@ func printCountProfile(w io.Writer, debug int, name string, p countProfile) erro
Sample: make([]*profile.Sample, 0, len(keys)),
SampleType: []*profile.ValueType{{Type: name, Unit: "count"}},
}
locMap := make(map[uintptr]*profile.Location)
for _, k := range keys {
stk := p.Stack(index[k])
c := count[k]
locs := make([]*profile.Location, len(stk))
for i, addr := range stk {
locs[i] = &profile.Location{Address: uint64(addr) - 1}
loc := locMap[addr]
if loc == nil {
loc = &profile.Location{
ID: uint64(len(locMap) + 1),
Address: uint64(addr - 1),
}
prof.Location = append(prof.Location, loc)
locMap[addr] = loc
}
locs[i] = loc
}
prof.Sample = append(prof.Sample, &profile.Sample{
Location: locs,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment