aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/perf/util/header.c44
1 files changed, 29 insertions, 15 deletions
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 5bb2d752ab8f..9f867d96c6a5 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -1466,25 +1466,48 @@ out:
1466 return err; 1466 return err;
1467} 1467}
1468 1468
1469static int process_trace_info(struct perf_file_section *section __unused,
1470 struct perf_header *ph __unused,
1471 int feat __unused, int fd)
1472{
1473 trace_report(fd, false);
1474 return 0;
1475}
1476
1477static int process_build_id(struct perf_file_section *section,
1478 struct perf_header *ph,
1479 int feat __unused, int fd)
1480{
1481 if (perf_header__read_build_ids(ph, fd, section->offset, section->size))
1482 pr_debug("Failed to read buildids, continuing...\n");
1483 return 0;
1484}
1485
1469struct feature_ops { 1486struct feature_ops {
1470 int (*write)(int fd, struct perf_header *h, struct perf_evlist *evlist); 1487 int (*write)(int fd, struct perf_header *h, struct perf_evlist *evlist);
1471 void (*print)(struct perf_header *h, int fd, FILE *fp); 1488 void (*print)(struct perf_header *h, int fd, FILE *fp);
1489 int (*process)(struct perf_file_section *section,
1490 struct perf_header *h, int feat, int fd);
1472 const char *name; 1491 const char *name;
1473 bool full_only; 1492 bool full_only;
1474}; 1493};
1475 1494
1476#define FEAT_OPA(n, func) \ 1495#define FEAT_OPA(n, func) \
1477 [n] = { .name = #n, .write = write_##func, .print = print_##func } 1496 [n] = { .name = #n, .write = write_##func, .print = print_##func }
1497#define FEAT_OPP(n, func) \
1498 [n] = { .name = #n, .write = write_##func, .print = print_##func, \
1499 .process = process_##func }
1478#define FEAT_OPF(n, func) \ 1500#define FEAT_OPF(n, func) \
1479 [n] = { .name = #n, .write = write_##func, .print = print_##func, .full_only = true } 1501 [n] = { .name = #n, .write = write_##func, .print = print_##func, \
1502 .full_only = true }
1480 1503
1481/* feature_ops not implemented: */ 1504/* feature_ops not implemented: */
1482#define print_trace_info NULL 1505#define print_trace_info NULL
1483#define print_build_id NULL 1506#define print_build_id NULL
1484 1507
1485static const struct feature_ops feat_ops[HEADER_LAST_FEATURE] = { 1508static const struct feature_ops feat_ops[HEADER_LAST_FEATURE] = {
1486 FEAT_OPA(HEADER_TRACE_INFO, trace_info), 1509 FEAT_OPP(HEADER_TRACE_INFO, trace_info),
1487 FEAT_OPA(HEADER_BUILD_ID, build_id), 1510 FEAT_OPP(HEADER_BUILD_ID, build_id),
1488 FEAT_OPA(HEADER_HOSTNAME, hostname), 1511 FEAT_OPA(HEADER_HOSTNAME, hostname),
1489 FEAT_OPA(HEADER_OSRELEASE, osrelease), 1512 FEAT_OPA(HEADER_OSRELEASE, osrelease),
1490 FEAT_OPA(HEADER_VERSION, version), 1513 FEAT_OPA(HEADER_VERSION, version),
@@ -1900,19 +1923,10 @@ static int perf_file_section__process(struct perf_file_section *section,
1900 return 0; 1923 return 0;
1901 } 1924 }
1902 1925
1903 switch (feat) { 1926 if (!feat_ops[feat].process)
1904 case HEADER_TRACE_INFO: 1927 return 0;
1905 trace_report(fd, false);
1906 break;
1907 case HEADER_BUILD_ID:
1908 if (perf_header__read_build_ids(ph, fd, section->offset, section->size))
1909 pr_debug("Failed to read buildids, continuing...\n");
1910 break;
1911 default:
1912 break;
1913 }
1914 1928
1915 return 0; 1929 return feat_ops[feat].process(section, ph, feat, fd);
1916} 1930}
1917 1931
1918static int perf_file_header__read_pipe(struct perf_pipe_file_header *header, 1932static int perf_file_header__read_pipe(struct perf_pipe_file_header *header,