Bladeren bron

perf tools: /proc/modules names don't always match its name

$ cut -d' ' -f1 /proc/modules|grep _|wc -l
 29
 $ cut -d' ' -f1 /proc/modules|grep _|sed 's/$/.ko'/g|while read n;do find /lib/modules/`uname -r` -name $n;done|wc -l
 12

For instance:

 $ grep ^aes_x86 /proc/modules
 aes_x86_64 9056 2 - Live 0xffffffffa0091000
 $ l /lib/modules/2.6.31-tip/kernel/arch/x86/crypto/aes-x86_64.ko
 -rw-r--r-- 1 root root 136438 2009-09-22 19:05 /lib/modules/2.6.31-tip/kernel/arch/x86/crypto/aes-x86_64.ko

Handle that by introducing a strxfrchar routine that replaces
dashes with underscores when matching file names to loaded modules.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Mike Galbraith <efault@gmx.de>
LKML-Reference: <new-submission>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Arnaldo Carvalho de Melo 15 jaren geleden
bovenliggende
commit
a2a99e8e12
3 gewijzigde bestanden met toevoegingen van 14 en 1 verwijderingen
  1. 11 0
      tools/perf/util/string.c
  2. 1 0
      tools/perf/util/string.h
  3. 2 1
      tools/perf/util/symbol.c

+ 11 - 0
tools/perf/util/string.c

@@ -1,3 +1,4 @@
+#include <string.h>
 #include "string.h"
 #include "string.h"
 
 
 static int hex(char ch)
 static int hex(char ch)
@@ -32,3 +33,13 @@ int hex2u64(const char *ptr, u64 *long_val)
 
 
 	return p - ptr;
 	return p - ptr;
 }
 }
+
+char *strxfrchar(char *s, char from, char to)
+{
+	char *p = s;
+
+	while ((p = strchr(p, from)) != NULL)
+		*p++ = to;
+
+	return s;
+}

+ 1 - 0
tools/perf/util/string.h

@@ -4,6 +4,7 @@
 #include "types.h"
 #include "types.h"
 
 
 int hex2u64(const char *ptr, u64 *val);
 int hex2u64(const char *ptr, u64 *val);
+char *strxfrchar(char *s, char from, char to);
 
 
 #define _STR(x) #x
 #define _STR(x) #x
 #define STR(x) _STR(x)
 #define STR(x) _STR(x)

+ 2 - 1
tools/perf/util/symbol.c

@@ -189,7 +189,7 @@ struct symbol *dso__find_symbol(struct dso *self, u64 ip)
 
 
 size_t dso__fprintf(struct dso *self, FILE *fp)
 size_t dso__fprintf(struct dso *self, FILE *fp)
 {
 {
-	size_t ret = fprintf(fp, "dso: %s\n", self->long_name);
+	size_t ret = fprintf(fp, "dso: %s\n", self->short_name);
 
 
 	struct rb_node *nd;
 	struct rb_node *nd;
 	for (nd = rb_first(&self->syms); nd; nd = rb_next(nd)) {
 	for (nd = rb_first(&self->syms); nd; nd = rb_next(nd)) {
@@ -977,6 +977,7 @@ static int dsos__load_modules_sym_dir(char *dirname,
 			snprintf(dso_name, sizeof(dso_name), "[%.*s]",
 			snprintf(dso_name, sizeof(dso_name), "[%.*s]",
 				 (int)(dot - dent->d_name), dent->d_name);
 				 (int)(dot - dent->d_name), dent->d_name);
 
 
+			strxfrchar(dso_name, '-', '_');
 			map = kernel_maps__find_by_dso_name(dso_name);
 			map = kernel_maps__find_by_dso_name(dso_name);
 			if (map == NULL)
 			if (map == NULL)
 				continue;
 				continue;