diff options
Diffstat (limited to 'tools/perf')
77 files changed, 606 insertions, 358 deletions
diff --git a/tools/perf/Documentation/perf-script.txt b/tools/perf/Documentation/perf-script.txt index 4f34379ebd77..1f6c70594f0f 100644 --- a/tools/perf/Documentation/perf-script.txt +++ b/tools/perf/Documentation/perf-script.txt | |||
@@ -170,7 +170,16 @@ OPTIONS | |||
170 | Trace decoding. The flags are "bcrosyiABEx" which stand for branch, | 170 | Trace decoding. The flags are "bcrosyiABEx" which stand for branch, |
171 | call, return, conditional, system, asynchronous, interrupt, | 171 | call, return, conditional, system, asynchronous, interrupt, |
172 | transaction abort, trace begin, trace end, and in transaction, | 172 | transaction abort, trace begin, trace end, and in transaction, |
173 | respectively. | 173 | respectively. Known combinations of flags are printed more nicely e.g. |
174 | "call" for "bc", "return" for "br", "jcc" for "bo", "jmp" for "b", | ||
175 | "int" for "bci", "iret" for "bri", "syscall" for "bcs", "sysret" for "brs", | ||
176 | "async" for "by", "hw int" for "bcyi", "tx abrt" for "bA", "tr strt" for "bB", | ||
177 | "tr end" for "bE". However the "x" flag will be display separately in those | ||
178 | cases e.g. "jcc (x)" for a condition branch within a transaction. | ||
179 | |||
180 | The callindent field is synthesized and may have a value when | ||
181 | Instruction Trace decoding. For calls and returns, it will display the | ||
182 | name of the symbol indented with spaces to reflect the stack depth. | ||
174 | 183 | ||
175 | Finally, a user may not set fields to none for all event types. | 184 | Finally, a user may not set fields to none for all event types. |
176 | i.e., -F "" is not allowed. | 185 | i.e., -F "" is not allowed. |
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index bde8cbae7dd9..d0a2cb11296f 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf | |||
@@ -254,7 +254,8 @@ PYTHON_EXT_SRCS := $(shell grep -v ^\# util/python-ext-sources) | |||
254 | PYTHON_EXT_DEPS := util/python-ext-sources util/setup.py $(LIBTRACEEVENT) $(LIBAPI) | 254 | PYTHON_EXT_DEPS := util/python-ext-sources util/setup.py $(LIBTRACEEVENT) $(LIBAPI) |
255 | 255 | ||
256 | $(OUTPUT)python/perf.so: $(PYTHON_EXT_SRCS) $(PYTHON_EXT_DEPS) $(LIBTRACEEVENT_DYNAMIC_LIST) | 256 | $(OUTPUT)python/perf.so: $(PYTHON_EXT_SRCS) $(PYTHON_EXT_DEPS) $(LIBTRACEEVENT_DYNAMIC_LIST) |
257 | $(QUIET_GEN)CFLAGS='$(CFLAGS)' LDFLAGS='$(LDFLAGS) $(LIBTRACEEVENT_DYNAMIC_LIST_LDFLAGS)' \ | 257 | $(QUIET_GEN)LDSHARED="$(CC) -pthread -shared" \ |
258 | CFLAGS='$(CFLAGS)' LDFLAGS='$(LDFLAGS) $(LIBTRACEEVENT_DYNAMIC_LIST_LDFLAGS)' \ | ||
258 | $(PYTHON_WORD) util/setup.py \ | 259 | $(PYTHON_WORD) util/setup.py \ |
259 | --quiet build_ext; \ | 260 | --quiet build_ext; \ |
260 | mkdir -p $(OUTPUT)python && \ | 261 | mkdir -p $(OUTPUT)python && \ |
diff --git a/tools/perf/arch/x86/tests/perf-time-to-tsc.c b/tools/perf/arch/x86/tests/perf-time-to-tsc.c index d4aa567a29c4..5c76cc83186a 100644 --- a/tools/perf/arch/x86/tests/perf-time-to-tsc.c +++ b/tools/perf/arch/x86/tests/perf-time-to-tsc.c | |||
@@ -154,10 +154,6 @@ next_event: | |||
154 | err = 0; | 154 | err = 0; |
155 | 155 | ||
156 | out_err: | 156 | out_err: |
157 | if (evlist) { | 157 | perf_evlist__delete(evlist); |
158 | perf_evlist__disable(evlist); | ||
159 | perf_evlist__delete(evlist); | ||
160 | } | ||
161 | |||
162 | return err; | 158 | return err; |
163 | } | 159 | } |
diff --git a/tools/perf/arch/x86/util/auxtrace.c b/tools/perf/arch/x86/util/auxtrace.c index 7a7805583e3f..cc1d865e31f1 100644 --- a/tools/perf/arch/x86/util/auxtrace.c +++ b/tools/perf/arch/x86/util/auxtrace.c | |||
@@ -37,7 +37,7 @@ struct auxtrace_record *auxtrace_record__init_intel(struct perf_evlist *evlist, | |||
37 | intel_bts_pmu = perf_pmu__find(INTEL_BTS_PMU_NAME); | 37 | intel_bts_pmu = perf_pmu__find(INTEL_BTS_PMU_NAME); |
38 | 38 | ||
39 | if (evlist) { | 39 | if (evlist) { |
40 | evlist__for_each(evlist, evsel) { | 40 | evlist__for_each_entry(evlist, evsel) { |
41 | if (intel_pt_pmu && | 41 | if (intel_pt_pmu && |
42 | evsel->attr.type == intel_pt_pmu->type) | 42 | evsel->attr.type == intel_pt_pmu->type) |
43 | found_pt = true; | 43 | found_pt = true; |
diff --git a/tools/perf/arch/x86/util/intel-bts.c b/tools/perf/arch/x86/util/intel-bts.c index 7dc30637cf66..5132775a044f 100644 --- a/tools/perf/arch/x86/util/intel-bts.c +++ b/tools/perf/arch/x86/util/intel-bts.c | |||
@@ -124,7 +124,7 @@ static int intel_bts_recording_options(struct auxtrace_record *itr, | |||
124 | btsr->evlist = evlist; | 124 | btsr->evlist = evlist; |
125 | btsr->snapshot_mode = opts->auxtrace_snapshot_mode; | 125 | btsr->snapshot_mode = opts->auxtrace_snapshot_mode; |
126 | 126 | ||
127 | evlist__for_each(evlist, evsel) { | 127 | evlist__for_each_entry(evlist, evsel) { |
128 | if (evsel->attr.type == intel_bts_pmu->type) { | 128 | if (evsel->attr.type == intel_bts_pmu->type) { |
129 | if (intel_bts_evsel) { | 129 | if (intel_bts_evsel) { |
130 | pr_err("There may be only one " INTEL_BTS_PMU_NAME " event\n"); | 130 | pr_err("There may be only one " INTEL_BTS_PMU_NAME " event\n"); |
@@ -327,7 +327,7 @@ static int intel_bts_snapshot_start(struct auxtrace_record *itr) | |||
327 | container_of(itr, struct intel_bts_recording, itr); | 327 | container_of(itr, struct intel_bts_recording, itr); |
328 | struct perf_evsel *evsel; | 328 | struct perf_evsel *evsel; |
329 | 329 | ||
330 | evlist__for_each(btsr->evlist, evsel) { | 330 | evlist__for_each_entry(btsr->evlist, evsel) { |
331 | if (evsel->attr.type == btsr->intel_bts_pmu->type) | 331 | if (evsel->attr.type == btsr->intel_bts_pmu->type) |
332 | return perf_evsel__disable(evsel); | 332 | return perf_evsel__disable(evsel); |
333 | } | 333 | } |
@@ -340,7 +340,7 @@ static int intel_bts_snapshot_finish(struct auxtrace_record *itr) | |||
340 | container_of(itr, struct intel_bts_recording, itr); | 340 | container_of(itr, struct intel_bts_recording, itr); |
341 | struct perf_evsel *evsel; | 341 | struct perf_evsel *evsel; |
342 | 342 | ||
343 | evlist__for_each(btsr->evlist, evsel) { | 343 | evlist__for_each_entry(btsr->evlist, evsel) { |
344 | if (evsel->attr.type == btsr->intel_bts_pmu->type) | 344 | if (evsel->attr.type == btsr->intel_bts_pmu->type) |
345 | return perf_evsel__enable(evsel); | 345 | return perf_evsel__enable(evsel); |
346 | } | 346 | } |
@@ -422,7 +422,7 @@ static int intel_bts_read_finish(struct auxtrace_record *itr, int idx) | |||
422 | container_of(itr, struct intel_bts_recording, itr); | 422 | container_of(itr, struct intel_bts_recording, itr); |
423 | struct perf_evsel *evsel; | 423 | struct perf_evsel *evsel; |
424 | 424 | ||
425 | evlist__for_each(btsr->evlist, evsel) { | 425 | evlist__for_each_entry(btsr->evlist, evsel) { |
426 | if (evsel->attr.type == btsr->intel_bts_pmu->type) | 426 | if (evsel->attr.type == btsr->intel_bts_pmu->type) |
427 | return perf_evlist__enable_event_idx(btsr->evlist, | 427 | return perf_evlist__enable_event_idx(btsr->evlist, |
428 | evsel, idx); | 428 | evsel, idx); |
diff --git a/tools/perf/arch/x86/util/intel-pt.c b/tools/perf/arch/x86/util/intel-pt.c index a07b9605e93b..fb51457ba338 100644 --- a/tools/perf/arch/x86/util/intel-pt.c +++ b/tools/perf/arch/x86/util/intel-pt.c | |||
@@ -131,7 +131,7 @@ static int intel_pt_read_config(struct perf_pmu *intel_pt_pmu, const char *str, | |||
131 | if (!mask) | 131 | if (!mask) |
132 | return -EINVAL; | 132 | return -EINVAL; |
133 | 133 | ||
134 | evlist__for_each(evlist, evsel) { | 134 | evlist__for_each_entry(evlist, evsel) { |
135 | if (evsel->attr.type == intel_pt_pmu->type) { | 135 | if (evsel->attr.type == intel_pt_pmu->type) { |
136 | *res = intel_pt_masked_bits(mask, evsel->attr.config); | 136 | *res = intel_pt_masked_bits(mask, evsel->attr.config); |
137 | return 0; | 137 | return 0; |
@@ -511,7 +511,7 @@ static int intel_pt_recording_options(struct auxtrace_record *itr, | |||
511 | ptr->evlist = evlist; | 511 | ptr->evlist = evlist; |
512 | ptr->snapshot_mode = opts->auxtrace_snapshot_mode; | 512 | ptr->snapshot_mode = opts->auxtrace_snapshot_mode; |
513 | 513 | ||
514 | evlist__for_each(evlist, evsel) { | 514 | evlist__for_each_entry(evlist, evsel) { |
515 | if (evsel->attr.type == intel_pt_pmu->type) { | 515 | if (evsel->attr.type == intel_pt_pmu->type) { |
516 | if (intel_pt_evsel) { | 516 | if (intel_pt_evsel) { |
517 | pr_err("There may be only one " INTEL_PT_PMU_NAME " event\n"); | 517 | pr_err("There may be only one " INTEL_PT_PMU_NAME " event\n"); |
@@ -725,7 +725,7 @@ static int intel_pt_snapshot_start(struct auxtrace_record *itr) | |||
725 | container_of(itr, struct intel_pt_recording, itr); | 725 | container_of(itr, struct intel_pt_recording, itr); |
726 | struct perf_evsel *evsel; | 726 | struct perf_evsel *evsel; |
727 | 727 | ||
728 | evlist__for_each(ptr->evlist, evsel) { | 728 | evlist__for_each_entry(ptr->evlist, evsel) { |
729 | if (evsel->attr.type == ptr->intel_pt_pmu->type) | 729 | if (evsel->attr.type == ptr->intel_pt_pmu->type) |
730 | return perf_evsel__disable(evsel); | 730 | return perf_evsel__disable(evsel); |
731 | } | 731 | } |
@@ -738,7 +738,7 @@ static int intel_pt_snapshot_finish(struct auxtrace_record *itr) | |||
738 | container_of(itr, struct intel_pt_recording, itr); | 738 | container_of(itr, struct intel_pt_recording, itr); |
739 | struct perf_evsel *evsel; | 739 | struct perf_evsel *evsel; |
740 | 740 | ||
741 | evlist__for_each(ptr->evlist, evsel) { | 741 | evlist__for_each_entry(ptr->evlist, evsel) { |
742 | if (evsel->attr.type == ptr->intel_pt_pmu->type) | 742 | if (evsel->attr.type == ptr->intel_pt_pmu->type) |
743 | return perf_evsel__enable(evsel); | 743 | return perf_evsel__enable(evsel); |
744 | } | 744 | } |
@@ -1011,7 +1011,7 @@ static int intel_pt_read_finish(struct auxtrace_record *itr, int idx) | |||
1011 | container_of(itr, struct intel_pt_recording, itr); | 1011 | container_of(itr, struct intel_pt_recording, itr); |
1012 | struct perf_evsel *evsel; | 1012 | struct perf_evsel *evsel; |
1013 | 1013 | ||
1014 | evlist__for_each(ptr->evlist, evsel) { | 1014 | evlist__for_each_entry(ptr->evlist, evsel) { |
1015 | if (evsel->attr.type == ptr->intel_pt_pmu->type) | 1015 | if (evsel->attr.type == ptr->intel_pt_pmu->type) |
1016 | return perf_evlist__enable_event_idx(ptr->evlist, evsel, | 1016 | return perf_evlist__enable_event_idx(ptr->evlist, evsel, |
1017 | idx); | 1017 | idx); |
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c index a2324e1892aa..b15e7683f38c 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c | |||
@@ -236,7 +236,7 @@ static int __cmd_annotate(struct perf_annotate *ann) | |||
236 | perf_session__fprintf_dsos(session, stdout); | 236 | perf_session__fprintf_dsos(session, stdout); |
237 | 237 | ||
238 | total_nr_samples = 0; | 238 | total_nr_samples = 0; |
239 | evlist__for_each(session->evlist, pos) { | 239 | evlist__for_each_entry(session->evlist, pos) { |
240 | struct hists *hists = evsel__hists(pos); | 240 | struct hists *hists = evsel__hists(pos); |
241 | u32 nr_samples = hists->stats.nr_events[PERF_RECORD_SAMPLE]; | 241 | u32 nr_samples = hists->stats.nr_events[PERF_RECORD_SAMPLE]; |
242 | 242 | ||
diff --git a/tools/perf/builtin-buildid-cache.c b/tools/perf/builtin-buildid-cache.c index d75bded21fe0..76a4d03c7cd0 100644 --- a/tools/perf/builtin-buildid-cache.c +++ b/tools/perf/builtin-buildid-cache.c | |||
@@ -209,7 +209,7 @@ static int build_id_cache__purge_path(const char *pathname) | |||
209 | if (err) | 209 | if (err) |
210 | goto out; | 210 | goto out; |
211 | 211 | ||
212 | strlist__for_each(pos, list) { | 212 | strlist__for_each_entry(pos, list) { |
213 | err = build_id_cache__remove_s(pos->s); | 213 | err = build_id_cache__remove_s(pos->s); |
214 | pr_debug("Removing %s %s: %s\n", pos->s, pathname, | 214 | pr_debug("Removing %s %s: %s\n", pos->s, pathname, |
215 | err ? "FAIL" : "Ok"); | 215 | err ? "FAIL" : "Ok"); |
@@ -343,7 +343,7 @@ int cmd_buildid_cache(int argc, const char **argv, | |||
343 | if (add_name_list_str) { | 343 | if (add_name_list_str) { |
344 | list = strlist__new(add_name_list_str, NULL); | 344 | list = strlist__new(add_name_list_str, NULL); |
345 | if (list) { | 345 | if (list) { |
346 | strlist__for_each(pos, list) | 346 | strlist__for_each_entry(pos, list) |
347 | if (build_id_cache__add_file(pos->s)) { | 347 | if (build_id_cache__add_file(pos->s)) { |
348 | if (errno == EEXIST) { | 348 | if (errno == EEXIST) { |
349 | pr_debug("%s already in the cache\n", | 349 | pr_debug("%s already in the cache\n", |
@@ -361,7 +361,7 @@ int cmd_buildid_cache(int argc, const char **argv, | |||
361 | if (remove_name_list_str) { | 361 | if (remove_name_list_str) { |
362 | list = strlist__new(remove_name_list_str, NULL); | 362 | list = strlist__new(remove_name_list_str, NULL); |
363 | if (list) { | 363 | if (list) { |
364 | strlist__for_each(pos, list) | 364 | strlist__for_each_entry(pos, list) |
365 | if (build_id_cache__remove_file(pos->s)) { | 365 | if (build_id_cache__remove_file(pos->s)) { |
366 | if (errno == ENOENT) { | 366 | if (errno == ENOENT) { |
367 | pr_debug("%s wasn't in the cache\n", | 367 | pr_debug("%s wasn't in the cache\n", |
@@ -379,7 +379,7 @@ int cmd_buildid_cache(int argc, const char **argv, | |||
379 | if (purge_name_list_str) { | 379 | if (purge_name_list_str) { |
380 | list = strlist__new(purge_name_list_str, NULL); | 380 | list = strlist__new(purge_name_list_str, NULL); |
381 | if (list) { | 381 | if (list) { |
382 | strlist__for_each(pos, list) | 382 | strlist__for_each_entry(pos, list) |
383 | if (build_id_cache__purge_path(pos->s)) { | 383 | if (build_id_cache__purge_path(pos->s)) { |
384 | if (errno == ENOENT) { | 384 | if (errno == ENOENT) { |
385 | pr_debug("%s wasn't in the cache\n", | 385 | pr_debug("%s wasn't in the cache\n", |
@@ -400,7 +400,7 @@ int cmd_buildid_cache(int argc, const char **argv, | |||
400 | if (update_name_list_str) { | 400 | if (update_name_list_str) { |
401 | list = strlist__new(update_name_list_str, NULL); | 401 | list = strlist__new(update_name_list_str, NULL); |
402 | if (list) { | 402 | if (list) { |
403 | strlist__for_each(pos, list) | 403 | strlist__for_each_entry(pos, list) |
404 | if (build_id_cache__update_file(pos->s)) { | 404 | if (build_id_cache__update_file(pos->s)) { |
405 | if (errno == ENOENT) { | 405 | if (errno == ENOENT) { |
406 | pr_debug("%s wasn't in the cache\n", | 406 | pr_debug("%s wasn't in the cache\n", |
@@ -419,8 +419,7 @@ int cmd_buildid_cache(int argc, const char **argv, | |||
419 | pr_warning("Couldn't add %s\n", kcore_filename); | 419 | pr_warning("Couldn't add %s\n", kcore_filename); |
420 | 420 | ||
421 | out: | 421 | out: |
422 | if (session) | 422 | perf_session__delete(session); |
423 | perf_session__delete(session); | ||
424 | 423 | ||
425 | return ret; | 424 | return ret; |
426 | } | 425 | } |
diff --git a/tools/perf/builtin-config.c b/tools/perf/builtin-config.c index fe1b77fa21f9..e4207a23b52c 100644 --- a/tools/perf/builtin-config.c +++ b/tools/perf/builtin-config.c | |||
@@ -37,23 +37,16 @@ static int show_config(struct perf_config_set *set) | |||
37 | { | 37 | { |
38 | struct perf_config_section *section; | 38 | struct perf_config_section *section; |
39 | struct perf_config_item *item; | 39 | struct perf_config_item *item; |
40 | struct list_head *sections; | ||
41 | 40 | ||
42 | if (set == NULL) | 41 | if (set == NULL) |
43 | return -1; | 42 | return -1; |
44 | 43 | ||
45 | sections = &set->sections; | 44 | perf_config_set__for_each_entry(set, section, item) { |
46 | if (list_empty(sections)) | 45 | char *value = item->value; |
47 | return -1; | ||
48 | |||
49 | list_for_each_entry(section, sections, node) { | ||
50 | list_for_each_entry(item, §ion->items, node) { | ||
51 | char *value = item->value; | ||
52 | 46 | ||
53 | if (value) | 47 | if (value) |
54 | printf("%s.%s=%s\n", section->name, | 48 | printf("%s.%s=%s\n", section->name, |
55 | item->name, value); | 49 | item->name, value); |
56 | } | ||
57 | } | 50 | } |
58 | 51 | ||
59 | return 0; | 52 | return 0; |
@@ -80,6 +73,10 @@ int cmd_config(int argc, const char **argv, const char *prefix __maybe_unused) | |||
80 | else if (use_user_config) | 73 | else if (use_user_config) |
81 | config_exclusive_filename = user_config; | 74 | config_exclusive_filename = user_config; |
82 | 75 | ||
76 | /* | ||
77 | * At only 'config' sub-command, individually use the config set | ||
78 | * because of reinitializing with options config file location. | ||
79 | */ | ||
83 | set = perf_config_set__new(); | 80 | set = perf_config_set__new(); |
84 | if (!set) { | 81 | if (!set) { |
85 | ret = -1; | 82 | ret = -1; |
diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c index 8b6735f35179..21ee753211ad 100644 --- a/tools/perf/builtin-diff.c +++ b/tools/perf/builtin-diff.c | |||
@@ -363,7 +363,7 @@ static struct perf_evsel *evsel_match(struct perf_evsel *evsel, | |||
363 | { | 363 | { |
364 | struct perf_evsel *e; | 364 | struct perf_evsel *e; |
365 | 365 | ||
366 | evlist__for_each(evlist, e) { | 366 | evlist__for_each_entry(evlist, e) { |
367 | if (perf_evsel__match2(evsel, e)) | 367 | if (perf_evsel__match2(evsel, e)) |
368 | return e; | 368 | return e; |
369 | } | 369 | } |
@@ -375,7 +375,7 @@ static void perf_evlist__collapse_resort(struct perf_evlist *evlist) | |||
375 | { | 375 | { |
376 | struct perf_evsel *evsel; | 376 | struct perf_evsel *evsel; |
377 | 377 | ||
378 | evlist__for_each(evlist, evsel) { | 378 | evlist__for_each_entry(evlist, evsel) { |
379 | struct hists *hists = evsel__hists(evsel); | 379 | struct hists *hists = evsel__hists(evsel); |
380 | 380 | ||
381 | hists__collapse_resort(hists, NULL); | 381 | hists__collapse_resort(hists, NULL); |
@@ -681,7 +681,7 @@ static void data_process(void) | |||
681 | struct perf_evsel *evsel_base; | 681 | struct perf_evsel *evsel_base; |
682 | bool first = true; | 682 | bool first = true; |
683 | 683 | ||
684 | evlist__for_each(evlist_base, evsel_base) { | 684 | evlist__for_each_entry(evlist_base, evsel_base) { |
685 | struct hists *hists_base = evsel__hists(evsel_base); | 685 | struct hists *hists_base = evsel__hists(evsel_base); |
686 | struct data__file *d; | 686 | struct data__file *d; |
687 | int i; | 687 | int i; |
@@ -756,9 +756,7 @@ static int __cmd_diff(void) | |||
756 | 756 | ||
757 | out_delete: | 757 | out_delete: |
758 | data__for_each_file(i, d) { | 758 | data__for_each_file(i, d) { |
759 | if (d->session) | 759 | perf_session__delete(d->session); |
760 | perf_session__delete(d->session); | ||
761 | |||
762 | data__free(d); | 760 | data__free(d); |
763 | } | 761 | } |
764 | 762 | ||
diff --git a/tools/perf/builtin-evlist.c b/tools/perf/builtin-evlist.c index 8a31f511e1a0..e09c4287fe87 100644 --- a/tools/perf/builtin-evlist.c +++ b/tools/perf/builtin-evlist.c | |||
@@ -32,7 +32,7 @@ static int __cmd_evlist(const char *file_name, struct perf_attr_details *details | |||
32 | if (session == NULL) | 32 | if (session == NULL) |
33 | return -1; | 33 | return -1; |
34 | 34 | ||
35 | evlist__for_each(session->evlist, pos) { | 35 | evlist__for_each_entry(session->evlist, pos) { |
36 | perf_evsel__fprintf(pos, details, stdout); | 36 | perf_evsel__fprintf(pos, details, stdout); |
37 | 37 | ||
38 | if (pos->attr.type == PERF_TYPE_TRACEPOINT) | 38 | if (pos->attr.type == PERF_TYPE_TRACEPOINT) |
diff --git a/tools/perf/builtin-help.c b/tools/perf/builtin-help.c index f9830c902b78..268ab732b8aa 100644 --- a/tools/perf/builtin-help.c +++ b/tools/perf/builtin-help.c | |||
@@ -4,7 +4,7 @@ | |||
4 | * Builtin help command | 4 | * Builtin help command |
5 | */ | 5 | */ |
6 | #include "perf.h" | 6 | #include "perf.h" |
7 | #include "util/cache.h" | 7 | #include "util/config.h" |
8 | #include "builtin.h" | 8 | #include "builtin.h" |
9 | #include <subcmd/exec-cmd.h> | 9 | #include <subcmd/exec-cmd.h> |
10 | #include "common-cmds.h" | 10 | #include "common-cmds.h" |
diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c index e5afa8fe1bf1..73c1c4cc3600 100644 --- a/tools/perf/builtin-inject.c +++ b/tools/perf/builtin-inject.c | |||
@@ -562,7 +562,7 @@ static void strip_init(struct perf_inject *inject) | |||
562 | 562 | ||
563 | inject->tool.context_switch = perf_event__drop; | 563 | inject->tool.context_switch = perf_event__drop; |
564 | 564 | ||
565 | evlist__for_each(evlist, evsel) | 565 | evlist__for_each_entry(evlist, evsel) |
566 | evsel->handler = drop_sample; | 566 | evsel->handler = drop_sample; |
567 | } | 567 | } |
568 | 568 | ||
@@ -590,7 +590,7 @@ static bool ok_to_remove(struct perf_evlist *evlist, | |||
590 | if (!has_tracking(evsel_to_remove)) | 590 | if (!has_tracking(evsel_to_remove)) |
591 | return true; | 591 | return true; |
592 | 592 | ||
593 | evlist__for_each(evlist, evsel) { | 593 | evlist__for_each_entry(evlist, evsel) { |
594 | if (evsel->handler != drop_sample) { | 594 | if (evsel->handler != drop_sample) { |
595 | cnt += 1; | 595 | cnt += 1; |
596 | if ((evsel->attr.sample_type & COMPAT_MASK) == | 596 | if ((evsel->attr.sample_type & COMPAT_MASK) == |
@@ -608,7 +608,7 @@ static void strip_fini(struct perf_inject *inject) | |||
608 | struct perf_evsel *evsel, *tmp; | 608 | struct perf_evsel *evsel, *tmp; |
609 | 609 | ||
610 | /* Remove non-synthesized evsels if possible */ | 610 | /* Remove non-synthesized evsels if possible */ |
611 | evlist__for_each_safe(evlist, tmp, evsel) { | 611 | evlist__for_each_entry_safe(evlist, tmp, evsel) { |
612 | if (evsel->handler == drop_sample && | 612 | if (evsel->handler == drop_sample && |
613 | ok_to_remove(evlist, evsel)) { | 613 | ok_to_remove(evlist, evsel)) { |
614 | pr_debug("Deleting %s\n", perf_evsel__name(evsel)); | 614 | pr_debug("Deleting %s\n", perf_evsel__name(evsel)); |
@@ -643,7 +643,7 @@ static int __cmd_inject(struct perf_inject *inject) | |||
643 | } else if (inject->sched_stat) { | 643 | } else if (inject->sched_stat) { |
644 | struct perf_evsel *evsel; | 644 | struct perf_evsel *evsel; |
645 | 645 | ||
646 | evlist__for_each(session->evlist, evsel) { | 646 | evlist__for_each_entry(session->evlist, evsel) { |
647 | const char *name = perf_evsel__name(evsel); | 647 | const char *name = perf_evsel__name(evsel); |
648 | 648 | ||
649 | if (!strcmp(name, "sched:sched_switch")) { | 649 | if (!strcmp(name, "sched:sched_switch")) { |
diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c index 58adfee230de..b1d491c2e704 100644 --- a/tools/perf/builtin-kmem.c +++ b/tools/perf/builtin-kmem.c | |||
@@ -4,7 +4,7 @@ | |||
4 | #include "util/evlist.h" | 4 | #include "util/evlist.h" |
5 | #include "util/evsel.h" | 5 | #include "util/evsel.h" |
6 | #include "util/util.h" | 6 | #include "util/util.h" |
7 | #include "util/cache.h" | 7 | #include "util/config.h" |
8 | #include "util/symbol.h" | 8 | #include "util/symbol.h" |
9 | #include "util/thread.h" | 9 | #include "util/thread.h" |
10 | #include "util/header.h" | 10 | #include "util/header.h" |
@@ -1354,7 +1354,7 @@ static int __cmd_kmem(struct perf_session *session) | |||
1354 | goto out; | 1354 | goto out; |
1355 | } | 1355 | } |
1356 | 1356 | ||
1357 | evlist__for_each(session->evlist, evsel) { | 1357 | evlist__for_each_entry(session->evlist, evsel) { |
1358 | if (!strcmp(perf_evsel__name(evsel), "kmem:mm_page_alloc") && | 1358 | if (!strcmp(perf_evsel__name(evsel), "kmem:mm_page_alloc") && |
1359 | perf_evsel__field(evsel, "pfn")) { | 1359 | perf_evsel__field(evsel, "pfn")) { |
1360 | use_pfn = true; | 1360 | use_pfn = true; |
diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c index 6487c06d2708..f4efef9d1eb3 100644 --- a/tools/perf/builtin-kvm.c +++ b/tools/perf/builtin-kvm.c | |||
@@ -988,7 +988,7 @@ static int kvm_live_open_events(struct perf_kvm_stat *kvm) | |||
988 | * Note: exclude_{guest,host} do not apply here. | 988 | * Note: exclude_{guest,host} do not apply here. |
989 | * This command processes KVM tracepoints from host only | 989 | * This command processes KVM tracepoints from host only |
990 | */ | 990 | */ |
991 | evlist__for_each(evlist, pos) { | 991 | evlist__for_each_entry(evlist, pos) { |
992 | struct perf_event_attr *attr = &pos->attr; | 992 | struct perf_event_attr *attr = &pos->attr; |
993 | 993 | ||
994 | /* make sure these *are* set */ | 994 | /* make sure these *are* set */ |
@@ -1426,11 +1426,9 @@ static int kvm_events_live(struct perf_kvm_stat *kvm, | |||
1426 | err = kvm_events_live_report(kvm); | 1426 | err = kvm_events_live_report(kvm); |
1427 | 1427 | ||
1428 | out: | 1428 | out: |
1429 | if (kvm->session) | 1429 | perf_session__delete(kvm->session); |
1430 | perf_session__delete(kvm->session); | ||
1431 | kvm->session = NULL; | 1430 | kvm->session = NULL; |
1432 | if (kvm->evlist) | 1431 | perf_evlist__delete(kvm->evlist); |
1433 | perf_evlist__delete(kvm->evlist); | ||
1434 | 1432 | ||
1435 | return err; | 1433 | return err; |
1436 | } | 1434 | } |
diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c index 6d7ab4316449..34262329f405 100644 --- a/tools/perf/builtin-probe.c +++ b/tools/perf/builtin-probe.c | |||
@@ -389,7 +389,7 @@ static int perf_del_probe_events(struct strfilter *filter) | |||
389 | 389 | ||
390 | ret = probe_file__get_events(kfd, filter, klist); | 390 | ret = probe_file__get_events(kfd, filter, klist); |
391 | if (ret == 0) { | 391 | if (ret == 0) { |
392 | strlist__for_each(ent, klist) | 392 | strlist__for_each_entry(ent, klist) |
393 | pr_info("Removed event: %s\n", ent->s); | 393 | pr_info("Removed event: %s\n", ent->s); |
394 | 394 | ||
395 | ret = probe_file__del_strlist(kfd, klist); | 395 | ret = probe_file__del_strlist(kfd, klist); |
@@ -399,7 +399,7 @@ static int perf_del_probe_events(struct strfilter *filter) | |||
399 | 399 | ||
400 | ret2 = probe_file__get_events(ufd, filter, ulist); | 400 | ret2 = probe_file__get_events(ufd, filter, ulist); |
401 | if (ret2 == 0) { | 401 | if (ret2 == 0) { |
402 | strlist__for_each(ent, ulist) | 402 | strlist__for_each_entry(ent, ulist) |
403 | pr_info("Removed event: %s\n", ent->s); | 403 | pr_info("Removed event: %s\n", ent->s); |
404 | 404 | ||
405 | ret2 = probe_file__del_strlist(ufd, ulist); | 405 | ret2 = probe_file__del_strlist(ufd, ulist); |
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index b1304ebc8779..81411b14df4c 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c | |||
@@ -13,6 +13,7 @@ | |||
13 | #include "util/util.h" | 13 | #include "util/util.h" |
14 | #include <subcmd/parse-options.h> | 14 | #include <subcmd/parse-options.h> |
15 | #include "util/parse-events.h" | 15 | #include "util/parse-events.h" |
16 | #include "util/config.h" | ||
16 | 17 | ||
17 | #include "util/callchain.h" | 18 | #include "util/callchain.h" |
18 | #include "util/cgroup.h" | 19 | #include "util/cgroup.h" |
@@ -352,7 +353,7 @@ static int record__open(struct record *rec) | |||
352 | 353 | ||
353 | perf_evlist__config(evlist, opts, &callchain_param); | 354 | perf_evlist__config(evlist, opts, &callchain_param); |
354 | 355 | ||
355 | evlist__for_each(evlist, pos) { | 356 | evlist__for_each_entry(evlist, pos) { |
356 | try_again: | 357 | try_again: |
357 | if (perf_evsel__open(pos, pos->cpus, pos->threads) < 0) { | 358 | if (perf_evsel__open(pos, pos->cpus, pos->threads) < 0) { |
358 | if (perf_evsel__fallback(pos, errno, msg, sizeof(msg))) { | 359 | if (perf_evsel__fallback(pos, errno, msg, sizeof(msg))) { |
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 9f36b236f0f9..f6cb357986c6 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c | |||
@@ -8,7 +8,7 @@ | |||
8 | #include "builtin.h" | 8 | #include "builtin.h" |
9 | 9 | ||
10 | #include "util/util.h" | 10 | #include "util/util.h" |
11 | #include "util/cache.h" | 11 | #include "util/config.h" |
12 | 12 | ||
13 | #include "util/annotate.h" | 13 | #include "util/annotate.h" |
14 | #include "util/color.h" | 14 | #include "util/color.h" |
@@ -361,7 +361,7 @@ static int perf_evlist__tty_browse_hists(struct perf_evlist *evlist, | |||
361 | struct perf_evsel *pos; | 361 | struct perf_evsel *pos; |
362 | 362 | ||
363 | fprintf(stdout, "#\n# Total Lost Samples: %" PRIu64 "\n#\n", evlist->stats.total_lost_samples); | 363 | fprintf(stdout, "#\n# Total Lost Samples: %" PRIu64 "\n#\n", evlist->stats.total_lost_samples); |
364 | evlist__for_each(evlist, pos) { | 364 | evlist__for_each_entry(evlist, pos) { |
365 | struct hists *hists = evsel__hists(pos); | 365 | struct hists *hists = evsel__hists(pos); |
366 | const char *evname = perf_evsel__name(pos); | 366 | const char *evname = perf_evsel__name(pos); |
367 | 367 | ||
@@ -478,7 +478,7 @@ static int report__collapse_hists(struct report *rep) | |||
478 | 478 | ||
479 | ui_progress__init(&prog, rep->nr_entries, "Merging related events..."); | 479 | ui_progress__init(&prog, rep->nr_entries, "Merging related events..."); |
480 | 480 | ||
481 | evlist__for_each(rep->session->evlist, pos) { | 481 | evlist__for_each_entry(rep->session->evlist, pos) { |
482 | struct hists *hists = evsel__hists(pos); | 482 | struct hists *hists = evsel__hists(pos); |
483 | 483 | ||
484 | if (pos->idx == 0) | 484 | if (pos->idx == 0) |
@@ -511,7 +511,7 @@ static void report__output_resort(struct report *rep) | |||
511 | 511 | ||
512 | ui_progress__init(&prog, rep->nr_entries, "Sorting events for output..."); | 512 | ui_progress__init(&prog, rep->nr_entries, "Sorting events for output..."); |
513 | 513 | ||
514 | evlist__for_each(rep->session->evlist, pos) | 514 | evlist__for_each_entry(rep->session->evlist, pos) |
515 | perf_evsel__output_resort(pos, &prog); | 515 | perf_evsel__output_resort(pos, &prog); |
516 | 516 | ||
517 | ui_progress__finish(); | 517 | ui_progress__finish(); |
@@ -552,7 +552,7 @@ static int __cmd_report(struct report *rep) | |||
552 | 552 | ||
553 | report__warn_kptr_restrict(rep); | 553 | report__warn_kptr_restrict(rep); |
554 | 554 | ||
555 | evlist__for_each(session->evlist, pos) | 555 | evlist__for_each_entry(session->evlist, pos) |
556 | rep->nr_entries += evsel__hists(pos)->nr_entries; | 556 | rep->nr_entries += evsel__hists(pos)->nr_entries; |
557 | 557 | ||
558 | if (use_browser == 0) { | 558 | if (use_browser == 0) { |
@@ -583,7 +583,7 @@ static int __cmd_report(struct report *rep) | |||
583 | * might be changed during the collapse phase. | 583 | * might be changed during the collapse phase. |
584 | */ | 584 | */ |
585 | rep->nr_entries = 0; | 585 | rep->nr_entries = 0; |
586 | evlist__for_each(session->evlist, pos) | 586 | evlist__for_each_entry(session->evlist, pos) |
587 | rep->nr_entries += evsel__hists(pos)->nr_entries; | 587 | rep->nr_entries += evsel__hists(pos)->nr_entries; |
588 | 588 | ||
589 | if (rep->nr_entries == 0) { | 589 | if (rep->nr_entries == 0) { |
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 46011235af5d..971ff91b16cb 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include "util/cpumap.h" | 21 | #include "util/cpumap.h" |
22 | #include "util/thread_map.h" | 22 | #include "util/thread_map.h" |
23 | #include "util/stat.h" | 23 | #include "util/stat.h" |
24 | #include "util/thread-stack.h" | ||
24 | #include <linux/bitmap.h> | 25 | #include <linux/bitmap.h> |
25 | #include <linux/stringify.h> | 26 | #include <linux/stringify.h> |
26 | #include "asm/bug.h" | 27 | #include "asm/bug.h" |
@@ -63,6 +64,7 @@ enum perf_output_field { | |||
63 | PERF_OUTPUT_DATA_SRC = 1U << 17, | 64 | PERF_OUTPUT_DATA_SRC = 1U << 17, |
64 | PERF_OUTPUT_WEIGHT = 1U << 18, | 65 | PERF_OUTPUT_WEIGHT = 1U << 18, |
65 | PERF_OUTPUT_BPF_OUTPUT = 1U << 19, | 66 | PERF_OUTPUT_BPF_OUTPUT = 1U << 19, |
67 | PERF_OUTPUT_CALLINDENT = 1U << 20, | ||
66 | }; | 68 | }; |
67 | 69 | ||
68 | struct output_option { | 70 | struct output_option { |
@@ -89,6 +91,7 @@ struct output_option { | |||
89 | {.str = "data_src", .field = PERF_OUTPUT_DATA_SRC}, | 91 | {.str = "data_src", .field = PERF_OUTPUT_DATA_SRC}, |
90 | {.str = "weight", .field = PERF_OUTPUT_WEIGHT}, | 92 | {.str = "weight", .field = PERF_OUTPUT_WEIGHT}, |
91 | {.str = "bpf-output", .field = PERF_OUTPUT_BPF_OUTPUT}, | 93 | {.str = "bpf-output", .field = PERF_OUTPUT_BPF_OUTPUT}, |
94 | {.str = "callindent", .field = PERF_OUTPUT_CALLINDENT}, | ||
92 | }; | 95 | }; |
93 | 96 | ||
94 | /* default set to maintain compatibility with current format */ | 97 | /* default set to maintain compatibility with current format */ |
@@ -369,7 +372,7 @@ static int perf_session__check_output_opt(struct perf_session *session) | |||
369 | if (!no_callchain) { | 372 | if (!no_callchain) { |
370 | bool use_callchain = false; | 373 | bool use_callchain = false; |
371 | 374 | ||
372 | evlist__for_each(session->evlist, evsel) { | 375 | evlist__for_each_entry(session->evlist, evsel) { |
373 | if (evsel->attr.sample_type & PERF_SAMPLE_CALLCHAIN) { | 376 | if (evsel->attr.sample_type & PERF_SAMPLE_CALLCHAIN) { |
374 | use_callchain = true; | 377 | use_callchain = true; |
375 | break; | 378 | break; |
@@ -389,7 +392,7 @@ static int perf_session__check_output_opt(struct perf_session *session) | |||
389 | 392 | ||
390 | j = PERF_TYPE_TRACEPOINT; | 393 | j = PERF_TYPE_TRACEPOINT; |
391 | 394 | ||
392 | evlist__for_each(session->evlist, evsel) { | 395 | evlist__for_each_entry(session->evlist, evsel) { |
393 | if (evsel->attr.type != j) | 396 | if (evsel->attr.type != j) |
394 | continue; | 397 | continue; |
395 | 398 | ||
@@ -562,6 +565,62 @@ static void print_sample_addr(struct perf_sample *sample, | |||
562 | } | 565 | } |
563 | } | 566 | } |
564 | 567 | ||
568 | static void print_sample_callindent(struct perf_sample *sample, | ||
569 | struct perf_evsel *evsel, | ||
570 | struct thread *thread, | ||
571 | struct addr_location *al) | ||
572 | { | ||
573 | struct perf_event_attr *attr = &evsel->attr; | ||
574 | size_t depth = thread_stack__depth(thread); | ||
575 | struct addr_location addr_al; | ||
576 | const char *name = NULL; | ||
577 | static int spacing; | ||
578 | int len = 0; | ||
579 | u64 ip = 0; | ||
580 | |||
581 | /* | ||
582 | * The 'return' has already been popped off the stack so the depth has | ||
583 | * to be adjusted to match the 'call'. | ||
584 | */ | ||
585 | if (thread->ts && sample->flags & PERF_IP_FLAG_RETURN) | ||
586 | depth += 1; | ||
587 | |||
588 | if (sample->flags & (PERF_IP_FLAG_CALL | PERF_IP_FLAG_TRACE_BEGIN)) { | ||
589 | if (sample_addr_correlates_sym(attr)) { | ||
590 | thread__resolve(thread, &addr_al, sample); | ||
591 | if (addr_al.sym) | ||
592 | name = addr_al.sym->name; | ||
593 | else | ||
594 | ip = sample->addr; | ||
595 | } else { | ||
596 | ip = sample->addr; | ||
597 | } | ||
598 | } else if (sample->flags & (PERF_IP_FLAG_RETURN | PERF_IP_FLAG_TRACE_END)) { | ||
599 | if (al->sym) | ||
600 | name = al->sym->name; | ||
601 | else | ||
602 | ip = sample->ip; | ||
603 | } | ||
604 | |||
605 | if (name) | ||
606 | len = printf("%*s%s", (int)depth * 4, "", name); | ||
607 | else if (ip) | ||
608 | len = printf("%*s%16" PRIx64, (int)depth * 4, "", ip); | ||
609 | |||
610 | if (len < 0) | ||
611 | return; | ||
612 | |||
613 | /* | ||
614 | * Try to keep the output length from changing frequently so that the | ||
615 | * output lines up more nicely. | ||
616 | */ | ||
617 | if (len > spacing || (len && len < spacing - 52)) | ||
618 | spacing = round_up(len + 4, 32); | ||
619 | |||
620 | if (len < spacing) | ||
621 | printf("%*s", spacing - len, ""); | ||
622 | } | ||
623 | |||
565 | static void print_sample_bts(struct perf_sample *sample, | 624 | static void print_sample_bts(struct perf_sample *sample, |
566 | struct perf_evsel *evsel, | 625 | struct perf_evsel *evsel, |
567 | struct thread *thread, | 626 | struct thread *thread, |
@@ -570,6 +629,9 @@ static void print_sample_bts(struct perf_sample *sample, | |||
570 | struct perf_event_attr *attr = &evsel->attr; | 629 | struct perf_event_attr *attr = &evsel->attr; |
571 | bool print_srcline_last = false; | 630 | bool print_srcline_last = false; |
572 | 631 | ||
632 | if (PRINT_FIELD(CALLINDENT)) | ||
633 | print_sample_callindent(sample, evsel, thread, al); | ||
634 | |||
573 | /* print branch_from information */ | 635 | /* print branch_from information */ |
574 | if (PRINT_FIELD(IP)) { | 636 | if (PRINT_FIELD(IP)) { |
575 | unsigned int print_opts = output[attr->type].print_ip_opts; | 637 | unsigned int print_opts = output[attr->type].print_ip_opts; |
@@ -606,13 +668,42 @@ static void print_sample_bts(struct perf_sample *sample, | |||
606 | printf("\n"); | 668 | printf("\n"); |
607 | } | 669 | } |
608 | 670 | ||
671 | static struct { | ||
672 | u32 flags; | ||
673 | const char *name; | ||
674 | } sample_flags[] = { | ||
675 | {PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_CALL, "call"}, | ||
676 | {PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_RETURN, "return"}, | ||
677 | {PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_CONDITIONAL, "jcc"}, | ||
678 | {PERF_IP_FLAG_BRANCH, "jmp"}, | ||
679 | {PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_CALL | PERF_IP_FLAG_INTERRUPT, "int"}, | ||
680 | {PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_RETURN | PERF_IP_FLAG_INTERRUPT, "iret"}, | ||
681 | {PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_CALL | PERF_IP_FLAG_SYSCALLRET, "syscall"}, | ||
682 | {PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_RETURN | PERF_IP_FLAG_SYSCALLRET, "sysret"}, | ||
683 | {PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_ASYNC, "async"}, | ||
684 | {PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_CALL | PERF_IP_FLAG_ASYNC | PERF_IP_FLAG_INTERRUPT, "hw int"}, | ||
685 | {PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_TX_ABORT, "tx abrt"}, | ||
686 | {PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_TRACE_BEGIN, "tr strt"}, | ||
687 | {PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_TRACE_END, "tr end"}, | ||
688 | {0, NULL} | ||
689 | }; | ||
690 | |||
609 | static void print_sample_flags(u32 flags) | 691 | static void print_sample_flags(u32 flags) |
610 | { | 692 | { |
611 | const char *chars = PERF_IP_FLAG_CHARS; | 693 | const char *chars = PERF_IP_FLAG_CHARS; |
612 | const int n = strlen(PERF_IP_FLAG_CHARS); | 694 | const int n = strlen(PERF_IP_FLAG_CHARS); |
695 | bool in_tx = flags & PERF_IP_FLAG_IN_TX; | ||
696 | const char *name = NULL; | ||
613 | char str[33]; | 697 | char str[33]; |
614 | int i, pos = 0; | 698 | int i, pos = 0; |
615 | 699 | ||
700 | for (i = 0; sample_flags[i].name ; i++) { | ||
701 | if (sample_flags[i].flags == (flags & ~PERF_IP_FLAG_IN_TX)) { | ||
702 | name = sample_flags[i].name; | ||
703 | break; | ||
704 | } | ||
705 | } | ||
706 | |||
616 | for (i = 0; i < n; i++, flags >>= 1) { | 707 | for (i = 0; i < n; i++, flags >>= 1) { |
617 | if (flags & 1) | 708 | if (flags & 1) |
618 | str[pos++] = chars[i]; | 709 | str[pos++] = chars[i]; |
@@ -622,7 +713,11 @@ static void print_sample_flags(u32 flags) | |||
622 | str[pos++] = '?'; | 713 | str[pos++] = '?'; |
623 | } | 714 | } |
624 | str[pos] = 0; | 715 | str[pos] = 0; |
625 | printf(" %-4s ", str); | 716 | |
717 | if (name) | ||
718 | printf(" %-7s%4s ", name, in_tx ? "(x)" : ""); | ||
719 | else | ||
720 | printf(" %-11s ", str); | ||
626 | } | 721 | } |
627 | 722 | ||
628 | struct printer_data { | 723 | struct printer_data { |
@@ -720,7 +815,7 @@ static int perf_evlist__max_name_len(struct perf_evlist *evlist) | |||
720 | struct perf_evsel *evsel; | 815 | struct perf_evsel *evsel; |
721 | int max = 0; | 816 | int max = 0; |
722 | 817 | ||
723 | evlist__for_each(evlist, evsel) { | 818 | evlist__for_each_entry(evlist, evsel) { |
724 | int len = strlen(perf_evsel__name(evsel)); | 819 | int len = strlen(perf_evsel__name(evsel)); |
725 | 820 | ||
726 | max = MAX(len, max); | 821 | max = MAX(len, max); |
@@ -945,7 +1040,7 @@ static int process_attr(struct perf_tool *tool, union perf_event *event, | |||
945 | if (evsel->attr.type >= PERF_TYPE_MAX) | 1040 | if (evsel->attr.type >= PERF_TYPE_MAX) |
946 | return 0; | 1041 | return 0; |
947 | 1042 | ||
948 | evlist__for_each(evlist, pos) { | 1043 | evlist__for_each_entry(evlist, pos) { |
949 | if (pos->attr.type == evsel->attr.type && pos != evsel) | 1044 | if (pos->attr.type == evsel->attr.type && pos != evsel) |
950 | return 0; | 1045 | return 0; |
951 | } | 1046 | } |
@@ -1671,7 +1766,7 @@ static int check_ev_match(char *dir_name, char *scriptname, | |||
1671 | snprintf(evname, len + 1, "%s", p); | 1766 | snprintf(evname, len + 1, "%s", p); |
1672 | 1767 | ||
1673 | match = 0; | 1768 | match = 0; |
1674 | evlist__for_each(session->evlist, pos) { | 1769 | evlist__for_each_entry(session->evlist, pos) { |
1675 | if (!strcmp(perf_evsel__name(pos), evname)) { | 1770 | if (!strcmp(perf_evsel__name(pos), evname)) { |
1676 | match = 1; | 1771 | match = 1; |
1677 | break; | 1772 | break; |
@@ -1873,7 +1968,7 @@ static int process_stat_round_event(struct perf_tool *tool __maybe_unused, | |||
1873 | struct stat_round_event *round = &event->stat_round; | 1968 | struct stat_round_event *round = &event->stat_round; |
1874 | struct perf_evsel *counter; | 1969 | struct perf_evsel *counter; |
1875 | 1970 | ||
1876 | evlist__for_each(session->evlist, counter) { | 1971 | evlist__for_each_entry(session->evlist, counter) { |
1877 | perf_stat_process_counter(&stat_config, counter); | 1972 | perf_stat_process_counter(&stat_config, counter); |
1878 | process_stat(counter, round->time); | 1973 | process_stat(counter, round->time); |
1879 | } | 1974 | } |
@@ -2020,7 +2115,8 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused) | |||
2020 | "comma separated output fields prepend with 'type:'. " | 2115 | "comma separated output fields prepend with 'type:'. " |
2021 | "Valid types: hw,sw,trace,raw. " | 2116 | "Valid types: hw,sw,trace,raw. " |
2022 | "Fields: comm,tid,pid,time,cpu,event,trace,ip,sym,dso," | 2117 | "Fields: comm,tid,pid,time,cpu,event,trace,ip,sym,dso," |
2023 | "addr,symoff,period,iregs,brstack,brstacksym,flags", parse_output_fields), | 2118 | "addr,symoff,period,iregs,brstack,brstacksym,flags," |
2119 | "callindent", parse_output_fields), | ||
2024 | OPT_BOOLEAN('a', "all-cpus", &system_wide, | 2120 | OPT_BOOLEAN('a', "all-cpus", &system_wide, |
2025 | "system-wide collection from all CPUs"), | 2121 | "system-wide collection from all CPUs"), |
2026 | OPT_STRING('S', "symbols", &symbol_conf.sym_list_str, "symbol[,symbol...]", | 2122 | OPT_STRING('S', "symbols", &symbol_conf.sym_list_str, "symbol[,symbol...]", |
@@ -2259,6 +2355,9 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused) | |||
2259 | script.session = session; | 2355 | script.session = session; |
2260 | script__setup_sample_type(&script); | 2356 | script__setup_sample_type(&script); |
2261 | 2357 | ||
2358 | if (output[PERF_TYPE_HARDWARE].fields & PERF_OUTPUT_CALLINDENT) | ||
2359 | itrace_synth_opts.thread_stack = true; | ||
2360 | |||
2262 | session->itrace_synth_opts = &itrace_synth_opts; | 2361 | session->itrace_synth_opts = &itrace_synth_opts; |
2263 | 2362 | ||
2264 | if (cpu_list) { | 2363 | if (cpu_list) { |
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index dff63733dfb7..c367a43525e6 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c | |||
@@ -331,7 +331,7 @@ static void read_counters(bool close_counters) | |||
331 | { | 331 | { |
332 | struct perf_evsel *counter; | 332 | struct perf_evsel *counter; |
333 | 333 | ||
334 | evlist__for_each(evsel_list, counter) { | 334 | evlist__for_each_entry(evsel_list, counter) { |
335 | if (read_counter(counter)) | 335 | if (read_counter(counter)) |
336 | pr_debug("failed to read counter %s\n", counter->name); | 336 | pr_debug("failed to read counter %s\n", counter->name); |
337 | 337 | ||
@@ -417,7 +417,7 @@ static int perf_stat_synthesize_config(bool is_pipe) | |||
417 | * Synthesize other events stuff not carried within | 417 | * Synthesize other events stuff not carried within |
418 | * attr event - unit, scale, name | 418 | * attr event - unit, scale, name |
419 | */ | 419 | */ |
420 | evlist__for_each(evsel_list, counter) { | 420 | evlist__for_each_entry(evsel_list, counter) { |
421 | if (!counter->supported) | 421 | if (!counter->supported) |
422 | continue; | 422 | continue; |
423 | 423 | ||
@@ -550,7 +550,7 @@ static int __run_perf_stat(int argc, const char **argv) | |||
550 | if (group) | 550 | if (group) |
551 | perf_evlist__set_leader(evsel_list); | 551 | perf_evlist__set_leader(evsel_list); |
552 | 552 | ||
553 | evlist__for_each(evsel_list, counter) { | 553 | evlist__for_each_entry(evsel_list, counter) { |
554 | try_again: | 554 | try_again: |
555 | if (create_perf_stat_counter(counter) < 0) { | 555 | if (create_perf_stat_counter(counter) < 0) { |
556 | /* | 556 | /* |
@@ -1134,7 +1134,7 @@ static void aggr_update_shadow(void) | |||
1134 | 1134 | ||
1135 | for (s = 0; s < aggr_map->nr; s++) { | 1135 | for (s = 0; s < aggr_map->nr; s++) { |
1136 | id = aggr_map->map[s]; | 1136 | id = aggr_map->map[s]; |
1137 | evlist__for_each(evsel_list, counter) { | 1137 | evlist__for_each_entry(evsel_list, counter) { |
1138 | val = 0; | 1138 | val = 0; |
1139 | for (cpu = 0; cpu < perf_evsel__nr_cpus(counter); cpu++) { | 1139 | for (cpu = 0; cpu < perf_evsel__nr_cpus(counter); cpu++) { |
1140 | s2 = aggr_get_id(evsel_list->cpus, cpu); | 1140 | s2 = aggr_get_id(evsel_list->cpus, cpu); |
@@ -1173,7 +1173,7 @@ static void print_aggr(char *prefix) | |||
1173 | 1173 | ||
1174 | id = aggr_map->map[s]; | 1174 | id = aggr_map->map[s]; |
1175 | first = true; | 1175 | first = true; |
1176 | evlist__for_each(evsel_list, counter) { | 1176 | evlist__for_each_entry(evsel_list, counter) { |
1177 | val = ena = run = 0; | 1177 | val = ena = run = 0; |
1178 | nr = 0; | 1178 | nr = 0; |
1179 | for (cpu = 0; cpu < perf_evsel__nr_cpus(counter); cpu++) { | 1179 | for (cpu = 0; cpu < perf_evsel__nr_cpus(counter); cpu++) { |
@@ -1292,7 +1292,7 @@ static void print_no_aggr_metric(char *prefix) | |||
1292 | 1292 | ||
1293 | if (prefix) | 1293 | if (prefix) |
1294 | fputs(prefix, stat_config.output); | 1294 | fputs(prefix, stat_config.output); |
1295 | evlist__for_each(evsel_list, counter) { | 1295 | evlist__for_each_entry(evsel_list, counter) { |
1296 | if (first) { | 1296 | if (first) { |
1297 | aggr_printout(counter, cpu, 0); | 1297 | aggr_printout(counter, cpu, 0); |
1298 | first = false; | 1298 | first = false; |
@@ -1346,7 +1346,7 @@ static void print_metric_headers(const char *prefix, bool no_indent) | |||
1346 | } | 1346 | } |
1347 | 1347 | ||
1348 | /* Print metrics headers only */ | 1348 | /* Print metrics headers only */ |
1349 | evlist__for_each(evsel_list, counter) { | 1349 | evlist__for_each_entry(evsel_list, counter) { |
1350 | os.evsel = counter; | 1350 | os.evsel = counter; |
1351 | out.ctx = &os; | 1351 | out.ctx = &os; |
1352 | out.print_metric = print_metric_header; | 1352 | out.print_metric = print_metric_header; |
@@ -1482,11 +1482,11 @@ static void print_counters(struct timespec *ts, int argc, const char **argv) | |||
1482 | print_aggr(prefix); | 1482 | print_aggr(prefix); |
1483 | break; | 1483 | break; |
1484 | case AGGR_THREAD: | 1484 | case AGGR_THREAD: |
1485 | evlist__for_each(evsel_list, counter) | 1485 | evlist__for_each_entry(evsel_list, counter) |
1486 | print_aggr_thread(counter, prefix); | 1486 | print_aggr_thread(counter, prefix); |
1487 | break; | 1487 | break; |
1488 | case AGGR_GLOBAL: | 1488 | case AGGR_GLOBAL: |
1489 | evlist__for_each(evsel_list, counter) | 1489 | evlist__for_each_entry(evsel_list, counter) |
1490 | print_counter_aggr(counter, prefix); | 1490 | print_counter_aggr(counter, prefix); |
1491 | if (metric_only) | 1491 | if (metric_only) |
1492 | fputc('\n', stat_config.output); | 1492 | fputc('\n', stat_config.output); |
@@ -1495,7 +1495,7 @@ static void print_counters(struct timespec *ts, int argc, const char **argv) | |||
1495 | if (metric_only) | 1495 | if (metric_only) |
1496 | print_no_aggr_metric(prefix); | 1496 | print_no_aggr_metric(prefix); |
1497 | else { | 1497 | else { |
1498 | evlist__for_each(evsel_list, counter) | 1498 | evlist__for_each_entry(evsel_list, counter) |
1499 | print_counter(counter, prefix); | 1499 | print_counter(counter, prefix); |
1500 | } | 1500 | } |
1501 | break; | 1501 | break; |
@@ -2149,7 +2149,7 @@ static int process_stat_round_event(struct perf_tool *tool __maybe_unused, | |||
2149 | const char **argv = session->header.env.cmdline_argv; | 2149 | const char **argv = session->header.env.cmdline_argv; |
2150 | int argc = session->header.env.nr_cmdline; | 2150 | int argc = session->header.env.nr_cmdline; |
2151 | 2151 | ||
2152 | evlist__for_each(evsel_list, counter) | 2152 | evlist__for_each_entry(evsel_list, counter) |
2153 | perf_stat_process_counter(&stat_config, counter); | 2153 | perf_stat_process_counter(&stat_config, counter); |
2154 | 2154 | ||
2155 | if (stat_round->type == PERF_STAT_ROUND_TYPE__FINAL) | 2155 | if (stat_round->type == PERF_STAT_ROUND_TYPE__FINAL) |
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index 81dba80a42b5..07fc7921980c 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c | |||
@@ -22,7 +22,7 @@ | |||
22 | #include "perf.h" | 22 | #include "perf.h" |
23 | 23 | ||
24 | #include "util/annotate.h" | 24 | #include "util/annotate.h" |
25 | #include "util/cache.h" | 25 | #include "util/config.h" |
26 | #include "util/color.h" | 26 | #include "util/color.h" |
27 | #include "util/evlist.h" | 27 | #include "util/evlist.h" |
28 | #include "util/evsel.h" | 28 | #include "util/evsel.h" |
@@ -479,7 +479,7 @@ static bool perf_top__handle_keypress(struct perf_top *top, int c) | |||
479 | 479 | ||
480 | fprintf(stderr, "\nAvailable events:"); | 480 | fprintf(stderr, "\nAvailable events:"); |
481 | 481 | ||
482 | evlist__for_each(top->evlist, top->sym_evsel) | 482 | evlist__for_each_entry(top->evlist, top->sym_evsel) |
483 | fprintf(stderr, "\n\t%d %s", top->sym_evsel->idx, perf_evsel__name(top->sym_evsel)); | 483 | fprintf(stderr, "\n\t%d %s", top->sym_evsel->idx, perf_evsel__name(top->sym_evsel)); |
484 | 484 | ||
485 | prompt_integer(&counter, "Enter details event counter"); | 485 | prompt_integer(&counter, "Enter details event counter"); |
@@ -490,7 +490,7 @@ static bool perf_top__handle_keypress(struct perf_top *top, int c) | |||
490 | sleep(1); | 490 | sleep(1); |
491 | break; | 491 | break; |
492 | } | 492 | } |
493 | evlist__for_each(top->evlist, top->sym_evsel) | 493 | evlist__for_each_entry(top->evlist, top->sym_evsel) |
494 | if (top->sym_evsel->idx == counter) | 494 | if (top->sym_evsel->idx == counter) |
495 | break; | 495 | break; |
496 | } else | 496 | } else |
@@ -583,7 +583,7 @@ static void *display_thread_tui(void *arg) | |||
583 | * Zooming in/out UIDs. For now juse use whatever the user passed | 583 | * Zooming in/out UIDs. For now juse use whatever the user passed |
584 | * via --uid. | 584 | * via --uid. |
585 | */ | 585 | */ |
586 | evlist__for_each(top->evlist, pos) { | 586 | evlist__for_each_entry(top->evlist, pos) { |
587 | struct hists *hists = evsel__hists(pos); | 587 | struct hists *hists = evsel__hists(pos); |
588 | hists->uid_filter_str = top->record_opts.target.uid_str; | 588 | hists->uid_filter_str = top->record_opts.target.uid_str; |
589 | } | 589 | } |
@@ -888,7 +888,7 @@ static int perf_top__start_counters(struct perf_top *top) | |||
888 | 888 | ||
889 | perf_evlist__config(evlist, opts, &callchain_param); | 889 | perf_evlist__config(evlist, opts, &callchain_param); |
890 | 890 | ||
891 | evlist__for_each(evlist, counter) { | 891 | evlist__for_each_entry(evlist, counter) { |
892 | try_again: | 892 | try_again: |
893 | if (perf_evsel__open(counter, top->evlist->cpus, | 893 | if (perf_evsel__open(counter, top->evlist->cpus, |
894 | top->evlist->threads) < 0) { | 894 | top->evlist->threads) < 0) { |
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 5c50fe70d6b3..cf90de811523 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c | |||
@@ -1247,7 +1247,7 @@ static int trace__validate_ev_qualifier(struct trace *trace) | |||
1247 | 1247 | ||
1248 | i = 0; | 1248 | i = 0; |
1249 | 1249 | ||
1250 | strlist__for_each(pos, trace->ev_qualifier) { | 1250 | strlist__for_each_entry(pos, trace->ev_qualifier) { |
1251 | const char *sc = pos->s; | 1251 | const char *sc = pos->s; |
1252 | int id = syscalltbl__id(trace->sctbl, sc); | 1252 | int id = syscalltbl__id(trace->sctbl, sc); |
1253 | 1253 | ||
@@ -2483,7 +2483,7 @@ static int trace__replay(struct trace *trace) | |||
2483 | goto out; | 2483 | goto out; |
2484 | } | 2484 | } |
2485 | 2485 | ||
2486 | evlist__for_each(session->evlist, evsel) { | 2486 | evlist__for_each_entry(session->evlist, evsel) { |
2487 | if (evsel->attr.type == PERF_TYPE_SOFTWARE && | 2487 | if (evsel->attr.type == PERF_TYPE_SOFTWARE && |
2488 | (evsel->attr.config == PERF_COUNT_SW_PAGE_FAULTS_MAJ || | 2488 | (evsel->attr.config == PERF_COUNT_SW_PAGE_FAULTS_MAJ || |
2489 | evsel->attr.config == PERF_COUNT_SW_PAGE_FAULTS_MIN || | 2489 | evsel->attr.config == PERF_COUNT_SW_PAGE_FAULTS_MIN || |
@@ -2550,7 +2550,7 @@ static size_t thread__dump_stats(struct thread_trace *ttrace, | |||
2550 | printed += fprintf(fp, " (msec) (msec) (msec) (msec) (%%)\n"); | 2550 | printed += fprintf(fp, " (msec) (msec) (msec) (msec) (%%)\n"); |
2551 | printed += fprintf(fp, " --------------- -------- --------- --------- --------- --------- ------\n"); | 2551 | printed += fprintf(fp, " --------------- -------- --------- --------- --------- --------- ------\n"); |
2552 | 2552 | ||
2553 | resort_rb__for_each(nd, syscall_stats) { | 2553 | resort_rb__for_each_entry(nd, syscall_stats) { |
2554 | struct stats *stats = syscall_stats_entry->stats; | 2554 | struct stats *stats = syscall_stats_entry->stats; |
2555 | if (stats) { | 2555 | if (stats) { |
2556 | double min = (double)(stats->min) / NSEC_PER_MSEC; | 2556 | double min = (double)(stats->min) / NSEC_PER_MSEC; |
@@ -2627,7 +2627,7 @@ static size_t trace__fprintf_thread_summary(struct trace *trace, FILE *fp) | |||
2627 | return 0; | 2627 | return 0; |
2628 | } | 2628 | } |
2629 | 2629 | ||
2630 | resort_rb__for_each(nd, threads) | 2630 | resort_rb__for_each_entry(nd, threads) |
2631 | printed += trace__fprintf_thread(fp, threads_entry->thread, trace); | 2631 | printed += trace__fprintf_thread(fp, threads_entry->thread, trace); |
2632 | 2632 | ||
2633 | resort_rb__delete(threads); | 2633 | resort_rb__delete(threads); |
@@ -2714,7 +2714,7 @@ static void evlist__set_evsel_handler(struct perf_evlist *evlist, void *handler) | |||
2714 | { | 2714 | { |
2715 | struct perf_evsel *evsel; | 2715 | struct perf_evsel *evsel; |
2716 | 2716 | ||
2717 | evlist__for_each(evlist, evsel) | 2717 | evlist__for_each_entry(evlist, evsel) |
2718 | evsel->handler = handler; | 2718 | evsel->handler = handler; |
2719 | } | 2719 | } |
2720 | 2720 | ||
diff --git a/tools/perf/perf.c b/tools/perf/perf.c index 634bf7c6c477..8f219223f305 100644 --- a/tools/perf/perf.c +++ b/tools/perf/perf.c | |||
@@ -10,7 +10,7 @@ | |||
10 | 10 | ||
11 | #include "util/env.h" | 11 | #include "util/env.h" |
12 | #include <subcmd/exec-cmd.h> | 12 | #include <subcmd/exec-cmd.h> |
13 | #include "util/cache.h" | 13 | #include "util/config.h" |
14 | #include "util/quote.h" | 14 | #include "util/quote.h" |
15 | #include <subcmd/run-command.h> | 15 | #include <subcmd/run-command.h> |
16 | #include "util/parse-events.h" | 16 | #include "util/parse-events.h" |
@@ -355,6 +355,7 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv) | |||
355 | 355 | ||
356 | perf_env__set_cmdline(&perf_env, argc, argv); | 356 | perf_env__set_cmdline(&perf_env, argc, argv); |
357 | status = p->fn(argc, argv, prefix); | 357 | status = p->fn(argc, argv, prefix); |
358 | perf_config__exit(); | ||
358 | exit_browser(status); | 359 | exit_browser(status); |
359 | perf_env__exit(&perf_env); | 360 | perf_env__exit(&perf_env); |
360 | bpf__clear(); | 361 | bpf__clear(); |
@@ -522,6 +523,7 @@ int main(int argc, const char **argv) | |||
522 | 523 | ||
523 | srandom(time(NULL)); | 524 | srandom(time(NULL)); |
524 | 525 | ||
526 | perf_config__init(); | ||
525 | perf_config(perf_default_config, NULL); | 527 | perf_config(perf_default_config, NULL); |
526 | set_buildid_dir(NULL); | 528 | set_buildid_dir(NULL); |
527 | 529 | ||
diff --git a/tools/perf/scripts/python/stackcollapse.py b/tools/perf/scripts/python/stackcollapse.py index a2dfcda41ae6..5a605f70ef32 100755 --- a/tools/perf/scripts/python/stackcollapse.py +++ b/tools/perf/scripts/python/stackcollapse.py | |||
@@ -1,5 +1,3 @@ | |||
1 | #!/usr/bin/perl -w | ||
2 | # | ||
3 | # stackcollapse.py - format perf samples with one line per distinct call stack | 1 | # stackcollapse.py - format perf samples with one line per distinct call stack |
4 | # | 2 | # |
5 | # This script's output has two space-separated fields. The first is a semicolon | 3 | # This script's output has two space-separated fields. The first is a semicolon |
diff --git a/tools/perf/tests/backward-ring-buffer.c b/tools/perf/tests/backward-ring-buffer.c index d9ba991a9a30..e70313fac5a5 100644 --- a/tools/perf/tests/backward-ring-buffer.c +++ b/tools/perf/tests/backward-ring-buffer.c | |||
@@ -118,7 +118,7 @@ int test__backward_ring_buffer(int subtest __maybe_unused) | |||
118 | perf_evlist__config(evlist, &opts, NULL); | 118 | perf_evlist__config(evlist, &opts, NULL); |
119 | 119 | ||
120 | /* Set backward bit, ring buffer should be writing from end */ | 120 | /* Set backward bit, ring buffer should be writing from end */ |
121 | evlist__for_each(evlist, evsel) | 121 | evlist__for_each_entry(evlist, evsel) |
122 | evsel->attr.write_backward = 1; | 122 | evsel->attr.write_backward = 1; |
123 | 123 | ||
124 | err = perf_evlist__open(evlist); | 124 | err = perf_evlist__open(evlist); |
diff --git a/tools/perf/tests/event-times.c b/tools/perf/tests/event-times.c index 95fb744f6628..9f5698ac81ae 100644 --- a/tools/perf/tests/event-times.c +++ b/tools/perf/tests/event-times.c | |||
@@ -200,8 +200,7 @@ static int test_times(int (attach)(struct perf_evlist *), | |||
200 | count.ena, count.run); | 200 | count.ena, count.run); |
201 | 201 | ||
202 | out_err: | 202 | out_err: |
203 | if (evlist) | 203 | perf_evlist__delete(evlist); |
204 | perf_evlist__delete(evlist); | ||
205 | return !err ? TEST_OK : TEST_FAIL; | 204 | return !err ? TEST_OK : TEST_FAIL; |
206 | } | 205 | } |
207 | 206 | ||
diff --git a/tools/perf/tests/evsel-roundtrip-name.c b/tools/perf/tests/evsel-roundtrip-name.c index 2de4a4f2c3ed..60926a1f6fd7 100644 --- a/tools/perf/tests/evsel-roundtrip-name.c +++ b/tools/perf/tests/evsel-roundtrip-name.c | |||
@@ -80,7 +80,7 @@ static int __perf_evsel__name_array_test(const char *names[], int nr_names) | |||
80 | } | 80 | } |
81 | 81 | ||
82 | err = 0; | 82 | err = 0; |
83 | evlist__for_each(evlist, evsel) { | 83 | evlist__for_each_entry(evlist, evsel) { |
84 | if (strcmp(perf_evsel__name(evsel), names[evsel->idx])) { | 84 | if (strcmp(perf_evsel__name(evsel), names[evsel->idx])) { |
85 | --err; | 85 | --err; |
86 | pr_debug("%s != %s\n", perf_evsel__name(evsel), names[evsel->idx]); | 86 | pr_debug("%s != %s\n", perf_evsel__name(evsel), names[evsel->idx]); |
diff --git a/tools/perf/tests/hists_filter.c b/tools/perf/tests/hists_filter.c index e846f8c42013..62efb14f3a5a 100644 --- a/tools/perf/tests/hists_filter.c +++ b/tools/perf/tests/hists_filter.c | |||
@@ -56,7 +56,7 @@ static int add_hist_entries(struct perf_evlist *evlist, | |||
56 | * (perf [perf] main) will be collapsed to an existing entry | 56 | * (perf [perf] main) will be collapsed to an existing entry |
57 | * so total 9 entries will be in the tree. | 57 | * so total 9 entries will be in the tree. |
58 | */ | 58 | */ |
59 | evlist__for_each(evlist, evsel) { | 59 | evlist__for_each_entry(evlist, evsel) { |
60 | for (i = 0; i < ARRAY_SIZE(fake_samples); i++) { | 60 | for (i = 0; i < ARRAY_SIZE(fake_samples); i++) { |
61 | struct hist_entry_iter iter = { | 61 | struct hist_entry_iter iter = { |
62 | .evsel = evsel, | 62 | .evsel = evsel, |
@@ -136,7 +136,7 @@ int test__hists_filter(int subtest __maybe_unused) | |||
136 | if (err < 0) | 136 | if (err < 0) |
137 | goto out; | 137 | goto out; |
138 | 138 | ||
139 | evlist__for_each(evlist, evsel) { | 139 | evlist__for_each_entry(evlist, evsel) { |
140 | struct hists *hists = evsel__hists(evsel); | 140 | struct hists *hists = evsel__hists(evsel); |
141 | 141 | ||
142 | hists__collapse_resort(hists, NULL); | 142 | hists__collapse_resort(hists, NULL); |
diff --git a/tools/perf/tests/hists_link.c b/tools/perf/tests/hists_link.c index 6f96ca4d4fc0..eddc7407ff8a 100644 --- a/tools/perf/tests/hists_link.c +++ b/tools/perf/tests/hists_link.c | |||
@@ -72,7 +72,7 @@ static int add_hist_entries(struct perf_evlist *evlist, struct machine *machine) | |||
72 | * However the second evsel also has a collapsed entry for | 72 | * However the second evsel also has a collapsed entry for |
73 | * "bash [libc] malloc" so total 9 entries will be in the tree. | 73 | * "bash [libc] malloc" so total 9 entries will be in the tree. |
74 | */ | 74 | */ |
75 | evlist__for_each(evlist, evsel) { | 75 | evlist__for_each_entry(evlist, evsel) { |
76 | struct hists *hists = evsel__hists(evsel); | 76 | struct hists *hists = evsel__hists(evsel); |
77 | 77 | ||
78 | for (k = 0; k < ARRAY_SIZE(fake_common_samples); k++) { | 78 | for (k = 0; k < ARRAY_SIZE(fake_common_samples); k++) { |
@@ -301,7 +301,7 @@ int test__hists_link(int subtest __maybe_unused) | |||
301 | if (err < 0) | 301 | if (err < 0) |
302 | goto out; | 302 | goto out; |
303 | 303 | ||
304 | evlist__for_each(evlist, evsel) { | 304 | evlist__for_each_entry(evlist, evsel) { |
305 | hists = evsel__hists(evsel); | 305 | hists = evsel__hists(evsel); |
306 | hists__collapse_resort(hists, NULL); | 306 | hists__collapse_resort(hists, NULL); |
307 | 307 | ||
diff --git a/tools/perf/tests/mmap-basic.c b/tools/perf/tests/mmap-basic.c index 359e98fcd94c..aea33f5589c5 100644 --- a/tools/perf/tests/mmap-basic.c +++ b/tools/perf/tests/mmap-basic.c | |||
@@ -126,7 +126,7 @@ int test__basic_mmap(int subtest __maybe_unused) | |||
126 | } | 126 | } |
127 | 127 | ||
128 | err = 0; | 128 | err = 0; |
129 | evlist__for_each(evlist, evsel) { | 129 | evlist__for_each_entry(evlist, evsel) { |
130 | if (nr_events[evsel->idx] != expected_nr_events[evsel->idx]) { | 130 | if (nr_events[evsel->idx] != expected_nr_events[evsel->idx]) { |
131 | pr_debug("expected %d %s events, got %d\n", | 131 | pr_debug("expected %d %s events, got %d\n", |
132 | expected_nr_events[evsel->idx], | 132 | expected_nr_events[evsel->idx], |
diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c index b2a2c74136a5..20c2e641c422 100644 --- a/tools/perf/tests/parse-events.c +++ b/tools/perf/tests/parse-events.c | |||
@@ -32,7 +32,7 @@ static int test__checkevent_tracepoint_multi(struct perf_evlist *evlist) | |||
32 | TEST_ASSERT_VAL("wrong number of entries", evlist->nr_entries > 1); | 32 | TEST_ASSERT_VAL("wrong number of entries", evlist->nr_entries > 1); |
33 | TEST_ASSERT_VAL("wrong number of groups", 0 == evlist->nr_groups); | 33 | TEST_ASSERT_VAL("wrong number of groups", 0 == evlist->nr_groups); |
34 | 34 | ||
35 | evlist__for_each(evlist, evsel) { | 35 | evlist__for_each_entry(evlist, evsel) { |
36 | TEST_ASSERT_VAL("wrong type", | 36 | TEST_ASSERT_VAL("wrong type", |
37 | PERF_TYPE_TRACEPOINT == evsel->attr.type); | 37 | PERF_TYPE_TRACEPOINT == evsel->attr.type); |
38 | TEST_ASSERT_VAL("wrong sample_type", | 38 | TEST_ASSERT_VAL("wrong sample_type", |
@@ -207,7 +207,7 @@ test__checkevent_tracepoint_multi_modifier(struct perf_evlist *evlist) | |||
207 | 207 | ||
208 | TEST_ASSERT_VAL("wrong number of entries", evlist->nr_entries > 1); | 208 | TEST_ASSERT_VAL("wrong number of entries", evlist->nr_entries > 1); |
209 | 209 | ||
210 | evlist__for_each(evlist, evsel) { | 210 | evlist__for_each_entry(evlist, evsel) { |
211 | TEST_ASSERT_VAL("wrong exclude_user", | 211 | TEST_ASSERT_VAL("wrong exclude_user", |
212 | !evsel->attr.exclude_user); | 212 | !evsel->attr.exclude_user); |
213 | TEST_ASSERT_VAL("wrong exclude_kernel", | 213 | TEST_ASSERT_VAL("wrong exclude_kernel", |
diff --git a/tools/perf/tests/parse-no-sample-id-all.c b/tools/perf/tests/parse-no-sample-id-all.c index 294c76b01b41..81c6eeaca0f5 100644 --- a/tools/perf/tests/parse-no-sample-id-all.c +++ b/tools/perf/tests/parse-no-sample-id-all.c | |||
@@ -44,8 +44,7 @@ static int process_events(union perf_event **events, size_t count) | |||
44 | for (i = 0; i < count && !err; i++) | 44 | for (i = 0; i < count && !err; i++) |
45 | err = process_event(&evlist, events[i]); | 45 | err = process_event(&evlist, events[i]); |
46 | 46 | ||
47 | if (evlist) | 47 | perf_evlist__delete(evlist); |
48 | perf_evlist__delete(evlist); | ||
49 | 48 | ||
50 | return err; | 49 | return err; |
51 | } | 50 | } |
diff --git a/tools/perf/tests/switch-tracking.c b/tools/perf/tests/switch-tracking.c index 39a689bf7574..7ddbe267d0ac 100644 --- a/tools/perf/tests/switch-tracking.c +++ b/tools/perf/tests/switch-tracking.c | |||
@@ -432,7 +432,7 @@ int test__switch_tracking(int subtest __maybe_unused) | |||
432 | } | 432 | } |
433 | 433 | ||
434 | /* Check non-tracking events are not tracking */ | 434 | /* Check non-tracking events are not tracking */ |
435 | evlist__for_each(evlist, evsel) { | 435 | evlist__for_each_entry(evlist, evsel) { |
436 | if (evsel != tracking_evsel) { | 436 | if (evsel != tracking_evsel) { |
437 | if (evsel->attr.mmap || evsel->attr.comm) { | 437 | if (evsel->attr.mmap || evsel->attr.comm) { |
438 | pr_debug("Non-tracking event is tracking\n"); | 438 | pr_debug("Non-tracking event is tracking\n"); |
diff --git a/tools/perf/ui/browser.c b/tools/perf/ui/browser.c index af68a9d488bf..3eb3edb307a4 100644 --- a/tools/perf/ui/browser.c +++ b/tools/perf/ui/browser.c | |||
@@ -1,5 +1,5 @@ | |||
1 | #include "../util.h" | 1 | #include "../util.h" |
2 | #include "../cache.h" | 2 | #include "../config.h" |
3 | #include "../../perf.h" | 3 | #include "../../perf.h" |
4 | #include "libslang.h" | 4 | #include "libslang.h" |
5 | #include "ui.h" | 5 | #include "ui.h" |
diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c index 4fc208e82c6f..0e106bb97525 100644 --- a/tools/perf/ui/browsers/annotate.c +++ b/tools/perf/ui/browsers/annotate.c | |||
@@ -8,6 +8,7 @@ | |||
8 | #include "../../util/sort.h" | 8 | #include "../../util/sort.h" |
9 | #include "../../util/symbol.h" | 9 | #include "../../util/symbol.h" |
10 | #include "../../util/evsel.h" | 10 | #include "../../util/evsel.h" |
11 | #include "../../util/config.h" | ||
11 | #include <pthread.h> | 12 | #include <pthread.h> |
12 | 13 | ||
13 | struct disasm_line_samples { | 14 | struct disasm_line_samples { |
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c index b1b60544a545..e08b8f7b6d3f 100644 --- a/tools/perf/ui/browsers/hists.c +++ b/tools/perf/ui/browsers/hists.c | |||
@@ -12,35 +12,17 @@ | |||
12 | #include "../../util/top.h" | 12 | #include "../../util/top.h" |
13 | #include "../../arch/common.h" | 13 | #include "../../arch/common.h" |
14 | 14 | ||
15 | #include "../browser.h" | 15 | #include "../browsers/hists.h" |
16 | #include "../helpline.h" | 16 | #include "../helpline.h" |
17 | #include "../util.h" | 17 | #include "../util.h" |
18 | #include "../ui.h" | 18 | #include "../ui.h" |
19 | #include "map.h" | 19 | #include "map.h" |
20 | #include "annotate.h" | 20 | #include "annotate.h" |
21 | 21 | ||
22 | struct hist_browser { | ||
23 | struct ui_browser b; | ||
24 | struct hists *hists; | ||
25 | struct hist_entry *he_selection; | ||
26 | struct map_symbol *selection; | ||
27 | struct hist_browser_timer *hbt; | ||
28 | struct pstack *pstack; | ||
29 | struct perf_env *env; | ||
30 | int print_seq; | ||
31 | bool show_dso; | ||
32 | bool show_headers; | ||
33 | float min_pcnt; | ||
34 | u64 nr_non_filtered_entries; | ||
35 | u64 nr_hierarchy_entries; | ||
36 | u64 nr_callchain_rows; | ||
37 | }; | ||
38 | |||
39 | extern void hist_browser__init_hpp(void); | 22 | extern void hist_browser__init_hpp(void); |
40 | 23 | ||
41 | static int hists__browser_title(struct hists *hists, | 24 | static int perf_evsel_browser_title(struct hist_browser *browser, |
42 | struct hist_browser_timer *hbt, | 25 | char *bf, size_t size); |
43 | char *bf, size_t size); | ||
44 | static void hist_browser__update_nr_entries(struct hist_browser *hb); | 26 | static void hist_browser__update_nr_entries(struct hist_browser *hb); |
45 | 27 | ||
46 | static struct rb_node *hists__filter_entries(struct rb_node *nd, | 28 | static struct rb_node *hists__filter_entries(struct rb_node *nd, |
@@ -585,7 +567,12 @@ static void ui_browser__warn_lost_events(struct ui_browser *browser) | |||
585 | "Or reduce the sampling frequency."); | 567 | "Or reduce the sampling frequency."); |
586 | } | 568 | } |
587 | 569 | ||
588 | static int hist_browser__run(struct hist_browser *browser, const char *help) | 570 | static int hist_browser__title(struct hist_browser *browser, char *bf, size_t size) |
571 | { | ||
572 | return browser->title ? browser->title(browser, bf, size) : 0; | ||
573 | } | ||
574 | |||
575 | int hist_browser__run(struct hist_browser *browser, const char *help) | ||
589 | { | 576 | { |
590 | int key; | 577 | int key; |
591 | char title[160]; | 578 | char title[160]; |
@@ -595,7 +582,7 @@ static int hist_browser__run(struct hist_browser *browser, const char *help) | |||
595 | browser->b.entries = &browser->hists->entries; | 582 | browser->b.entries = &browser->hists->entries; |
596 | browser->b.nr_entries = hist_browser__nr_entries(browser); | 583 | browser->b.nr_entries = hist_browser__nr_entries(browser); |
597 | 584 | ||
598 | hists__browser_title(browser->hists, hbt, title, sizeof(title)); | 585 | hist_browser__title(browser, title, sizeof(title)); |
599 | 586 | ||
600 | if (ui_browser__show(&browser->b, title, "%s", help) < 0) | 587 | if (ui_browser__show(&browser->b, title, "%s", help) < 0) |
601 | return -1; | 588 | return -1; |
@@ -621,8 +608,7 @@ static int hist_browser__run(struct hist_browser *browser, const char *help) | |||
621 | ui_browser__warn_lost_events(&browser->b); | 608 | ui_browser__warn_lost_events(&browser->b); |
622 | } | 609 | } |
623 | 610 | ||
624 | hists__browser_title(browser->hists, | 611 | hist_browser__title(browser, title, sizeof(title)); |
625 | hbt, title, sizeof(title)); | ||
626 | ui_browser__show_title(&browser->b, title); | 612 | ui_browser__show_title(&browser->b, title); |
627 | continue; | 613 | continue; |
628 | } | 614 | } |
@@ -2056,27 +2042,50 @@ static int hist_browser__dump(struct hist_browser *browser) | |||
2056 | return 0; | 2042 | return 0; |
2057 | } | 2043 | } |
2058 | 2044 | ||
2059 | static struct hist_browser *hist_browser__new(struct hists *hists, | 2045 | void hist_browser__init(struct hist_browser *browser, |
2060 | struct hist_browser_timer *hbt, | 2046 | struct hists *hists) |
2061 | struct perf_env *env) | 2047 | { |
2048 | struct perf_hpp_fmt *fmt; | ||
2049 | |||
2050 | browser->hists = hists; | ||
2051 | browser->b.refresh = hist_browser__refresh; | ||
2052 | browser->b.refresh_dimensions = hist_browser__refresh_dimensions; | ||
2053 | browser->b.seek = ui_browser__hists_seek; | ||
2054 | browser->b.use_navkeypressed = true; | ||
2055 | browser->show_headers = symbol_conf.show_hist_headers; | ||
2056 | |||
2057 | hists__for_each_format(hists, fmt) { | ||
2058 | perf_hpp__reset_width(fmt, hists); | ||
2059 | ++browser->b.columns; | ||
2060 | } | ||
2061 | } | ||
2062 | |||
2063 | struct hist_browser *hist_browser__new(struct hists *hists) | ||
2062 | { | 2064 | { |
2063 | struct hist_browser *browser = zalloc(sizeof(*browser)); | 2065 | struct hist_browser *browser = zalloc(sizeof(*browser)); |
2064 | 2066 | ||
2067 | if (browser) | ||
2068 | hist_browser__init(browser, hists); | ||
2069 | |||
2070 | return browser; | ||
2071 | } | ||
2072 | |||
2073 | static struct hist_browser * | ||
2074 | perf_evsel_browser__new(struct perf_evsel *evsel, | ||
2075 | struct hist_browser_timer *hbt, | ||
2076 | struct perf_env *env) | ||
2077 | { | ||
2078 | struct hist_browser *browser = hist_browser__new(evsel__hists(evsel)); | ||
2079 | |||
2065 | if (browser) { | 2080 | if (browser) { |
2066 | browser->hists = hists; | 2081 | browser->hbt = hbt; |
2067 | browser->b.refresh = hist_browser__refresh; | 2082 | browser->env = env; |
2068 | browser->b.refresh_dimensions = hist_browser__refresh_dimensions; | 2083 | browser->title = perf_evsel_browser_title; |
2069 | browser->b.seek = ui_browser__hists_seek; | ||
2070 | browser->b.use_navkeypressed = true; | ||
2071 | browser->show_headers = symbol_conf.show_hist_headers; | ||
2072 | browser->hbt = hbt; | ||
2073 | browser->env = env; | ||
2074 | } | 2084 | } |
2075 | |||
2076 | return browser; | 2085 | return browser; |
2077 | } | 2086 | } |
2078 | 2087 | ||
2079 | static void hist_browser__delete(struct hist_browser *browser) | 2088 | void hist_browser__delete(struct hist_browser *browser) |
2080 | { | 2089 | { |
2081 | free(browser); | 2090 | free(browser); |
2082 | } | 2091 | } |
@@ -2097,10 +2106,11 @@ static inline bool is_report_browser(void *timer) | |||
2097 | return timer == NULL; | 2106 | return timer == NULL; |
2098 | } | 2107 | } |
2099 | 2108 | ||
2100 | static int hists__browser_title(struct hists *hists, | 2109 | static int perf_evsel_browser_title(struct hist_browser *browser, |
2101 | struct hist_browser_timer *hbt, | ||
2102 | char *bf, size_t size) | 2110 | char *bf, size_t size) |
2103 | { | 2111 | { |
2112 | struct hist_browser_timer *hbt = browser->hbt; | ||
2113 | struct hists *hists = browser->hists; | ||
2104 | char unit; | 2114 | char unit; |
2105 | int printed; | 2115 | int printed; |
2106 | const struct dso *dso = hists->dso_filter; | 2116 | const struct dso *dso = hists->dso_filter; |
@@ -2657,7 +2667,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events, | |||
2657 | struct perf_env *env) | 2667 | struct perf_env *env) |
2658 | { | 2668 | { |
2659 | struct hists *hists = evsel__hists(evsel); | 2669 | struct hists *hists = evsel__hists(evsel); |
2660 | struct hist_browser *browser = hist_browser__new(hists, hbt, env); | 2670 | struct hist_browser *browser = perf_evsel_browser__new(evsel, hbt, env); |
2661 | struct branch_info *bi; | 2671 | struct branch_info *bi; |
2662 | #define MAX_OPTIONS 16 | 2672 | #define MAX_OPTIONS 16 |
2663 | char *options[MAX_OPTIONS]; | 2673 | char *options[MAX_OPTIONS]; |
@@ -2666,7 +2676,6 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events, | |||
2666 | int key = -1; | 2676 | int key = -1; |
2667 | char buf[64]; | 2677 | char buf[64]; |
2668 | int delay_secs = hbt ? hbt->refresh : 0; | 2678 | int delay_secs = hbt ? hbt->refresh : 0; |
2669 | struct perf_hpp_fmt *fmt; | ||
2670 | 2679 | ||
2671 | #define HIST_BROWSER_HELP_COMMON \ | 2680 | #define HIST_BROWSER_HELP_COMMON \ |
2672 | "h/?/F1 Show this window\n" \ | 2681 | "h/?/F1 Show this window\n" \ |
@@ -2725,18 +2734,6 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events, | |||
2725 | memset(options, 0, sizeof(options)); | 2734 | memset(options, 0, sizeof(options)); |
2726 | memset(actions, 0, sizeof(actions)); | 2735 | memset(actions, 0, sizeof(actions)); |
2727 | 2736 | ||
2728 | hists__for_each_format(browser->hists, fmt) { | ||
2729 | perf_hpp__reset_width(fmt, hists); | ||
2730 | /* | ||
2731 | * This is done just once, and activates the horizontal scrolling | ||
2732 | * code in the ui_browser code, it would be better to have a the | ||
2733 | * counter in the perf_hpp code, but I couldn't find doing it here | ||
2734 | * works, FIXME by setting this in hist_browser__new, for now, be | ||
2735 | * clever 8-) | ||
2736 | */ | ||
2737 | ++browser->b.columns; | ||
2738 | } | ||
2739 | |||
2740 | if (symbol_conf.col_width_list_str) | 2737 | if (symbol_conf.col_width_list_str) |
2741 | perf_hpp__set_user_width(symbol_conf.col_width_list_str); | 2738 | perf_hpp__set_user_width(symbol_conf.col_width_list_str); |
2742 | 2739 | ||
@@ -3202,7 +3199,7 @@ static int __perf_evlist__tui_browse_hists(struct perf_evlist *evlist, | |||
3202 | 3199 | ||
3203 | ui_helpline__push("Press ESC to exit"); | 3200 | ui_helpline__push("Press ESC to exit"); |
3204 | 3201 | ||
3205 | evlist__for_each(evlist, pos) { | 3202 | evlist__for_each_entry(evlist, pos) { |
3206 | const char *ev_name = perf_evsel__name(pos); | 3203 | const char *ev_name = perf_evsel__name(pos); |
3207 | size_t line_len = strlen(ev_name) + 7; | 3204 | size_t line_len = strlen(ev_name) + 7; |
3208 | 3205 | ||
@@ -3233,7 +3230,7 @@ single_entry: | |||
3233 | struct perf_evsel *pos; | 3230 | struct perf_evsel *pos; |
3234 | 3231 | ||
3235 | nr_entries = 0; | 3232 | nr_entries = 0; |
3236 | evlist__for_each(evlist, pos) { | 3233 | evlist__for_each_entry(evlist, pos) { |
3237 | if (perf_evsel__is_group_leader(pos)) | 3234 | if (perf_evsel__is_group_leader(pos)) |
3238 | nr_entries++; | 3235 | nr_entries++; |
3239 | } | 3236 | } |
diff --git a/tools/perf/ui/browsers/hists.h b/tools/perf/ui/browsers/hists.h new file mode 100644 index 000000000000..39bd0f28f211 --- /dev/null +++ b/tools/perf/ui/browsers/hists.h | |||
@@ -0,0 +1,32 @@ | |||
1 | #ifndef _PERF_UI_BROWSER_HISTS_H_ | ||
2 | #define _PERF_UI_BROWSER_HISTS_H_ 1 | ||
3 | |||
4 | #include "ui/browser.h" | ||
5 | |||
6 | struct hist_browser { | ||
7 | struct ui_browser b; | ||
8 | struct hists *hists; | ||
9 | struct hist_entry *he_selection; | ||
10 | struct map_symbol *selection; | ||
11 | struct hist_browser_timer *hbt; | ||
12 | struct pstack *pstack; | ||
13 | struct perf_env *env; | ||
14 | int print_seq; | ||
15 | bool show_dso; | ||
16 | bool show_headers; | ||
17 | float min_pcnt; | ||
18 | u64 nr_non_filtered_entries; | ||
19 | u64 nr_hierarchy_entries; | ||
20 | u64 nr_callchain_rows; | ||
21 | |||
22 | /* Get title string. */ | ||
23 | int (*title)(struct hist_browser *browser, | ||
24 | char *bf, size_t size); | ||
25 | }; | ||
26 | |||
27 | struct hist_browser *hist_browser__new(struct hists *hists); | ||
28 | void hist_browser__delete(struct hist_browser *browser); | ||
29 | int hist_browser__run(struct hist_browser *browser, const char *help); | ||
30 | void hist_browser__init(struct hist_browser *browser, | ||
31 | struct hists *hists); | ||
32 | #endif /* _PERF_UI_BROWSER_HISTS_H_ */ | ||
diff --git a/tools/perf/ui/gtk/hists.c b/tools/perf/ui/gtk/hists.c index e5c1325b0340..c5f3677f6679 100644 --- a/tools/perf/ui/gtk/hists.c +++ b/tools/perf/ui/gtk/hists.c | |||
@@ -627,7 +627,7 @@ int perf_evlist__gtk_browse_hists(struct perf_evlist *evlist, | |||
627 | 627 | ||
628 | gtk_container_add(GTK_CONTAINER(window), vbox); | 628 | gtk_container_add(GTK_CONTAINER(window), vbox); |
629 | 629 | ||
630 | evlist__for_each(evlist, pos) { | 630 | evlist__for_each_entry(evlist, pos) { |
631 | struct hists *hists = evsel__hists(pos); | 631 | struct hists *hists = evsel__hists(pos); |
632 | const char *evname = perf_evsel__name(pos); | 632 | const char *evname = perf_evsel__name(pos); |
633 | GtkWidget *scrolled_window; | 633 | GtkWidget *scrolled_window; |
diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c index 6940745aa77c..4274969ddc89 100644 --- a/tools/perf/ui/hist.c +++ b/tools/perf/ui/hist.c | |||
@@ -766,7 +766,7 @@ int perf_hpp__setup_hists_formats(struct perf_hpp_list *list, | |||
766 | if (!symbol_conf.report_hierarchy) | 766 | if (!symbol_conf.report_hierarchy) |
767 | return 0; | 767 | return 0; |
768 | 768 | ||
769 | evlist__for_each(evlist, evsel) { | 769 | evlist__for_each_entry(evlist, evsel) { |
770 | hists = evsel__hists(evsel); | 770 | hists = evsel__hists(evsel); |
771 | 771 | ||
772 | perf_hpp_list__for_each_sort_list(list, fmt) { | 772 | perf_hpp_list__for_each_sort_list(list, fmt) { |
diff --git a/tools/perf/util/alias.c b/tools/perf/util/alias.c index c0b43ee40d95..6c80f830358b 100644 --- a/tools/perf/util/alias.c +++ b/tools/perf/util/alias.c | |||
@@ -1,4 +1,5 @@ | |||
1 | #include "cache.h" | 1 | #include "cache.h" |
2 | #include "config.h" | ||
2 | 3 | ||
3 | static const char *alias_key; | 4 | static const char *alias_key; |
4 | static char *alias_val; | 5 | static char *alias_val; |
diff --git a/tools/perf/util/auxtrace.h b/tools/perf/util/auxtrace.h index 767989e0e312..ac5f0d7167e6 100644 --- a/tools/perf/util/auxtrace.h +++ b/tools/perf/util/auxtrace.h | |||
@@ -63,6 +63,7 @@ enum itrace_period_type { | |||
63 | * @calls: limit branch samples to calls (can be combined with @returns) | 63 | * @calls: limit branch samples to calls (can be combined with @returns) |
64 | * @returns: limit branch samples to returns (can be combined with @calls) | 64 | * @returns: limit branch samples to returns (can be combined with @calls) |
65 | * @callchain: add callchain to 'instructions' events | 65 | * @callchain: add callchain to 'instructions' events |
66 | * @thread_stack: feed branches to the thread_stack | ||
66 | * @last_branch: add branch context to 'instruction' events | 67 | * @last_branch: add branch context to 'instruction' events |
67 | * @callchain_sz: maximum callchain size | 68 | * @callchain_sz: maximum callchain size |
68 | * @last_branch_sz: branch context size | 69 | * @last_branch_sz: branch context size |
@@ -82,6 +83,7 @@ struct itrace_synth_opts { | |||
82 | bool calls; | 83 | bool calls; |
83 | bool returns; | 84 | bool returns; |
84 | bool callchain; | 85 | bool callchain; |
86 | bool thread_stack; | ||
85 | bool last_branch; | 87 | bool last_branch; |
86 | unsigned int callchain_sz; | 88 | unsigned int callchain_sz; |
87 | unsigned int last_branch_sz; | 89 | unsigned int last_branch_sz; |
diff --git a/tools/perf/util/cache.h b/tools/perf/util/cache.h index 369f382eedb6..9f90e36b56fb 100644 --- a/tools/perf/util/cache.h +++ b/tools/perf/util/cache.h | |||
@@ -18,17 +18,6 @@ | |||
18 | #define PERF_TRACEFS_ENVIRONMENT "PERF_TRACEFS_DIR" | 18 | #define PERF_TRACEFS_ENVIRONMENT "PERF_TRACEFS_DIR" |
19 | #define PERF_PAGER_ENVIRONMENT "PERF_PAGER" | 19 | #define PERF_PAGER_ENVIRONMENT "PERF_PAGER" |
20 | 20 | ||
21 | extern const char *config_exclusive_filename; | ||
22 | |||
23 | typedef int (*config_fn_t)(const char *, const char *, void *); | ||
24 | int perf_default_config(const char *, const char *, void *); | ||
25 | int perf_config(config_fn_t fn, void *); | ||
26 | int perf_config_int(const char *, const char *); | ||
27 | u64 perf_config_u64(const char *, const char *); | ||
28 | int perf_config_bool(const char *, const char *); | ||
29 | int config_error_nonbool(const char *); | ||
30 | const char *perf_etc_perfconfig(void); | ||
31 | |||
32 | char *alias_lookup(const char *alias); | 21 | char *alias_lookup(const char *alias); |
33 | int split_cmdline(char *cmdline, const char ***argv); | 22 | int split_cmdline(char *cmdline, const char ***argv); |
34 | 23 | ||
diff --git a/tools/perf/util/cgroup.c b/tools/perf/util/cgroup.c index 90aa1b46b2e5..8fdee24725a7 100644 --- a/tools/perf/util/cgroup.c +++ b/tools/perf/util/cgroup.c | |||
@@ -81,7 +81,7 @@ static int add_cgroup(struct perf_evlist *evlist, char *str) | |||
81 | /* | 81 | /* |
82 | * check if cgrp is already defined, if so we reuse it | 82 | * check if cgrp is already defined, if so we reuse it |
83 | */ | 83 | */ |
84 | evlist__for_each(evlist, counter) { | 84 | evlist__for_each_entry(evlist, counter) { |
85 | cgrp = counter->cgrp; | 85 | cgrp = counter->cgrp; |
86 | if (!cgrp) | 86 | if (!cgrp) |
87 | continue; | 87 | continue; |
@@ -110,7 +110,7 @@ static int add_cgroup(struct perf_evlist *evlist, char *str) | |||
110 | * if add cgroup N, then need to find event N | 110 | * if add cgroup N, then need to find event N |
111 | */ | 111 | */ |
112 | n = 0; | 112 | n = 0; |
113 | evlist__for_each(evlist, counter) { | 113 | evlist__for_each_entry(evlist, counter) { |
114 | if (n == nr_cgroups) | 114 | if (n == nr_cgroups) |
115 | goto found; | 115 | goto found; |
116 | n++; | 116 | n++; |
diff --git a/tools/perf/util/color.c b/tools/perf/util/color.c index 43e84aa27e4a..1210ba555d07 100644 --- a/tools/perf/util/color.c +++ b/tools/perf/util/color.c | |||
@@ -1,5 +1,6 @@ | |||
1 | #include <linux/kernel.h> | 1 | #include <linux/kernel.h> |
2 | #include "cache.h" | 2 | #include "cache.h" |
3 | #include "config.h" | ||
3 | #include "color.h" | 4 | #include "color.h" |
4 | #include <math.h> | 5 | #include <math.h> |
5 | 6 | ||
diff --git a/tools/perf/util/config.c b/tools/perf/util/config.c index d15c59267644..18dae745034f 100644 --- a/tools/perf/util/config.c +++ b/tools/perf/util/config.c | |||
@@ -26,6 +26,7 @@ static FILE *config_file; | |||
26 | static const char *config_file_name; | 26 | static const char *config_file_name; |
27 | static int config_linenr; | 27 | static int config_linenr; |
28 | static int config_file_eof; | 28 | static int config_file_eof; |
29 | static struct perf_config_set *config_set; | ||
29 | 30 | ||
30 | const char *config_exclusive_filename; | 31 | const char *config_exclusive_filename; |
31 | 32 | ||
@@ -478,51 +479,6 @@ static int perf_config_global(void) | |||
478 | return !perf_env_bool("PERF_CONFIG_NOGLOBAL", 0); | 479 | return !perf_env_bool("PERF_CONFIG_NOGLOBAL", 0); |
479 | } | 480 | } |
480 | 481 | ||
481 | int perf_config(config_fn_t fn, void *data) | ||
482 | { | ||
483 | int ret = -1; | ||
484 | const char *home = NULL; | ||
485 | |||
486 | /* Setting $PERF_CONFIG makes perf read _only_ the given config file. */ | ||
487 | if (config_exclusive_filename) | ||
488 | return perf_config_from_file(fn, config_exclusive_filename, data); | ||
489 | if (perf_config_system() && !access(perf_etc_perfconfig(), R_OK)) { | ||
490 | if (perf_config_from_file(fn, perf_etc_perfconfig(), data) < 0) | ||
491 | goto out; | ||
492 | } | ||
493 | |||
494 | home = getenv("HOME"); | ||
495 | if (perf_config_global() && home) { | ||
496 | char *user_config = strdup(mkpath("%s/.perfconfig", home)); | ||
497 | struct stat st; | ||
498 | |||
499 | if (user_config == NULL) { | ||
500 | warning("Not enough memory to process %s/.perfconfig, " | ||
501 | "ignoring it.", home); | ||
502 | goto out; | ||
503 | } | ||
504 | |||
505 | if (stat(user_config, &st) < 0) | ||
506 | goto out_free; | ||
507 | |||
508 | if (st.st_uid && (st.st_uid != geteuid())) { | ||
509 | warning("File %s not owned by current user or root, " | ||
510 | "ignoring it.", user_config); | ||
511 | goto out_free; | ||
512 | } | ||
513 | |||
514 | if (!st.st_size) | ||
515 | goto out_free; | ||
516 | |||
517 | ret = perf_config_from_file(fn, user_config, data); | ||
518 | |||
519 | out_free: | ||
520 | free(user_config); | ||
521 | } | ||
522 | out: | ||
523 | return ret; | ||
524 | } | ||
525 | |||
526 | static struct perf_config_section *find_section(struct list_head *sections, | 482 | static struct perf_config_section *find_section(struct list_head *sections, |
527 | const char *section_name) | 483 | const char *section_name) |
528 | { | 484 | { |
@@ -706,6 +662,52 @@ struct perf_config_set *perf_config_set__new(void) | |||
706 | return set; | 662 | return set; |
707 | } | 663 | } |
708 | 664 | ||
665 | int perf_config(config_fn_t fn, void *data) | ||
666 | { | ||
667 | int ret = 0; | ||
668 | char key[BUFSIZ]; | ||
669 | struct perf_config_section *section; | ||
670 | struct perf_config_item *item; | ||
671 | |||
672 | if (config_set == NULL) | ||
673 | return -1; | ||
674 | |||
675 | perf_config_set__for_each_entry(config_set, section, item) { | ||
676 | char *value = item->value; | ||
677 | |||
678 | if (value) { | ||
679 | scnprintf(key, sizeof(key), "%s.%s", | ||
680 | section->name, item->name); | ||
681 | ret = fn(key, value, data); | ||
682 | if (ret < 0) { | ||
683 | pr_err("Error: wrong config key-value pair %s=%s\n", | ||
684 | key, value); | ||
685 | break; | ||
686 | } | ||
687 | } | ||
688 | } | ||
689 | |||
690 | return ret; | ||
691 | } | ||
692 | |||
693 | void perf_config__init(void) | ||
694 | { | ||
695 | if (config_set == NULL) | ||
696 | config_set = perf_config_set__new(); | ||
697 | } | ||
698 | |||
699 | void perf_config__exit(void) | ||
700 | { | ||
701 | perf_config_set__delete(config_set); | ||
702 | config_set = NULL; | ||
703 | } | ||
704 | |||
705 | void perf_config__refresh(void) | ||
706 | { | ||
707 | perf_config__exit(); | ||
708 | perf_config__init(); | ||
709 | } | ||
710 | |||
709 | static void perf_config_item__delete(struct perf_config_item *item) | 711 | static void perf_config_item__delete(struct perf_config_item *item) |
710 | { | 712 | { |
711 | zfree(&item->name); | 713 | zfree(&item->name); |
diff --git a/tools/perf/util/config.h b/tools/perf/util/config.h index 22ec626ac718..6f813d46045e 100644 --- a/tools/perf/util/config.h +++ b/tools/perf/util/config.h | |||
@@ -20,7 +20,47 @@ struct perf_config_set { | |||
20 | struct list_head sections; | 20 | struct list_head sections; |
21 | }; | 21 | }; |
22 | 22 | ||
23 | extern const char *config_exclusive_filename; | ||
24 | |||
25 | typedef int (*config_fn_t)(const char *, const char *, void *); | ||
26 | int perf_default_config(const char *, const char *, void *); | ||
27 | int perf_config(config_fn_t fn, void *); | ||
28 | int perf_config_int(const char *, const char *); | ||
29 | u64 perf_config_u64(const char *, const char *); | ||
30 | int perf_config_bool(const char *, const char *); | ||
31 | int config_error_nonbool(const char *); | ||
32 | const char *perf_etc_perfconfig(void); | ||
33 | |||
23 | struct perf_config_set *perf_config_set__new(void); | 34 | struct perf_config_set *perf_config_set__new(void); |
24 | void perf_config_set__delete(struct perf_config_set *set); | 35 | void perf_config_set__delete(struct perf_config_set *set); |
36 | void perf_config__init(void); | ||
37 | void perf_config__exit(void); | ||
38 | void perf_config__refresh(void); | ||
39 | |||
40 | /** | ||
41 | * perf_config_sections__for_each - iterate thru all the sections | ||
42 | * @list: list_head instance to iterate | ||
43 | * @section: struct perf_config_section iterator | ||
44 | */ | ||
45 | #define perf_config_sections__for_each_entry(list, section) \ | ||
46 | list_for_each_entry(section, list, node) | ||
47 | |||
48 | /** | ||
49 | * perf_config_items__for_each - iterate thru all the items | ||
50 | * @list: list_head instance to iterate | ||
51 | * @item: struct perf_config_item iterator | ||
52 | */ | ||
53 | #define perf_config_items__for_each_entry(list, item) \ | ||
54 | list_for_each_entry(item, list, node) | ||
55 | |||
56 | /** | ||
57 | * perf_config_set__for_each - iterate thru all the config section-item pairs | ||
58 | * @set: evlist instance to iterate | ||
59 | * @section: struct perf_config_section iterator | ||
60 | * @item: struct perf_config_item iterator | ||
61 | */ | ||
62 | #define perf_config_set__for_each_entry(set, section, item) \ | ||
63 | perf_config_sections__for_each_entry(&set->sections, section) \ | ||
64 | perf_config_items__for_each_entry(§ion->items, item) | ||
25 | 65 | ||
26 | #endif /* __PERF_CONFIG_H */ | 66 | #endif /* __PERF_CONFIG_H */ |
diff --git a/tools/perf/util/data-convert-bt.c b/tools/perf/util/data-convert-bt.c index 9f53020c3269..4b59879391c0 100644 --- a/tools/perf/util/data-convert-bt.c +++ b/tools/perf/util/data-convert-bt.c | |||
@@ -997,7 +997,7 @@ static int setup_events(struct ctf_writer *cw, struct perf_session *session) | |||
997 | struct perf_evsel *evsel; | 997 | struct perf_evsel *evsel; |
998 | int ret; | 998 | int ret; |
999 | 999 | ||
1000 | evlist__for_each(evlist, evsel) { | 1000 | evlist__for_each_entry(evlist, evsel) { |
1001 | ret = add_event(cw, evsel); | 1001 | ret = add_event(cw, evsel); |
1002 | if (ret) | 1002 | if (ret) |
1003 | return ret; | 1003 | return ret; |
@@ -1010,7 +1010,7 @@ static void cleanup_events(struct perf_session *session) | |||
1010 | struct perf_evlist *evlist = session->evlist; | 1010 | struct perf_evlist *evlist = session->evlist; |
1011 | struct perf_evsel *evsel; | 1011 | struct perf_evsel *evsel; |
1012 | 1012 | ||
1013 | evlist__for_each(evlist, evsel) { | 1013 | evlist__for_each_entry(evlist, evsel) { |
1014 | struct evsel_priv *priv; | 1014 | struct evsel_priv *priv; |
1015 | 1015 | ||
1016 | priv = evsel->priv; | 1016 | priv = evsel->priv; |
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 1b918aa075d6..113507716044 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c | |||
@@ -100,7 +100,7 @@ static void perf_evlist__update_id_pos(struct perf_evlist *evlist) | |||
100 | { | 100 | { |
101 | struct perf_evsel *evsel; | 101 | struct perf_evsel *evsel; |
102 | 102 | ||
103 | evlist__for_each(evlist, evsel) | 103 | evlist__for_each_entry(evlist, evsel) |
104 | perf_evsel__calc_id_pos(evsel); | 104 | perf_evsel__calc_id_pos(evsel); |
105 | 105 | ||
106 | perf_evlist__set_id_pos(evlist); | 106 | perf_evlist__set_id_pos(evlist); |
@@ -110,7 +110,7 @@ static void perf_evlist__purge(struct perf_evlist *evlist) | |||
110 | { | 110 | { |
111 | struct perf_evsel *pos, *n; | 111 | struct perf_evsel *pos, *n; |
112 | 112 | ||
113 | evlist__for_each_safe(evlist, n, pos) { | 113 | evlist__for_each_entry_safe(evlist, n, pos) { |
114 | list_del_init(&pos->node); | 114 | list_del_init(&pos->node); |
115 | pos->evlist = NULL; | 115 | pos->evlist = NULL; |
116 | perf_evsel__delete(pos); | 116 | perf_evsel__delete(pos); |
@@ -127,6 +127,9 @@ void perf_evlist__exit(struct perf_evlist *evlist) | |||
127 | 127 | ||
128 | void perf_evlist__delete(struct perf_evlist *evlist) | 128 | void perf_evlist__delete(struct perf_evlist *evlist) |
129 | { | 129 | { |
130 | if (evlist == NULL) | ||
131 | return; | ||
132 | |||
130 | perf_evlist__munmap(evlist); | 133 | perf_evlist__munmap(evlist); |
131 | perf_evlist__close(evlist); | 134 | perf_evlist__close(evlist); |
132 | cpu_map__put(evlist->cpus); | 135 | cpu_map__put(evlist->cpus); |
@@ -161,7 +164,7 @@ static void perf_evlist__propagate_maps(struct perf_evlist *evlist) | |||
161 | { | 164 | { |
162 | struct perf_evsel *evsel; | 165 | struct perf_evsel *evsel; |
163 | 166 | ||
164 | evlist__for_each(evlist, evsel) | 167 | evlist__for_each_entry(evlist, evsel) |
165 | __perf_evlist__propagate_maps(evlist, evsel); | 168 | __perf_evlist__propagate_maps(evlist, evsel); |
166 | } | 169 | } |
167 | 170 | ||
@@ -190,7 +193,7 @@ void perf_evlist__splice_list_tail(struct perf_evlist *evlist, | |||
190 | { | 193 | { |
191 | struct perf_evsel *evsel, *temp; | 194 | struct perf_evsel *evsel, *temp; |
192 | 195 | ||
193 | __evlist__for_each_safe(list, temp, evsel) { | 196 | __evlist__for_each_entry_safe(list, temp, evsel) { |
194 | list_del_init(&evsel->node); | 197 | list_del_init(&evsel->node); |
195 | perf_evlist__add(evlist, evsel); | 198 | perf_evlist__add(evlist, evsel); |
196 | } | 199 | } |
@@ -205,7 +208,7 @@ void __perf_evlist__set_leader(struct list_head *list) | |||
205 | 208 | ||
206 | leader->nr_members = evsel->idx - leader->idx + 1; | 209 | leader->nr_members = evsel->idx - leader->idx + 1; |
207 | 210 | ||
208 | __evlist__for_each(list, evsel) { | 211 | __evlist__for_each_entry(list, evsel) { |
209 | evsel->leader = leader; | 212 | evsel->leader = leader; |
210 | } | 213 | } |
211 | } | 214 | } |
@@ -296,7 +299,7 @@ static int perf_evlist__add_attrs(struct perf_evlist *evlist, | |||
296 | return 0; | 299 | return 0; |
297 | 300 | ||
298 | out_delete_partial_list: | 301 | out_delete_partial_list: |
299 | __evlist__for_each_safe(&head, n, evsel) | 302 | __evlist__for_each_entry_safe(&head, n, evsel) |
300 | perf_evsel__delete(evsel); | 303 | perf_evsel__delete(evsel); |
301 | return -1; | 304 | return -1; |
302 | } | 305 | } |
@@ -317,7 +320,7 @@ perf_evlist__find_tracepoint_by_id(struct perf_evlist *evlist, int id) | |||
317 | { | 320 | { |
318 | struct perf_evsel *evsel; | 321 | struct perf_evsel *evsel; |
319 | 322 | ||
320 | evlist__for_each(evlist, evsel) { | 323 | evlist__for_each_entry(evlist, evsel) { |
321 | if (evsel->attr.type == PERF_TYPE_TRACEPOINT && | 324 | if (evsel->attr.type == PERF_TYPE_TRACEPOINT && |
322 | (int)evsel->attr.config == id) | 325 | (int)evsel->attr.config == id) |
323 | return evsel; | 326 | return evsel; |
@@ -332,7 +335,7 @@ perf_evlist__find_tracepoint_by_name(struct perf_evlist *evlist, | |||
332 | { | 335 | { |
333 | struct perf_evsel *evsel; | 336 | struct perf_evsel *evsel; |
334 | 337 | ||
335 | evlist__for_each(evlist, evsel) { | 338 | evlist__for_each_entry(evlist, evsel) { |
336 | if ((evsel->attr.type == PERF_TYPE_TRACEPOINT) && | 339 | if ((evsel->attr.type == PERF_TYPE_TRACEPOINT) && |
337 | (strcmp(evsel->name, name) == 0)) | 340 | (strcmp(evsel->name, name) == 0)) |
338 | return evsel; | 341 | return evsel; |
@@ -367,7 +370,7 @@ void perf_evlist__disable(struct perf_evlist *evlist) | |||
367 | { | 370 | { |
368 | struct perf_evsel *pos; | 371 | struct perf_evsel *pos; |
369 | 372 | ||
370 | evlist__for_each(evlist, pos) { | 373 | evlist__for_each_entry(evlist, pos) { |
371 | if (!perf_evsel__is_group_leader(pos) || !pos->fd) | 374 | if (!perf_evsel__is_group_leader(pos) || !pos->fd) |
372 | continue; | 375 | continue; |
373 | perf_evsel__disable(pos); | 376 | perf_evsel__disable(pos); |
@@ -380,7 +383,7 @@ void perf_evlist__enable(struct perf_evlist *evlist) | |||
380 | { | 383 | { |
381 | struct perf_evsel *pos; | 384 | struct perf_evsel *pos; |
382 | 385 | ||
383 | evlist__for_each(evlist, pos) { | 386 | evlist__for_each_entry(evlist, pos) { |
384 | if (!perf_evsel__is_group_leader(pos) || !pos->fd) | 387 | if (!perf_evsel__is_group_leader(pos) || !pos->fd) |
385 | continue; | 388 | continue; |
386 | perf_evsel__enable(pos); | 389 | perf_evsel__enable(pos); |
@@ -448,7 +451,7 @@ int perf_evlist__alloc_pollfd(struct perf_evlist *evlist) | |||
448 | int nfds = 0; | 451 | int nfds = 0; |
449 | struct perf_evsel *evsel; | 452 | struct perf_evsel *evsel; |
450 | 453 | ||
451 | evlist__for_each(evlist, evsel) { | 454 | evlist__for_each_entry(evlist, evsel) { |
452 | if (evsel->system_wide) | 455 | if (evsel->system_wide) |
453 | nfds += nr_cpus; | 456 | nfds += nr_cpus; |
454 | else | 457 | else |
@@ -1012,7 +1015,7 @@ static int perf_evlist__mmap_per_evsel(struct perf_evlist *evlist, int idx, | |||
1012 | struct perf_evsel *evsel; | 1015 | struct perf_evsel *evsel; |
1013 | int revent; | 1016 | int revent; |
1014 | 1017 | ||
1015 | evlist__for_each(evlist, evsel) { | 1018 | evlist__for_each_entry(evlist, evsel) { |
1016 | int fd; | 1019 | int fd; |
1017 | 1020 | ||
1018 | if (evsel->overwrite != (evlist->overwrite && evlist->backward)) | 1021 | if (evsel->overwrite != (evlist->overwrite && evlist->backward)) |
@@ -1259,7 +1262,7 @@ int perf_evlist__mmap_ex(struct perf_evlist *evlist, unsigned int pages, | |||
1259 | auxtrace_mmap_params__init(&mp.auxtrace_mp, evlist->mmap_len, | 1262 | auxtrace_mmap_params__init(&mp.auxtrace_mp, evlist->mmap_len, |
1260 | auxtrace_pages, auxtrace_overwrite); | 1263 | auxtrace_pages, auxtrace_overwrite); |
1261 | 1264 | ||
1262 | evlist__for_each(evlist, evsel) { | 1265 | evlist__for_each_entry(evlist, evsel) { |
1263 | if ((evsel->attr.read_format & PERF_FORMAT_ID) && | 1266 | if ((evsel->attr.read_format & PERF_FORMAT_ID) && |
1264 | evsel->sample_id == NULL && | 1267 | evsel->sample_id == NULL && |
1265 | perf_evsel__alloc_id(evsel, cpu_map__nr(cpus), threads->nr) < 0) | 1268 | perf_evsel__alloc_id(evsel, cpu_map__nr(cpus), threads->nr) < 0) |
@@ -1335,7 +1338,7 @@ void __perf_evlist__set_sample_bit(struct perf_evlist *evlist, | |||
1335 | { | 1338 | { |
1336 | struct perf_evsel *evsel; | 1339 | struct perf_evsel *evsel; |
1337 | 1340 | ||
1338 | evlist__for_each(evlist, evsel) | 1341 | evlist__for_each_entry(evlist, evsel) |
1339 | __perf_evsel__set_sample_bit(evsel, bit); | 1342 | __perf_evsel__set_sample_bit(evsel, bit); |
1340 | } | 1343 | } |
1341 | 1344 | ||
@@ -1344,7 +1347,7 @@ void __perf_evlist__reset_sample_bit(struct perf_evlist *evlist, | |||
1344 | { | 1347 | { |
1345 | struct perf_evsel *evsel; | 1348 | struct perf_evsel *evsel; |
1346 | 1349 | ||
1347 | evlist__for_each(evlist, evsel) | 1350 | evlist__for_each_entry(evlist, evsel) |
1348 | __perf_evsel__reset_sample_bit(evsel, bit); | 1351 | __perf_evsel__reset_sample_bit(evsel, bit); |
1349 | } | 1352 | } |
1350 | 1353 | ||
@@ -1355,7 +1358,7 @@ int perf_evlist__apply_filters(struct perf_evlist *evlist, struct perf_evsel **e | |||
1355 | const int ncpus = cpu_map__nr(evlist->cpus), | 1358 | const int ncpus = cpu_map__nr(evlist->cpus), |
1356 | nthreads = thread_map__nr(evlist->threads); | 1359 | nthreads = thread_map__nr(evlist->threads); |
1357 | 1360 | ||
1358 | evlist__for_each(evlist, evsel) { | 1361 | evlist__for_each_entry(evlist, evsel) { |
1359 | if (evsel->filter == NULL) | 1362 | if (evsel->filter == NULL) |
1360 | continue; | 1363 | continue; |
1361 | 1364 | ||
@@ -1378,7 +1381,7 @@ int perf_evlist__set_filter(struct perf_evlist *evlist, const char *filter) | |||
1378 | struct perf_evsel *evsel; | 1381 | struct perf_evsel *evsel; |
1379 | int err = 0; | 1382 | int err = 0; |
1380 | 1383 | ||
1381 | evlist__for_each(evlist, evsel) { | 1384 | evlist__for_each_entry(evlist, evsel) { |
1382 | if (evsel->attr.type != PERF_TYPE_TRACEPOINT) | 1385 | if (evsel->attr.type != PERF_TYPE_TRACEPOINT) |
1383 | continue; | 1386 | continue; |
1384 | 1387 | ||
@@ -1432,7 +1435,7 @@ bool perf_evlist__valid_sample_type(struct perf_evlist *evlist) | |||
1432 | if (evlist->id_pos < 0 || evlist->is_pos < 0) | 1435 | if (evlist->id_pos < 0 || evlist->is_pos < 0) |
1433 | return false; | 1436 | return false; |
1434 | 1437 | ||
1435 | evlist__for_each(evlist, pos) { | 1438 | evlist__for_each_entry(evlist, pos) { |
1436 | if (pos->id_pos != evlist->id_pos || | 1439 | if (pos->id_pos != evlist->id_pos || |
1437 | pos->is_pos != evlist->is_pos) | 1440 | pos->is_pos != evlist->is_pos) |
1438 | return false; | 1441 | return false; |
@@ -1448,7 +1451,7 @@ u64 __perf_evlist__combined_sample_type(struct perf_evlist *evlist) | |||
1448 | if (evlist->combined_sample_type) | 1451 | if (evlist->combined_sample_type) |
1449 | return evlist->combined_sample_type; | 1452 | return evlist->combined_sample_type; |
1450 | 1453 | ||
1451 | evlist__for_each(evlist, evsel) | 1454 | evlist__for_each_entry(evlist, evsel) |
1452 | evlist->combined_sample_type |= evsel->attr.sample_type; | 1455 | evlist->combined_sample_type |= evsel->attr.sample_type; |
1453 | 1456 | ||
1454 | return evlist->combined_sample_type; | 1457 | return evlist->combined_sample_type; |
@@ -1465,7 +1468,7 @@ u64 perf_evlist__combined_branch_type(struct perf_evlist *evlist) | |||
1465 | struct perf_evsel *evsel; | 1468 | struct perf_evsel *evsel; |
1466 | u64 branch_type = 0; | 1469 | u64 branch_type = 0; |
1467 | 1470 | ||
1468 | evlist__for_each(evlist, evsel) | 1471 | evlist__for_each_entry(evlist, evsel) |
1469 | branch_type |= evsel->attr.branch_sample_type; | 1472 | branch_type |= evsel->attr.branch_sample_type; |
1470 | return branch_type; | 1473 | return branch_type; |
1471 | } | 1474 | } |
@@ -1476,7 +1479,7 @@ bool perf_evlist__valid_read_format(struct perf_evlist *evlist) | |||
1476 | u64 read_format = first->attr.read_format; | 1479 | u64 read_format = first->attr.read_format; |
1477 | u64 sample_type = first->attr.sample_type; | 1480 | u64 sample_type = first->attr.sample_type; |
1478 | 1481 | ||
1479 | evlist__for_each(evlist, pos) { | 1482 | evlist__for_each_entry(evlist, pos) { |
1480 | if (read_format != pos->attr.read_format) | 1483 | if (read_format != pos->attr.read_format) |
1481 | return false; | 1484 | return false; |
1482 | } | 1485 | } |
@@ -1533,7 +1536,7 @@ bool perf_evlist__valid_sample_id_all(struct perf_evlist *evlist) | |||
1533 | { | 1536 | { |
1534 | struct perf_evsel *first = perf_evlist__first(evlist), *pos = first; | 1537 | struct perf_evsel *first = perf_evlist__first(evlist), *pos = first; |
1535 | 1538 | ||
1536 | evlist__for_each_continue(evlist, pos) { | 1539 | evlist__for_each_entry_continue(evlist, pos) { |
1537 | if (first->attr.sample_id_all != pos->attr.sample_id_all) | 1540 | if (first->attr.sample_id_all != pos->attr.sample_id_all) |
1538 | return false; | 1541 | return false; |
1539 | } | 1542 | } |
@@ -1560,7 +1563,7 @@ void perf_evlist__close(struct perf_evlist *evlist) | |||
1560 | int nthreads = thread_map__nr(evlist->threads); | 1563 | int nthreads = thread_map__nr(evlist->threads); |
1561 | int n; | 1564 | int n; |
1562 | 1565 | ||
1563 | evlist__for_each_reverse(evlist, evsel) { | 1566 | evlist__for_each_entry_reverse(evlist, evsel) { |
1564 | n = evsel->cpus ? evsel->cpus->nr : ncpus; | 1567 | n = evsel->cpus ? evsel->cpus->nr : ncpus; |
1565 | perf_evsel__close(evsel, n, nthreads); | 1568 | perf_evsel__close(evsel, n, nthreads); |
1566 | } | 1569 | } |
@@ -1614,7 +1617,7 @@ int perf_evlist__open(struct perf_evlist *evlist) | |||
1614 | 1617 | ||
1615 | perf_evlist__update_id_pos(evlist); | 1618 | perf_evlist__update_id_pos(evlist); |
1616 | 1619 | ||
1617 | evlist__for_each(evlist, evsel) { | 1620 | evlist__for_each_entry(evlist, evsel) { |
1618 | err = perf_evsel__open(evsel, evsel->cpus, evsel->threads); | 1621 | err = perf_evsel__open(evsel, evsel->cpus, evsel->threads); |
1619 | if (err < 0) | 1622 | if (err < 0) |
1620 | goto out_err; | 1623 | goto out_err; |
@@ -1775,7 +1778,7 @@ size_t perf_evlist__fprintf(struct perf_evlist *evlist, FILE *fp) | |||
1775 | struct perf_evsel *evsel; | 1778 | struct perf_evsel *evsel; |
1776 | size_t printed = 0; | 1779 | size_t printed = 0; |
1777 | 1780 | ||
1778 | evlist__for_each(evlist, evsel) { | 1781 | evlist__for_each_entry(evlist, evsel) { |
1779 | printed += fprintf(fp, "%s%s", evsel->idx ? ", " : "", | 1782 | printed += fprintf(fp, "%s%s", evsel->idx ? ", " : "", |
1780 | perf_evsel__name(evsel)); | 1783 | perf_evsel__name(evsel)); |
1781 | } | 1784 | } |
@@ -1877,7 +1880,7 @@ void perf_evlist__to_front(struct perf_evlist *evlist, | |||
1877 | if (move_evsel == perf_evlist__first(evlist)) | 1880 | if (move_evsel == perf_evlist__first(evlist)) |
1878 | return; | 1881 | return; |
1879 | 1882 | ||
1880 | evlist__for_each_safe(evlist, n, evsel) { | 1883 | evlist__for_each_entry_safe(evlist, n, evsel) { |
1881 | if (evsel->leader == move_evsel->leader) | 1884 | if (evsel->leader == move_evsel->leader) |
1882 | list_move_tail(&evsel->node, &move); | 1885 | list_move_tail(&evsel->node, &move); |
1883 | } | 1886 | } |
@@ -1893,7 +1896,7 @@ void perf_evlist__set_tracking_event(struct perf_evlist *evlist, | |||
1893 | if (tracking_evsel->tracking) | 1896 | if (tracking_evsel->tracking) |
1894 | return; | 1897 | return; |
1895 | 1898 | ||
1896 | evlist__for_each(evlist, evsel) { | 1899 | evlist__for_each_entry(evlist, evsel) { |
1897 | if (evsel != tracking_evsel) | 1900 | if (evsel != tracking_evsel) |
1898 | evsel->tracking = false; | 1901 | evsel->tracking = false; |
1899 | } | 1902 | } |
@@ -1907,7 +1910,7 @@ perf_evlist__find_evsel_by_str(struct perf_evlist *evlist, | |||
1907 | { | 1910 | { |
1908 | struct perf_evsel *evsel; | 1911 | struct perf_evsel *evsel; |
1909 | 1912 | ||
1910 | evlist__for_each(evlist, evsel) { | 1913 | evlist__for_each_entry(evlist, evsel) { |
1911 | if (!evsel->name) | 1914 | if (!evsel->name) |
1912 | continue; | 1915 | continue; |
1913 | if (strcmp(str, evsel->name) == 0) | 1916 | if (strcmp(str, evsel->name) == 0) |
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h index 68cb1361c97c..872912b392c9 100644 --- a/tools/perf/util/evlist.h +++ b/tools/perf/util/evlist.h | |||
@@ -251,70 +251,70 @@ void perf_evlist__to_front(struct perf_evlist *evlist, | |||
251 | struct perf_evsel *move_evsel); | 251 | struct perf_evsel *move_evsel); |
252 | 252 | ||
253 | /** | 253 | /** |
254 | * __evlist__for_each - iterate thru all the evsels | 254 | * __evlist__for_each_entry - iterate thru all the evsels |
255 | * @list: list_head instance to iterate | 255 | * @list: list_head instance to iterate |
256 | * @evsel: struct evsel iterator | 256 | * @evsel: struct evsel iterator |
257 | */ | 257 | */ |
258 | #define __evlist__for_each(list, evsel) \ | 258 | #define __evlist__for_each_entry(list, evsel) \ |
259 | list_for_each_entry(evsel, list, node) | 259 | list_for_each_entry(evsel, list, node) |
260 | 260 | ||
261 | /** | 261 | /** |
262 | * evlist__for_each - iterate thru all the evsels | 262 | * evlist__for_each_entry - iterate thru all the evsels |
263 | * @evlist: evlist instance to iterate | 263 | * @evlist: evlist instance to iterate |
264 | * @evsel: struct evsel iterator | 264 | * @evsel: struct evsel iterator |
265 | */ | 265 | */ |
266 | #define evlist__for_each(evlist, evsel) \ | 266 | #define evlist__for_each_entry(evlist, evsel) \ |
267 | __evlist__for_each(&(evlist)->entries, evsel) | 267 | __evlist__for_each_entry(&(evlist)->entries, evsel) |
268 | 268 | ||
269 | /** | 269 | /** |
270 | * __evlist__for_each_continue - continue iteration thru all the evsels | 270 | * __evlist__for_each_entry_continue - continue iteration thru all the evsels |
271 | * @list: list_head instance to iterate | 271 | * @list: list_head instance to iterate |
272 | * @evsel: struct evsel iterator | 272 | * @evsel: struct evsel iterator |
273 | */ | 273 | */ |
274 | #define __evlist__for_each_continue(list, evsel) \ | 274 | #define __evlist__for_each_entry_continue(list, evsel) \ |
275 | list_for_each_entry_continue(evsel, list, node) | 275 | list_for_each_entry_continue(evsel, list, node) |
276 | 276 | ||
277 | /** | 277 | /** |
278 | * evlist__for_each_continue - continue iteration thru all the evsels | 278 | * evlist__for_each_entry_continue - continue iteration thru all the evsels |
279 | * @evlist: evlist instance to iterate | 279 | * @evlist: evlist instance to iterate |
280 | * @evsel: struct evsel iterator | 280 | * @evsel: struct evsel iterator |
281 | */ | 281 | */ |
282 | #define evlist__for_each_continue(evlist, evsel) \ | 282 | #define evlist__for_each_entry_continue(evlist, evsel) \ |
283 | __evlist__for_each_continue(&(evlist)->entries, evsel) | 283 | __evlist__for_each_entry_continue(&(evlist)->entries, evsel) |
284 | 284 | ||
285 | /** | 285 | /** |
286 | * __evlist__for_each_reverse - iterate thru all the evsels in reverse order | 286 | * __evlist__for_each_entry_reverse - iterate thru all the evsels in reverse order |
287 | * @list: list_head instance to iterate | 287 | * @list: list_head instance to iterate |
288 | * @evsel: struct evsel iterator | 288 | * @evsel: struct evsel iterator |
289 | */ | 289 | */ |
290 | #define __evlist__for_each_reverse(list, evsel) \ | 290 | #define __evlist__for_each_entry_reverse(list, evsel) \ |
291 | list_for_each_entry_reverse(evsel, list, node) | 291 | list_for_each_entry_reverse(evsel, list, node) |
292 | 292 | ||
293 | /** | 293 | /** |
294 | * evlist__for_each_reverse - iterate thru all the evsels in reverse order | 294 | * evlist__for_each_entry_reverse - iterate thru all the evsels in reverse order |
295 | * @evlist: evlist instance to iterate | 295 | * @evlist: evlist instance to iterate |
296 | * @evsel: struct evsel iterator | 296 | * @evsel: struct evsel iterator |
297 | */ | 297 | */ |
298 | #define evlist__for_each_reverse(evlist, evsel) \ | 298 | #define evlist__for_each_entry_reverse(evlist, evsel) \ |
299 | __evlist__for_each_reverse(&(evlist)->entries, evsel) | 299 | __evlist__for_each_entry_reverse(&(evlist)->entries, evsel) |
300 | 300 | ||
301 | /** | 301 | /** |
302 | * __evlist__for_each_safe - safely iterate thru all the evsels | 302 | * __evlist__for_each_entry_safe - safely iterate thru all the evsels |
303 | * @list: list_head instance to iterate | 303 | * @list: list_head instance to iterate |
304 | * @tmp: struct evsel temp iterator | 304 | * @tmp: struct evsel temp iterator |
305 | * @evsel: struct evsel iterator | 305 | * @evsel: struct evsel iterator |
306 | */ | 306 | */ |
307 | #define __evlist__for_each_safe(list, tmp, evsel) \ | 307 | #define __evlist__for_each_entry_safe(list, tmp, evsel) \ |
308 | list_for_each_entry_safe(evsel, tmp, list, node) | 308 | list_for_each_entry_safe(evsel, tmp, list, node) |
309 | 309 | ||
310 | /** | 310 | /** |
311 | * evlist__for_each_safe - safely iterate thru all the evsels | 311 | * evlist__for_each_entry_safe - safely iterate thru all the evsels |
312 | * @evlist: evlist instance to iterate | 312 | * @evlist: evlist instance to iterate |
313 | * @evsel: struct evsel iterator | 313 | * @evsel: struct evsel iterator |
314 | * @tmp: struct evsel temp iterator | 314 | * @tmp: struct evsel temp iterator |
315 | */ | 315 | */ |
316 | #define evlist__for_each_safe(evlist, tmp, evsel) \ | 316 | #define evlist__for_each_entry_safe(evlist, tmp, evsel) \ |
317 | __evlist__for_each_safe(&(evlist)->entries, tmp, evsel) | 317 | __evlist__for_each_entry_safe(&(evlist)->entries, tmp, evsel) |
318 | 318 | ||
319 | void perf_evlist__set_tracking_event(struct perf_evlist *evlist, | 319 | void perf_evlist__set_tracking_event(struct perf_evlist *evlist, |
320 | struct perf_evsel *tracking_evsel); | 320 | struct perf_evsel *tracking_evsel); |
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index 08852dde1378..c5cd2698281f 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c | |||
@@ -336,7 +336,7 @@ static int write_event_desc(int fd, struct perf_header *h __maybe_unused, | |||
336 | if (ret < 0) | 336 | if (ret < 0) |
337 | return ret; | 337 | return ret; |
338 | 338 | ||
339 | evlist__for_each(evlist, evsel) { | 339 | evlist__for_each_entry(evlist, evsel) { |
340 | ret = do_write(fd, &evsel->attr, sz); | 340 | ret = do_write(fd, &evsel->attr, sz); |
341 | if (ret < 0) | 341 | if (ret < 0) |
342 | return ret; | 342 | return ret; |
@@ -801,7 +801,7 @@ static int write_group_desc(int fd, struct perf_header *h __maybe_unused, | |||
801 | if (ret < 0) | 801 | if (ret < 0) |
802 | return ret; | 802 | return ret; |
803 | 803 | ||
804 | evlist__for_each(evlist, evsel) { | 804 | evlist__for_each_entry(evlist, evsel) { |
805 | if (perf_evsel__is_group_leader(evsel) && | 805 | if (perf_evsel__is_group_leader(evsel) && |
806 | evsel->nr_members > 1) { | 806 | evsel->nr_members > 1) { |
807 | const char *name = evsel->group_name ?: "{anon_group}"; | 807 | const char *name = evsel->group_name ?: "{anon_group}"; |
@@ -1425,7 +1425,7 @@ static void print_group_desc(struct perf_header *ph, int fd __maybe_unused, | |||
1425 | 1425 | ||
1426 | session = container_of(ph, struct perf_session, header); | 1426 | session = container_of(ph, struct perf_session, header); |
1427 | 1427 | ||
1428 | evlist__for_each(session->evlist, evsel) { | 1428 | evlist__for_each_entry(session->evlist, evsel) { |
1429 | if (perf_evsel__is_group_leader(evsel) && | 1429 | if (perf_evsel__is_group_leader(evsel) && |
1430 | evsel->nr_members > 1) { | 1430 | evsel->nr_members > 1) { |
1431 | fprintf(fp, "# group: %s{%s", evsel->group_name ?: "", | 1431 | fprintf(fp, "# group: %s{%s", evsel->group_name ?: "", |
@@ -1703,7 +1703,7 @@ perf_evlist__find_by_index(struct perf_evlist *evlist, int idx) | |||
1703 | { | 1703 | { |
1704 | struct perf_evsel *evsel; | 1704 | struct perf_evsel *evsel; |
1705 | 1705 | ||
1706 | evlist__for_each(evlist, evsel) { | 1706 | evlist__for_each_entry(evlist, evsel) { |
1707 | if (evsel->idx == idx) | 1707 | if (evsel->idx == idx) |
1708 | return evsel; | 1708 | return evsel; |
1709 | } | 1709 | } |
@@ -2075,7 +2075,7 @@ static int process_group_desc(struct perf_file_section *section __maybe_unused, | |||
2075 | session->evlist->nr_groups = nr_groups; | 2075 | session->evlist->nr_groups = nr_groups; |
2076 | 2076 | ||
2077 | i = nr = 0; | 2077 | i = nr = 0; |
2078 | evlist__for_each(session->evlist, evsel) { | 2078 | evlist__for_each_entry(session->evlist, evsel) { |
2079 | if (evsel->idx == (int) desc[i].leader_idx) { | 2079 | if (evsel->idx == (int) desc[i].leader_idx) { |
2080 | evsel->leader = evsel; | 2080 | evsel->leader = evsel; |
2081 | /* {anon_group} is a dummy name */ | 2081 | /* {anon_group} is a dummy name */ |
@@ -2383,7 +2383,7 @@ int perf_session__write_header(struct perf_session *session, | |||
2383 | 2383 | ||
2384 | lseek(fd, sizeof(f_header), SEEK_SET); | 2384 | lseek(fd, sizeof(f_header), SEEK_SET); |
2385 | 2385 | ||
2386 | evlist__for_each(session->evlist, evsel) { | 2386 | evlist__for_each_entry(session->evlist, evsel) { |
2387 | evsel->id_offset = lseek(fd, 0, SEEK_CUR); | 2387 | evsel->id_offset = lseek(fd, 0, SEEK_CUR); |
2388 | err = do_write(fd, evsel->id, evsel->ids * sizeof(u64)); | 2388 | err = do_write(fd, evsel->id, evsel->ids * sizeof(u64)); |
2389 | if (err < 0) { | 2389 | if (err < 0) { |
@@ -2394,7 +2394,7 @@ int perf_session__write_header(struct perf_session *session, | |||
2394 | 2394 | ||
2395 | attr_offset = lseek(fd, 0, SEEK_CUR); | 2395 | attr_offset = lseek(fd, 0, SEEK_CUR); |
2396 | 2396 | ||
2397 | evlist__for_each(evlist, evsel) { | 2397 | evlist__for_each_entry(evlist, evsel) { |
2398 | f_attr = (struct perf_file_attr){ | 2398 | f_attr = (struct perf_file_attr){ |
2399 | .attr = evsel->attr, | 2399 | .attr = evsel->attr, |
2400 | .ids = { | 2400 | .ids = { |
@@ -2828,7 +2828,7 @@ static int perf_evlist__prepare_tracepoint_events(struct perf_evlist *evlist, | |||
2828 | { | 2828 | { |
2829 | struct perf_evsel *pos; | 2829 | struct perf_evsel *pos; |
2830 | 2830 | ||
2831 | evlist__for_each(evlist, pos) { | 2831 | evlist__for_each_entry(evlist, pos) { |
2832 | if (pos->attr.type == PERF_TYPE_TRACEPOINT && | 2832 | if (pos->attr.type == PERF_TYPE_TRACEPOINT && |
2833 | perf_evsel__prepare_tracepoint_event(pos, pevent)) | 2833 | perf_evsel__prepare_tracepoint_event(pos, pevent)) |
2834 | return -1; | 2834 | return -1; |
@@ -3127,7 +3127,7 @@ int perf_event__synthesize_attrs(struct perf_tool *tool, | |||
3127 | struct perf_evsel *evsel; | 3127 | struct perf_evsel *evsel; |
3128 | int err = 0; | 3128 | int err = 0; |
3129 | 3129 | ||
3130 | evlist__for_each(session->evlist, evsel) { | 3130 | evlist__for_each_entry(session->evlist, evsel) { |
3131 | err = perf_event__synthesize_attr(tool, &evsel->attr, evsel->ids, | 3131 | err = perf_event__synthesize_attr(tool, &evsel->attr, evsel->ids, |
3132 | evsel->id, process); | 3132 | evsel->id, process); |
3133 | if (err) { | 3133 | if (err) { |
diff --git a/tools/perf/util/help-unknown-cmd.c b/tools/perf/util/help-unknown-cmd.c index d62ccaeeadd6..776e28562345 100644 --- a/tools/perf/util/help-unknown-cmd.c +++ b/tools/perf/util/help-unknown-cmd.c | |||
@@ -1,4 +1,5 @@ | |||
1 | #include "cache.h" | 1 | #include "cache.h" |
2 | #include "config.h" | ||
2 | #include <subcmd/help.h> | 3 | #include <subcmd/help.h> |
3 | #include "../builtin.h" | 4 | #include "../builtin.h" |
4 | #include "levenshtein.h" | 5 | #include "levenshtein.h" |
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index d2647b1d82c0..e1fcc8d7c01a 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c | |||
@@ -79,7 +79,7 @@ void hists__calc_col_len(struct hists *hists, struct hist_entry *h) | |||
79 | 79 | ||
80 | len = thread__comm_len(h->thread); | 80 | len = thread__comm_len(h->thread); |
81 | if (hists__new_col_len(hists, HISTC_COMM, len)) | 81 | if (hists__new_col_len(hists, HISTC_COMM, len)) |
82 | hists__set_col_len(hists, HISTC_THREAD, len + 6); | 82 | hists__set_col_len(hists, HISTC_THREAD, len + 8); |
83 | 83 | ||
84 | if (h->ms.map) { | 84 | if (h->ms.map) { |
85 | len = dso__name_len(h->ms.map->dso); | 85 | len = dso__name_len(h->ms.map->dso); |
@@ -2199,7 +2199,7 @@ size_t perf_evlist__fprintf_nr_events(struct perf_evlist *evlist, FILE *fp) | |||
2199 | struct perf_evsel *pos; | 2199 | struct perf_evsel *pos; |
2200 | size_t ret = 0; | 2200 | size_t ret = 0; |
2201 | 2201 | ||
2202 | evlist__for_each(evlist, pos) { | 2202 | evlist__for_each_entry(evlist, pos) { |
2203 | ret += fprintf(fp, "%s stats:\n", perf_evsel__name(pos)); | 2203 | ret += fprintf(fp, "%s stats:\n", perf_evsel__name(pos)); |
2204 | ret += events_stats__fprintf(&evsel__hists(pos)->stats, fp); | 2204 | ret += events_stats__fprintf(&evsel__hists(pos)->stats, fp); |
2205 | } | 2205 | } |
diff --git a/tools/perf/util/intel-bts.c b/tools/perf/util/intel-bts.c index 9df996085563..749e6f2e37ca 100644 --- a/tools/perf/util/intel-bts.c +++ b/tools/perf/util/intel-bts.c | |||
@@ -422,7 +422,8 @@ static int intel_bts_get_branch_type(struct intel_bts_queue *btsq, | |||
422 | } | 422 | } |
423 | 423 | ||
424 | static int intel_bts_process_buffer(struct intel_bts_queue *btsq, | 424 | static int intel_bts_process_buffer(struct intel_bts_queue *btsq, |
425 | struct auxtrace_buffer *buffer) | 425 | struct auxtrace_buffer *buffer, |
426 | struct thread *thread) | ||
426 | { | 427 | { |
427 | struct branch *branch; | 428 | struct branch *branch; |
428 | size_t sz, bsz = sizeof(struct branch); | 429 | size_t sz, bsz = sizeof(struct branch); |
@@ -444,6 +445,12 @@ static int intel_bts_process_buffer(struct intel_bts_queue *btsq, | |||
444 | if (!branch->from && !branch->to) | 445 | if (!branch->from && !branch->to) |
445 | continue; | 446 | continue; |
446 | intel_bts_get_branch_type(btsq, branch); | 447 | intel_bts_get_branch_type(btsq, branch); |
448 | if (btsq->bts->synth_opts.thread_stack) | ||
449 | thread_stack__event(thread, btsq->sample_flags, | ||
450 | le64_to_cpu(branch->from), | ||
451 | le64_to_cpu(branch->to), | ||
452 | btsq->intel_pt_insn.length, | ||
453 | buffer->buffer_nr + 1); | ||
447 | if (filter && !(filter & btsq->sample_flags)) | 454 | if (filter && !(filter & btsq->sample_flags)) |
448 | continue; | 455 | continue; |
449 | err = intel_bts_synth_branch_sample(btsq, branch); | 456 | err = intel_bts_synth_branch_sample(btsq, branch); |
@@ -507,12 +514,13 @@ static int intel_bts_process_queue(struct intel_bts_queue *btsq, u64 *timestamp) | |||
507 | goto out_put; | 514 | goto out_put; |
508 | } | 515 | } |
509 | 516 | ||
510 | if (!btsq->bts->synth_opts.callchain && thread && | 517 | if (!btsq->bts->synth_opts.callchain && |
518 | !btsq->bts->synth_opts.thread_stack && thread && | ||
511 | (!old_buffer || btsq->bts->sampling_mode || | 519 | (!old_buffer || btsq->bts->sampling_mode || |
512 | (btsq->bts->snapshot_mode && !buffer->consecutive))) | 520 | (btsq->bts->snapshot_mode && !buffer->consecutive))) |
513 | thread_stack__set_trace_nr(thread, buffer->buffer_nr + 1); | 521 | thread_stack__set_trace_nr(thread, buffer->buffer_nr + 1); |
514 | 522 | ||
515 | err = intel_bts_process_buffer(btsq, buffer); | 523 | err = intel_bts_process_buffer(btsq, buffer, thread); |
516 | 524 | ||
517 | auxtrace_buffer__drop_data(buffer); | 525 | auxtrace_buffer__drop_data(buffer); |
518 | 526 | ||
@@ -777,7 +785,7 @@ static int intel_bts_synth_events(struct intel_bts *bts, | |||
777 | u64 id; | 785 | u64 id; |
778 | int err; | 786 | int err; |
779 | 787 | ||
780 | evlist__for_each(evlist, evsel) { | 788 | evlist__for_each_entry(evlist, evsel) { |
781 | if (evsel->attr.type == bts->pmu_type && evsel->ids) { | 789 | if (evsel->attr.type == bts->pmu_type && evsel->ids) { |
782 | found = true; | 790 | found = true; |
783 | break; | 791 | break; |
@@ -905,10 +913,14 @@ int intel_bts_process_auxtrace_info(union perf_event *event, | |||
905 | if (dump_trace) | 913 | if (dump_trace) |
906 | return 0; | 914 | return 0; |
907 | 915 | ||
908 | if (session->itrace_synth_opts && session->itrace_synth_opts->set) | 916 | if (session->itrace_synth_opts && session->itrace_synth_opts->set) { |
909 | bts->synth_opts = *session->itrace_synth_opts; | 917 | bts->synth_opts = *session->itrace_synth_opts; |
910 | else | 918 | } else { |
911 | itrace_synth_opts__set_default(&bts->synth_opts); | 919 | itrace_synth_opts__set_default(&bts->synth_opts); |
920 | if (session->itrace_synth_opts) | ||
921 | bts->synth_opts.thread_stack = | ||
922 | session->itrace_synth_opts->thread_stack; | ||
923 | } | ||
912 | 924 | ||
913 | if (bts->synth_opts.calls) | 925 | if (bts->synth_opts.calls) |
914 | bts->branches_filter |= PERF_IP_FLAG_CALL | PERF_IP_FLAG_ASYNC | | 926 | bts->branches_filter |= PERF_IP_FLAG_CALL | PERF_IP_FLAG_ASYNC | |
diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c index 137196990012..551ff6f640be 100644 --- a/tools/perf/util/intel-pt.c +++ b/tools/perf/util/intel-pt.c | |||
@@ -39,6 +39,7 @@ | |||
39 | #include "auxtrace.h" | 39 | #include "auxtrace.h" |
40 | #include "tsc.h" | 40 | #include "tsc.h" |
41 | #include "intel-pt.h" | 41 | #include "intel-pt.h" |
42 | #include "config.h" | ||
42 | 43 | ||
43 | #include "intel-pt-decoder/intel-pt-log.h" | 44 | #include "intel-pt-decoder/intel-pt-log.h" |
44 | #include "intel-pt-decoder/intel-pt-decoder.h" | 45 | #include "intel-pt-decoder/intel-pt-decoder.h" |
@@ -556,7 +557,7 @@ static bool intel_pt_exclude_kernel(struct intel_pt *pt) | |||
556 | { | 557 | { |
557 | struct perf_evsel *evsel; | 558 | struct perf_evsel *evsel; |
558 | 559 | ||
559 | evlist__for_each(pt->session->evlist, evsel) { | 560 | evlist__for_each_entry(pt->session->evlist, evsel) { |
560 | if (intel_pt_get_config(pt, &evsel->attr, NULL) && | 561 | if (intel_pt_get_config(pt, &evsel->attr, NULL) && |
561 | !evsel->attr.exclude_kernel) | 562 | !evsel->attr.exclude_kernel) |
562 | return false; | 563 | return false; |
@@ -572,7 +573,7 @@ static bool intel_pt_return_compression(struct intel_pt *pt) | |||
572 | if (!pt->noretcomp_bit) | 573 | if (!pt->noretcomp_bit) |
573 | return true; | 574 | return true; |
574 | 575 | ||
575 | evlist__for_each(pt->session->evlist, evsel) { | 576 | evlist__for_each_entry(pt->session->evlist, evsel) { |
576 | if (intel_pt_get_config(pt, &evsel->attr, &config) && | 577 | if (intel_pt_get_config(pt, &evsel->attr, &config) && |
577 | (config & pt->noretcomp_bit)) | 578 | (config & pt->noretcomp_bit)) |
578 | return false; | 579 | return false; |
@@ -592,7 +593,7 @@ static unsigned int intel_pt_mtc_period(struct intel_pt *pt) | |||
592 | for (shift = 0, config = pt->mtc_freq_bits; !(config & 1); shift++) | 593 | for (shift = 0, config = pt->mtc_freq_bits; !(config & 1); shift++) |
593 | config >>= 1; | 594 | config >>= 1; |
594 | 595 | ||
595 | evlist__for_each(pt->session->evlist, evsel) { | 596 | evlist__for_each_entry(pt->session->evlist, evsel) { |
596 | if (intel_pt_get_config(pt, &evsel->attr, &config)) | 597 | if (intel_pt_get_config(pt, &evsel->attr, &config)) |
597 | return (config & pt->mtc_freq_bits) >> shift; | 598 | return (config & pt->mtc_freq_bits) >> shift; |
598 | } | 599 | } |
@@ -608,7 +609,7 @@ static bool intel_pt_timeless_decoding(struct intel_pt *pt) | |||
608 | if (!pt->tsc_bit || !pt->cap_user_time_zero) | 609 | if (!pt->tsc_bit || !pt->cap_user_time_zero) |
609 | return true; | 610 | return true; |
610 | 611 | ||
611 | evlist__for_each(pt->session->evlist, evsel) { | 612 | evlist__for_each_entry(pt->session->evlist, evsel) { |
612 | if (!(evsel->attr.sample_type & PERF_SAMPLE_TIME)) | 613 | if (!(evsel->attr.sample_type & PERF_SAMPLE_TIME)) |
613 | return true; | 614 | return true; |
614 | if (intel_pt_get_config(pt, &evsel->attr, &config)) { | 615 | if (intel_pt_get_config(pt, &evsel->attr, &config)) { |
@@ -625,7 +626,7 @@ static bool intel_pt_tracing_kernel(struct intel_pt *pt) | |||
625 | { | 626 | { |
626 | struct perf_evsel *evsel; | 627 | struct perf_evsel *evsel; |
627 | 628 | ||
628 | evlist__for_each(pt->session->evlist, evsel) { | 629 | evlist__for_each_entry(pt->session->evlist, evsel) { |
629 | if (intel_pt_get_config(pt, &evsel->attr, NULL) && | 630 | if (intel_pt_get_config(pt, &evsel->attr, NULL) && |
630 | !evsel->attr.exclude_kernel) | 631 | !evsel->attr.exclude_kernel) |
631 | return true; | 632 | return true; |
@@ -642,7 +643,7 @@ static bool intel_pt_have_tsc(struct intel_pt *pt) | |||
642 | if (!pt->tsc_bit) | 643 | if (!pt->tsc_bit) |
643 | return false; | 644 | return false; |
644 | 645 | ||
645 | evlist__for_each(pt->session->evlist, evsel) { | 646 | evlist__for_each_entry(pt->session->evlist, evsel) { |
646 | if (intel_pt_get_config(pt, &evsel->attr, &config)) { | 647 | if (intel_pt_get_config(pt, &evsel->attr, &config)) { |
647 | if (config & pt->tsc_bit) | 648 | if (config & pt->tsc_bit) |
648 | have_tsc = true; | 649 | have_tsc = true; |
@@ -1233,7 +1234,7 @@ static int intel_pt_sample(struct intel_pt_queue *ptq) | |||
1233 | if (!(state->type & INTEL_PT_BRANCH)) | 1234 | if (!(state->type & INTEL_PT_BRANCH)) |
1234 | return 0; | 1235 | return 0; |
1235 | 1236 | ||
1236 | if (pt->synth_opts.callchain) | 1237 | if (pt->synth_opts.callchain || pt->synth_opts.thread_stack) |
1237 | thread_stack__event(ptq->thread, ptq->flags, state->from_ip, | 1238 | thread_stack__event(ptq->thread, ptq->flags, state->from_ip, |
1238 | state->to_ip, ptq->insn_len, | 1239 | state->to_ip, ptq->insn_len, |
1239 | state->trace_nr); | 1240 | state->trace_nr); |
@@ -1850,7 +1851,7 @@ static int intel_pt_synth_events(struct intel_pt *pt, | |||
1850 | u64 id; | 1851 | u64 id; |
1851 | int err; | 1852 | int err; |
1852 | 1853 | ||
1853 | evlist__for_each(evlist, evsel) { | 1854 | evlist__for_each_entry(evlist, evsel) { |
1854 | if (evsel->attr.type == pt->pmu_type && evsel->ids) { | 1855 | if (evsel->attr.type == pt->pmu_type && evsel->ids) { |
1855 | found = true; | 1856 | found = true; |
1856 | break; | 1857 | break; |
@@ -1930,7 +1931,7 @@ static int intel_pt_synth_events(struct intel_pt *pt, | |||
1930 | pt->sample_transactions = true; | 1931 | pt->sample_transactions = true; |
1931 | pt->transactions_id = id; | 1932 | pt->transactions_id = id; |
1932 | id += 1; | 1933 | id += 1; |
1933 | evlist__for_each(evlist, evsel) { | 1934 | evlist__for_each_entry(evlist, evsel) { |
1934 | if (evsel->id && evsel->id[0] == pt->transactions_id) { | 1935 | if (evsel->id && evsel->id[0] == pt->transactions_id) { |
1935 | if (evsel->name) | 1936 | if (evsel->name) |
1936 | zfree(&evsel->name); | 1937 | zfree(&evsel->name); |
@@ -1968,7 +1969,7 @@ static struct perf_evsel *intel_pt_find_sched_switch(struct perf_evlist *evlist) | |||
1968 | { | 1969 | { |
1969 | struct perf_evsel *evsel; | 1970 | struct perf_evsel *evsel; |
1970 | 1971 | ||
1971 | evlist__for_each_reverse(evlist, evsel) { | 1972 | evlist__for_each_entry_reverse(evlist, evsel) { |
1972 | const char *name = perf_evsel__name(evsel); | 1973 | const char *name = perf_evsel__name(evsel); |
1973 | 1974 | ||
1974 | if (!strcmp(name, "sched:sched_switch")) | 1975 | if (!strcmp(name, "sched:sched_switch")) |
@@ -1982,7 +1983,7 @@ static bool intel_pt_find_switch(struct perf_evlist *evlist) | |||
1982 | { | 1983 | { |
1983 | struct perf_evsel *evsel; | 1984 | struct perf_evsel *evsel; |
1984 | 1985 | ||
1985 | evlist__for_each(evlist, evsel) { | 1986 | evlist__for_each_entry(evlist, evsel) { |
1986 | if (evsel->attr.context_switch) | 1987 | if (evsel->attr.context_switch) |
1987 | return true; | 1988 | return true; |
1988 | } | 1989 | } |
@@ -2136,6 +2137,9 @@ int intel_pt_process_auxtrace_info(union perf_event *event, | |||
2136 | pt->synth_opts.branches = false; | 2137 | pt->synth_opts.branches = false; |
2137 | pt->synth_opts.callchain = true; | 2138 | pt->synth_opts.callchain = true; |
2138 | } | 2139 | } |
2140 | if (session->itrace_synth_opts) | ||
2141 | pt->synth_opts.thread_stack = | ||
2142 | session->itrace_synth_opts->thread_stack; | ||
2139 | } | 2143 | } |
2140 | 2144 | ||
2141 | if (pt->synth_opts.log) | 2145 | if (pt->synth_opts.log) |
diff --git a/tools/perf/util/intlist.h b/tools/perf/util/intlist.h index aa6877d36858..020b9ca1b47e 100644 --- a/tools/perf/util/intlist.h +++ b/tools/perf/util/intlist.h | |||
@@ -57,21 +57,21 @@ static inline struct int_node *intlist__next(struct int_node *in) | |||
57 | } | 57 | } |
58 | 58 | ||
59 | /** | 59 | /** |
60 | * intlist_for_each - iterate over a intlist | 60 | * intlist__for_each_entry - iterate over a intlist |
61 | * @pos: the &struct int_node to use as a loop cursor. | 61 | * @pos: the &struct int_node to use as a loop cursor. |
62 | * @ilist: the &struct intlist for loop. | 62 | * @ilist: the &struct intlist for loop. |
63 | */ | 63 | */ |
64 | #define intlist__for_each(pos, ilist) \ | 64 | #define intlist__for_each_entry(pos, ilist) \ |
65 | for (pos = intlist__first(ilist); pos; pos = intlist__next(pos)) | 65 | for (pos = intlist__first(ilist); pos; pos = intlist__next(pos)) |
66 | 66 | ||
67 | /** | 67 | /** |
68 | * intlist_for_each_safe - iterate over a intlist safe against removal of | 68 | * intlist__for_each_entry_safe - iterate over a intlist safe against removal of |
69 | * int_node | 69 | * int_node |
70 | * @pos: the &struct int_node to use as a loop cursor. | 70 | * @pos: the &struct int_node to use as a loop cursor. |
71 | * @n: another &struct int_node to use as temporary storage. | 71 | * @n: another &struct int_node to use as temporary storage. |
72 | * @ilist: the &struct intlist for loop. | 72 | * @ilist: the &struct intlist for loop. |
73 | */ | 73 | */ |
74 | #define intlist__for_each_safe(pos, n, ilist) \ | 74 | #define intlist__for_each_entry_safe(pos, n, ilist) \ |
75 | for (pos = intlist__first(ilist), n = intlist__next(pos); pos;\ | 75 | for (pos = intlist__first(ilist), n = intlist__next(pos); pos;\ |
76 | pos = n, n = intlist__next(n)) | 76 | pos = n, n = intlist__next(n)) |
77 | #endif /* __PERF_INTLIST_H */ | 77 | #endif /* __PERF_INTLIST_H */ |
diff --git a/tools/perf/util/jitdump.c b/tools/perf/util/jitdump.c index 86afe9618bb0..9f3305f6b6d5 100644 --- a/tools/perf/util/jitdump.c +++ b/tools/perf/util/jitdump.c | |||
@@ -108,7 +108,7 @@ jit_validate_events(struct perf_session *session) | |||
108 | /* | 108 | /* |
109 | * check that all events use CLOCK_MONOTONIC | 109 | * check that all events use CLOCK_MONOTONIC |
110 | */ | 110 | */ |
111 | evlist__for_each(session->evlist, evsel) { | 111 | evlist__for_each_entry(session->evlist, evsel) { |
112 | if (evsel->attr.use_clockid == 0 || evsel->attr.clockid != CLOCK_MONOTONIC) | 112 | if (evsel->attr.use_clockid == 0 || evsel->attr.clockid != CLOCK_MONOTONIC) |
113 | return -1; | 113 | return -1; |
114 | } | 114 | } |
diff --git a/tools/perf/util/libunwind/arm64.c b/tools/perf/util/libunwind/arm64.c index 4fb5395669f8..6559bc586643 100644 --- a/tools/perf/util/libunwind/arm64.c +++ b/tools/perf/util/libunwind/arm64.c | |||
@@ -13,7 +13,12 @@ | |||
13 | 13 | ||
14 | #define REMOTE_UNWIND_LIBUNWIND | 14 | #define REMOTE_UNWIND_LIBUNWIND |
15 | 15 | ||
16 | /* Define arch specific functions & regs for libunwind, should be | ||
17 | * defined before including "unwind.h" | ||
18 | */ | ||
16 | #define LIBUNWIND__ARCH_REG_ID(regnum) libunwind__arm64_reg_id(regnum) | 19 | #define LIBUNWIND__ARCH_REG_ID(regnum) libunwind__arm64_reg_id(regnum) |
20 | #define LIBUNWIND__ARCH_REG_IP PERF_REG_ARM64_PC | ||
21 | #define LIBUNWIND__ARCH_REG_SP PERF_REG_ARM64_SP | ||
17 | 22 | ||
18 | #include "unwind.h" | 23 | #include "unwind.h" |
19 | #include "debug.h" | 24 | #include "debug.h" |
diff --git a/tools/perf/util/libunwind/x86_32.c b/tools/perf/util/libunwind/x86_32.c index d98c17e19a2b..957ffff72428 100644 --- a/tools/perf/util/libunwind/x86_32.c +++ b/tools/perf/util/libunwind/x86_32.c | |||
@@ -12,7 +12,13 @@ | |||
12 | */ | 12 | */ |
13 | 13 | ||
14 | #define REMOTE_UNWIND_LIBUNWIND | 14 | #define REMOTE_UNWIND_LIBUNWIND |
15 | |||
16 | /* Define arch specific functions & regs for libunwind, should be | ||
17 | * defined before including "unwind.h" | ||
18 | */ | ||
15 | #define LIBUNWIND__ARCH_REG_ID(regnum) libunwind__x86_reg_id(regnum) | 19 | #define LIBUNWIND__ARCH_REG_ID(regnum) libunwind__x86_reg_id(regnum) |
20 | #define LIBUNWIND__ARCH_REG_IP PERF_REG_X86_IP | ||
21 | #define LIBUNWIND__ARCH_REG_SP PERF_REG_X86_SP | ||
16 | 22 | ||
17 | #include "unwind.h" | 23 | #include "unwind.h" |
18 | #include "debug.h" | 24 | #include "debug.h" |
diff --git a/tools/perf/util/llvm-utils.c b/tools/perf/util/llvm-utils.c index 878a566763c3..40b6f7269cb4 100644 --- a/tools/perf/util/llvm-utils.c +++ b/tools/perf/util/llvm-utils.c | |||
@@ -8,6 +8,7 @@ | |||
8 | #include <stdlib.h> | 8 | #include <stdlib.h> |
9 | #include "debug.h" | 9 | #include "debug.h" |
10 | #include "llvm-utils.h" | 10 | #include "llvm-utils.h" |
11 | #include "config.h" | ||
11 | 12 | ||
12 | #define CLANG_BPF_CMD_DEFAULT_TEMPLATE \ | 13 | #define CLANG_BPF_CMD_DEFAULT_TEMPLATE \ |
13 | "$CLANG_EXEC -D__KERNEL__ -D__NR_CPUS__=$NR_CPUS "\ | 14 | "$CLANG_EXEC -D__KERNEL__ -D__NR_CPUS__=$NR_CPUS "\ |
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index a0c186acb1f3..bc2cdbd09a25 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c | |||
@@ -138,8 +138,10 @@ void machine__exit(struct machine *machine) | |||
138 | 138 | ||
139 | void machine__delete(struct machine *machine) | 139 | void machine__delete(struct machine *machine) |
140 | { | 140 | { |
141 | machine__exit(machine); | 141 | if (machine) { |
142 | free(machine); | 142 | machine__exit(machine); |
143 | free(machine); | ||
144 | } | ||
143 | } | 145 | } |
144 | 146 | ||
145 | void machines__init(struct machines *machines) | 147 | void machines__init(struct machines *machines) |
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index d15e335842b7..ebd87b773f56 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c | |||
@@ -1396,7 +1396,7 @@ int parse_events__modifier_event(struct list_head *list, char *str, bool add) | |||
1396 | if (!add && get_event_modifier(&mod, str, NULL)) | 1396 | if (!add && get_event_modifier(&mod, str, NULL)) |
1397 | return -EINVAL; | 1397 | return -EINVAL; |
1398 | 1398 | ||
1399 | __evlist__for_each(list, evsel) { | 1399 | __evlist__for_each_entry(list, evsel) { |
1400 | if (add && get_event_modifier(&mod, str, evsel)) | 1400 | if (add && get_event_modifier(&mod, str, evsel)) |
1401 | return -EINVAL; | 1401 | return -EINVAL; |
1402 | 1402 | ||
@@ -1422,7 +1422,7 @@ int parse_events_name(struct list_head *list, char *name) | |||
1422 | { | 1422 | { |
1423 | struct perf_evsel *evsel; | 1423 | struct perf_evsel *evsel; |
1424 | 1424 | ||
1425 | __evlist__for_each(list, evsel) { | 1425 | __evlist__for_each_entry(list, evsel) { |
1426 | if (!evsel->name) | 1426 | if (!evsel->name) |
1427 | evsel->name = strdup(name); | 1427 | evsel->name = strdup(name); |
1428 | } | 1428 | } |
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c index 084756c17309..55f41d5e20d1 100644 --- a/tools/perf/util/probe-event.c +++ b/tools/perf/util/probe-event.c | |||
@@ -102,10 +102,8 @@ out: | |||
102 | 102 | ||
103 | void exit_probe_symbol_maps(void) | 103 | void exit_probe_symbol_maps(void) |
104 | { | 104 | { |
105 | if (host_machine) { | 105 | machine__delete(host_machine); |
106 | machine__delete(host_machine); | 106 | host_machine = NULL; |
107 | host_machine = NULL; | ||
108 | } | ||
109 | symbol__exit(); | 107 | symbol__exit(); |
110 | } | 108 | } |
111 | 109 | ||
@@ -898,7 +896,7 @@ static int __show_line_range(struct line_range *lr, const char *module, | |||
898 | goto end; | 896 | goto end; |
899 | } | 897 | } |
900 | 898 | ||
901 | intlist__for_each(ln, lr->line_list) { | 899 | intlist__for_each_entry(ln, lr->line_list) { |
902 | for (; ln->i > l; l++) { | 900 | for (; ln->i > l; l++) { |
903 | ret = show_one_line(fp, l - lr->offset); | 901 | ret = show_one_line(fp, l - lr->offset); |
904 | if (ret < 0) | 902 | if (ret < 0) |
@@ -982,7 +980,7 @@ static int show_available_vars_at(struct debuginfo *dinfo, | |||
982 | zfree(&vl->point.symbol); | 980 | zfree(&vl->point.symbol); |
983 | nvars = 0; | 981 | nvars = 0; |
984 | if (vl->vars) { | 982 | if (vl->vars) { |
985 | strlist__for_each(node, vl->vars) { | 983 | strlist__for_each_entry(node, vl->vars) { |
986 | var = strchr(node->s, '\t') + 1; | 984 | var = strchr(node->s, '\t') + 1; |
987 | if (strfilter__compare(_filter, var)) { | 985 | if (strfilter__compare(_filter, var)) { |
988 | fprintf(stdout, "\t\t%s\n", node->s); | 986 | fprintf(stdout, "\t\t%s\n", node->s); |
@@ -2335,7 +2333,7 @@ static int __show_perf_probe_events(int fd, bool is_kprobe, | |||
2335 | if (!rawlist) | 2333 | if (!rawlist) |
2336 | return -ENOMEM; | 2334 | return -ENOMEM; |
2337 | 2335 | ||
2338 | strlist__for_each(ent, rawlist) { | 2336 | strlist__for_each_entry(ent, rawlist) { |
2339 | ret = parse_probe_trace_command(ent->s, &tev); | 2337 | ret = parse_probe_trace_command(ent->s, &tev); |
2340 | if (ret >= 0) { | 2338 | if (ret >= 0) { |
2341 | if (!filter_probe_trace_event(&tev, filter)) | 2339 | if (!filter_probe_trace_event(&tev, filter)) |
diff --git a/tools/perf/util/probe-file.c b/tools/perf/util/probe-file.c index 25a40427003e..1c12c1ab19c9 100644 --- a/tools/perf/util/probe-file.c +++ b/tools/perf/util/probe-file.c | |||
@@ -178,7 +178,7 @@ static struct strlist *__probe_file__get_namelist(int fd, bool include_group) | |||
178 | if (!rawlist) | 178 | if (!rawlist) |
179 | return NULL; | 179 | return NULL; |
180 | sl = strlist__new(NULL, NULL); | 180 | sl = strlist__new(NULL, NULL); |
181 | strlist__for_each(ent, rawlist) { | 181 | strlist__for_each_entry(ent, rawlist) { |
182 | ret = parse_probe_trace_command(ent->s, &tev); | 182 | ret = parse_probe_trace_command(ent->s, &tev); |
183 | if (ret < 0) | 183 | if (ret < 0) |
184 | break; | 184 | break; |
@@ -281,7 +281,7 @@ int probe_file__get_events(int fd, struct strfilter *filter, | |||
281 | if (!namelist) | 281 | if (!namelist) |
282 | return -ENOENT; | 282 | return -ENOENT; |
283 | 283 | ||
284 | strlist__for_each(ent, namelist) { | 284 | strlist__for_each_entry(ent, namelist) { |
285 | p = strchr(ent->s, ':'); | 285 | p = strchr(ent->s, ':'); |
286 | if ((p && strfilter__compare(filter, p + 1)) || | 286 | if ((p && strfilter__compare(filter, p + 1)) || |
287 | strfilter__compare(filter, ent->s)) { | 287 | strfilter__compare(filter, ent->s)) { |
@@ -299,7 +299,7 @@ int probe_file__del_strlist(int fd, struct strlist *namelist) | |||
299 | int ret = 0; | 299 | int ret = 0; |
300 | struct str_node *ent; | 300 | struct str_node *ent; |
301 | 301 | ||
302 | strlist__for_each(ent, namelist) { | 302 | strlist__for_each_entry(ent, namelist) { |
303 | ret = __del_trace_probe_event(fd, ent); | 303 | ret = __del_trace_probe_event(fd, ent); |
304 | if (ret < 0) | 304 | if (ret < 0) |
305 | break; | 305 | break; |
@@ -612,7 +612,7 @@ static int probe_cache_entry__write(struct probe_cache_entry *entry, int fd) | |||
612 | if (ret < (int)iov[1].iov_len + 2) | 612 | if (ret < (int)iov[1].iov_len + 2) |
613 | goto rollback; | 613 | goto rollback; |
614 | 614 | ||
615 | strlist__for_each(snode, entry->tevlist) { | 615 | strlist__for_each_entry(snode, entry->tevlist) { |
616 | iov[0].iov_base = (void *)snode->s; | 616 | iov[0].iov_base = (void *)snode->s; |
617 | iov[0].iov_len = strlen(snode->s); | 617 | iov[0].iov_len = strlen(snode->s); |
618 | iov[1].iov_base = (void *)"\n"; iov[1].iov_len = 1; | 618 | iov[1].iov_base = (void *)"\n"; iov[1].iov_len = 1; |
diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c index 98f127abfa42..65c6c73d28fe 100644 --- a/tools/perf/util/python.c +++ b/tools/perf/util/python.c | |||
@@ -957,7 +957,7 @@ static PyObject *pyrf_evlist__item(PyObject *obj, Py_ssize_t i) | |||
957 | if (i >= pevlist->evlist.nr_entries) | 957 | if (i >= pevlist->evlist.nr_entries) |
958 | return NULL; | 958 | return NULL; |
959 | 959 | ||
960 | evlist__for_each(&pevlist->evlist, pos) { | 960 | evlist__for_each_entry(&pevlist->evlist, pos) { |
961 | if (i-- == 0) | 961 | if (i-- == 0) |
962 | break; | 962 | break; |
963 | } | 963 | } |
diff --git a/tools/perf/util/rb_resort.h b/tools/perf/util/rb_resort.h index abc76e3d3098..808cc45611fe 100644 --- a/tools/perf/util/rb_resort.h +++ b/tools/perf/util/rb_resort.h | |||
@@ -35,7 +35,7 @@ DEFINE_RB_RESORT_RB(threads, strcmp(a->thread->shortname, | |||
35 | 35 | ||
36 | struct rb_node *nd; | 36 | struct rb_node *nd; |
37 | 37 | ||
38 | resort_rb__for_each(nd, threads) { | 38 | resort_rb__for_each_entry(nd, threads) { |
39 | struct thread *t = threads_entry; | 39 | struct thread *t = threads_entry; |
40 | printf("%s: %d\n", t->shortname, t->tid); | 40 | printf("%s: %d\n", t->shortname, t->tid); |
41 | } | 41 | } |
@@ -123,7 +123,7 @@ static void __name##_sorted__init_entry(struct rb_node *nd, \ | |||
123 | struct __name##_sorted_entry *__name##_entry; \ | 123 | struct __name##_sorted_entry *__name##_entry; \ |
124 | struct __name##_sorted *__name = __name##_sorted__new | 124 | struct __name##_sorted *__name = __name##_sorted__new |
125 | 125 | ||
126 | #define resort_rb__for_each(__nd, __name) \ | 126 | #define resort_rb__for_each_entry(__nd, __name) \ |
127 | for (__nd = rb_first(&__name->entries); \ | 127 | for (__nd = rb_first(&__name->entries); \ |
128 | __name##_entry = rb_entry(__nd, struct __name##_sorted_entry, \ | 128 | __name##_entry = rb_entry(__nd, struct __name##_sorted_entry, \ |
129 | rb_node), __nd; \ | 129 | rb_node), __nd; \ |
diff --git a/tools/perf/util/record.c b/tools/perf/util/record.c index 481792c7484b..98bf584853ea 100644 --- a/tools/perf/util/record.c +++ b/tools/perf/util/record.c | |||
@@ -148,7 +148,7 @@ void perf_evlist__config(struct perf_evlist *evlist, struct record_opts *opts, | |||
148 | 148 | ||
149 | use_comm_exec = perf_can_comm_exec(); | 149 | use_comm_exec = perf_can_comm_exec(); |
150 | 150 | ||
151 | evlist__for_each(evlist, evsel) { | 151 | evlist__for_each_entry(evlist, evsel) { |
152 | perf_evsel__config(evsel, opts, callchain); | 152 | perf_evsel__config(evsel, opts, callchain); |
153 | if (evsel->tracking && use_comm_exec) | 153 | if (evsel->tracking && use_comm_exec) |
154 | evsel->attr.comm_exec = 1; | 154 | evsel->attr.comm_exec = 1; |
@@ -161,18 +161,18 @@ void perf_evlist__config(struct perf_evlist *evlist, struct record_opts *opts, | |||
161 | * match the id. | 161 | * match the id. |
162 | */ | 162 | */ |
163 | use_sample_identifier = perf_can_sample_identifier(); | 163 | use_sample_identifier = perf_can_sample_identifier(); |
164 | evlist__for_each(evlist, evsel) | 164 | evlist__for_each_entry(evlist, evsel) |
165 | perf_evsel__set_sample_id(evsel, use_sample_identifier); | 165 | perf_evsel__set_sample_id(evsel, use_sample_identifier); |
166 | } else if (evlist->nr_entries > 1) { | 166 | } else if (evlist->nr_entries > 1) { |
167 | struct perf_evsel *first = perf_evlist__first(evlist); | 167 | struct perf_evsel *first = perf_evlist__first(evlist); |
168 | 168 | ||
169 | evlist__for_each(evlist, evsel) { | 169 | evlist__for_each_entry(evlist, evsel) { |
170 | if (evsel->attr.sample_type == first->attr.sample_type) | 170 | if (evsel->attr.sample_type == first->attr.sample_type) |
171 | continue; | 171 | continue; |
172 | use_sample_identifier = perf_can_sample_identifier(); | 172 | use_sample_identifier = perf_can_sample_identifier(); |
173 | break; | 173 | break; |
174 | } | 174 | } |
175 | evlist__for_each(evlist, evsel) | 175 | evlist__for_each_entry(evlist, evsel) |
176 | perf_evsel__set_sample_id(evsel, use_sample_identifier); | 176 | perf_evsel__set_sample_id(evsel, use_sample_identifier); |
177 | } | 177 | } |
178 | 178 | ||
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index dfedf097b9b1..078d49626494 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c | |||
@@ -83,7 +83,7 @@ static bool perf_session__has_comm_exec(struct perf_session *session) | |||
83 | { | 83 | { |
84 | struct perf_evsel *evsel; | 84 | struct perf_evsel *evsel; |
85 | 85 | ||
86 | evlist__for_each(session->evlist, evsel) { | 86 | evlist__for_each_entry(session->evlist, evsel) { |
87 | if (evsel->attr.comm_exec) | 87 | if (evsel->attr.comm_exec) |
88 | return true; | 88 | return true; |
89 | } | 89 | } |
@@ -178,6 +178,8 @@ static void perf_session__delete_threads(struct perf_session *session) | |||
178 | 178 | ||
179 | void perf_session__delete(struct perf_session *session) | 179 | void perf_session__delete(struct perf_session *session) |
180 | { | 180 | { |
181 | if (session == NULL) | ||
182 | return; | ||
181 | auxtrace__free(session); | 183 | auxtrace__free(session); |
182 | auxtrace_index__free(&session->auxtrace_index); | 184 | auxtrace_index__free(&session->auxtrace_index); |
183 | perf_session__destroy_kernel_maps(session); | 185 | perf_session__destroy_kernel_maps(session); |
@@ -1870,7 +1872,7 @@ bool perf_session__has_traces(struct perf_session *session, const char *msg) | |||
1870 | { | 1872 | { |
1871 | struct perf_evsel *evsel; | 1873 | struct perf_evsel *evsel; |
1872 | 1874 | ||
1873 | evlist__for_each(session->evlist, evsel) { | 1875 | evlist__for_each_entry(session->evlist, evsel) { |
1874 | if (evsel->attr.type == PERF_TYPE_TRACEPOINT) | 1876 | if (evsel->attr.type == PERF_TYPE_TRACEPOINT) |
1875 | return true; | 1877 | return true; |
1876 | } | 1878 | } |
@@ -1952,7 +1954,7 @@ struct perf_evsel *perf_session__find_first_evtype(struct perf_session *session, | |||
1952 | { | 1954 | { |
1953 | struct perf_evsel *pos; | 1955 | struct perf_evsel *pos; |
1954 | 1956 | ||
1955 | evlist__for_each(session->evlist, pos) { | 1957 | evlist__for_each_entry(session->evlist, pos) { |
1956 | if (pos->attr.type == type) | 1958 | if (pos->attr.type == type) |
1957 | return pos; | 1959 | return pos; |
1958 | } | 1960 | } |
@@ -2107,7 +2109,7 @@ int perf_event__synthesize_id_index(struct perf_tool *tool, | |||
2107 | max_nr = (UINT16_MAX - sizeof(struct id_index_event)) / | 2109 | max_nr = (UINT16_MAX - sizeof(struct id_index_event)) / |
2108 | sizeof(struct id_index_entry); | 2110 | sizeof(struct id_index_entry); |
2109 | 2111 | ||
2110 | evlist__for_each(evlist, evsel) | 2112 | evlist__for_each_entry(evlist, evsel) |
2111 | nr += evsel->ids; | 2113 | nr += evsel->ids; |
2112 | 2114 | ||
2113 | n = nr > max_nr ? max_nr : nr; | 2115 | n = nr > max_nr ? max_nr : nr; |
@@ -2120,7 +2122,7 @@ int perf_event__synthesize_id_index(struct perf_tool *tool, | |||
2120 | ev->id_index.header.size = sz; | 2122 | ev->id_index.header.size = sz; |
2121 | ev->id_index.nr = n; | 2123 | ev->id_index.nr = n; |
2122 | 2124 | ||
2123 | evlist__for_each(evlist, evsel) { | 2125 | evlist__for_each_entry(evlist, evsel) { |
2124 | u32 j; | 2126 | u32 j; |
2125 | 2127 | ||
2126 | for (j = 0; j < evsel->ids; j++) { | 2128 | for (j = 0; j < evsel->ids; j++) { |
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c index 896d34ebcc1e..5854b4660a49 100644 --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c | |||
@@ -79,8 +79,8 @@ static int hist_entry__thread_snprintf(struct hist_entry *he, char *bf, | |||
79 | { | 79 | { |
80 | const char *comm = thread__comm_str(he->thread); | 80 | const char *comm = thread__comm_str(he->thread); |
81 | 81 | ||
82 | width = max(7U, width) - 6; | 82 | width = max(7U, width) - 8; |
83 | return repsep_snprintf(bf, size, "%5d:%-*.*s", he->thread->tid, | 83 | return repsep_snprintf(bf, size, "%7d:%-*.*s", he->thread->tid, |
84 | width, width, comm ?: ""); | 84 | width, width, comm ?: ""); |
85 | } | 85 | } |
86 | 86 | ||
@@ -95,7 +95,7 @@ static int hist_entry__thread_filter(struct hist_entry *he, int type, const void | |||
95 | } | 95 | } |
96 | 96 | ||
97 | struct sort_entry sort_thread = { | 97 | struct sort_entry sort_thread = { |
98 | .se_header = " Pid:Command", | 98 | .se_header = " Pid:Command", |
99 | .se_cmp = sort__thread_cmp, | 99 | .se_cmp = sort__thread_cmp, |
100 | .se_snprintf = hist_entry__thread_snprintf, | 100 | .se_snprintf = hist_entry__thread_snprintf, |
101 | .se_filter = hist_entry__thread_filter, | 101 | .se_filter = hist_entry__thread_filter, |
@@ -2069,7 +2069,7 @@ static struct perf_evsel *find_evsel(struct perf_evlist *evlist, char *event_nam | |||
2069 | } | 2069 | } |
2070 | 2070 | ||
2071 | full_name = !!strchr(event_name, ':'); | 2071 | full_name = !!strchr(event_name, ':'); |
2072 | evlist__for_each(evlist, pos) { | 2072 | evlist__for_each_entry(evlist, pos) { |
2073 | /* case 2 */ | 2073 | /* case 2 */ |
2074 | if (full_name && !strcmp(pos->name, event_name)) | 2074 | if (full_name && !strcmp(pos->name, event_name)) |
2075 | return pos; | 2075 | return pos; |
@@ -2125,7 +2125,7 @@ static int add_all_dynamic_fields(struct perf_evlist *evlist, bool raw_trace, | |||
2125 | int ret; | 2125 | int ret; |
2126 | struct perf_evsel *evsel; | 2126 | struct perf_evsel *evsel; |
2127 | 2127 | ||
2128 | evlist__for_each(evlist, evsel) { | 2128 | evlist__for_each_entry(evlist, evsel) { |
2129 | if (evsel->attr.type != PERF_TYPE_TRACEPOINT) | 2129 | if (evsel->attr.type != PERF_TYPE_TRACEPOINT) |
2130 | continue; | 2130 | continue; |
2131 | 2131 | ||
@@ -2143,7 +2143,7 @@ static int add_all_matching_fields(struct perf_evlist *evlist, | |||
2143 | struct perf_evsel *evsel; | 2143 | struct perf_evsel *evsel; |
2144 | struct format_field *field; | 2144 | struct format_field *field; |
2145 | 2145 | ||
2146 | evlist__for_each(evlist, evsel) { | 2146 | evlist__for_each_entry(evlist, evsel) { |
2147 | if (evsel->attr.type != PERF_TYPE_TRACEPOINT) | 2147 | if (evsel->attr.type != PERF_TYPE_TRACEPOINT) |
2148 | continue; | 2148 | continue; |
2149 | 2149 | ||
@@ -2456,7 +2456,7 @@ static const char *get_default_sort_order(struct perf_evlist *evlist) | |||
2456 | if (evlist == NULL) | 2456 | if (evlist == NULL) |
2457 | goto out_no_evlist; | 2457 | goto out_no_evlist; |
2458 | 2458 | ||
2459 | evlist__for_each(evlist, evsel) { | 2459 | evlist__for_each_entry(evlist, evsel) { |
2460 | if (evsel->attr.type != PERF_TYPE_TRACEPOINT) { | 2460 | if (evsel->attr.type != PERF_TYPE_TRACEPOINT) { |
2461 | use_trace = false; | 2461 | use_trace = false; |
2462 | break; | 2462 | break; |
diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c index c1ba255f2abe..39345c2ddfc2 100644 --- a/tools/perf/util/stat.c +++ b/tools/perf/util/stat.c | |||
@@ -162,7 +162,7 @@ int perf_evlist__alloc_stats(struct perf_evlist *evlist, bool alloc_raw) | |||
162 | { | 162 | { |
163 | struct perf_evsel *evsel; | 163 | struct perf_evsel *evsel; |
164 | 164 | ||
165 | evlist__for_each(evlist, evsel) { | 165 | evlist__for_each_entry(evlist, evsel) { |
166 | if (perf_evsel__alloc_stats(evsel, alloc_raw)) | 166 | if (perf_evsel__alloc_stats(evsel, alloc_raw)) |
167 | goto out_free; | 167 | goto out_free; |
168 | } | 168 | } |
@@ -178,7 +178,7 @@ void perf_evlist__free_stats(struct perf_evlist *evlist) | |||
178 | { | 178 | { |
179 | struct perf_evsel *evsel; | 179 | struct perf_evsel *evsel; |
180 | 180 | ||
181 | evlist__for_each(evlist, evsel) { | 181 | evlist__for_each_entry(evlist, evsel) { |
182 | perf_evsel__free_stat_priv(evsel); | 182 | perf_evsel__free_stat_priv(evsel); |
183 | perf_evsel__free_counts(evsel); | 183 | perf_evsel__free_counts(evsel); |
184 | perf_evsel__free_prev_raw_counts(evsel); | 184 | perf_evsel__free_prev_raw_counts(evsel); |
@@ -189,7 +189,7 @@ void perf_evlist__reset_stats(struct perf_evlist *evlist) | |||
189 | { | 189 | { |
190 | struct perf_evsel *evsel; | 190 | struct perf_evsel *evsel; |
191 | 191 | ||
192 | evlist__for_each(evlist, evsel) { | 192 | evlist__for_each_entry(evlist, evsel) { |
193 | perf_evsel__reset_stat_priv(evsel); | 193 | perf_evsel__reset_stat_priv(evsel); |
194 | perf_evsel__reset_counts(evsel); | 194 | perf_evsel__reset_counts(evsel); |
195 | } | 195 | } |
diff --git a/tools/perf/util/strlist.h b/tools/perf/util/strlist.h index ca990029e243..19207e50fce5 100644 --- a/tools/perf/util/strlist.h +++ b/tools/perf/util/strlist.h | |||
@@ -73,7 +73,7 @@ static inline struct str_node *strlist__next(struct str_node *sn) | |||
73 | * @pos: the &struct str_node to use as a loop cursor. | 73 | * @pos: the &struct str_node to use as a loop cursor. |
74 | * @slist: the &struct strlist for loop. | 74 | * @slist: the &struct strlist for loop. |
75 | */ | 75 | */ |
76 | #define strlist__for_each(pos, slist) \ | 76 | #define strlist__for_each_entry(pos, slist) \ |
77 | for (pos = strlist__first(slist); pos; pos = strlist__next(pos)) | 77 | for (pos = strlist__first(slist); pos; pos = strlist__next(pos)) |
78 | 78 | ||
79 | /** | 79 | /** |
@@ -83,7 +83,7 @@ static inline struct str_node *strlist__next(struct str_node *sn) | |||
83 | * @n: another &struct str_node to use as temporary storage. | 83 | * @n: another &struct str_node to use as temporary storage. |
84 | * @slist: the &struct strlist for loop. | 84 | * @slist: the &struct strlist for loop. |
85 | */ | 85 | */ |
86 | #define strlist__for_each_safe(pos, n, slist) \ | 86 | #define strlist__for_each_entry_safe(pos, n, slist) \ |
87 | for (pos = strlist__first(slist), n = strlist__next(pos); pos;\ | 87 | for (pos = strlist__first(slist), n = strlist__next(pos); pos;\ |
88 | pos = n, n = strlist__next(n)) | 88 | pos = n, n = strlist__next(n)) |
89 | #endif /* __PERF_STRLIST_H */ | 89 | #endif /* __PERF_STRLIST_H */ |
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index 09c5c34ae38d..b044f1a32d16 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c | |||
@@ -1626,7 +1626,7 @@ static int find_matching_kcore(struct map *map, char *dir, size_t dir_sz) | |||
1626 | if (!dirs) | 1626 | if (!dirs) |
1627 | return -1; | 1627 | return -1; |
1628 | 1628 | ||
1629 | strlist__for_each(nd, dirs) { | 1629 | strlist__for_each_entry(nd, dirs) { |
1630 | scnprintf(kallsyms_filename, sizeof(kallsyms_filename), | 1630 | scnprintf(kallsyms_filename, sizeof(kallsyms_filename), |
1631 | "%s/%s/kallsyms", dir, nd->s); | 1631 | "%s/%s/kallsyms", dir, nd->s); |
1632 | if (!validate_kcore_addresses(kallsyms_filename, map)) { | 1632 | if (!validate_kcore_addresses(kallsyms_filename, map)) { |
diff --git a/tools/perf/util/thread-stack.c b/tools/perf/util/thread-stack.c index 825086aa9a08..d3301529f6a7 100644 --- a/tools/perf/util/thread-stack.c +++ b/tools/perf/util/thread-stack.c | |||
@@ -616,3 +616,10 @@ int thread_stack__process(struct thread *thread, struct comm *comm, | |||
616 | 616 | ||
617 | return err; | 617 | return err; |
618 | } | 618 | } |
619 | |||
620 | size_t thread_stack__depth(struct thread *thread) | ||
621 | { | ||
622 | if (!thread->ts) | ||
623 | return 0; | ||
624 | return thread->ts->cnt; | ||
625 | } | ||
diff --git a/tools/perf/util/thread-stack.h b/tools/perf/util/thread-stack.h index ad44c7944b8e..b7e41c4ebfdd 100644 --- a/tools/perf/util/thread-stack.h +++ b/tools/perf/util/thread-stack.h | |||
@@ -87,6 +87,7 @@ void thread_stack__sample(struct thread *thread, struct ip_callchain *chain, | |||
87 | size_t sz, u64 ip); | 87 | size_t sz, u64 ip); |
88 | int thread_stack__flush(struct thread *thread); | 88 | int thread_stack__flush(struct thread *thread); |
89 | void thread_stack__free(struct thread *thread); | 89 | void thread_stack__free(struct thread *thread); |
90 | size_t thread_stack__depth(struct thread *thread); | ||
90 | 91 | ||
91 | struct call_return_processor * | 92 | struct call_return_processor * |
92 | call_return_processor__new(int (*process)(struct call_return *cr, void *data), | 93 | call_return_processor__new(int (*process)(struct call_return *cr, void *data), |
diff --git a/tools/perf/util/thread_map.c b/tools/perf/util/thread_map.c index 5654fe15e036..40585f5b7027 100644 --- a/tools/perf/util/thread_map.c +++ b/tools/perf/util/thread_map.c | |||
@@ -202,7 +202,7 @@ static struct thread_map *thread_map__new_by_pid_str(const char *pid_str) | |||
202 | if (!slist) | 202 | if (!slist) |
203 | return NULL; | 203 | return NULL; |
204 | 204 | ||
205 | strlist__for_each(pos, slist) { | 205 | strlist__for_each_entry(pos, slist) { |
206 | pid = strtol(pos->s, &end_ptr, 10); | 206 | pid = strtol(pos->s, &end_ptr, 10); |
207 | 207 | ||
208 | if (pid == INT_MIN || pid == INT_MAX || | 208 | if (pid == INT_MIN || pid == INT_MAX || |
@@ -278,7 +278,7 @@ struct thread_map *thread_map__new_by_tid_str(const char *tid_str) | |||
278 | if (!slist) | 278 | if (!slist) |
279 | return NULL; | 279 | return NULL; |
280 | 280 | ||
281 | strlist__for_each(pos, slist) { | 281 | strlist__for_each_entry(pos, slist) { |
282 | tid = strtol(pos->s, &end_ptr, 10); | 282 | tid = strtol(pos->s, &end_ptr, 10); |
283 | 283 | ||
284 | if (tid == INT_MIN || tid == INT_MAX || | 284 | if (tid == INT_MIN || tid == INT_MAX || |
diff --git a/tools/perf/util/unwind-libunwind-local.c b/tools/perf/util/unwind-libunwind-local.c index 01c2e86977f4..97c0f8fc5561 100644 --- a/tools/perf/util/unwind-libunwind-local.c +++ b/tools/perf/util/unwind-libunwind-local.c | |||
@@ -462,7 +462,8 @@ static int access_mem(unw_addr_space_t __maybe_unused as, | |||
462 | return 0; | 462 | return 0; |
463 | } | 463 | } |
464 | 464 | ||
465 | ret = perf_reg_value(&start, &ui->sample->user_regs, PERF_REG_SP); | 465 | ret = perf_reg_value(&start, &ui->sample->user_regs, |
466 | LIBUNWIND__ARCH_REG_SP); | ||
466 | if (ret) | 467 | if (ret) |
467 | return ret; | 468 | return ret; |
468 | 469 | ||
@@ -621,7 +622,8 @@ static int get_entries(struct unwind_info *ui, unwind_entry_cb_t cb, | |||
621 | unw_cursor_t c; | 622 | unw_cursor_t c; |
622 | int ret, i = 0; | 623 | int ret, i = 0; |
623 | 624 | ||
624 | ret = perf_reg_value(&val, &ui->sample->user_regs, PERF_REG_IP); | 625 | ret = perf_reg_value(&val, &ui->sample->user_regs, |
626 | LIBUNWIND__ARCH_REG_IP); | ||
625 | if (ret) | 627 | if (ret) |
626 | return ret; | 628 | return ret; |
627 | 629 | ||
diff --git a/tools/perf/util/unwind.h b/tools/perf/util/unwind.h index b07466240346..84c6d44d52f9 100644 --- a/tools/perf/util/unwind.h +++ b/tools/perf/util/unwind.h | |||
@@ -32,6 +32,15 @@ int unwind__get_entries(unwind_entry_cb_t cb, void *arg, | |||
32 | #ifndef LIBUNWIND__ARCH_REG_ID | 32 | #ifndef LIBUNWIND__ARCH_REG_ID |
33 | #define LIBUNWIND__ARCH_REG_ID(regnum) libunwind__arch_reg_id(regnum) | 33 | #define LIBUNWIND__ARCH_REG_ID(regnum) libunwind__arch_reg_id(regnum) |
34 | #endif | 34 | #endif |
35 | |||
36 | #ifndef LIBUNWIND__ARCH_REG_SP | ||
37 | #define LIBUNWIND__ARCH_REG_SP PERF_REG_SP | ||
38 | #endif | ||
39 | |||
40 | #ifndef LIBUNWIND__ARCH_REG_IP | ||
41 | #define LIBUNWIND__ARCH_REG_IP PERF_REG_IP | ||
42 | #endif | ||
43 | |||
35 | int LIBUNWIND__ARCH_REG_ID(int regnum); | 44 | int LIBUNWIND__ARCH_REG_ID(int regnum); |
36 | int unwind__prepare_access(struct thread *thread, struct map *map); | 45 | int unwind__prepare_access(struct thread *thread, struct map *map); |
37 | void unwind__flush_access(struct thread *thread); | 46 | void unwind__flush_access(struct thread *thread); |
diff --git a/tools/perf/util/vdso.c b/tools/perf/util/vdso.c index 44d440da15dc..7bdcad484225 100644 --- a/tools/perf/util/vdso.c +++ b/tools/perf/util/vdso.c | |||
@@ -134,8 +134,6 @@ static struct dso *__machine__addnew_vdso(struct machine *machine, const char *s | |||
134 | return dso; | 134 | return dso; |
135 | } | 135 | } |
136 | 136 | ||
137 | #if BITS_PER_LONG == 64 | ||
138 | |||
139 | static enum dso_type machine__thread_dso_type(struct machine *machine, | 137 | static enum dso_type machine__thread_dso_type(struct machine *machine, |
140 | struct thread *thread) | 138 | struct thread *thread) |
141 | { | 139 | { |
@@ -156,6 +154,8 @@ static enum dso_type machine__thread_dso_type(struct machine *machine, | |||
156 | return dso_type; | 154 | return dso_type; |
157 | } | 155 | } |
158 | 156 | ||
157 | #if BITS_PER_LONG == 64 | ||
158 | |||
159 | static int vdso__do_copy_compat(FILE *f, int fd) | 159 | static int vdso__do_copy_compat(FILE *f, int fd) |
160 | { | 160 | { |
161 | char buf[4096]; | 161 | char buf[4096]; |
@@ -283,8 +283,38 @@ static int __machine__findnew_vdso_compat(struct machine *machine, | |||
283 | 283 | ||
284 | #endif | 284 | #endif |
285 | 285 | ||
286 | static struct dso *machine__find_vdso(struct machine *machine, | ||
287 | struct thread *thread) | ||
288 | { | ||
289 | struct dso *dso = NULL; | ||
290 | enum dso_type dso_type; | ||
291 | |||
292 | dso_type = machine__thread_dso_type(machine, thread); | ||
293 | switch (dso_type) { | ||
294 | case DSO__TYPE_32BIT: | ||
295 | dso = __dsos__find(&machine->dsos, DSO__NAME_VDSO32, true); | ||
296 | if (!dso) { | ||
297 | dso = __dsos__find(&machine->dsos, DSO__NAME_VDSO, | ||
298 | true); | ||
299 | if (dso && dso_type != dso__type(dso, machine)) | ||
300 | dso = NULL; | ||
301 | } | ||
302 | break; | ||
303 | case DSO__TYPE_X32BIT: | ||
304 | dso = __dsos__find(&machine->dsos, DSO__NAME_VDSOX32, true); | ||
305 | break; | ||
306 | case DSO__TYPE_64BIT: | ||
307 | case DSO__TYPE_UNKNOWN: | ||
308 | default: | ||
309 | dso = __dsos__find(&machine->dsos, DSO__NAME_VDSO, true); | ||
310 | break; | ||
311 | } | ||
312 | |||
313 | return dso; | ||
314 | } | ||
315 | |||
286 | struct dso *machine__findnew_vdso(struct machine *machine, | 316 | struct dso *machine__findnew_vdso(struct machine *machine, |
287 | struct thread *thread __maybe_unused) | 317 | struct thread *thread) |
288 | { | 318 | { |
289 | struct vdso_info *vdso_info; | 319 | struct vdso_info *vdso_info; |
290 | struct dso *dso = NULL; | 320 | struct dso *dso = NULL; |
@@ -297,6 +327,10 @@ struct dso *machine__findnew_vdso(struct machine *machine, | |||
297 | if (!vdso_info) | 327 | if (!vdso_info) |
298 | goto out_unlock; | 328 | goto out_unlock; |
299 | 329 | ||
330 | dso = machine__find_vdso(machine, thread); | ||
331 | if (dso) | ||
332 | goto out_unlock; | ||
333 | |||
300 | #if BITS_PER_LONG == 64 | 334 | #if BITS_PER_LONG == 64 |
301 | if (__machine__findnew_vdso_compat(machine, thread, vdso_info, &dso)) | 335 | if (__machine__findnew_vdso_compat(machine, thread, vdso_info, &dso)) |
302 | goto out_unlock; | 336 | goto out_unlock; |