diff options
author | Ingo Molnar <mingo@elte.hu> | 2010-12-07 01:51:14 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2010-12-07 01:51:14 -0500 |
commit | 75b5293a5d176cd9caf6dc590da4f3458c048c3c (patch) | |
tree | 40929d6108c662d6eb4c65f900312a37d0d6d566 /tools/perf/builtin-script.c | |
parent | 10a18d7dc0d9f12483c95ffc234118e9b80edfeb (diff) | |
parent | ce47dc56a2241dc035160a85bc5e34283cdd622c (diff) |
Merge branch 'perf/core' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux-2.6 into perf/core
Diffstat (limited to 'tools/perf/builtin-script.c')
-rw-r--r-- | tools/perf/builtin-script.c | 44 |
1 files changed, 17 insertions, 27 deletions
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 4539551ab40e..54f1ea808db5 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c | |||
@@ -63,22 +63,11 @@ static int cleanup_scripting(void) | |||
63 | 63 | ||
64 | static char const *input_name = "perf.data"; | 64 | static char const *input_name = "perf.data"; |
65 | 65 | ||
66 | static int process_sample_event(event_t *event, struct perf_session *session) | 66 | static int process_sample_event(event_t *event, struct sample_data *sample, |
67 | struct perf_session *session) | ||
67 | { | 68 | { |
68 | struct sample_data data; | 69 | struct thread *thread = perf_session__findnew(session, event->ip.pid); |
69 | struct thread *thread; | ||
70 | 70 | ||
71 | memset(&data, 0, sizeof(data)); | ||
72 | data.time = -1; | ||
73 | data.cpu = -1; | ||
74 | data.period = 1; | ||
75 | |||
76 | event__parse_sample(event, session->sample_type, &data); | ||
77 | |||
78 | dump_printf("(IP, %d): %d/%d: %#Lx period: %Ld\n", event->header.misc, | ||
79 | data.pid, data.tid, data.ip, data.period); | ||
80 | |||
81 | thread = perf_session__findnew(session, event->ip.pid); | ||
82 | if (thread == NULL) { | 71 | if (thread == NULL) { |
83 | pr_debug("problem processing %d event, skipping it.\n", | 72 | pr_debug("problem processing %d event, skipping it.\n", |
84 | event->header.type); | 73 | event->header.type); |
@@ -87,13 +76,13 @@ static int process_sample_event(event_t *event, struct perf_session *session) | |||
87 | 76 | ||
88 | if (session->sample_type & PERF_SAMPLE_RAW) { | 77 | if (session->sample_type & PERF_SAMPLE_RAW) { |
89 | if (debug_mode) { | 78 | if (debug_mode) { |
90 | if (data.time < last_timestamp) { | 79 | if (sample->time < last_timestamp) { |
91 | pr_err("Samples misordered, previous: %llu " | 80 | pr_err("Samples misordered, previous: %llu " |
92 | "this: %llu\n", last_timestamp, | 81 | "this: %llu\n", last_timestamp, |
93 | data.time); | 82 | sample->time); |
94 | nr_unordered++; | 83 | nr_unordered++; |
95 | } | 84 | } |
96 | last_timestamp = data.time; | 85 | last_timestamp = sample->time; |
97 | return 0; | 86 | return 0; |
98 | } | 87 | } |
99 | /* | 88 | /* |
@@ -101,18 +90,19 @@ static int process_sample_event(event_t *event, struct perf_session *session) | |||
101 | * field, although it should be the same than this perf | 90 | * field, although it should be the same than this perf |
102 | * event pid | 91 | * event pid |
103 | */ | 92 | */ |
104 | scripting_ops->process_event(data.cpu, data.raw_data, | 93 | scripting_ops->process_event(sample->cpu, sample->raw_data, |
105 | data.raw_size, | 94 | sample->raw_size, |
106 | data.time, thread->comm); | 95 | sample->time, thread->comm); |
107 | } | 96 | } |
108 | 97 | ||
109 | session->hists.stats.total_period += data.period; | 98 | session->hists.stats.total_period += sample->period; |
110 | return 0; | 99 | return 0; |
111 | } | 100 | } |
112 | 101 | ||
113 | static u64 nr_lost; | 102 | static u64 nr_lost; |
114 | 103 | ||
115 | static int process_lost_event(event_t *event, struct perf_session *session __used) | 104 | static int process_lost_event(event_t *event, struct sample_data *sample __used, |
105 | struct perf_session *session __used) | ||
116 | { | 106 | { |
117 | nr_lost += event->lost.lost; | 107 | nr_lost += event->lost.lost; |
118 | 108 | ||
@@ -397,10 +387,10 @@ out_delete_desc: | |||
397 | return NULL; | 387 | return NULL; |
398 | } | 388 | } |
399 | 389 | ||
400 | static char *ends_with(char *str, const char *suffix) | 390 | static const char *ends_with(const char *str, const char *suffix) |
401 | { | 391 | { |
402 | size_t suffix_len = strlen(suffix); | 392 | size_t suffix_len = strlen(suffix); |
403 | char *p = str; | 393 | const char *p = str; |
404 | 394 | ||
405 | if (strlen(str) > suffix_len) { | 395 | if (strlen(str) > suffix_len) { |
406 | p = str + strlen(str) - suffix_len; | 396 | p = str + strlen(str) - suffix_len; |
@@ -492,7 +482,7 @@ static int list_available_scripts(const struct option *opt __used, | |||
492 | 482 | ||
493 | for_each_script(lang_path, lang_dir, script_dirent, script_next) { | 483 | for_each_script(lang_path, lang_dir, script_dirent, script_next) { |
494 | script_root = strdup(script_dirent.d_name); | 484 | script_root = strdup(script_dirent.d_name); |
495 | str = ends_with(script_root, REPORT_SUFFIX); | 485 | str = (char *)ends_with(script_root, REPORT_SUFFIX); |
496 | if (str) { | 486 | if (str) { |
497 | *str = '\0'; | 487 | *str = '\0'; |
498 | desc = script_desc__findnew(script_root); | 488 | desc = script_desc__findnew(script_root); |
@@ -540,7 +530,7 @@ static char *get_script_path(const char *script_root, const char *suffix) | |||
540 | 530 | ||
541 | for_each_script(lang_path, lang_dir, script_dirent, script_next) { | 531 | for_each_script(lang_path, lang_dir, script_dirent, script_next) { |
542 | __script_root = strdup(script_dirent.d_name); | 532 | __script_root = strdup(script_dirent.d_name); |
543 | str = ends_with(__script_root, suffix); | 533 | str = (char *)ends_with(__script_root, suffix); |
544 | if (str) { | 534 | if (str) { |
545 | *str = '\0'; | 535 | *str = '\0'; |
546 | if (strcmp(__script_root, script_root)) | 536 | if (strcmp(__script_root, script_root)) |
@@ -560,7 +550,7 @@ static char *get_script_path(const char *script_root, const char *suffix) | |||
560 | 550 | ||
561 | static bool is_top_script(const char *script_path) | 551 | static bool is_top_script(const char *script_path) |
562 | { | 552 | { |
563 | return ends_with((char *)script_path, "top") == NULL ? false : true; | 553 | return ends_with(script_path, "top") == NULL ? false : true; |
564 | } | 554 | } |
565 | 555 | ||
566 | static int has_required_arg(char *script_path) | 556 | static int has_required_arg(char *script_path) |