Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 288665
b: refs/heads/master
c: f1c67db
h: refs/heads/master
i:
  288663: 9880970
v: v3
  • Loading branch information
Robert Richter authored and Arnaldo Carvalho de Melo committed Feb 14, 2012
1 parent 29ddbeb commit 1b88c7f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 16 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 08d95bd256277f914e525aeb292da52f15173e7d
refs/heads/master: f1c67db7e351bf9fd328e368ba045cbeca11d513
44 changes: 29 additions & 15 deletions trunk/tools/perf/util/header.c
Original file line number Diff line number Diff line change
Expand Up @@ -1466,25 +1466,48 @@ static int perf_header__read_build_ids(struct perf_header *header,
return err;
}

static int process_trace_info(struct perf_file_section *section __unused,
struct perf_header *ph __unused,
int feat __unused, int fd)
{
trace_report(fd, false);
return 0;
}

static int process_build_id(struct perf_file_section *section,
struct perf_header *ph,
int feat __unused, int fd)
{
if (perf_header__read_build_ids(ph, fd, section->offset, section->size))
pr_debug("Failed to read buildids, continuing...\n");
return 0;
}

struct feature_ops {
int (*write)(int fd, struct perf_header *h, struct perf_evlist *evlist);
void (*print)(struct perf_header *h, int fd, FILE *fp);
int (*process)(struct perf_file_section *section,
struct perf_header *h, int feat, int fd);
const char *name;
bool full_only;
};

#define FEAT_OPA(n, func) \
[n] = { .name = #n, .write = write_##func, .print = print_##func }
#define FEAT_OPP(n, func) \
[n] = { .name = #n, .write = write_##func, .print = print_##func, \
.process = process_##func }
#define FEAT_OPF(n, func) \
[n] = { .name = #n, .write = write_##func, .print = print_##func, .full_only = true }
[n] = { .name = #n, .write = write_##func, .print = print_##func, \
.full_only = true }

/* feature_ops not implemented: */
#define print_trace_info NULL
#define print_build_id NULL

static const struct feature_ops feat_ops[HEADER_LAST_FEATURE] = {
FEAT_OPA(HEADER_TRACE_INFO, trace_info),
FEAT_OPA(HEADER_BUILD_ID, build_id),
FEAT_OPP(HEADER_TRACE_INFO, trace_info),
FEAT_OPP(HEADER_BUILD_ID, build_id),
FEAT_OPA(HEADER_HOSTNAME, hostname),
FEAT_OPA(HEADER_OSRELEASE, osrelease),
FEAT_OPA(HEADER_VERSION, version),
Expand Down Expand Up @@ -1900,19 +1923,10 @@ static int perf_file_section__process(struct perf_file_section *section,
return 0;
}

switch (feat) {
case HEADER_TRACE_INFO:
trace_report(fd, false);
break;
case HEADER_BUILD_ID:
if (perf_header__read_build_ids(ph, fd, section->offset, section->size))
pr_debug("Failed to read buildids, continuing...\n");
break;
default:
break;
}
if (!feat_ops[feat].process)
return 0;

return 0;
return feat_ops[feat].process(section, ph, feat, fd);
}

static int perf_file_header__read_pipe(struct perf_pipe_file_header *header,
Expand Down

0 comments on commit 1b88c7f

Please sign in to comment.