diff options
Diffstat (limited to 'tools/perf/builtin-stat.c')
-rw-r--r-- | tools/perf/builtin-stat.c | 43 |
1 files changed, 8 insertions, 35 deletions
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 955930e0a5c3..cc53de335ced 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c | |||
@@ -1108,22 +1108,13 @@ static const struct option options[] = { | |||
1108 | */ | 1108 | */ |
1109 | static int add_default_attributes(void) | 1109 | static int add_default_attributes(void) |
1110 | { | 1110 | { |
1111 | struct perf_evsel *pos; | ||
1112 | size_t attr_nr = 0; | ||
1113 | size_t c; | ||
1114 | |||
1115 | /* Set attrs if no event is selected and !null_run: */ | 1111 | /* Set attrs if no event is selected and !null_run: */ |
1116 | if (null_run) | 1112 | if (null_run) |
1117 | return 0; | 1113 | return 0; |
1118 | 1114 | ||
1119 | if (!evsel_list->nr_entries) { | 1115 | if (!evsel_list->nr_entries) { |
1120 | for (c = 0; c < ARRAY_SIZE(default_attrs); c++) { | 1116 | if (perf_evlist__add_attrs_array(evsel_list, default_attrs) < 0) |
1121 | pos = perf_evsel__new(default_attrs + c, c + attr_nr); | 1117 | return -1; |
1122 | if (pos == NULL) | ||
1123 | return -1; | ||
1124 | perf_evlist__add(evsel_list, pos); | ||
1125 | } | ||
1126 | attr_nr += c; | ||
1127 | } | 1118 | } |
1128 | 1119 | ||
1129 | /* Detailed events get appended to the event list: */ | 1120 | /* Detailed events get appended to the event list: */ |
@@ -1132,38 +1123,21 @@ static int add_default_attributes(void) | |||
1132 | return 0; | 1123 | return 0; |
1133 | 1124 | ||
1134 | /* Append detailed run extra attributes: */ | 1125 | /* Append detailed run extra attributes: */ |
1135 | for (c = 0; c < ARRAY_SIZE(detailed_attrs); c++) { | 1126 | if (perf_evlist__add_attrs_array(evsel_list, detailed_attrs) < 0) |
1136 | pos = perf_evsel__new(detailed_attrs + c, c + attr_nr); | 1127 | return -1; |
1137 | if (pos == NULL) | ||
1138 | return -1; | ||
1139 | perf_evlist__add(evsel_list, pos); | ||
1140 | } | ||
1141 | attr_nr += c; | ||
1142 | 1128 | ||
1143 | if (detailed_run < 2) | 1129 | if (detailed_run < 2) |
1144 | return 0; | 1130 | return 0; |
1145 | 1131 | ||
1146 | /* Append very detailed run extra attributes: */ | 1132 | /* Append very detailed run extra attributes: */ |
1147 | for (c = 0; c < ARRAY_SIZE(very_detailed_attrs); c++) { | 1133 | if (perf_evlist__add_attrs_array(evsel_list, very_detailed_attrs) < 0) |
1148 | pos = perf_evsel__new(very_detailed_attrs + c, c + attr_nr); | 1134 | return -1; |
1149 | if (pos == NULL) | ||
1150 | return -1; | ||
1151 | perf_evlist__add(evsel_list, pos); | ||
1152 | } | ||
1153 | 1135 | ||
1154 | if (detailed_run < 3) | 1136 | if (detailed_run < 3) |
1155 | return 0; | 1137 | return 0; |
1156 | 1138 | ||
1157 | /* Append very, very detailed run extra attributes: */ | 1139 | /* Append very, very detailed run extra attributes: */ |
1158 | for (c = 0; c < ARRAY_SIZE(very_very_detailed_attrs); c++) { | 1140 | return perf_evlist__add_attrs_array(evsel_list, very_very_detailed_attrs); |
1159 | pos = perf_evsel__new(very_very_detailed_attrs + c, c + attr_nr); | ||
1160 | if (pos == NULL) | ||
1161 | return -1; | ||
1162 | perf_evlist__add(evsel_list, pos); | ||
1163 | } | ||
1164 | |||
1165 | |||
1166 | return 0; | ||
1167 | } | 1141 | } |
1168 | 1142 | ||
1169 | int cmd_stat(int argc, const char **argv, const char *prefix __used) | 1143 | int cmd_stat(int argc, const char **argv, const char *prefix __used) |
@@ -1267,8 +1241,7 @@ int cmd_stat(int argc, const char **argv, const char *prefix __used) | |||
1267 | 1241 | ||
1268 | list_for_each_entry(pos, &evsel_list->entries, node) { | 1242 | list_for_each_entry(pos, &evsel_list->entries, node) { |
1269 | if (perf_evsel__alloc_stat_priv(pos) < 0 || | 1243 | if (perf_evsel__alloc_stat_priv(pos) < 0 || |
1270 | perf_evsel__alloc_counts(pos, evsel_list->cpus->nr) < 0 || | 1244 | perf_evsel__alloc_counts(pos, evsel_list->cpus->nr) < 0) |
1271 | perf_evsel__alloc_fd(pos, evsel_list->cpus->nr, evsel_list->threads->nr) < 0) | ||
1272 | goto out_free_fd; | 1245 | goto out_free_fd; |
1273 | } | 1246 | } |
1274 | 1247 | ||