1# Executable commands reference 2 3[TOC] 4 5## How simpleperf works 6 7Modern CPUs have a hardware component called the performance monitoring unit (PMU). The PMU has 8several hardware counters, counting events like how many cpu cycles have happened, how many 9instructions have executed, or how many cache misses have happened. 10 11The Linux kernel wraps these hardware counters into hardware perf events. In addition, the Linux 12kernel also provides hardware independent software events and tracepoint events. The Linux kernel 13exposes all events to userspace via the perf_event_open system call, which is used by simpleperf. 14 15Simpleperf has three main commands: stat, record and report. 16 17The stat command gives a summary of how many events have happened in the profiled processes in a 18time period. Here’s how it works: 191. Given user options, simpleperf enables profiling by making a system call to the kernel. 202. The kernel enables counters while the profiled processes are running. 213. After profiling, simpleperf reads counters from the kernel, and reports a counter summary. 22 23The record command records samples of the profiled processes in a time period. Here’s how it works: 241. Given user options, simpleperf enables profiling by making a system call to the kernel. 252. Simpleperf creates mapped buffers between simpleperf and the kernel. 263. The kernel enables counters while the profiled processes are running. 274. Each time a given number of events happen, the kernel dumps a sample to the mapped buffers. 285. Simpleperf reads samples from the mapped buffers and stores profiling data in a file called 29 perf.data. 30 31The report command reads perf.data and any shared libraries used by the profiled processes, 32and outputs a report showing where the time was spent. 33 34## Commands 35 36Simpleperf supports several commands, listed below: 37 38``` 39The debug-unwind command: debug/test dwarf based offline unwinding, used for debugging simpleperf. 40The dump command: dumps content in perf.data, used for debugging simpleperf. 41The help command: prints help information for other commands. 42The kmem command: collects kernel memory allocation information (will be replaced by Python scripts). 43The list command: lists all event types supported on the Android device. 44The record command: profiles processes and stores profiling data in perf.data. 45The report command: reports profiling data in perf.data. 46The report-sample command: reports each sample in perf.data, used for supporting integration of 47 simpleperf in Android Studio. 48The stat command: profiles processes and prints counter summary. 49 50``` 51 52Each command supports different options, which can be seen through help message. 53 54```sh 55# List all commands. 56$ simpleperf --help 57 58# Print help message for record command. 59$ simpleperf record --help 60``` 61 62Below describes the most frequently used commands, which are list, stat, record and report. 63 64## The list command 65 66The list command lists all events available on the device. Different devices may support different 67events because they have different hardware and kernels. 68 69```sh 70$ simpleperf list 71List of hw-cache events: 72 branch-loads 73 ... 74List of hardware events: 75 cpu-cycles 76 instructions 77 ... 78List of software events: 79 cpu-clock 80 task-clock 81 ... 82``` 83 84On ARM/ARM64, the list command also shows a list of raw events, they are the events supported by 85the ARM PMU on the device. The kernel has wrapped part of them into hardware events and hw-cache 86events. For example, raw-cpu-cycles is wrapped into cpu-cycles, raw-instruction-retired is wrapped 87into instructions. The raw events are provided in case we want to use some events supported on the 88device, but unfortunately not wrapped by the kernel. 89 90## The stat command 91 92The stat command is used to get event counter values of the profiled processes. By passing options, 93we can select which events to use, which processes/threads to monitor, how long to monitor and the 94print interval. 95 96```sh 97# Stat using default events (cpu-cycles,instructions,...), and monitor process 7394 for 10 seconds. 98$ simpleperf stat -p 7394 --duration 10 99Performance counter statistics: 100 101# count event_name # count / runtime 102 16,513,564 cpu-cycles # 1.612904 GHz 103 4,564,133 stalled-cycles-frontend # 341.490 M/sec 104 6,520,383 stalled-cycles-backend # 591.666 M/sec 105 4,900,403 instructions # 612.859 M/sec 106 47,821 branch-misses # 6.085 M/sec 107 25.274251(ms) task-clock # 0.002520 cpus used 108 4 context-switches # 158.264 /sec 109 466 page-faults # 18.438 K/sec 110 111Total test time: 10.027923 seconds. 112``` 113 114### Select events to stat 115 116We can select which events to use via -e. 117 118```sh 119# Stat event cpu-cycles. 120$ simpleperf stat -e cpu-cycles -p 11904 --duration 10 121 122# Stat event cache-references and cache-misses. 123$ simpleperf stat -e cache-references,cache-misses -p 11904 --duration 10 124``` 125 126When running the stat command, if the number of hardware events is larger than the number of 127hardware counters available in the PMU, the kernel shares hardware counters between events, so each 128event is only monitored for part of the total time. As a result, the number of events shown is 129smaller than the number of events that actually happened. The following is an example. 130 131```sh 132# Stat using event cache-references, cache-references:u,.... 133$ simpleperf stat -p 7394 -e cache-references,cache-references:u,cache-references:k \ 134 -e cache-misses,cache-misses:u,cache-misses:k,instructions --duration 1 135Performance counter statistics: 136 137# count event_name # count / runtime 138 490,713 cache-references # 151.682 M/sec 139 899,652 cache-references:u # 130.152 M/sec 140 855,218 cache-references:k # 111.356 M/sec 141 61,602 cache-misses # 7.710 M/sec 142 33,282 cache-misses:u # 5.050 M/sec 143 11,662 cache-misses:k # 4.478 M/sec 144 0 instructions # 145 146Total test time: 1.000867 seconds. 147simpleperf W cmd_stat.cpp:946] It seems the number of hardware events are more than the number of 148available CPU PMU hardware counters. That will trigger hardware counter 149multiplexing. As a result, events are not counted all the time processes 150running, and event counts are smaller than what really happens. 151Use --print-hw-counter to show available hardware counters. 152``` 153 154In the example above, we monitor 7 events. Each event is only monitored part of the total time. 155Because the number of cache-references is smaller than the number of cache-references:u 156(cache-references only in userspace) and cache-references:k (cache-references only in kernel). 157The number of instructions is zero. After printing the result, simpleperf checks if CPUs have 158enough hardware counters to count hardware events at the same time. If not, it prints a warning. 159 160To avoid hardware counter multiplexing, we can use `simpleperf stat --print-hw-counter` to show 161available counters on each CPU. Then don't monitor more hardware events than counters available. 162 163```sh 164$ simpleperf stat --print-hw-counter 165There are 2 CPU PMU hardware counters available on cpu 0. 166There are 2 CPU PMU hardware counters available on cpu 1. 167There are 2 CPU PMU hardware counters available on cpu 2. 168There are 2 CPU PMU hardware counters available on cpu 3. 169There are 2 CPU PMU hardware counters available on cpu 4. 170There are 2 CPU PMU hardware counters available on cpu 5. 171There are 2 CPU PMU hardware counters available on cpu 6. 172There are 2 CPU PMU hardware counters available on cpu 7. 173``` 174 175When counter multiplexing happens, there is no guarantee of which events will be monitored at 176which time. If we want to ensure some events are always monitored at the same time, we can use 177`--group`. 178 179```sh 180# Stat using event cache-references, cache-references:u,.... 181$ simpleperf stat -p 7964 --group cache-references,cache-misses \ 182 --group cache-references:u,cache-misses:u --group cache-references:k,cache-misses:k \ 183 --duration 1 184Performance counter statistics: 185 186# count event_name # count / runtime 187 2,088,463 cache-references # 181.360 M/sec 188 47,871 cache-misses # 2.292164% miss rate 189 1,277,600 cache-references:u # 136.419 M/sec 190 25,977 cache-misses:u # 2.033265% miss rate 191 326,305 cache-references:k # 74.724 M/sec 192 13,596 cache-misses:k # 4.166654% miss rate 193 194Total test time: 1.029729 seconds. 195simpleperf W cmd_stat.cpp:946] It seems the number of hardware events are more than the number of 196... 197``` 198 199### Select target to stat 200 201We can select which processes or threads to monitor via -p or -t. Monitoring a 202process is the same as monitoring all threads in the process. Simpleperf can also fork a child 203process to run the new command and then monitor the child process. 204 205```sh 206# Stat process 11904 and 11905. 207$ simpleperf stat -p 11904,11905 --duration 10 208 209# Stat processes with name containing "chrome". 210$ simpleperf stat -p chrome --duration 10 211# Stat processes with name containing part matching regex "chrome:(privileged|sandboxed)". 212$ simpleperf stat -p "chrome:(privileged|sandboxed)" --duration 10 213 214# Stat thread 11904 and 11905. 215$ simpleperf stat -t 11904,11905 --duration 10 216 217# Start a child process running `ls`, and stat it. 218$ simpleperf stat ls 219 220# Stat the process of an Android application. On non-root devices, this only works for debuggable 221# or profileable from shell apps. 222$ simpleperf stat --app simpleperf.example.cpp --duration 10 223 224# Stat only selected thread 11904 in an app. 225$ simpleperf stat --app simpleperf.example.cpp -t 11904 --duration 10 226 227# Stat system wide using -a. 228$ simpleperf stat -a --duration 10 229``` 230 231### Decide how long to stat 232 233When monitoring existing threads, we can use --duration to decide how long to monitor. When 234monitoring a child process running a new command, simpleperf monitors until the child process ends. 235In this case, we can use Ctrl-C to stop monitoring at any time. 236 237```sh 238# Stat process 11904 for 10 seconds. 239$ simpleperf stat -p 11904 --duration 10 240 241# Stat until the child process running `ls` finishes. 242$ simpleperf stat ls 243 244# Stop monitoring using Ctrl-C. 245$ simpleperf stat -p 11904 --duration 10 246^C 247``` 248 249If you want to write a script to control how long to monitor, you can send one of SIGINT, SIGTERM, 250SIGHUP signals to simpleperf to stop monitoring. 251 252### Decide the print interval 253 254When monitoring perf counters, we can also use --interval to decide the print interval. 255 256```sh 257# Print stat for process 11904 every 300ms. 258$ simpleperf stat -p 11904 --duration 10 --interval 300 259 260# Print system wide stat at interval of 300ms for 10 seconds. Note that system wide profiling needs 261# root privilege. 262$ su 0 simpleperf stat -a --duration 10 --interval 300 263``` 264 265### Display counters in systrace 266 267Simpleperf can also work with systrace to dump counters in the collected trace. Below is an example 268to do a system wide stat. 269 270```sh 271# Capture instructions (kernel only) and cache misses with interval of 300 milliseconds for 15 272# seconds. 273$ su 0 simpleperf stat -e instructions:k,cache-misses -a --interval 300 --duration 15 274# On host launch systrace to collect trace for 10 seconds. 275(HOST)$ external/chromium-trace/systrace.py --time=10 -o new.html sched gfx view 276# Open the collected new.html in browser and perf counters will be shown up. 277``` 278 279### Show event count per thread 280 281By default, stat cmd outputs an event count sum for all monitored targets. But when `--per-thread` 282option is used, stat cmd outputs an event count for each thread in monitored targets. It can be 283used to find busy threads in a process or system wide. With `--per-thread` option, stat cmd opens 284a perf_event_file for each exisiting thread. If a monitored thread creates new threads, event 285count for new threads will be added to the monitored thread by default, otherwise omitted if 286`--no-inherit` option is also used. 287 288```sh 289# Print event counts for each thread in process 11904. Event counts for threads created after 290# stat cmd will be added to threads creating them. 291$ simpleperf stat --per-thread -p 11904 --duration 1 292 293# Print event counts for all threads running in the system every 1s. Threads not running will not 294# be reported. 295$ su 0 simpleperf stat --per-thread -a --interval 1000 --interval-only-values 296 297# Print event counts for all threads running in the system every 1s. Event counts for threads 298# created after stat cmd will be omitted. 299$ su 0 simpleperf stat --per-thread -a --interval 1000 --interval-only-values --no-inherit 300``` 301 302### Show event count per core 303 304By default, stat cmd outputs an event count sum for all monitored cpu cores. But when `--per-core` 305option is used, stat cmd outputs an event count for each core. It can be used to see how events 306are distributed on different cores. 307When stating non-system wide with `--per-core` option, simpleperf creates a perf event for each 308monitored thread on each core. When a thread is in running state, perf events on all cores are 309enabled, but only the perf event on the core running the thread is in running state. So the 310percentage comment shows runtime_on_a_core / runtime_on_all_cores. Note that, percentage is still 311affected by hardware counter multiplexing. Check simpleperf log output for ways to distinguish it. 312 313```sh 314# Print event counts for each cpu running threads in process 11904. 315# A percentage shows runtime_on_a_cpu / runtime_on_all_cpus. 316$ simpleperf stat -e cpu-cycles --per-core -p 1057 --duration 3 317Performance counter statistics: 318 319# cpu count event_name # count / runtime 320 0 1,667,660 cpu-cycles # 1.571565 GHz 321 1 3,850,440 cpu-cycles # 1.736958 GHz 322 2 2,463,792 cpu-cycles # 1.701367 GHz 323 3 2,350,528 cpu-cycles # 1.700841 GHz 324 5 7,919,520 cpu-cycles # 2.377081 GHz 325 6 105,622,673 cpu-cycles # 2.381331 GHz 326 327Total test time: 3.002703 seconds. 328 329# Print event counts for each cpu system wide. 330$ su 0 simpleperf stat --per-core -a --duration 1 331 332# Print cpu-cycle event counts for each cpu for each thread running in the system. 333$ su 0 simpleperf stat -e cpu-cycles -a --per-thread --per-core --duration 1 334``` 335 336### Monitor different events on different cores 337 338Android devices usually have big and little cores. Different cores may support different events. 339Therefore, we may want to monitor different events on different cores. We can do this using 340the `--cpu` option. The `--cpu` option selects the cores on which to monitor events. A `--cpu` 341option affects all the following events until meeting another `--cpu` option. The first `--cpu` 342option also affects all events before it. Following are some examples: 343 344```sh 345# By default, cpu-cycles and instructions are monitored on all cpus. 346$ su 0 simpleperf stat -e cpu-cycles,instructions -a --duration 1 --per-core 347 348# Use one `--cpu` option to monitor cpu-cycles and instructions only on cpu 0-3,8. 349$ su 0 simpleperf stat -e cpu-cycles --cpu 0-3,8 -e instructions -a --duration 1 --per-core 350 351# Use two `--cpu` options to monitor raw-l3d-cache-refill-rd on cpu 0-3, and raw-l3d-cache-refill on 352# cpu 4-8. 353$ su 0 simpleperf stat --cpu 0-3 -e raw-l3d-cache-refill-rd --cpu 4-8 -e raw-l3d-cache-refill \ 354 -a --duration 1 --per-core 355``` 356 357## The record command 358 359The record command is used to dump samples of the profiled processes. Each sample can contain 360information like the time at which the sample was generated, the number of events since last 361sample, the program counter of a thread, the call chain of a thread. 362 363By passing options, we can select which events to use, which processes/threads to monitor, 364what frequency to dump samples, how long to monitor, and where to store samples. 365 366```sh 367# Record on process 7394 for 10 seconds, using default event (cpu-cycles), using default sample 368# frequency (4000 samples per second), writing records to perf.data. 369$ simpleperf record -p 7394 --duration 10 370simpleperf I cmd_record.cpp:316] Samples recorded: 21430. Samples lost: 0. 371``` 372 373### Select events to record 374 375By default, the cpu-cycles event is used to evaluate consumed cpu cycles. But we can also use other 376events via -e. 377 378```sh 379# Record using event instructions. 380$ simpleperf record -e instructions -p 11904 --duration 10 381 382# Record using task-clock, which shows the passed CPU time in nanoseconds. 383$ simpleperf record -e task-clock -p 11904 --duration 10 384``` 385 386### Select target to record 387 388The way to select target in record command is similar to that in the stat command. 389 390```sh 391# Record process 11904 and 11905. 392$ simpleperf record -p 11904,11905 --duration 10 393 394# Record processes with name containing "chrome". 395$ simpleperf record -p chrome --duration 10 396# Record processes with name containing part matching regex "chrome:(privileged|sandboxed)". 397$ simpleperf record -p "chrome:(privileged|sandboxed)" --duration 10 398 399# Record thread 11904 and 11905. 400$ simpleperf record -t 11904,11905 --duration 10 401 402# Record a child process running `ls`. 403$ simpleperf record ls 404 405# Record the process of an Android application. On non-root devices, this only works for debuggable 406# or profileable from shell apps. 407$ simpleperf record --app simpleperf.example.cpp --duration 10 408 409# Record only selected thread 11904 in an app. 410$ simpleperf record --app simpleperf.example.cpp -t 11904 --duration 10 411 412# Record system wide. 413$ simpleperf record -a --duration 10 414``` 415 416### Set the frequency to record 417 418We can set the frequency to dump records via -f or -c. For example, -f 4000 means 419dumping approximately 4000 records every second when the monitored thread runs. If a monitored 420thread runs 0.2s in one second (it can be preempted or blocked in other times), simpleperf dumps 421about 4000 * 0.2 / 1.0 = 800 records every second. Another way is using -c. For example, -c 10000 422means dumping one record whenever 10000 events happen. 423 424```sh 425# Record with sample frequency 1000: sample 1000 times every second running. 426$ simpleperf record -f 1000 -p 11904,11905 --duration 10 427 428# Record with sample period 100000: sample 1 time every 100000 events. 429$ simpleperf record -c 100000 -t 11904,11905 --duration 10 430``` 431 432To avoid taking too much time generating samples, kernel >= 3.10 sets the max percent of cpu time 433used for generating samples (default is 25%), and decreases the max allowed sample frequency when 434hitting that limit. Simpleperf uses --cpu-percent option to adjust it, but it needs either root 435privilege or to be on Android >= Q. 436 437```sh 438# Record with sample frequency 10000, with max allowed cpu percent to be 50%. 439$ simpleperf record -f 1000 -p 11904,11905 --duration 10 --cpu-percent 50 440``` 441 442### Decide how long to record 443 444The way to decide how long to monitor in record command is similar to that in the stat command. 445 446```sh 447# Record process 11904 for 10 seconds. 448$ simpleperf record -p 11904 --duration 10 449 450# Record until the child process running `ls` finishes. 451$ simpleperf record ls 452 453# Stop monitoring using Ctrl-C. 454$ simpleperf record -p 11904 --duration 10 455^C 456``` 457 458If you want to write a script to control how long to monitor, you can send one of SIGINT, SIGTERM, 459SIGHUP signals to simpleperf to stop monitoring. 460 461### Set the path to store profiling data 462 463By default, simpleperf stores profiling data in perf.data in the current directory. But the path 464can be changed using -o. 465 466```sh 467# Write records to data/perf2.data. 468$ simpleperf record -p 11904 -o data/perf2.data --duration 10 469``` 470 471#### Record call graphs 472 473A call graph is a tree showing function call relations. Below is an example. 474 475``` 476main() { 477 FunctionOne(); 478 FunctionTwo(); 479} 480FunctionOne() { 481 FunctionTwo(); 482 FunctionThree(); 483} 484a call graph: 485 main-> FunctionOne 486 | | 487 | |-> FunctionTwo 488 | |-> FunctionThree 489 | 490 |-> FunctionTwo 491``` 492 493A call graph shows how a function calls other functions, and a reversed call graph shows how 494a function is called by other functions. To show a call graph, we need to first record it, then 495report it. 496 497There are two ways to record a call graph, one is recording a dwarf based call graph, the other is 498recording a stack frame based call graph. Recording dwarf based call graphs needs support of debug 499information in native binaries. While recording stack frame based call graphs needs support of 500stack frame registers. 501 502```sh 503# Record a dwarf based call graph 504$ simpleperf record -p 11904 -g --duration 10 505 506# Record a stack frame based call graph 507$ simpleperf record -p 11904 --call-graph fp --duration 10 508``` 509 510[Here](README.md#suggestions-about-recording-call-graphs) are some suggestions about recording call graphs. 511 512### Record both on CPU time and off CPU time 513 514Simpleperf is a CPU profiler, which generates samples for a thread only when it is running on a 515CPU. But sometimes we want to know where the thread time is spent off-cpu (like preempted by other 516threads, blocked in IO or waiting for some events). To support this, simpleperf added a 517--trace-offcpu option to the record command. When --trace-offcpu is used, simpleperf does the 518following things: 519 5201) Only cpu-clock/task-clock event is allowed to be used with --trace-offcpu. This let simpleperf 521 generate on-cpu samples for cpu-clock event. 5222) Simpleperf also monitors sched:sched_switch event, which will generate a sched_switch sample 523 each time the monitored thread is scheduled off cpu. 5243) Simpleperf also records context switch records. So it knows when the thread is scheduled back on 525 a cpu. 526 527The samples and context switch records collected by simpleperf for a thread are shown below: 528 529 530 531Here we have two types of samples: 5321) on-cpu samples generated for cpu-clock event. The period value in each sample means how many 533 nanoseconds are spent on cpu (for the callchain of this sample). 5342) off-cpu (sched_switch) samples generated for sched:sched_switch event. The period value is 535 calculated as **Timestamp of the next switch on record** minus **Timestamp of the current sample** 536 by simpleperf. So the period value in each sample means how many nanoseconds are spent off cpu 537 (for the callchain of this sample). 538 539**note**: In reality, switch on records and samples may lost. To mitigate the loss of accuracy, we 540calculate the period of an off-cpu sample as **Timestamp of the next switch on record or sample** 541minus **Timestamp of the current sample**. 542 543When reporting via python scripts, simpleperf_report_lib.py provides SetTraceOffCpuMode() method 544to control how to report the samples: 5451) on-cpu mode: only report on-cpu samples. 5462) off-cpu mode: only report off-cpu samples. 5473) on-off-cpu mode: report both on-cpu and off-cpu samples, which can be split by event name. 5484) mixed-on-off-cpu mode: report on-cpu and off-cpu samples under the same event name. 549 550If not set, mixed-on-off-cpu mode will be used to report. 551 552When using report_html.py, inferno and report_sample.py, the report mode can be set by 553--trace-offcpu option. 554 555Below are some examples recording and reporting trace offcpu profiles. 556 557```sh 558# Check if --trace-offcpu is supported by the kernel (should be available on kernel >= 4.2). 559$ simpleperf list --show-features 560trace-offcpu 561... 562 563# Record with --trace-offcpu. 564$ simpleperf record -g -p 11904 --duration 10 --trace-offcpu -e cpu-clock 565 566# Record system wide with --trace-offcpu. 567$ simpleperf record -a -g --duration 3 --trace-offcpu -e cpu-clock 568 569# Record with --trace-offcpu using app_profiler.py. 570$ ./app_profiler.py -p com.google.samples.apps.sunflower \ 571 -r "-g -e cpu-clock:u --duration 10 --trace-offcpu" 572 573# Report on-cpu samples. 574$ ./report_html.py --trace-offcpu on-cpu 575# Report off-cpu samples. 576$ ./report_html.py --trace-offcpu off-cpu 577# Report on-cpu and off-cpu samples under different event names. 578$ ./report_html.py --trace-offcpu on-off-cpu 579# Report on-cpu and off-cpu samples under the same event name. 580$ ./report_html.py --trace-offcpu mixed-on-off-cpu 581``` 582 583## The report command 584 585The report command is used to report profiling data generated by the record command. The report 586contains a table of sample entries. Each sample entry is a row in the report. The report command 587groups samples belong to the same process, thread, library, function in the same sample entry. Then 588sort the sample entries based on the event count a sample entry has. 589 590By passing options, we can decide how to filter out uninteresting samples, how to group samples 591into sample entries, and where to find profiling data and binaries. 592 593Below is an example. Records are grouped into 4 sample entries, each entry is a row. There are 594several columns, each column shows piece of information belonging to a sample entry. The first 595column is Overhead, which shows the percentage of events inside the current sample entry in total 596events. As the perf event is cpu-cycles, the overhead is the percentage of CPU cycles used in each 597function. 598 599```sh 600# Reports perf.data, using only records sampled in libsudo-game-jni.so, grouping records using 601# thread name(comm), process id(pid), thread id(tid), function name(symbol), and showing sample 602# count for each row. 603$ simpleperf report --dsos /data/app/com.example.sudogame-2/lib/arm64/libsudo-game-jni.so \ 604 --sort comm,pid,tid,symbol -n 605Cmdline: /data/data/com.example.sudogame/simpleperf record -p 7394 --duration 10 606Arch: arm64 607Event: cpu-cycles (type 0, config 0) 608Samples: 28235 609Event count: 546356211 610 611Overhead Sample Command Pid Tid Symbol 61259.25% 16680 sudogame 7394 7394 checkValid(Board const&, int, int) 61320.42% 5620 sudogame 7394 7394 canFindSolution_r(Board&, int, int) 61413.82% 4088 sudogame 7394 7394 randomBlock_r(Board&, int, int, int, int, int) 6156.24% 1756 sudogame 7394 7394 @plt 616``` 617 618### Set the path to read profiling data 619 620By default, the report command reads profiling data from perf.data in the current directory. 621But the path can be changed using -i. 622 623```sh 624$ simpleperf report -i data/perf2.data 625``` 626 627### Set the path to find binaries 628 629To report function symbols, simpleperf needs to read executable binaries used by the monitored 630processes to get symbol table and debug information. By default, the paths are the executable 631binaries used by monitored processes while recording. However, these binaries may not exist when 632reporting or not contain symbol table and debug information. So we can use --symfs to redirect 633the paths. 634 635```sh 636# In this case, when simpleperf wants to read executable binary /A/b, it reads file in /A/b. 637$ simpleperf report 638 639# In this case, when simpleperf wants to read executable binary /A/b, it prefers file in 640# /debug_dir/A/b to file in /A/b. 641$ simpleperf report --symfs /debug_dir 642 643# Read symbols for system libraries built locally. Note that this is not needed since Android O, 644# which ships symbols for system libraries on device. 645$ simpleperf report --symfs $ANDROID_PRODUCT_OUT/symbols 646``` 647 648### Filter samples 649 650When reporting, it happens that not all records are of interest. The report command supports four 651filters to select samples of interest. 652 653```sh 654# Report records in threads having name sudogame. 655$ simpleperf report --comms sudogame 656 657# Report records in process 7394 or 7395 658$ simpleperf report --pids 7394,7395 659 660# Report records in thread 7394 or 7395. 661$ simpleperf report --tids 7394,7395 662 663# Report records in libsudo-game-jni.so. 664$ simpleperf report --dsos /data/app/com.example.sudogame-2/lib/arm64/libsudo-game-jni.so 665``` 666 667### Group samples into sample entries 668 669The report command uses --sort to decide how to group sample entries. 670 671```sh 672# Group records based on their process id: records having the same process id are in the same 673# sample entry. 674$ simpleperf report --sort pid 675 676# Group records based on their thread id and thread comm: records having the same thread id and 677# thread name are in the same sample entry. 678$ simpleperf report --sort tid,comm 679 680# Group records based on their binary and function: records in the same binary and function are in 681# the same sample entry. 682$ simpleperf report --sort dso,symbol 683 684# Default option: --sort comm,pid,tid,dso,symbol. Group records in the same thread, and belong to 685# the same function in the same binary. 686$ simpleperf report 687``` 688 689#### Report call graphs 690 691To report a call graph, please make sure the profiling data is recorded with call graphs, 692as [here](#record-call-graphs). 693 694``` 695$ simpleperf report -g 696``` 697