Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 169581
b: refs/heads/master
c: 57f395a
h: refs/heads/master
i:
  169579: de94105
v: v3
  • Loading branch information
Frederic Weisbecker authored and Ingo Molnar committed Nov 11, 2009
1 parent 7f3c681 commit a9f079e
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 25 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: 8671dab9d5b2f0b444b8d09792384dccbfd43d14
refs/heads/master: 57f395a7eabb913d3605d7392be5bdb0837c9f3d
7 changes: 7 additions & 0 deletions trunk/tools/perf/util/event.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ struct build_id_event {
char filename[];
};

struct build_id_list {
struct build_id_event event;
struct list_head list;
const char *dso_name;
int len;
};

typedef union event_union {
struct perf_event_header header;
struct ip_event ip;
Expand Down
41 changes: 17 additions & 24 deletions trunk/tools/perf/util/header.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,29 +174,18 @@ static void do_write(int fd, void *buf, size_t size)
}
}

static bool write_buildid_table(int fd)
static void write_buildid_table(int fd, struct list_head *id_head)
{
struct dso *pos;
bool have_buildid = false;

list_for_each_entry(pos, &dsos, node) {
struct build_id_event b;
size_t len;

if (filename__read_build_id(pos->long_name,
&b.build_id,
sizeof(b.build_id)) < 0)
continue;
have_buildid = true;
memset(&b.header, 0, sizeof(b.header));
len = strlen(pos->long_name) + 1;
len = ALIGN(len, 64);
b.header.size = sizeof(b) + len;
do_write(fd, &b, sizeof(b));
do_write(fd, pos->long_name, len);
}
struct build_id_list *iter, *next;

list_for_each_entry_safe(iter, next, id_head, list) {
struct build_id_event *b = &iter->event;

return have_buildid;
do_write(fd, b, sizeof(*b));
do_write(fd, (void *)iter->dso_name, iter->len);
list_del(&iter->list);
free(iter);
}
}

static void
Expand Down Expand Up @@ -226,10 +215,14 @@ perf_header__adds_write(struct perf_header *self, int fd, bool at_exit)
}

if (at_exit) {
lseek(fd, self->data_offset + self->data_size, SEEK_SET);
if (write_buildid_table(fd))
LIST_HEAD(id_list);

if (fetch_build_id_table(&id_list)) {
lseek(fd, self->data_offset + self->data_size, SEEK_SET);
perf_header__set_feat(self, HEADER_BUILD_ID);
lseek(fd, cur_offset, SEEK_SET);
write_buildid_table(fd, &id_list);
lseek(fd, cur_offset, SEEK_SET);
}
}
};

Expand Down
34 changes: 34 additions & 0 deletions trunk/tools/perf/util/symbol.c
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,40 @@ static int dso__load_sym(struct dso *self, struct map *map, const char *name,
return err;
}

bool fetch_build_id_table(struct list_head *head)
{
bool have_buildid = false;
struct dso *pos;

list_for_each_entry(pos, &dsos, node) {
struct build_id_list *new;
struct build_id_event b;
size_t len;

if (filename__read_build_id(pos->long_name,
&b.build_id,
sizeof(b.build_id)) < 0)
continue;
have_buildid = true;
memset(&b.header, 0, sizeof(b.header));
len = strlen(pos->long_name) + 1;
len = ALIGN(len, 64);
b.header.size = sizeof(b) + len;

new = malloc(sizeof(*new));
if (!new)
die("No memory\n");

memcpy(&new->event, &b, sizeof(b));
new->dso_name = pos->long_name;
new->len = len;

list_add_tail(&new->list, head);
}

return have_buildid;
}

int filename__read_build_id(const char *filename, void *bf, size_t size)
{
int fd, err = -1;
Expand Down
1 change: 1 addition & 0 deletions trunk/tools/perf/util/symbol.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ char dso__symtab_origin(const struct dso *self);
void dso__set_build_id(struct dso *self, void *build_id);

int filename__read_build_id(const char *filename, void *bf, size_t size);
bool fetch_build_id_table(struct list_head *head);
int build_id__sprintf(u8 *self, int len, char *bf);

int load_kernel(symbol_filter_t filter);
Expand Down

0 comments on commit a9f079e

Please sign in to comment.