Skip to content

Commit 45b4ed7

Browse files
committed
runtime/pprof: delete unused locForPC
Change-Id: Ie4754fefba6057b1cf558d0096fe0e83355f8eff Reviewed-on: https://go-review.googlesource.com/c/go/+/205098 TryBot-Result: Gobot Gobot <[email protected]> Run-TryBot: Hyang-Ah Hana Kim <[email protected]> Reviewed-by: Keith Randall <[email protected]>
1 parent e25de44 commit 45b4ed7

File tree

1 file changed

+0
-85
lines changed

1 file changed

+0
-85
lines changed

src/runtime/pprof/proto.go

Lines changed: 0 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -239,91 +239,6 @@ func allFrames(addr uintptr) ([]runtime.Frame, symbolizeFlag) {
239239
return ret, symbolizeResult
240240
}
241241

242-
// locForPC returns the location ID for addr.
243-
// addr must a return PC or 1 + the PC of an inline marker. This returns the location of the corresponding call.
244-
// It may emit to b.pb, so there must be no message encoding in progress.
245-
func (b *profileBuilder) locForPC(addr uintptr) uint64 {
246-
if loc, ok := b.locs[addr]; ok {
247-
return loc.id
248-
}
249-
250-
// Expand this one address using CallersFrames so we can cache
251-
// each expansion. In general, CallersFrames takes a whole
252-
// stack, but in this case we know there will be no skips in
253-
// the stack and we have return PCs anyway.
254-
frames := runtime.CallersFrames([]uintptr{addr})
255-
frame, more := frames.Next()
256-
if frame.Function == "runtime.goexit" {
257-
// Short-circuit if we see runtime.goexit so the loop
258-
// below doesn't allocate a useless empty location.
259-
return 0
260-
}
261-
262-
symbolizeResult := lookupTried
263-
if frame.PC == 0 || frame.Function == "" || frame.File == "" || frame.Line == 0 {
264-
symbolizeResult |= lookupFailed
265-
}
266-
267-
if frame.PC == 0 {
268-
// If we failed to resolve the frame, at least make up
269-
// a reasonable call PC. This mostly happens in tests.
270-
frame.PC = addr - 1
271-
}
272-
273-
// We can't write out functions while in the middle of the
274-
// Location message, so record new functions we encounter and
275-
// write them out after the Location.
276-
type newFunc struct {
277-
id uint64
278-
name, file string
279-
}
280-
newFuncs := make([]newFunc, 0, 8)
281-
282-
id := uint64(len(b.locs)) + 1
283-
b.locs[addr] = locInfo{id: id, pcs: []uintptr{addr}}
284-
start := b.pb.startMessage()
285-
b.pb.uint64Opt(tagLocation_ID, id)
286-
b.pb.uint64Opt(tagLocation_Address, uint64(frame.PC))
287-
for frame.Function != "runtime.goexit" {
288-
// Write out each line in frame expansion.
289-
funcID := uint64(b.funcs[frame.Function])
290-
if funcID == 0 {
291-
funcID = uint64(len(b.funcs)) + 1
292-
b.funcs[frame.Function] = int(funcID)
293-
newFuncs = append(newFuncs, newFunc{funcID, frame.Function, frame.File})
294-
}
295-
b.pbLine(tagLocation_Line, funcID, int64(frame.Line))
296-
if !more {
297-
break
298-
}
299-
frame, more = frames.Next()
300-
}
301-
for i := range b.mem {
302-
if b.mem[i].start <= addr && addr < b.mem[i].end || b.mem[i].fake {
303-
b.pb.uint64Opt(tagLocation_MappingID, uint64(i+1))
304-
305-
m := b.mem[i]
306-
m.funcs |= symbolizeResult
307-
b.mem[i] = m
308-
break
309-
}
310-
}
311-
b.pb.endMessage(tagProfile_Location, start)
312-
313-
// Write out functions we found during frame expansion.
314-
for _, fn := range newFuncs {
315-
start := b.pb.startMessage()
316-
b.pb.uint64Opt(tagFunction_ID, fn.id)
317-
b.pb.int64Opt(tagFunction_Name, b.stringIndex(fn.name))
318-
b.pb.int64Opt(tagFunction_SystemName, b.stringIndex(fn.name))
319-
b.pb.int64Opt(tagFunction_Filename, b.stringIndex(fn.file))
320-
b.pb.endMessage(tagProfile_Function, start)
321-
}
322-
323-
b.flush()
324-
return id
325-
}
326-
327242
type locInfo struct {
328243
// location id assigned by the profileBuilder
329244
id uint64

0 commit comments

Comments
 (0)