diff options
Diffstat (limited to 'tools/perf/util/evsel.c')
-rw-r--r-- | tools/perf/util/evsel.c | 52 |
1 files changed, 50 insertions, 2 deletions
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 643df4b06b84..7a2a3dc3ff03 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c | |||
@@ -1257,6 +1257,53 @@ static int __if_fprintf(FILE *fp, bool *first, const char *field, u64 value) | |||
1257 | 1257 | ||
1258 | #define if_print(field) printed += __if_fprintf(fp, &first, #field, evsel->attr.field) | 1258 | #define if_print(field) printed += __if_fprintf(fp, &first, #field, evsel->attr.field) |
1259 | 1259 | ||
1260 | struct bit_names { | ||
1261 | int bit; | ||
1262 | const char *name; | ||
1263 | }; | ||
1264 | |||
1265 | static int bits__fprintf(FILE *fp, const char *field, u64 value, | ||
1266 | struct bit_names *bits, bool *first) | ||
1267 | { | ||
1268 | int i = 0, printed = comma_fprintf(fp, first, " %s: ", field); | ||
1269 | bool first_bit = true; | ||
1270 | |||
1271 | do { | ||
1272 | if (value & bits[i].bit) { | ||
1273 | printed += fprintf(fp, "%s%s", first_bit ? "" : "|", bits[i].name); | ||
1274 | first_bit = false; | ||
1275 | } | ||
1276 | } while (bits[++i].name != NULL); | ||
1277 | |||
1278 | return printed; | ||
1279 | } | ||
1280 | |||
1281 | static int sample_type__fprintf(FILE *fp, bool *first, u64 value) | ||
1282 | { | ||
1283 | #define bit_name(n) { PERF_SAMPLE_##n, #n } | ||
1284 | struct bit_names bits[] = { | ||
1285 | bit_name(IP), bit_name(TID), bit_name(TIME), bit_name(ADDR), | ||
1286 | bit_name(READ), bit_name(CALLCHAIN), bit_name(ID), bit_name(CPU), | ||
1287 | bit_name(PERIOD), bit_name(STREAM_ID), bit_name(RAW), | ||
1288 | bit_name(BRANCH_STACK), bit_name(REGS_USER), bit_name(STACK_USER), | ||
1289 | { .name = NULL, } | ||
1290 | }; | ||
1291 | #undef bit_name | ||
1292 | return bits__fprintf(fp, "sample_type", value, bits, first); | ||
1293 | } | ||
1294 | |||
1295 | static int read_format__fprintf(FILE *fp, bool *first, u64 value) | ||
1296 | { | ||
1297 | #define bit_name(n) { PERF_FORMAT_##n, #n } | ||
1298 | struct bit_names bits[] = { | ||
1299 | bit_name(TOTAL_TIME_ENABLED), bit_name(TOTAL_TIME_RUNNING), | ||
1300 | bit_name(ID), bit_name(GROUP), | ||
1301 | { .name = NULL, } | ||
1302 | }; | ||
1303 | #undef bit_name | ||
1304 | return bits__fprintf(fp, "read_format", value, bits, first); | ||
1305 | } | ||
1306 | |||
1260 | int perf_evsel__fprintf(struct perf_evsel *evsel, | 1307 | int perf_evsel__fprintf(struct perf_evsel *evsel, |
1261 | struct perf_attr_details *details, FILE *fp) | 1308 | struct perf_attr_details *details, FILE *fp) |
1262 | { | 1309 | { |
@@ -1274,8 +1321,9 @@ int perf_evsel__fprintf(struct perf_evsel *evsel, | |||
1274 | if_print(config1); | 1321 | if_print(config1); |
1275 | if_print(config2); | 1322 | if_print(config2); |
1276 | if_print(size); | 1323 | if_print(size); |
1277 | if_print(sample_type); | 1324 | printed += sample_type__fprintf(fp, &first, evsel->attr.sample_type); |
1278 | if_print(read_format); | 1325 | if (evsel->attr.read_format) |
1326 | printed += read_format__fprintf(fp, &first, evsel->attr.read_format); | ||
1279 | if_print(disabled); | 1327 | if_print(disabled); |
1280 | if_print(inherit); | 1328 | if_print(inherit); |
1281 | if_print(pinned); | 1329 | if_print(pinned); |