diff options
-rw-r--r-- | tools/perf/builtin-stat.c | 8 | ||||
-rw-r--r-- | tools/perf/util/evlist.c | 11 | ||||
-rw-r--r-- | tools/perf/util/evlist.h | 4 |
3 files changed, 19 insertions, 4 deletions
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 62ae30d34fa6..262589991ea4 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c | |||
@@ -1129,7 +1129,7 @@ static int add_default_attributes(void) | |||
1129 | return 0; | 1129 | return 0; |
1130 | 1130 | ||
1131 | if (!evsel_list->nr_entries) { | 1131 | if (!evsel_list->nr_entries) { |
1132 | if (perf_evlist__add_attrs_array(evsel_list, default_attrs) < 0) | 1132 | if (perf_evlist__add_default_attrs(evsel_list, default_attrs) < 0) |
1133 | return -1; | 1133 | return -1; |
1134 | } | 1134 | } |
1135 | 1135 | ||
@@ -1139,21 +1139,21 @@ static int add_default_attributes(void) | |||
1139 | return 0; | 1139 | return 0; |
1140 | 1140 | ||
1141 | /* Append detailed run extra attributes: */ | 1141 | /* Append detailed run extra attributes: */ |
1142 | if (perf_evlist__add_attrs_array(evsel_list, detailed_attrs) < 0) | 1142 | if (perf_evlist__add_default_attrs(evsel_list, detailed_attrs) < 0) |
1143 | return -1; | 1143 | return -1; |
1144 | 1144 | ||
1145 | if (detailed_run < 2) | 1145 | if (detailed_run < 2) |
1146 | return 0; | 1146 | return 0; |
1147 | 1147 | ||
1148 | /* Append very detailed run extra attributes: */ | 1148 | /* Append very detailed run extra attributes: */ |
1149 | if (perf_evlist__add_attrs_array(evsel_list, very_detailed_attrs) < 0) | 1149 | if (perf_evlist__add_default_attrs(evsel_list, very_detailed_attrs) < 0) |
1150 | return -1; | 1150 | return -1; |
1151 | 1151 | ||
1152 | if (detailed_run < 3) | 1152 | if (detailed_run < 3) |
1153 | return 0; | 1153 | return 0; |
1154 | 1154 | ||
1155 | /* Append very, very detailed run extra attributes: */ | 1155 | /* Append very, very detailed run extra attributes: */ |
1156 | return perf_evlist__add_attrs_array(evsel_list, very_very_detailed_attrs); | 1156 | return perf_evlist__add_default_attrs(evsel_list, very_very_detailed_attrs); |
1157 | } | 1157 | } |
1158 | 1158 | ||
1159 | int cmd_stat(int argc, const char **argv, const char *prefix __used) | 1159 | int cmd_stat(int argc, const char **argv, const char *prefix __used) |
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 4ac5f5ae4ce9..ed277e5627cf 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c | |||
@@ -159,6 +159,17 @@ out_delete_partial_list: | |||
159 | return -1; | 159 | return -1; |
160 | } | 160 | } |
161 | 161 | ||
162 | int __perf_evlist__add_default_attrs(struct perf_evlist *evlist, | ||
163 | struct perf_event_attr *attrs, size_t nr_attrs) | ||
164 | { | ||
165 | size_t i; | ||
166 | |||
167 | for (i = 0; i < nr_attrs; i++) | ||
168 | event_attr_init(attrs + i); | ||
169 | |||
170 | return perf_evlist__add_attrs(evlist, attrs, nr_attrs); | ||
171 | } | ||
172 | |||
162 | static int trace_event__id(const char *evname) | 173 | static int trace_event__id(const char *evname) |
163 | { | 174 | { |
164 | char *filename, *colon; | 175 | char *filename, *colon; |
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h index 58abb63ac13a..989bee9624c2 100644 --- a/tools/perf/util/evlist.h +++ b/tools/perf/util/evlist.h | |||
@@ -54,6 +54,8 @@ void perf_evlist__add(struct perf_evlist *evlist, struct perf_evsel *entry); | |||
54 | int perf_evlist__add_default(struct perf_evlist *evlist); | 54 | int perf_evlist__add_default(struct perf_evlist *evlist); |
55 | int perf_evlist__add_attrs(struct perf_evlist *evlist, | 55 | int perf_evlist__add_attrs(struct perf_evlist *evlist, |
56 | struct perf_event_attr *attrs, size_t nr_attrs); | 56 | struct perf_event_attr *attrs, size_t nr_attrs); |
57 | int __perf_evlist__add_default_attrs(struct perf_evlist *evlist, | ||
58 | struct perf_event_attr *attrs, size_t nr_attrs); | ||
57 | int perf_evlist__add_tracepoints(struct perf_evlist *evlist, | 59 | int perf_evlist__add_tracepoints(struct perf_evlist *evlist, |
58 | const char *tracepoints[], size_t nr_tracepoints); | 60 | const char *tracepoints[], size_t nr_tracepoints); |
59 | int perf_evlist__set_tracepoints_handlers(struct perf_evlist *evlist, | 61 | int perf_evlist__set_tracepoints_handlers(struct perf_evlist *evlist, |
@@ -62,6 +64,8 @@ int perf_evlist__set_tracepoints_handlers(struct perf_evlist *evlist, | |||
62 | 64 | ||
63 | #define perf_evlist__add_attrs_array(evlist, array) \ | 65 | #define perf_evlist__add_attrs_array(evlist, array) \ |
64 | perf_evlist__add_attrs(evlist, array, ARRAY_SIZE(array)) | 66 | perf_evlist__add_attrs(evlist, array, ARRAY_SIZE(array)) |
67 | #define perf_evlist__add_default_attrs(evlist, array) \ | ||
68 | __perf_evlist__add_default_attrs(evlist, array, ARRAY_SIZE(array)) | ||
65 | 69 | ||
66 | #define perf_evlist__add_tracepoints_array(evlist, array) \ | 70 | #define perf_evlist__add_tracepoints_array(evlist, array) \ |
67 | perf_evlist__add_tracepoints(evlist, array, ARRAY_SIZE(array)) | 71 | perf_evlist__add_tracepoints(evlist, array, ARRAY_SIZE(array)) |