Skip to content

Commit e90debd

Browse files
Jiri Olsaacmel
authored andcommitted
perf script: Add --header/--header-only options
Currently the perf.data header is always displayed for stdio output, which is no always useful. Disabling header information by default and adding following options to control header output: --header - display header information --header-only - display header information only w/o further processing Signed-off-by: Jiri Olsa <jolsa@redhat.com> Link: http://lkml.kernel.org/n/tip-0ehaawv5xc83w6ag03c5hi10@git.kernel.org Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com> Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/r/1386583370-1699-3-git-send-email-jolsa@redhat.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 5cfe2c8 commit e90debd

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

‎tools/perf/Documentation/perf-script.txt‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,12 @@ OPTIONS
209209
--show-mmap-events
210210
Display mmap related events (e.g. MMAP, MMAP2).
211211

212+
--header
213+
Show perf.data header.
214+
215+
--header-only
216+
Show only perf.data header.
217+
212218
SEE ALSO
213219
--------
214220
linkperf:perf-record[1], linkperf:perf-script-perl[1],

‎tools/perf/builtin-script.c‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1494,6 +1494,8 @@ static int have_cmd(int argc, const char **argv)
14941494
int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)
14951495
{
14961496
bool show_full_info = false;
1497+
bool header = false;
1498+
bool header_only = false;
14971499
char *rec_script_path = NULL;
14981500
char *rep_script_path = NULL;
14991501
struct perf_session *session;
@@ -1532,6 +1534,8 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)
15321534
OPT_STRING('i', "input", &input_name, "file", "input file name"),
15331535
OPT_BOOLEAN('d', "debug-mode", &debug_mode,
15341536
"do various checks like samples ordering and lost events"),
1537+
OPT_BOOLEAN(0, "header", &header, "Show data header."),
1538+
OPT_BOOLEAN(0, "header-only", &header_only, "Show only data header."),
15351539
OPT_STRING('k', "vmlinux", &symbol_conf.vmlinux_name,
15361540
"file", "vmlinux pathname"),
15371541
OPT_STRING(0, "kallsyms", &symbol_conf.kallsyms_name,
@@ -1748,16 +1752,19 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)
17481752
if (session == NULL)
17491753
return -ENOMEM;
17501754

1755+
if (header || header_only) {
1756+
perf_session__fprintf_info(session, stdout, show_full_info);
1757+
if (header_only)
1758+
return 0;
1759+
}
1760+
17511761
script.session = session;
17521762

17531763
if (cpu_list) {
17541764
if (perf_session__cpu_bitmap(session, cpu_list, cpu_bitmap))
17551765
return -1;
17561766
}
17571767

1758-
if (!script_name && !generate_script_lang)
1759-
perf_session__fprintf_info(session, stdout, show_full_info);
1760-
17611768
if (!no_callchain)
17621769
symbol_conf.use_callchain = true;
17631770
else

0 commit comments

Comments
 (0)