Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 182335
b: refs/heads/master
c: ae99fb2
h: refs/heads/master
i:
  182333: 291ba8e
  182331: 962b30b
  182327: e656eda
  182319: 06c1854
  182303: db7f0c7
  182271: f857544
v: v3
  • Loading branch information
Arnaldo Carvalho de Melo authored and Ingo Molnar committed Dec 30, 2009
1 parent 2d5d0f0 commit bcff305
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 15 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: 769885f372300a7fcfb9e54e4e2990718d40b529
refs/heads/master: ae99fb2c335ef018520950ddc9692faacab39cf2
16 changes: 10 additions & 6 deletions trunk/tools/perf/util/header.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,24 +105,28 @@ struct perf_trace_event_type {
static int event_count;
static struct perf_trace_event_type *events;

void perf_header__push_event(u64 id, const char *name)
int perf_header__push_event(u64 id, const char *name)
{
if (strlen(name) > MAX_EVENT_NAME)
pr_warning("Event %s will be truncated\n", name);

if (!events) {
events = malloc(sizeof(struct perf_trace_event_type));
if (!events)
die("nomem");
if (events == NULL)
return -ENOMEM;
} else {
events = realloc(events, (event_count + 1) * sizeof(struct perf_trace_event_type));
if (!events)
die("nomem");
struct perf_trace_event_type *nevents;

nevents = realloc(events, (event_count + 1) * sizeof(*events));
if (nevents == NULL)
return -ENOMEM;
events = nevents;
}
memset(&events[event_count], 0, sizeof(struct perf_trace_event_type));
events[event_count].event_id = id;
strncpy(events[event_count].name, name, MAX_EVENT_NAME - 1);
event_count++;
return 0;
}

char *perf_header__find_event(u64 id)
Expand Down
2 changes: 1 addition & 1 deletion trunk/tools/perf/util/header.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ int perf_header__write(struct perf_header *self, int fd, bool at_exit);
int perf_header__add_attr(struct perf_header *self,
struct perf_header_attr *attr);

void perf_header__push_event(u64 id, const char *name);
int perf_header__push_event(u64 id, const char *name);
char *perf_header__find_event(u64 id);

struct perf_header_attr *perf_header_attr__new(struct perf_event_attr *attr);
Expand Down
18 changes: 11 additions & 7 deletions trunk/tools/perf/util/parse-events.c
Original file line number Diff line number Diff line change
Expand Up @@ -753,11 +753,11 @@ parse_event_symbols(const char **str, struct perf_event_attr *attr)
return ret;
}

static void store_event_type(const char *orgname)
static int store_event_type(const char *orgname)
{
char filename[PATH_MAX], *c;
FILE *file;
int id;
int id, n;

sprintf(filename, "%s/", debugfs_path);
strncat(filename, orgname, strlen(orgname));
Expand All @@ -769,11 +769,14 @@ static void store_event_type(const char *orgname)

file = fopen(filename, "r");
if (!file)
return;
if (fscanf(file, "%i", &id) < 1)
die("cannot store event ID");
return 0;
n = fscanf(file, "%i", &id);
fclose(file);
perf_header__push_event(id, orgname);
if (n < 1) {
pr_err("cannot store event ID\n");
return -EINVAL;
}
return perf_header__push_event(id, orgname);
}

int parse_events(const struct option *opt __used, const char *str, int unset __used)
Expand All @@ -782,7 +785,8 @@ int parse_events(const struct option *opt __used, const char *str, int unset __u
enum event_result ret;

if (strchr(str, ':'))
store_event_type(str);
if (store_event_type(str) < 0)
return -1;

for (;;) {
if (nr_counters == MAX_COUNTERS)
Expand Down

0 comments on commit bcff305

Please sign in to comment.