diff options
Diffstat (limited to 'tools/perf/util')
-rw-r--r-- | tools/perf/util/callchain.h | 3 | ||||
-rw-r--r-- | tools/perf/util/event.c | 32 | ||||
-rw-r--r-- | tools/perf/util/evlist.c | 13 | ||||
-rw-r--r-- | tools/perf/util/evlist.h | 2 | ||||
-rw-r--r-- | tools/perf/util/evsel.c | 1 | ||||
-rw-r--r-- | tools/perf/util/hist.h | 13 | ||||
-rw-r--r-- | tools/perf/util/probe-finder.c | 2 | ||||
-rw-r--r-- | tools/perf/util/python.c | 2 | ||||
-rw-r--r-- | tools/perf/util/scripting-engines/trace-event-perl.c | 2 | ||||
-rw-r--r-- | tools/perf/util/scripting-engines/trace-event-python.c | 37 |
10 files changed, 70 insertions, 37 deletions
diff --git a/tools/perf/util/callchain.h b/tools/perf/util/callchain.h index 2b585bc308cf..9e99060408ae 100644 --- a/tools/perf/util/callchain.h +++ b/tools/perf/util/callchain.h | |||
@@ -147,6 +147,9 @@ static inline void callchain_cursor_advance(struct callchain_cursor *cursor) | |||
147 | 147 | ||
148 | struct option; | 148 | struct option; |
149 | 149 | ||
150 | int record_parse_callchain(const char *arg, struct perf_record_opts *opts); | ||
150 | int record_parse_callchain_opt(const struct option *opt, const char *arg, int unset); | 151 | int record_parse_callchain_opt(const struct option *opt, const char *arg, int unset); |
152 | int record_callchain_opt(const struct option *opt, const char *arg, int unset); | ||
153 | |||
151 | extern const char record_callchain_help[]; | 154 | extern const char record_callchain_help[]; |
152 | #endif /* __PERF_CALLCHAIN_H */ | 155 | #endif /* __PERF_CALLCHAIN_H */ |
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index 9b393e7dca6f..49096ea58a15 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c | |||
@@ -187,7 +187,7 @@ static int perf_event__synthesize_mmap_events(struct perf_tool *tool, | |||
187 | return -1; | 187 | return -1; |
188 | } | 188 | } |
189 | 189 | ||
190 | event->header.type = PERF_RECORD_MMAP2; | 190 | event->header.type = PERF_RECORD_MMAP; |
191 | /* | 191 | /* |
192 | * Just like the kernel, see __perf_event_mmap in kernel/perf_event.c | 192 | * Just like the kernel, see __perf_event_mmap in kernel/perf_event.c |
193 | */ | 193 | */ |
@@ -198,7 +198,6 @@ static int perf_event__synthesize_mmap_events(struct perf_tool *tool, | |||
198 | char prot[5]; | 198 | char prot[5]; |
199 | char execname[PATH_MAX]; | 199 | char execname[PATH_MAX]; |
200 | char anonstr[] = "//anon"; | 200 | char anonstr[] = "//anon"; |
201 | unsigned int ino; | ||
202 | size_t size; | 201 | size_t size; |
203 | ssize_t n; | 202 | ssize_t n; |
204 | 203 | ||
@@ -209,15 +208,12 @@ static int perf_event__synthesize_mmap_events(struct perf_tool *tool, | |||
209 | strcpy(execname, ""); | 208 | strcpy(execname, ""); |
210 | 209 | ||
211 | /* 00400000-0040c000 r-xp 00000000 fd:01 41038 /bin/cat */ | 210 | /* 00400000-0040c000 r-xp 00000000 fd:01 41038 /bin/cat */ |
212 | n = sscanf(bf, "%"PRIx64"-%"PRIx64" %s %"PRIx64" %x:%x %u %s\n", | 211 | n = sscanf(bf, "%"PRIx64"-%"PRIx64" %s %"PRIx64" %*x:%*x %*u %s\n", |
213 | &event->mmap2.start, &event->mmap2.len, prot, | 212 | &event->mmap.start, &event->mmap.len, prot, |
214 | &event->mmap2.pgoff, &event->mmap2.maj, | 213 | &event->mmap.pgoff, |
215 | &event->mmap2.min, | 214 | execname); |
216 | &ino, execname); | ||
217 | |||
218 | event->mmap2.ino = (u64)ino; | ||
219 | 215 | ||
220 | if (n != 8) | 216 | if (n != 5) |
221 | continue; | 217 | continue; |
222 | 218 | ||
223 | if (prot[2] != 'x') | 219 | if (prot[2] != 'x') |
@@ -227,15 +223,15 @@ static int perf_event__synthesize_mmap_events(struct perf_tool *tool, | |||
227 | strcpy(execname, anonstr); | 223 | strcpy(execname, anonstr); |
228 | 224 | ||
229 | size = strlen(execname) + 1; | 225 | size = strlen(execname) + 1; |
230 | memcpy(event->mmap2.filename, execname, size); | 226 | memcpy(event->mmap.filename, execname, size); |
231 | size = PERF_ALIGN(size, sizeof(u64)); | 227 | size = PERF_ALIGN(size, sizeof(u64)); |
232 | event->mmap2.len -= event->mmap.start; | 228 | event->mmap.len -= event->mmap.start; |
233 | event->mmap2.header.size = (sizeof(event->mmap2) - | 229 | event->mmap.header.size = (sizeof(event->mmap) - |
234 | (sizeof(event->mmap2.filename) - size)); | 230 | (sizeof(event->mmap.filename) - size)); |
235 | memset(event->mmap2.filename + size, 0, machine->id_hdr_size); | 231 | memset(event->mmap.filename + size, 0, machine->id_hdr_size); |
236 | event->mmap2.header.size += machine->id_hdr_size; | 232 | event->mmap.header.size += machine->id_hdr_size; |
237 | event->mmap2.pid = tgid; | 233 | event->mmap.pid = tgid; |
238 | event->mmap2.tid = pid; | 234 | event->mmap.tid = pid; |
239 | 235 | ||
240 | if (process(tool, event, &synth_sample, machine) != 0) { | 236 | if (process(tool, event, &synth_sample, machine) != 0) { |
241 | rc = -1; | 237 | rc = -1; |
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index f9f77bee0b1b..e584cd30b0f2 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c | |||
@@ -545,12 +545,19 @@ union perf_event *perf_evlist__mmap_read(struct perf_evlist *evlist, int idx) | |||
545 | 545 | ||
546 | md->prev = old; | 546 | md->prev = old; |
547 | 547 | ||
548 | if (!evlist->overwrite) | ||
549 | perf_mmap__write_tail(md, old); | ||
550 | |||
551 | return event; | 548 | return event; |
552 | } | 549 | } |
553 | 550 | ||
551 | void perf_evlist__mmap_consume(struct perf_evlist *evlist, int idx) | ||
552 | { | ||
553 | if (!evlist->overwrite) { | ||
554 | struct perf_mmap *md = &evlist->mmap[idx]; | ||
555 | unsigned int old = md->prev; | ||
556 | |||
557 | perf_mmap__write_tail(md, old); | ||
558 | } | ||
559 | } | ||
560 | |||
554 | static void __perf_evlist__munmap(struct perf_evlist *evlist, int idx) | 561 | static void __perf_evlist__munmap(struct perf_evlist *evlist, int idx) |
555 | { | 562 | { |
556 | if (evlist->mmap[idx].base != NULL) { | 563 | if (evlist->mmap[idx].base != NULL) { |
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h index 880d7139d2fb..206d09339306 100644 --- a/tools/perf/util/evlist.h +++ b/tools/perf/util/evlist.h | |||
@@ -89,6 +89,8 @@ struct perf_sample_id *perf_evlist__id2sid(struct perf_evlist *evlist, u64 id); | |||
89 | 89 | ||
90 | union perf_event *perf_evlist__mmap_read(struct perf_evlist *self, int idx); | 90 | union perf_event *perf_evlist__mmap_read(struct perf_evlist *self, int idx); |
91 | 91 | ||
92 | void perf_evlist__mmap_consume(struct perf_evlist *evlist, int idx); | ||
93 | |||
92 | int perf_evlist__open(struct perf_evlist *evlist); | 94 | int perf_evlist__open(struct perf_evlist *evlist); |
93 | void perf_evlist__close(struct perf_evlist *evlist); | 95 | void perf_evlist__close(struct perf_evlist *evlist); |
94 | 96 | ||
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 0ce9febf1ba0..9f1ef9bee2d0 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c | |||
@@ -678,7 +678,6 @@ void perf_evsel__config(struct perf_evsel *evsel, | |||
678 | attr->sample_type |= PERF_SAMPLE_WEIGHT; | 678 | attr->sample_type |= PERF_SAMPLE_WEIGHT; |
679 | 679 | ||
680 | attr->mmap = track; | 680 | attr->mmap = track; |
681 | attr->mmap2 = track && !perf_missing_features.mmap2; | ||
682 | attr->comm = track; | 681 | attr->comm = track; |
683 | 682 | ||
684 | /* | 683 | /* |
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h index 1329b6b6ffe6..ce8dc61ce2c3 100644 --- a/tools/perf/util/hist.h +++ b/tools/perf/util/hist.h | |||
@@ -5,6 +5,7 @@ | |||
5 | #include <pthread.h> | 5 | #include <pthread.h> |
6 | #include "callchain.h" | 6 | #include "callchain.h" |
7 | #include "header.h" | 7 | #include "header.h" |
8 | #include "color.h" | ||
8 | 9 | ||
9 | extern struct callchain_param callchain_param; | 10 | extern struct callchain_param callchain_param; |
10 | 11 | ||
@@ -175,6 +176,18 @@ void perf_hpp__init(void); | |||
175 | void perf_hpp__column_register(struct perf_hpp_fmt *format); | 176 | void perf_hpp__column_register(struct perf_hpp_fmt *format); |
176 | void perf_hpp__column_enable(unsigned col); | 177 | void perf_hpp__column_enable(unsigned col); |
177 | 178 | ||
179 | static inline size_t perf_hpp__use_color(void) | ||
180 | { | ||
181 | return !symbol_conf.field_sep; | ||
182 | } | ||
183 | |||
184 | static inline size_t perf_hpp__color_overhead(void) | ||
185 | { | ||
186 | return perf_hpp__use_color() ? | ||
187 | (COLOR_MAXLEN + sizeof(PERF_COLOR_RESET)) * PERF_HPP__MAX_INDEX | ||
188 | : 0; | ||
189 | } | ||
190 | |||
178 | struct perf_evlist; | 191 | struct perf_evlist; |
179 | 192 | ||
180 | struct hist_browser_timer { | 193 | struct hist_browser_timer { |
diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c index c09e0a9fdf4c..f0692737ebf1 100644 --- a/tools/perf/util/probe-finder.c +++ b/tools/perf/util/probe-finder.c | |||
@@ -1357,10 +1357,10 @@ int debuginfo__find_probe_point(struct debuginfo *self, unsigned long addr, | |||
1357 | goto post; | 1357 | goto post; |
1358 | } | 1358 | } |
1359 | 1359 | ||
1360 | fname = dwarf_decl_file(&spdie); | ||
1360 | if (addr == (unsigned long)baseaddr) { | 1361 | if (addr == (unsigned long)baseaddr) { |
1361 | /* Function entry - Relative line number is 0 */ | 1362 | /* Function entry - Relative line number is 0 */ |
1362 | lineno = baseline; | 1363 | lineno = baseline; |
1363 | fname = dwarf_decl_file(&spdie); | ||
1364 | goto post; | 1364 | goto post; |
1365 | } | 1365 | } |
1366 | 1366 | ||
diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c index 71b5412bbbb9..2ac4bc92bb1f 100644 --- a/tools/perf/util/python.c +++ b/tools/perf/util/python.c | |||
@@ -822,6 +822,8 @@ static PyObject *pyrf_evlist__read_on_cpu(struct pyrf_evlist *pevlist, | |||
822 | PyObject *pyevent = pyrf_event__new(event); | 822 | PyObject *pyevent = pyrf_event__new(event); |
823 | struct pyrf_event *pevent = (struct pyrf_event *)pyevent; | 823 | struct pyrf_event *pevent = (struct pyrf_event *)pyevent; |
824 | 824 | ||
825 | perf_evlist__mmap_consume(evlist, cpu); | ||
826 | |||
825 | if (pyevent == NULL) | 827 | if (pyevent == NULL) |
826 | return PyErr_NoMemory(); | 828 | return PyErr_NoMemory(); |
827 | 829 | ||
diff --git a/tools/perf/util/scripting-engines/trace-event-perl.c b/tools/perf/util/scripting-engines/trace-event-perl.c index a85e4ae5f3ac..c0c9795c4f02 100644 --- a/tools/perf/util/scripting-engines/trace-event-perl.c +++ b/tools/perf/util/scripting-engines/trace-event-perl.c | |||
@@ -282,7 +282,7 @@ static void perl_process_tracepoint(union perf_event *perf_event __maybe_unused, | |||
282 | 282 | ||
283 | event = find_cache_event(evsel); | 283 | event = find_cache_event(evsel); |
284 | if (!event) | 284 | if (!event) |
285 | die("ug! no event found for type %" PRIu64, evsel->attr.config); | 285 | die("ug! no event found for type %" PRIu64, (u64)evsel->attr.config); |
286 | 286 | ||
287 | pid = raw_field_value(event, "common_pid", data); | 287 | pid = raw_field_value(event, "common_pid", data); |
288 | 288 | ||
diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c index cc75a3cef388..95d91a0b23af 100644 --- a/tools/perf/util/scripting-engines/trace-event-python.c +++ b/tools/perf/util/scripting-engines/trace-event-python.c | |||
@@ -56,6 +56,17 @@ static void handler_call_die(const char *handler_name) | |||
56 | Py_FatalError("problem in Python trace event handler"); | 56 | Py_FatalError("problem in Python trace event handler"); |
57 | } | 57 | } |
58 | 58 | ||
59 | /* | ||
60 | * Insert val into into the dictionary and decrement the reference counter. | ||
61 | * This is necessary for dictionaries since PyDict_SetItemString() does not | ||
62 | * steal a reference, as opposed to PyTuple_SetItem(). | ||
63 | */ | ||
64 | static void pydict_set_item_string_decref(PyObject *dict, const char *key, PyObject *val) | ||
65 | { | ||
66 | PyDict_SetItemString(dict, key, val); | ||
67 | Py_DECREF(val); | ||
68 | } | ||
69 | |||
59 | static void define_value(enum print_arg_type field_type, | 70 | static void define_value(enum print_arg_type field_type, |
60 | const char *ev_name, | 71 | const char *ev_name, |
61 | const char *field_name, | 72 | const char *field_name, |
@@ -279,11 +290,11 @@ static void python_process_tracepoint(union perf_event *perf_event | |||
279 | PyTuple_SetItem(t, n++, PyInt_FromLong(pid)); | 290 | PyTuple_SetItem(t, n++, PyInt_FromLong(pid)); |
280 | PyTuple_SetItem(t, n++, PyString_FromString(comm)); | 291 | PyTuple_SetItem(t, n++, PyString_FromString(comm)); |
281 | } else { | 292 | } else { |
282 | PyDict_SetItemString(dict, "common_cpu", PyInt_FromLong(cpu)); | 293 | pydict_set_item_string_decref(dict, "common_cpu", PyInt_FromLong(cpu)); |
283 | PyDict_SetItemString(dict, "common_s", PyInt_FromLong(s)); | 294 | pydict_set_item_string_decref(dict, "common_s", PyInt_FromLong(s)); |
284 | PyDict_SetItemString(dict, "common_ns", PyInt_FromLong(ns)); | 295 | pydict_set_item_string_decref(dict, "common_ns", PyInt_FromLong(ns)); |
285 | PyDict_SetItemString(dict, "common_pid", PyInt_FromLong(pid)); | 296 | pydict_set_item_string_decref(dict, "common_pid", PyInt_FromLong(pid)); |
286 | PyDict_SetItemString(dict, "common_comm", PyString_FromString(comm)); | 297 | pydict_set_item_string_decref(dict, "common_comm", PyString_FromString(comm)); |
287 | } | 298 | } |
288 | for (field = event->format.fields; field; field = field->next) { | 299 | for (field = event->format.fields; field; field = field->next) { |
289 | if (field->flags & FIELD_IS_STRING) { | 300 | if (field->flags & FIELD_IS_STRING) { |
@@ -313,7 +324,7 @@ static void python_process_tracepoint(union perf_event *perf_event | |||
313 | if (handler) | 324 | if (handler) |
314 | PyTuple_SetItem(t, n++, obj); | 325 | PyTuple_SetItem(t, n++, obj); |
315 | else | 326 | else |
316 | PyDict_SetItemString(dict, field->name, obj); | 327 | pydict_set_item_string_decref(dict, field->name, obj); |
317 | 328 | ||
318 | } | 329 | } |
319 | if (!handler) | 330 | if (!handler) |
@@ -370,21 +381,21 @@ static void python_process_general_event(union perf_event *perf_event | |||
370 | if (!handler || !PyCallable_Check(handler)) | 381 | if (!handler || !PyCallable_Check(handler)) |
371 | goto exit; | 382 | goto exit; |
372 | 383 | ||
373 | PyDict_SetItemString(dict, "ev_name", PyString_FromString(perf_evsel__name(evsel))); | 384 | pydict_set_item_string_decref(dict, "ev_name", PyString_FromString(perf_evsel__name(evsel))); |
374 | PyDict_SetItemString(dict, "attr", PyString_FromStringAndSize( | 385 | pydict_set_item_string_decref(dict, "attr", PyString_FromStringAndSize( |
375 | (const char *)&evsel->attr, sizeof(evsel->attr))); | 386 | (const char *)&evsel->attr, sizeof(evsel->attr))); |
376 | PyDict_SetItemString(dict, "sample", PyString_FromStringAndSize( | 387 | pydict_set_item_string_decref(dict, "sample", PyString_FromStringAndSize( |
377 | (const char *)sample, sizeof(*sample))); | 388 | (const char *)sample, sizeof(*sample))); |
378 | PyDict_SetItemString(dict, "raw_buf", PyString_FromStringAndSize( | 389 | pydict_set_item_string_decref(dict, "raw_buf", PyString_FromStringAndSize( |
379 | (const char *)sample->raw_data, sample->raw_size)); | 390 | (const char *)sample->raw_data, sample->raw_size)); |
380 | PyDict_SetItemString(dict, "comm", | 391 | pydict_set_item_string_decref(dict, "comm", |
381 | PyString_FromString(thread->comm)); | 392 | PyString_FromString(thread->comm)); |
382 | if (al->map) { | 393 | if (al->map) { |
383 | PyDict_SetItemString(dict, "dso", | 394 | pydict_set_item_string_decref(dict, "dso", |
384 | PyString_FromString(al->map->dso->name)); | 395 | PyString_FromString(al->map->dso->name)); |
385 | } | 396 | } |
386 | if (al->sym) { | 397 | if (al->sym) { |
387 | PyDict_SetItemString(dict, "symbol", | 398 | pydict_set_item_string_decref(dict, "symbol", |
388 | PyString_FromString(al->sym->name)); | 399 | PyString_FromString(al->sym->name)); |
389 | } | 400 | } |
390 | 401 | ||