aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/perf/util/symbol.c28
-rw-r--r--tools/perf/util/symbol.h2
2 files changed, 23 insertions, 7 deletions
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 26ec603083e0..f9049d12ead6 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -1762,24 +1762,38 @@ size_t dsos__fprintf_buildid(FILE *fp, bool with_hits)
1762 __dsos__fprintf_buildid(&dsos__user, fp, with_hits)); 1762 __dsos__fprintf_buildid(&dsos__user, fp, with_hits));
1763} 1763}
1764 1764
1765struct dso *dso__new_kernel(const char *name)
1766{
1767 struct dso *self = dso__new(name ?: "[kernel.kallsyms]");
1768
1769 if (self != NULL) {
1770 self->short_name = "[kernel]";
1771 self->kernel = 1;
1772 }
1773
1774 return self;
1775}
1776
1777void dso__read_running_kernel_build_id(struct dso *self)
1778{
1779 if (sysfs__read_build_id("/sys/kernel/notes", self->build_id,
1780 sizeof(self->build_id)) == 0)
1781 self->has_build_id = true;
1782}
1783
1765static struct dso *dsos__create_kernel(const char *vmlinux) 1784static struct dso *dsos__create_kernel(const char *vmlinux)
1766{ 1785{
1767 struct dso *kernel = dso__new(vmlinux ?: "[kernel.kallsyms]"); 1786 struct dso *kernel = dso__new_kernel(vmlinux);
1768 1787
1769 if (kernel == NULL) 1788 if (kernel == NULL)
1770 return NULL; 1789 return NULL;
1771 1790
1772 kernel->short_name = "[kernel]";
1773 kernel->kernel = 1;
1774
1775 vdso = dso__new("[vdso]"); 1791 vdso = dso__new("[vdso]");
1776 if (vdso == NULL) 1792 if (vdso == NULL)
1777 goto out_delete_kernel_dso; 1793 goto out_delete_kernel_dso;
1778 dso__set_loaded(vdso, MAP__FUNCTION); 1794 dso__set_loaded(vdso, MAP__FUNCTION);
1779 1795
1780 if (sysfs__read_build_id("/sys/kernel/notes", kernel->build_id, 1796 dso__read_running_kernel_build_id(kernel);
1781 sizeof(kernel->build_id)) == 0)
1782 kernel->has_build_id = true;
1783 1797
1784 dsos__add(&dsos__kernel, kernel); 1798 dsos__add(&dsos__kernel, kernel);
1785 dsos__add(&dsos__user, vdso); 1799 dsos__add(&dsos__user, vdso);
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index a94997aeb334..124302778c09 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -109,6 +109,7 @@ struct dso {
109}; 109};
110 110
111struct dso *dso__new(const char *name); 111struct dso *dso__new(const char *name);
112struct dso *dso__new_kernel(const char *name);
112void dso__delete(struct dso *self); 113void dso__delete(struct dso *self);
113 114
114bool dso__loaded(const struct dso *self, enum map_type type); 115bool dso__loaded(const struct dso *self, enum map_type type);
@@ -139,6 +140,7 @@ size_t dso__fprintf(struct dso *self, enum map_type type, FILE *fp);
139char dso__symtab_origin(const struct dso *self); 140char dso__symtab_origin(const struct dso *self);
140void dso__set_long_name(struct dso *self, char *name); 141void dso__set_long_name(struct dso *self, char *name);
141void dso__set_build_id(struct dso *self, void *build_id); 142void dso__set_build_id(struct dso *self, void *build_id);
143void dso__read_running_kernel_build_id(struct dso *self);
142struct symbol *dso__find_symbol(struct dso *self, enum map_type type, u64 addr); 144struct symbol *dso__find_symbol(struct dso *self, enum map_type type, u64 addr);
143struct symbol *dso__find_symbol_by_name(struct dso *self, enum map_type type, 145struct symbol *dso__find_symbol_by_name(struct dso *self, enum map_type type,
144 const char *name); 146 const char *name);