mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime: simplify CPU profiling code
This makes Go's CPU profiling code somewhat more idiomatic; e.g., using := instead of forward declaring variables, using "int" for element counts instead of "uintptr", and slices instead of C-style pointer+length. This makes the code easier to read and eliminates a lot of type conversion clutter. Additionally, in sigprof we can collect just maxCPUProfStack stack frames, as cpuprof won't use more than that anyway. Change-Id: I0235b5ae552191bcbb453b14add6d8c01381bd06 Reviewed-on: https://go-review.googlesource.com/6072 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
This commit is contained in:
parent
a32dd83253
commit
3c8a89daf3
11 changed files with 50 additions and 58 deletions
|
|
@ -114,7 +114,7 @@ func Caller(skip int) (pc uintptr, file string, line int, ok bool) {
|
|||
// and what it called, so that we can see if it
|
||||
// "called" sigpanic.
|
||||
var rpc [2]uintptr
|
||||
if callers(1+skip-1, &rpc[0], 2) < 2 {
|
||||
if callers(1+skip-1, rpc[:]) < 2 {
|
||||
return
|
||||
}
|
||||
f := findfunc(rpc[1])
|
||||
|
|
@ -161,7 +161,7 @@ func Callers(skip int, pc []uintptr) int {
|
|||
if len(pc) == 0 {
|
||||
return 0
|
||||
}
|
||||
return callers(skip, &pc[0], len(pc))
|
||||
return callers(skip, pc)
|
||||
}
|
||||
|
||||
// GOROOT returns the root of the Go tree.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue