mirror of
https://github.com/golang/go
synced 2024-11-11 19:31:37 -07:00
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/34028 Reviewed-by: Michael Matloob <matloob@golang.org> Run-TryBot: Michael Matloob <matloob@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
3a067cc812
commit
c6228ef7e2
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user