Bug 207777

Summary: Userspace frames are missing despite -fno-omit-frame-pointer
Product: Tracing/Profiling Reporter: Konstantin Kharlamov (hi-angel)
Component: Perf toolAssignee: Arnaldo Carvalho de Melo (acme)
Status: NEW ---    
Severity: normal CC: jolsa
Priority: P1    
Hardware: All   
OS: Linux   
See Also: https://bugzilla.kernel.org/show_bug.cgi?id=207301
Kernel Version: 5.6.13 Subsystem:
Regression: No Bisected commit-id:

Description Konstantin Kharlamov 2020-05-18 15:29:17 UTC
# Steps to reproduce (in terms of terminal commands)

    $ gcc test.c -o test -O0 -g3 -fno-omit-frame-pointer
    $ sudo sysctl kernel.sched_schedstats=1
    kernel.sched_schedstats = 1
    $ sudo perf record -e sched:sched_stat_sleep,sched:sched_switch,sched:sched_process_exit -g ./test
    [ perf record: Woken up 1 times to write data ]
    [ perf record: Captured and wrote 0.033 MB perf.data (34 samples) ]
    $ sudo perf script | grep -E "main|\bg\b|\bf\b"

## Expected

Last command should've printed lines that accord to frames inside `main`, `g`, `f` functions

## Actual

No output from the last command
Comment 1 Konstantin Kharlamov 2020-05-18 15:29:55 UTC
Omg, sorry, forgot to put the code in the description

    #include <unistd.h>

    void f() {
        for (size_t i = 0; i < 5; ++i) {
            sleep(1);
        }
    }

    void g() {
        f();
    }

    int main() {
        g();
    }
Comment 2 Konstantin Kharlamov 2020-05-18 15:36:43 UTC
I just remember that there's an alternative way to get stack traces: by using `--callgraph=X`. When that X is dwarf, I get the correct output.