How can I get perf to find symbols in my program

后端 未结 8 1749
醉梦人生
醉梦人生 2021-01-30 09:24

When using perf report, I don\'t see any symbols for my program, instead I get output like this:

$ perf record /path/to/racket ints.rkt 10000
$ pe         


        
8条回答
  •  天命终不由人
    2021-01-30 09:51

    This post is already over a year old, but since it came out at the top of my Google search results when I had the same problem, I thought I'd answer it here. After some more searching around, I found the answer given in this related StackOverflow question very helpful. On my Ubuntu Raring system, I then ended up doing the following:

    1. Compile my C++ sources with -g (fairly obvious, you need debug symbols)
    2. Run perf as

      record -g dwarf -F 97 /path/to/my/program
      

      This way perf is able to handle the DWARF 2 debug format, which is the standard format gcc uses on Linux. The -F 97 parameter reduces the sampling rate to 97 Hz. The default sampling rate was apparently too large for my system and resulted in messages like this:

      Warning:
      Processed 172390 events and lost 126 chunks!
      
      Check IO/CPU overload!
      

      and the perf report call afterwards would fail with a segmentation fault. With the reduced sampling rate everything worked out fine.

    3. Once the perf.data file has been generated without any errors in the previous step, you can run perf report etc. I personally like the FlameGraph tools to generate SVG visualizations.
    4. Other people reported that running

      echo 0 > /proc/sys/kernel/kptr_restrict
      

      as root can help as well, if kernel symbols are required.

提交回复
热议问题