aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2010-01-07 16:59:39 -0500
committerIngo Molnar <mingo@elte.hu>2010-01-13 04:09:16 -0500
commita89e5abe3efcc7facc666d3985769278937f86b0 (patch)
tree4aa271d7d1d751ff842bb23874fcb91b384343cc
parentfed5af61dc0d9402d26e7fb8fb9731a60a8e05ca (diff)
perf symbols: Record the domain of DSOs in HEADER_BUILD_ID header table
So that we can restore them to the right DSO list (either dsos__kernel or dsos__user). We do that just like the kernel does for the other events, encoding PERF_RECORD_MISC_{KERNEL,USER} in perf_event_header. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Frédéric Weisbecker <fweisbec@gmail.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Paul Mackerras <paulus@samba.org> LKML-Reference: <1262901583-8074-2-git-send-email-acme@infradead.org> Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r--tools/perf/util/header.c9
-rw-r--r--tools/perf/util/session.c6
-rw-r--r--tools/perf/util/symbol.c6
-rw-r--r--tools/perf/util/symbol.h11
4 files changed, 23 insertions, 9 deletions
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 942f7da8bf84..ec96321eb9e4 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -193,7 +193,7 @@ static int write_padded(int fd, const void *bf, size_t count,
193 continue; \ 193 continue; \
194 else 194 else
195 195
196static int __dsos__write_buildid_table(struct list_head *head, int fd) 196static int __dsos__write_buildid_table(struct list_head *head, u16 misc, int fd)
197{ 197{
198 struct dso *pos; 198 struct dso *pos;
199 199
@@ -205,6 +205,7 @@ static int __dsos__write_buildid_table(struct list_head *head, int fd)
205 len = ALIGN(len, NAME_ALIGN); 205 len = ALIGN(len, NAME_ALIGN);
206 memset(&b, 0, sizeof(b)); 206 memset(&b, 0, sizeof(b));
207 memcpy(&b.build_id, pos->build_id, sizeof(pos->build_id)); 207 memcpy(&b.build_id, pos->build_id, sizeof(pos->build_id));
208 b.header.misc = misc;
208 b.header.size = sizeof(b) + len; 209 b.header.size = sizeof(b) + len;
209 err = do_write(fd, &b, sizeof(b)); 210 err = do_write(fd, &b, sizeof(b));
210 if (err < 0) 211 if (err < 0)
@@ -220,9 +221,11 @@ static int __dsos__write_buildid_table(struct list_head *head, int fd)
220 221
221static int dsos__write_buildid_table(int fd) 222static int dsos__write_buildid_table(int fd)
222{ 223{
223 int err = __dsos__write_buildid_table(&dsos__kernel, fd); 224 int err = __dsos__write_buildid_table(&dsos__kernel,
225 PERF_RECORD_MISC_KERNEL, fd);
224 if (err == 0) 226 if (err == 0)
225 err = __dsos__write_buildid_table(&dsos__user, fd); 227 err = __dsos__write_buildid_table(&dsos__user,
228 PERF_RECORD_MISC_USER, fd);
226 return err; 229 return err;
227} 230}
228 231
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index e0e6a075489e..378ac5422bcf 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -255,6 +255,7 @@ int perf_header__read_build_ids(int input, u64 offset, u64 size)
255 while (offset < limit) { 255 while (offset < limit) {
256 struct dso *dso; 256 struct dso *dso;
257 ssize_t len; 257 ssize_t len;
258 struct list_head *head = &dsos__user;
258 259
259 if (read(input, &bev, sizeof(bev)) != sizeof(bev)) 260 if (read(input, &bev, sizeof(bev)) != sizeof(bev))
260 goto out; 261 goto out;
@@ -263,7 +264,10 @@ int perf_header__read_build_ids(int input, u64 offset, u64 size)
263 if (read(input, filename, len) != len) 264 if (read(input, filename, len) != len)
264 goto out; 265 goto out;
265 266
266 dso = dsos__findnew(filename); 267 if (bev.header.misc & PERF_RECORD_MISC_KERNEL)
268 head = &dsos__kernel;
269
270 dso = __dsos__findnew(head, filename);
267 if (dso != NULL) 271 if (dso != NULL)
268 dso__set_build_id(dso, &bev.build_id); 272 dso__set_build_id(dso, &bev.build_id);
269 273
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index da2f07f1af8f..8e6627e6b778 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -1615,14 +1615,14 @@ static struct dso *dsos__find(struct list_head *head, const char *name)
1615 return NULL; 1615 return NULL;
1616} 1616}
1617 1617
1618struct dso *dsos__findnew(const char *name) 1618struct dso *__dsos__findnew(struct list_head *head, const char *name)
1619{ 1619{
1620 struct dso *dso = dsos__find(&dsos__user, name); 1620 struct dso *dso = dsos__find(head, name);
1621 1621
1622 if (!dso) { 1622 if (!dso) {
1623 dso = dso__new(name); 1623 dso = dso__new(name);
1624 if (dso != NULL) { 1624 if (dso != NULL) {
1625 dsos__add(&dsos__user, dso); 1625 dsos__add(head, dso);
1626 dso__set_basename(dso); 1626 dso__set_basename(dso);
1627 } 1627 }
1628 } 1628 }
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index b2b5330a82a0..ee0b4593db7b 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -115,9 +115,17 @@ bool dso__sorted_by_name(const struct dso *self, enum map_type type);
115 115
116void dso__sort_by_name(struct dso *self, enum map_type type); 116void dso__sort_by_name(struct dso *self, enum map_type type);
117 117
118extern struct list_head dsos__user, dsos__kernel;
119
120struct dso *__dsos__findnew(struct list_head *head, const char *name);
121
122static inline struct dso *dsos__findnew(const char *name)
123{
124 return __dsos__findnew(&dsos__user, name);
125}
126
118struct perf_session; 127struct perf_session;
119 128
120struct dso *dsos__findnew(const char *name);
121int dso__load(struct dso *self, struct map *map, struct perf_session *session, 129int dso__load(struct dso *self, struct map *map, struct perf_session *session,
122 symbol_filter_t filter); 130 symbol_filter_t filter);
123void dsos__fprintf(FILE *fp); 131void dsos__fprintf(FILE *fp);
@@ -143,6 +151,5 @@ bool symbol_type__is_a(char symbol_type, enum map_type map_type);
143 151
144int perf_session__create_kernel_maps(struct perf_session *self); 152int perf_session__create_kernel_maps(struct perf_session *self);
145 153
146extern struct list_head dsos__user, dsos__kernel;
147extern struct dso *vdso; 154extern struct dso *vdso;
148#endif /* __PERF_SYMBOL */ 155#endif /* __PERF_SYMBOL */