Userspace stack missing detail
here is my golang demo
package main
import (
"log"
"time"
)`
func main() {
for {
log.Printf("hello world")
add(1, 1)
del(1, 1)
time.Sleep(time.Millisecond * 100)
}
}
func add(x int, y int) int {
return x + y
}
func del(x int, y int) int {
return x - y
}
I compile it like that
gccgo -O0 -fno-omit-frameointer -o main main.go
I run it and use the offcputime tool to mesurement it. However, the userspace stack seems not correct
./offcputime -U -p 3303
And get the result is
write
[unknown]
- main (3372)
1915
select
- main (3371)
11303
syscall
- main (3371)
3824106
syscall
- main (3372)
3829608
syscall
- main (3373)
3836335
It looks like -O0 and -fno-omit-frameointer makes no sense. I just get a main stack what I expect get should contains add function and del function's stack. Is there any idea about it?
You could trace bpf_get_stackid helper -> kernel source perf_callchain_kernel() -> walk_stackframe() See what happened in those parts, also print out the address that kernel unwinded. And compare those addresses with your process stack.
Sometimes the result will surprise you.