[PATCH 26/26] perf tools: Add report --store option

Jiri Olsa
2020-09-13T21:07:12Z

Adding report --store option as a wrapper for 'buildid-list --store'
to save some typing.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/perf/Documentation/perf-report.txt | 3 +++
tools/perf/builtin-report.c | 17 +++++++++++++++++
2 files changed, 20 insertions(+)

diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt
index d068103690cc..698fe90d6e1d 100644
--- a/tools/perf/Documentation/perf-report.txt
+++ b/tools/perf/Documentation/perf-report.txt
@@ -548,6 +548,9 @@ include::itrace.txt[]
Configure time quantum for time sort key. Default 100ms.
Accepts s, us, ms, ns units.

+--store::
+ Store build id DSOs in .debug cache. See `--store` option n perf-buildid-list.
+
--total-cycles::
When --total-cycles is specified, it supports sorting for all blocks by
'Sampled Cycles%'. This is useful to concentrate on the globally hottest
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 3dd37513eb94..3450e441d894 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -1098,6 +1098,18 @@ static int process_attr(struct perf_tool *tool __maybe_unused,
return 0;
}

+static int build_id_store(const char *file)
+{
+ const char *argv[4];
+
+ argv[0] = "buildid-list";
+ argv[1] = "-i";
+ argv[2] = file;
+ argv[3] = "--store";
+
+ return cmd_buildid_list(4, argv);
+}
+
int cmd_report(int argc, const char **argv)
{
struct perf_session *session;
@@ -1107,6 +1119,7 @@ int cmd_report(int argc, const char **argv)
int branch_mode = -1;
int last_key = 0;
bool branch_call_mode = false;
+ bool store = false;
#define CALLCHAIN_DEFAULT_OPT "graph,0.5,caller,function,percent"
static const char report_callchain_help[] = "Display call graph (stack chain/backtrace):\n\n"
CALLCHAIN_REPORT_HELP
@@ -1301,6 +1314,7 @@ int cmd_report(int argc, const char **argv)
OPTS_EVSWITCH(&report.evswitch),
OPT_BOOLEAN(0, "total-cycles", &report.total_cycles_mode,
"Sort all blocks by 'Sampled Cycles%'"),
+ OPT_BOOLEAN(0, "store", &store, "Store build id dsos in .debug cache"),
OPT_END()
};
struct perf_data data = {
@@ -1367,6 +1381,9 @@ int cmd_report(int argc, const char **argv)
input_name = "perf.data";
}

+ if (store)
+ return build_id_store(input_name);
+
data.path = input_name;
data.force = symbol_conf.force;

--
2.26.2