[tip:perf/core] perf tools: Add a global variable " const char *input_name"
Commit-ID: 70cb4e963f77dae90ae2aa3dd9385a43737c469f Gitweb: http://git.kernel.org/tip/70cb4e963f77dae90ae2aa3dd9385a43737c469f Author: Feng Tang AuthorDate: Tue, 30 Oct 2012 11:56:02 +0800 Committer: Arnaldo Carvalho de Melo CommitDate: Mon, 29 Oct 2012 11:45:34 -0200 perf tools: Add a global variable "const char *input_name" Currently many perf commands annotate/evlist/report/script/lock etc all support "-i" option to chose a specific perf data, and all of them create a local "input_name" to save the file name for that perf data. Since most of these commands need it, we can add a global variable for it, also it can some other benefits: 1. When calling script browser inside hists/annotation browser, it needs to know the perf data file name to run that script. 2. For further feature like runtime switching to another perf data file, this variable can also help. Signed-off-by: Feng Tang Cc: Andi Kleen Cc: Ingo Molnar Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/1351569369-26732-2-git-send-email-feng.t...@intel.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-annotate.c |5 ++--- tools/perf/builtin-buildid-list.c |6 ++ tools/perf/builtin-evlist.c |5 ++--- tools/perf/builtin-kmem.c |5 ++--- tools/perf/builtin-lock.c |2 -- tools/perf/builtin-report.c | 13 ++--- tools/perf/builtin-sched.c|5 ++--- tools/perf/builtin-script.c |1 - tools/perf/builtin-timechart.c|5 ++--- tools/perf/perf.c |1 + tools/perf/perf.h |1 + 11 files changed, 20 insertions(+), 29 deletions(-) diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c index c4bb645..cb23476 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c @@ -34,7 +34,6 @@ struct perf_annotate { struct perf_tool tool; - char const *input_name; bool force, use_tui, use_stdio; bool full_paths; bool print_line; @@ -175,7 +174,7 @@ static int __cmd_annotate(struct perf_annotate *ann) struct perf_evsel *pos; u64 total_nr_samples; - session = perf_session__new(ann->input_name, O_RDONLY, + session = perf_session__new(input_name, O_RDONLY, ann->force, false, >tool); if (session == NULL) return -ENOMEM; @@ -260,7 +259,7 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused) }, }; const struct option options[] = { - OPT_STRING('i', "input", _name, "file", + OPT_STRING('i', "input", _name, "file", "input file name"), OPT_STRING('d', "dsos", _conf.dso_list_str, "dso[,dso...]", "only consider symbols in these dsos"), diff --git a/tools/perf/builtin-buildid-list.c b/tools/perf/builtin-buildid-list.c index a0e94ff..a82d99f 100644 --- a/tools/perf/builtin-buildid-list.c +++ b/tools/perf/builtin-buildid-list.c @@ -44,8 +44,7 @@ static int filename__fprintf_build_id(const char *name, FILE *fp) return fprintf(fp, "%s\n", sbuild_id); } -static int perf_session__list_build_ids(const char *input_name, - bool force, bool with_hits) +static int perf_session__list_build_ids(bool force, bool with_hits) { struct perf_session *session; @@ -81,7 +80,6 @@ int cmd_buildid_list(int argc, const char **argv, bool show_kernel = false; bool with_hits = false; bool force = false; - const char *input_name = NULL; const struct option options[] = { OPT_BOOLEAN('H', "with-hits", _hits, "Show only DSOs with hits"), OPT_STRING('i', "input", _name, "file", "input file name"), @@ -101,5 +99,5 @@ int cmd_buildid_list(int argc, const char **argv, if (show_kernel) return sysfs__fprintf_build_id(stdout); - return perf_session__list_build_ids(input_name, force, with_hits); + return perf_session__list_build_ids(force, with_hits); } diff --git a/tools/perf/builtin-evlist.c b/tools/perf/builtin-evlist.c index 997afb8..c20f1dc 100644 --- a/tools/perf/builtin-evlist.c +++ b/tools/perf/builtin-evlist.c @@ -48,12 +48,12 @@ static int __if_print(bool *first, const char *field, u64 value) #define if_print(field) __if_print(, #field, pos->attr.field) -static int __cmd_evlist(const char *input_name, struct perf_attr_details *details) +static int __cmd_evlist(const char *file_name, struct perf_attr_details *details) { struct perf_session *session; struct perf_evsel *pos; - session = perf_session__new(input_name, O_RDONLY, 0, false, NULL); + session = perf_session__new(file_name, O_RDONLY, 0, false, NULL); if (session == NULL) return -ENOMEM; @@ -111,7 +111,6 @@ static int __cmd_evlist(const char
[tip:perf/core] perf tools: Add a global variable const char *input_name
Commit-ID: 70cb4e963f77dae90ae2aa3dd9385a43737c469f Gitweb: http://git.kernel.org/tip/70cb4e963f77dae90ae2aa3dd9385a43737c469f Author: Feng Tang feng.t...@intel.com AuthorDate: Tue, 30 Oct 2012 11:56:02 +0800 Committer: Arnaldo Carvalho de Melo a...@redhat.com CommitDate: Mon, 29 Oct 2012 11:45:34 -0200 perf tools: Add a global variable const char *input_name Currently many perf commands annotate/evlist/report/script/lock etc all support -i option to chose a specific perf data, and all of them create a local input_name to save the file name for that perf data. Since most of these commands need it, we can add a global variable for it, also it can some other benefits: 1. When calling script browser inside hists/annotation browser, it needs to know the perf data file name to run that script. 2. For further feature like runtime switching to another perf data file, this variable can also help. Signed-off-by: Feng Tang feng.t...@intel.com Cc: Andi Kleen a...@firstfloor.org Cc: Ingo Molnar mi...@elte.hu Cc: Namhyung Kim namhy...@kernel.org Cc: Peter Zijlstra pet...@infradead.org Link: http://lkml.kernel.org/r/1351569369-26732-2-git-send-email-feng.t...@intel.com Signed-off-by: Arnaldo Carvalho de Melo a...@redhat.com --- tools/perf/builtin-annotate.c |5 ++--- tools/perf/builtin-buildid-list.c |6 ++ tools/perf/builtin-evlist.c |5 ++--- tools/perf/builtin-kmem.c |5 ++--- tools/perf/builtin-lock.c |2 -- tools/perf/builtin-report.c | 13 ++--- tools/perf/builtin-sched.c|5 ++--- tools/perf/builtin-script.c |1 - tools/perf/builtin-timechart.c|5 ++--- tools/perf/perf.c |1 + tools/perf/perf.h |1 + 11 files changed, 20 insertions(+), 29 deletions(-) diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c index c4bb645..cb23476 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c @@ -34,7 +34,6 @@ struct perf_annotate { struct perf_tool tool; - char const *input_name; bool force, use_tui, use_stdio; bool full_paths; bool print_line; @@ -175,7 +174,7 @@ static int __cmd_annotate(struct perf_annotate *ann) struct perf_evsel *pos; u64 total_nr_samples; - session = perf_session__new(ann-input_name, O_RDONLY, + session = perf_session__new(input_name, O_RDONLY, ann-force, false, ann-tool); if (session == NULL) return -ENOMEM; @@ -260,7 +259,7 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused) }, }; const struct option options[] = { - OPT_STRING('i', input, annotate.input_name, file, + OPT_STRING('i', input, input_name, file, input file name), OPT_STRING('d', dsos, symbol_conf.dso_list_str, dso[,dso...], only consider symbols in these dsos), diff --git a/tools/perf/builtin-buildid-list.c b/tools/perf/builtin-buildid-list.c index a0e94ff..a82d99f 100644 --- a/tools/perf/builtin-buildid-list.c +++ b/tools/perf/builtin-buildid-list.c @@ -44,8 +44,7 @@ static int filename__fprintf_build_id(const char *name, FILE *fp) return fprintf(fp, %s\n, sbuild_id); } -static int perf_session__list_build_ids(const char *input_name, - bool force, bool with_hits) +static int perf_session__list_build_ids(bool force, bool with_hits) { struct perf_session *session; @@ -81,7 +80,6 @@ int cmd_buildid_list(int argc, const char **argv, bool show_kernel = false; bool with_hits = false; bool force = false; - const char *input_name = NULL; const struct option options[] = { OPT_BOOLEAN('H', with-hits, with_hits, Show only DSOs with hits), OPT_STRING('i', input, input_name, file, input file name), @@ -101,5 +99,5 @@ int cmd_buildid_list(int argc, const char **argv, if (show_kernel) return sysfs__fprintf_build_id(stdout); - return perf_session__list_build_ids(input_name, force, with_hits); + return perf_session__list_build_ids(force, with_hits); } diff --git a/tools/perf/builtin-evlist.c b/tools/perf/builtin-evlist.c index 997afb8..c20f1dc 100644 --- a/tools/perf/builtin-evlist.c +++ b/tools/perf/builtin-evlist.c @@ -48,12 +48,12 @@ static int __if_print(bool *first, const char *field, u64 value) #define if_print(field) __if_print(first, #field, pos-attr.field) -static int __cmd_evlist(const char *input_name, struct perf_attr_details *details) +static int __cmd_evlist(const char *file_name, struct perf_attr_details *details) { struct perf_session *session; struct perf_evsel *pos; - session = perf_session__new(input_name, O_RDONLY, 0, false, NULL); + session = perf_session__new(file_name,