[tip:perfcounters/core] perf_counter tools: Consolidate dso methods to load kernel symbols

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Commit-ID:  a827c875f2ebe69c6e6db5e7f112d4beb4d80f01
Gitweb:     http://git.kernel.org/tip/a827c875f2ebe69c6e6db5e7f112d4beb4d80f01
Author:     Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
AuthorDate: Thu, 28 May 2009 14:55:19 -0300
Committer:  Ingo Molnar <mingo@xxxxxxx>
CommitDate: Thu, 28 May 2009 23:25:44 +0200

perf_counter tools: Consolidate dso methods to load kernel symbols

Now one has just to use dso__load_kernel() optionally passing a vmlinux
filename.

Will make things easier for perf top that will want to pass a callback
to filter some symbols.

Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
Cc: Paul Mackerras <paulus@xxxxxxxxx>
Cc: Mike Galbraith <efault@xxxxxx>
Cc: Steven Rostedt <rostedt@xxxxxxxxxxx>
Cc: Peter Zijlstra <a.p.zijlstra@xxxxxxxxx>
Signed-off-by: Ingo Molnar <mingo@xxxxxxx>


---
 Documentation/perf_counter/builtin-report.c |    9 ++-------
 Documentation/perf_counter/util/symbol.c    |   17 +++++++++++++++--
 Documentation/perf_counter/util/symbol.h    |    3 +--
 3 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/Documentation/perf_counter/builtin-report.c b/Documentation/perf_counter/builtin-report.c
index 889067e..4e9f2bc 100644
--- a/Documentation/perf_counter/builtin-report.c
+++ b/Documentation/perf_counter/builtin-report.c
@@ -118,18 +118,13 @@ static void dsos__fprintf(FILE *fp)
 
 static int load_kernel(void)
 {
-	int err = -1;
+	int err;
 
 	kernel_dso = dso__new("[kernel]", 0);
 	if (!kernel_dso)
 		return -1;
 
-	if (vmlinux)
-		err = dso__load_vmlinux(kernel_dso, vmlinux);
-
-	if (err)
-		err = dso__load_kallsyms(kernel_dso);
-
+	err = dso__load_kernel(kernel_dso, vmlinux);
 	if (err) {
 		dso__delete(kernel_dso);
 		kernel_dso = NULL;
diff --git a/Documentation/perf_counter/util/symbol.c b/Documentation/perf_counter/util/symbol.c
index 7088206..504ac31 100644
--- a/Documentation/perf_counter/util/symbol.c
+++ b/Documentation/perf_counter/util/symbol.c
@@ -155,7 +155,7 @@ static int hex2long(char *ptr, unsigned long *long_val)
 	return p - ptr;
 }
 
-int dso__load_kallsyms(struct dso *self)
+static int dso__load_kallsyms(struct dso *self)
 {
 	struct rb_node *nd, *prevnd;
 	char *line = NULL;
@@ -410,7 +410,7 @@ out:
 	return ret;
 }
 
-int dso__load_vmlinux(struct dso *self, const char *vmlinux)
+static int dso__load_vmlinux(struct dso *self, const char *vmlinux)
 {
 	int err, fd = open(vmlinux, O_RDONLY);
 
@@ -423,6 +423,19 @@ int dso__load_vmlinux(struct dso *self, const char *vmlinux)
 	return err;
 }
 
+int dso__load_kernel(struct dso *self, const char *vmlinux)
+{
+	int err = -1;
+
+	if (vmlinux)
+		err = dso__load_vmlinux(self, vmlinux);
+
+	if (err)
+		err = dso__load_kallsyms(self);
+
+	return err;
+}
+
 void symbol__init(void)
 {
 	elf_version(EV_CURRENT);
diff --git a/Documentation/perf_counter/util/symbol.h b/Documentation/perf_counter/util/symbol.h
index 9e120af..db2fdf9 100644
--- a/Documentation/perf_counter/util/symbol.h
+++ b/Documentation/perf_counter/util/symbol.h
@@ -29,8 +29,7 @@ static inline void *dso__sym_priv(struct dso *self, struct symbol *sym)
 
 struct symbol *dso__find_symbol(struct dso *self, uint64_t ip);
 
-int dso__load_kallsyms(struct dso *self);
-int dso__load_vmlinux(struct dso *self, const char *vmlinux);
+int dso__load_kernel(struct dso *self, const char *vmlinux);
 int dso__load(struct dso *self);
 
 size_t dso__fprintf(struct dso *self, FILE *fp);
--
To unsubscribe from this list: send the line "unsubscribe linux-tip-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Stable Commits]     [Linux Stable Kernel]     [Linux Kernel]     [Linux USB Devel]     [Linux Video &Media]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux