summaryrefslogtreecommitdiff
path: root/simpleperf/command.cpp
AgeCommit message (Collapse)Author
2020-11-10simpleperf: add "monitor" commandThiƩbaud Weksteen
Introduce a new "monitor" command which combines the recording of events and the printing of their summary to stdout. There is a large overlap between the "monitor" and "record" command. Only basic functionality (i.e. system-wide collection) has been implemented, using the same logic as "record". If further functionality is required, a merging of both command logics should be done. Test: atest on crosshatch Change-Id: Ifd42d5e9cb9db144dc2bbbe7a7983570730e3f87
2020-10-28simpleperf: Add merge cmd.Yabin Cui
The merge cmd merges recording files. The files should be recorded in the same environment using the same event types. Bug: 159156784 Test: run simpleperf_unit_test. Change-Id: I6002728246e59957235e811d4c74099961eeae4f
2020-10-23simpleperf: enable .clang-formatThiƩbaud Weksteen
Use the 2-space configuration by default and disable any formatting for the demo/ subdirectory. The following command was used to generate this change: $ find . \( -name \*.cpp -o -name \*.h \) -exec clang-format \ --style=file -i {} \; Test: mm Change-Id: I89ec1f18f6e352f40cfa1a770087f3b586b1d7cb
2020-07-28simpleperf: share option formats with simpleperf_app_runner.Yabin Cui
This CL avoids the need to define option formats in simpleperf_app_runner. Each time an option is changed in simpleperf, it's also changed in simpleperf_app_runner. 1. Use OptionFormatMap to parse options for api-collect and stat cmd. 2. Add OptionFormatMap for common options. 3. Add AppRunnerType in OptionFormat, and define its value for each option in api-collect, stat and record cmd. 4. Use OptionFormatMap in simpleperf_app_runner. Bug: 161387498 Test: run simpleperf_unit_test. Test: run CtsSimpleperfTestCases. Change-Id: Ib4600b4b62839dee1002eec090d7db86ce8fd346
2020-07-08simpleperf: add function to preprocess options.Yabin Cui
Add Command::PreprocessOptions() to extracts options from the argument list. It splits options into different types. Instead of replying on the order in the argument list, it allows a command choosing the order to process each option. Also put whole command.h in simpleperf namespace. Bug: 160701181 Test: run simpleperf_unit_test. Change-Id: I9b20e21a94797c322c1371cbe1704b3e2ce1be28
2020-02-14simpleperf: pass log option to cmd running in app context.Yabin Cui
Bug: none Test: run simpleperf_unit_test. Test: run `simpleperf record --app xxx --log-to-android-buffer`. Change-Id: I0f8c25f2fc9140c101c65f3356296dd64a3ceda3
2019-10-29simpleperf: just use _Exit directly.Elliott Hughes
We don't actually need the quick_exit() machinery because we weren't setting any at_quick_exit() handlers, so just call _Exit() directly. This will let us remove the Mac/Windows quick_exit() implementation from libbase (and will let simpleperf exit just a little bit quicker). Test: treehugger Change-Id: I4ce74cb80acc744721cf367930ca3e577b8fc614
2019-08-22simpleperf: add inject cmd.Yabin Cui
Add inject cmd to convert etm data into executed instr ranges. Bug: 135204414 Test: run simpleperf_unit_test. Change-Id: I46acf7b24ddb4865d0925f70e09b861b7f6748b6
2019-02-28simpleperf: make app api available for profileable apps.Yabin Cui
Add api-prepare cmd to prepare recording via app api. Add api-collect cmd to collect recording data generated by app api. The recording data is compressed into a zip file. The two added cmds support both debuggable apps and profileable apps. Move api_app_profiler.py to api_profiler.py. And use the two added cmds in it. Also improve app_api code: 1. Fix finding simpleperf. 2. Use time based output filenames. Bug: 123717243 Test: test manually, will add run python tests later. Change-Id: I88c20578d01a84bc20ea72276f2cab0f3c4d9109
2019-02-14simpleperf: prepare for adding user api.Yabin Cui
In record cmd, add --stdio-controls-profiling option to pause/resume profiling. It reads cmds from stdin, and writes replies to stdout. Add --log-to-android-buffer option to show simpleperf logs in logcat. Bug: 123717243 Test: run simpleperf through user api manually. Test: run simpleperf_unit_test. Change-Id: I6c32c669d003cbd670a45e6fd31f764656837111
2018-12-11Fix performance-for-range-copy warningsChih-Hung Hsieh
Bug: 30413223 Test: make with WITH_TIDY=1 DEFAULT_GLOBAL_TIDY_CHECKS=-*,performance* Change-Id: I94c2456e8ef958abcb0909871fb772dd67060dfc
2018-04-20simpleperf: add --size-limit option in record cmd.Yabin Cui
--size-limit option stops recording when the recorded data reaches the size limit. It is used by run_simpleperf_without_usb_connection.py to avoid taking too much disk space. Bug: http://b/74198167 Test: run simpleperf_unit_test. Test: run test.py. Change-Id: I11f0023c342c50e1cf8035430e6af1b3caa329e7
2018-03-20simpleperf: Add trace-sched command.Yabin Cui
trace-sched command traces system-wide process runtime events, and reports potential spin loops. Bug: http://b/74443296 Test: run simpleperf_unit_test. Test: run `simpleperf trace-sched` manually. Change-Id: I6d5205442fe17019f214e9966f93636b1db9f1ef
2018-02-26simpleperf: flush output before quick_exit.Yabin Cui
Bug: http://b/73875722 Test: run simpleperf manually. Change-Id: I010c8612b18cd4034199440cb178d9d9cc8f0ff4
2018-02-23simpleperf: use quick_exit.Yabin Cui
Bug: none Test: run simpleperf_unit_test. Test: run simpleperf manually. Change-Id: I5e7229c8d5bfc4d47a6b7e403e627137c7f36b55
2018-02-05simpleperf: add debug-unwind cmd.Yabin Cui
Currently, we use --log debug option in record cmd to debug offline unwinding. However, it has below disadvantages: 1. It adds extra complexity in record cmd. 2. It doesn't keep reg/stack data of samples. 3. It isn't convenient to reproduce samples in problem. Because each time recording gets different samples. 4. It isn't very suitable for performance test of unwinding, for the same reason as item 3. So instead, this CL adds debug-unwind cmd focusing on debugging and testing offline unwinding. It solves problems mentioned above. Also change unwinding_result_reporter.py to make it work with perf.data generated by debug-unwind cmd. Bug: http://b/72556486 Test: run simpleperf_unit_test. Test: run unwinding_result_reporter.py manually. Change-Id: I11cdf1eba993f48d61ef9891ad1be54d29679fdb
2017-08-11simpleperf: improve warning msg.Yabin Cui
The warning of missing symbol for each lib is shown twice, once in recording, and once in reporting. This is redundant and maybe misleading. Because when reporting we actually don't know if we have collected enough symbols in perf.data. So move warning of missing symbols to debug info if we have symbols in perf.data. Use customized StderrLogger, because simpleperf doesn't need time,pid,tid information in log. Bug: http://b/29574526 Test: run simpleperf manually and run simpleperf_unit_test. Change-Id: I9baf6d8fdcd63907681f2daa45b8fad6bf7e2516
2017-07-14simpleperf: change the way running cts tests.Yabin Cui
Before this CL, CtsSimpleperfTestCases copies itself to the app's directory, then run it using run-as. With this CL, CtsSimpleperfTestCases keeps itself in /data/local/tmp, but forces stat/record cmd to run with --app option. This gives more freedom to tests: 1. They can stay in shell's context with --in-app option. 2. The stat/record cmds are started in the shell's context, so they can collect information no available in app's context (like data in /sys/kernel/debug/tracing/events). This is a preparation to add tests for recording tracepoint events. It also matches the way we want users to use simpleperf (with --app option). Bug: http://b/29520177 Test: run CtsSimpleperfTestCases. Change-Id: I1709adfb1ff7169df87560226c197e473fdf8516
2016-07-27simpleperf: use libevent in stat command.Yabin Cui
Wrap libevent in IOEventLoop, use IOEventLoop in stat command. Add corresponding tests. Bug: http://b/30405638 Change-Id: I78b79e0eff1365ab46dde29c2a24a2def586af79 Test: run simpleperf_unit_test.
2016-06-20simpleperf: add kmem command to report slab allocation information.Yabin Cui
Bug: 27403614 Change-Id: Id3015a4828ec32170ea1db3a1580b14a8bd159ba
2016-06-02simpleperf: add report-sample command.Yabin Cui
1. Add report-sample command to report each sample with symbol information. 2. Add --dump-symbols option to record command to collect dso and symbol information in perf.data. Bug: 28114205 Change-Id: I37424ee6abd74a21ad41cd3b6c4249cf0625c201
2016-02-25simpleperf: fix mac build.Yabin Cui
I forgot that mac doesn't support whole static library. Change to static library to avoid hiting the same problem in the future. Bug: 26962895 Change-Id: Ia8e26c2e1cf7621391e00e100b22b7ed451dfa32
2015-12-04Track rename from base/ to android-base/.Elliott Hughes
Change-Id: Ic15d4778c7accd1382de0b440a437aba2cf67016
2015-06-04Simpleperf: refactor command system.Yabin Cui
Register a callback function to create a new command instance instead of registering a command instance. Then we can release resources in the command destructors, and don't need xxxCommandImpl classes any more. Bug: 19483574 Change-Id: Ibb54892ec0655fd43909347afd72bb08bc8a716c
2015-05-04Implement simpleperf record/dumprecord subcommands.Yabin Cui
Bug: 19483574 Change-Id: Id879713a75c2d3a6289d8847b95ee0bb4a2cc8a0
2015-04-23Implement simpleperf stat subcommand.Yabin Cui
Also add some simple unit-tests. Change-Id: Ic30a2d4a879e028a8c82babbaf82e322fc49a838
2015-04-18Implement simpleperf list subcommand.Yabin Cui
simpleperf is used to replace linux/tools/perf. And This CL implements the list subcommand of it. Change-Id: I3e6fe854e19cc370070d0fd8416d0aa6fa8f8e90