diff options
author | Ingo Molnar <mingo@kernel.org> | 2012-06-20 07:41:42 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2012-06-20 07:41:53 -0400 |
commit | 32c46e579b68c7ac0cd19d0803898a841d99833d (patch) | |
tree | 64a15c3b6eca5b302ef5aff0e045f52035c33eb7 /tools/perf/builtin-script.c | |
parent | 2992c542fcd40777ed253f57362c65711fb8acaf (diff) | |
parent | c0a58fb2bdf033df433cad9009c7dac4c6b872b0 (diff) |
Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core
Pull perf improvements from Arnaldo Carvalho de Melo:
* Replace event_name with perf_evsel__name, that handles the event
modifiers and doesn't use static variables.
* GTK browser improvements, from Namhyung Kim
* Fix possible NULL pointer deref in the TUI annotate browser, from
Samuel Liao
* Add sort by source file:line number, using addr2line.
* Allow printing histogram text snapshots at any point in top/report.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'tools/perf/builtin-script.c')
-rw-r--r-- | tools/perf/builtin-script.c | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 8e395a538eb9..8fecd3b8130a 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c | |||
@@ -137,10 +137,11 @@ static const char *output_field2str(enum perf_output_field field) | |||
137 | 137 | ||
138 | #define PRINT_FIELD(x) (output[attr->type].fields & PERF_OUTPUT_##x) | 138 | #define PRINT_FIELD(x) (output[attr->type].fields & PERF_OUTPUT_##x) |
139 | 139 | ||
140 | static int perf_event_attr__check_stype(struct perf_event_attr *attr, | 140 | static int perf_evsel__check_stype(struct perf_evsel *evsel, |
141 | u64 sample_type, const char *sample_msg, | 141 | u64 sample_type, const char *sample_msg, |
142 | enum perf_output_field field) | 142 | enum perf_output_field field) |
143 | { | 143 | { |
144 | struct perf_event_attr *attr = &evsel->attr; | ||
144 | int type = attr->type; | 145 | int type = attr->type; |
145 | const char *evname; | 146 | const char *evname; |
146 | 147 | ||
@@ -148,7 +149,7 @@ static int perf_event_attr__check_stype(struct perf_event_attr *attr, | |||
148 | return 0; | 149 | return 0; |
149 | 150 | ||
150 | if (output[type].user_set) { | 151 | if (output[type].user_set) { |
151 | evname = __event_name(attr->type, attr->config); | 152 | evname = perf_evsel__name(evsel); |
152 | pr_err("Samples for '%s' event do not have %s attribute set. " | 153 | pr_err("Samples for '%s' event do not have %s attribute set. " |
153 | "Cannot print '%s' field.\n", | 154 | "Cannot print '%s' field.\n", |
154 | evname, sample_msg, output_field2str(field)); | 155 | evname, sample_msg, output_field2str(field)); |
@@ -157,7 +158,7 @@ static int perf_event_attr__check_stype(struct perf_event_attr *attr, | |||
157 | 158 | ||
158 | /* user did not ask for it explicitly so remove from the default list */ | 159 | /* user did not ask for it explicitly so remove from the default list */ |
159 | output[type].fields &= ~field; | 160 | output[type].fields &= ~field; |
160 | evname = __event_name(attr->type, attr->config); | 161 | evname = perf_evsel__name(evsel); |
161 | pr_debug("Samples for '%s' event do not have %s attribute set. " | 162 | pr_debug("Samples for '%s' event do not have %s attribute set. " |
162 | "Skipping '%s' field.\n", | 163 | "Skipping '%s' field.\n", |
163 | evname, sample_msg, output_field2str(field)); | 164 | evname, sample_msg, output_field2str(field)); |
@@ -175,8 +176,8 @@ static int perf_evsel__check_attr(struct perf_evsel *evsel, | |||
175 | return -EINVAL; | 176 | return -EINVAL; |
176 | 177 | ||
177 | if (PRINT_FIELD(IP)) { | 178 | if (PRINT_FIELD(IP)) { |
178 | if (perf_event_attr__check_stype(attr, PERF_SAMPLE_IP, "IP", | 179 | if (perf_evsel__check_stype(evsel, PERF_SAMPLE_IP, "IP", |
179 | PERF_OUTPUT_IP)) | 180 | PERF_OUTPUT_IP)) |
180 | return -EINVAL; | 181 | return -EINVAL; |
181 | 182 | ||
182 | if (!no_callchain && | 183 | if (!no_callchain && |
@@ -185,8 +186,8 @@ static int perf_evsel__check_attr(struct perf_evsel *evsel, | |||
185 | } | 186 | } |
186 | 187 | ||
187 | if (PRINT_FIELD(ADDR) && | 188 | if (PRINT_FIELD(ADDR) && |
188 | perf_event_attr__check_stype(attr, PERF_SAMPLE_ADDR, "ADDR", | 189 | perf_evsel__check_stype(evsel, PERF_SAMPLE_ADDR, "ADDR", |
189 | PERF_OUTPUT_ADDR)) | 190 | PERF_OUTPUT_ADDR)) |
190 | return -EINVAL; | 191 | return -EINVAL; |
191 | 192 | ||
192 | if (PRINT_FIELD(SYM) && !PRINT_FIELD(IP) && !PRINT_FIELD(ADDR)) { | 193 | if (PRINT_FIELD(SYM) && !PRINT_FIELD(IP) && !PRINT_FIELD(ADDR)) { |
@@ -208,18 +209,18 @@ static int perf_evsel__check_attr(struct perf_evsel *evsel, | |||
208 | } | 209 | } |
209 | 210 | ||
210 | if ((PRINT_FIELD(PID) || PRINT_FIELD(TID)) && | 211 | if ((PRINT_FIELD(PID) || PRINT_FIELD(TID)) && |
211 | perf_event_attr__check_stype(attr, PERF_SAMPLE_TID, "TID", | 212 | perf_evsel__check_stype(evsel, PERF_SAMPLE_TID, "TID", |
212 | PERF_OUTPUT_TID|PERF_OUTPUT_PID)) | 213 | PERF_OUTPUT_TID|PERF_OUTPUT_PID)) |
213 | return -EINVAL; | 214 | return -EINVAL; |
214 | 215 | ||
215 | if (PRINT_FIELD(TIME) && | 216 | if (PRINT_FIELD(TIME) && |
216 | perf_event_attr__check_stype(attr, PERF_SAMPLE_TIME, "TIME", | 217 | perf_evsel__check_stype(evsel, PERF_SAMPLE_TIME, "TIME", |
217 | PERF_OUTPUT_TIME)) | 218 | PERF_OUTPUT_TIME)) |
218 | return -EINVAL; | 219 | return -EINVAL; |
219 | 220 | ||
220 | if (PRINT_FIELD(CPU) && | 221 | if (PRINT_FIELD(CPU) && |
221 | perf_event_attr__check_stype(attr, PERF_SAMPLE_CPU, "CPU", | 222 | perf_evsel__check_stype(evsel, PERF_SAMPLE_CPU, "CPU", |
222 | PERF_OUTPUT_CPU)) | 223 | PERF_OUTPUT_CPU)) |
223 | return -EINVAL; | 224 | return -EINVAL; |
224 | 225 | ||
225 | return 0; | 226 | return 0; |
@@ -258,9 +259,10 @@ static int perf_session__check_output_opt(struct perf_session *session) | |||
258 | 259 | ||
259 | static void print_sample_start(struct perf_sample *sample, | 260 | static void print_sample_start(struct perf_sample *sample, |
260 | struct thread *thread, | 261 | struct thread *thread, |
261 | struct perf_event_attr *attr) | 262 | struct perf_evsel *evsel) |
262 | { | 263 | { |
263 | int type; | 264 | int type; |
265 | struct perf_event_attr *attr = &evsel->attr; | ||
264 | struct event_format *event; | 266 | struct event_format *event; |
265 | const char *evname = NULL; | 267 | const char *evname = NULL; |
266 | unsigned long secs; | 268 | unsigned long secs; |
@@ -305,7 +307,7 @@ static void print_sample_start(struct perf_sample *sample, | |||
305 | if (event) | 307 | if (event) |
306 | evname = event->name; | 308 | evname = event->name; |
307 | } else | 309 | } else |
308 | evname = __event_name(attr->type, attr->config); | 310 | evname = perf_evsel__name(evsel); |
309 | 311 | ||
310 | printf("%s: ", evname ? evname : "[unknown]"); | 312 | printf("%s: ", evname ? evname : "[unknown]"); |
311 | } | 313 | } |
@@ -387,7 +389,7 @@ static void print_sample_bts(union perf_event *event, | |||
387 | printf(" "); | 389 | printf(" "); |
388 | else | 390 | else |
389 | printf("\n"); | 391 | printf("\n"); |
390 | perf_event__print_ip(event, sample, machine, evsel, | 392 | perf_event__print_ip(event, sample, machine, |
391 | PRINT_FIELD(SYM), PRINT_FIELD(DSO), | 393 | PRINT_FIELD(SYM), PRINT_FIELD(DSO), |
392 | PRINT_FIELD(SYMOFFSET)); | 394 | PRINT_FIELD(SYMOFFSET)); |
393 | } | 395 | } |
@@ -412,7 +414,7 @@ static void process_event(union perf_event *event __unused, | |||
412 | if (output[attr->type].fields == 0) | 414 | if (output[attr->type].fields == 0) |
413 | return; | 415 | return; |
414 | 416 | ||
415 | print_sample_start(sample, thread, attr); | 417 | print_sample_start(sample, thread, evsel); |
416 | 418 | ||
417 | if (is_bts_event(attr)) { | 419 | if (is_bts_event(attr)) { |
418 | print_sample_bts(event, sample, evsel, machine, thread); | 420 | print_sample_bts(event, sample, evsel, machine, thread); |
@@ -431,7 +433,7 @@ static void process_event(union perf_event *event __unused, | |||
431 | printf(" "); | 433 | printf(" "); |
432 | else | 434 | else |
433 | printf("\n"); | 435 | printf("\n"); |
434 | perf_event__print_ip(event, sample, machine, evsel, | 436 | perf_event__print_ip(event, sample, machine, |
435 | PRINT_FIELD(SYM), PRINT_FIELD(DSO), | 437 | PRINT_FIELD(SYM), PRINT_FIELD(DSO), |
436 | PRINT_FIELD(SYMOFFSET)); | 438 | PRINT_FIELD(SYMOFFSET)); |
437 | } | 439 | } |