diff options
author | Scott Wood <scottwood@freescale.com> | 2014-04-07 23:49:35 (GMT) |
---|---|---|
committer | Scott Wood <scottwood@freescale.com> | 2014-04-07 23:49:35 (GMT) |
commit | 62b8c978ee6b8d135d9e7953221de58000dba986 (patch) | |
tree | 683b04b2e627f6710c22c151b23c8cc9a165315e /tools/perf/builtin-script.c | |
parent | 78fd82238d0e5716578c326404184a27ba67fd6e (diff) | |
download | linux-fsl-qoriq-62b8c978ee6b8d135d9e7953221de58000dba986.tar.xz |
Rewind v3.13-rc3+ (78fd82238d0e5716) to v3.12
Diffstat (limited to 'tools/perf/builtin-script.c')
-rw-r--r-- | tools/perf/builtin-script.c | 127 |
1 files changed, 38 insertions, 89 deletions
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index baf1798..9c333ff 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -15,7 +15,6 @@ #include "util/evlist.h" #include "util/evsel.h" #include "util/sort.h" -#include "util/data.h" #include <linux/bitmap.h> static char const *script_name; @@ -229,24 +228,6 @@ static int perf_evsel__check_attr(struct perf_evsel *evsel, return 0; } -static void set_print_ip_opts(struct perf_event_attr *attr) -{ - unsigned int type = attr->type; - - output[type].print_ip_opts = 0; - if (PRINT_FIELD(IP)) - output[type].print_ip_opts |= PRINT_IP_OPT_IP; - - if (PRINT_FIELD(SYM)) - output[type].print_ip_opts |= PRINT_IP_OPT_SYM; - - if (PRINT_FIELD(DSO)) - output[type].print_ip_opts |= PRINT_IP_OPT_DSO; - - if (PRINT_FIELD(SYMOFFSET)) - output[type].print_ip_opts |= PRINT_IP_OPT_SYMOFFSET; -} - /* * verify all user requested events exist and the samples * have the expected data @@ -255,6 +236,7 @@ static int perf_session__check_output_opt(struct perf_session *session) { int j; struct perf_evsel *evsel; + struct perf_event_attr *attr; for (j = 0; j < PERF_TYPE_MAX; ++j) { evsel = perf_session__find_first_evtype(session, j); @@ -277,7 +259,20 @@ static int perf_session__check_output_opt(struct perf_session *session) if (evsel == NULL) continue; - set_print_ip_opts(&evsel->attr); + attr = &evsel->attr; + + output[j].print_ip_opts = 0; + if (PRINT_FIELD(IP)) + output[j].print_ip_opts |= PRINT_IP_OPT_IP; + + if (PRINT_FIELD(SYM)) + output[j].print_ip_opts |= PRINT_IP_OPT_SYM; + + if (PRINT_FIELD(DSO)) + output[j].print_ip_opts |= PRINT_IP_OPT_DSO; + + if (PRINT_FIELD(SYMOFFSET)) + output[j].print_ip_opts |= PRINT_IP_OPT_SYMOFFSET; } return 0; @@ -295,11 +290,11 @@ static void print_sample_start(struct perf_sample *sample, if (PRINT_FIELD(COMM)) { if (latency_format) - printf("%8.8s ", thread__comm_str(thread)); + printf("%8.8s ", thread->comm); else if (PRINT_FIELD(IP) && symbol_conf.use_callchain) - printf("%s ", thread__comm_str(thread)); + printf("%s ", thread->comm); else - printf("%16s ", thread__comm_str(thread)); + printf("%16s ", thread->comm); } if (PRINT_FIELD(PID) && PRINT_FIELD(TID)) @@ -414,9 +409,7 @@ static void print_sample_bts(union perf_event *event, printf(" => "); /* print branch_to information */ - if (PRINT_FIELD(ADDR) || - ((evsel->attr.sample_type & PERF_SAMPLE_ADDR) && - !output[attr->type].user_set)) + if (PRINT_FIELD(ADDR)) print_sample_addr(event, sample, machine, thread, attr); printf("\n"); @@ -546,51 +539,32 @@ static int process_sample_event(struct perf_tool *tool __maybe_unused, return 0; } -struct perf_script { - struct perf_tool tool; - struct perf_session *session; +static struct perf_tool perf_script = { + .sample = process_sample_event, + .mmap = perf_event__process_mmap, + .mmap2 = perf_event__process_mmap2, + .comm = perf_event__process_comm, + .exit = perf_event__process_exit, + .fork = perf_event__process_fork, + .attr = perf_event__process_attr, + .tracing_data = perf_event__process_tracing_data, + .build_id = perf_event__process_build_id, + .ordered_samples = true, + .ordering_requires_timestamps = true, }; -static int process_attr(struct perf_tool *tool, union perf_event *event, - struct perf_evlist **pevlist) -{ - struct perf_script *scr = container_of(tool, struct perf_script, tool); - struct perf_evlist *evlist; - struct perf_evsel *evsel, *pos; - int err; - - err = perf_event__process_attr(tool, event, pevlist); - if (err) - return err; - - evlist = *pevlist; - evsel = perf_evlist__last(*pevlist); - - if (evsel->attr.type >= PERF_TYPE_MAX) - return 0; - - list_for_each_entry(pos, &evlist->entries, node) { - if (pos->attr.type == evsel->attr.type && pos != evsel) - return 0; - } - - set_print_ip_opts(&evsel->attr); - - return perf_evsel__check_attr(evsel, scr->session); -} - static void sig_handler(int sig __maybe_unused) { session_done = 1; } -static int __cmd_script(struct perf_script *script) +static int __cmd_script(struct perf_session *session) { int ret; signal(SIGINT, sig_handler); - ret = perf_session__process_events(script->session, &script->tool); + ret = perf_session__process_events(session, &perf_script); if (debug_mode) pr_err("Misordered timestamps: %" PRIu64 "\n", nr_unordered); @@ -1139,14 +1113,10 @@ int find_scripts(char **scripts_array, char **scripts_path_array) char scripts_path[MAXPATHLEN], lang_path[MAXPATHLEN]; DIR *scripts_dir, *lang_dir; struct perf_session *session; - struct perf_data_file file = { - .path = input_name, - .mode = PERF_DATA_MODE_READ, - }; char *temp; int i = 0; - session = perf_session__new(&file, false, NULL); + session = perf_session__new(input_name, O_RDONLY, 0, false, NULL); if (!session) return -1; @@ -1296,21 +1266,6 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused) char *script_path = NULL; const char **__argv; int i, j, err; - struct perf_script script = { - .tool = { - .sample = process_sample_event, - .mmap = perf_event__process_mmap, - .mmap2 = perf_event__process_mmap2, - .comm = perf_event__process_comm, - .exit = perf_event__process_exit, - .fork = perf_event__process_fork, - .attr = process_attr, - .tracing_data = perf_event__process_tracing_data, - .build_id = perf_event__process_build_id, - .ordered_samples = true, - .ordering_requires_timestamps = true, - }, - }; const struct option options[] = { OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, "dump raw trace in ASCII"), @@ -1362,17 +1317,12 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused) "perf script [<options>] <top-script> [script-args]", NULL }; - struct perf_data_file file = { - .mode = PERF_DATA_MODE_READ, - }; setup_scripting(); argc = parse_options(argc, argv, options, script_usage, PARSE_OPT_STOP_AT_NON_OPTION); - file.path = input_name; - if (argc > 1 && !strncmp(argv[0], "rec", strlen("rec"))) { rec_script_path = get_script_path(argv[1], RECORD_SUFFIX); if (!rec_script_path) @@ -1536,12 +1486,11 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused) if (!script_name) setup_pager(); - session = perf_session__new(&file, false, &script.tool); + session = perf_session__new(input_name, O_RDONLY, 0, false, + &perf_script); if (session == NULL) return -ENOMEM; - script.session = session; - if (cpu_list) { if (perf_session__cpu_bitmap(session, cpu_list, cpu_bitmap)) return -1; @@ -1565,7 +1514,7 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused) return -1; } - input = open(file.path, O_RDONLY); /* input_name */ + input = open(session->filename, O_RDONLY); /* input_name */ if (input < 0) { perror("failed to open file"); return -1; @@ -1605,7 +1554,7 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused) if (err < 0) goto out; - err = __cmd_script(&script); + err = __cmd_script(session); perf_session__delete(session); cleanup_scripting(); |