perf_counter tools: Use hex2u64 in more places
This has also a nice side effect, tools built on newer systems such as
fedora 10 again work on systems with older versions of glibc:
My workstation:
[acme@doppio ~]$ rpm -q glibc.x86_64
glibc-2.9-3.x86_64
Test machine:
[acme@emilia ~]$ rpm -q glibc.x86_64
glibc-2.5-24
Before:
[acme@emilia ~]$ perf
perf: /lib64/libc.so.6: version `GLIBC_2.7' not found (required by perf)
[acme@emilia ~]$ nm `which perf` | grep GLIBC_2\.7
U __isoc99_sscanf@@GLIBC_2.7
[acme@emilia ~]$
After:
[acme@emilia ~]$ perf
usage: perf [--version] [--help] COMMAND [ARGS]
The most commonly used perf commands are:
record Run a command and record its profile into perf.data
report Read perf.data (created by perf record) and display the
profile
stat Run a command and gather performance counter statistics
top Run a command and profile it
See 'perf help COMMAND' for more information on a specific command.
[acme@emilia ~]$ nm `which perf` | grep GLIBC_2\.7
[acme@emilia ~]$
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
LKML-Reference: <20090601205019.GA7805@ghostprotocols.net>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
diff --git a/Documentation/perf_counter/util/symbol.c b/Documentation/perf_counter/util/symbol.c
index 4728121..31e8fae 100644
--- a/Documentation/perf_counter/util/symbol.c
+++ b/Documentation/perf_counter/util/symbol.c
@@ -1,5 +1,6 @@
#include "util.h"
#include "../perf.h"
+#include "string.h"
#include "symbol.h"
#include <libelf.h>
@@ -122,39 +123,6 @@
return ret;
}
-static int hex(char ch)
-{
- if ((ch >= '0') && (ch <= '9'))
- return ch - '0';
- if ((ch >= 'a') && (ch <= 'f'))
- return ch - 'a' + 10;
- if ((ch >= 'A') && (ch <= 'F'))
- return ch - 'A' + 10;
- return -1;
-}
-
-/*
- * While we find nice hex chars, build a long_val.
- * Return number of chars processed.
- */
-static int hex2long(char *ptr, unsigned long *long_val)
-{
- const char *p = ptr;
- *long_val = 0;
-
- while (*p) {
- const int hex_val = hex(*p);
-
- if (hex_val < 0)
- break;
-
- *long_val = (*long_val << 4) | hex_val;
- p++;
- }
-
- return p - ptr;
-}
-
static int dso__load_kallsyms(struct dso *self, symbol_filter_t filter)
{
struct rb_node *nd, *prevnd;
@@ -166,7 +134,7 @@
goto out_failure;
while (!feof(file)) {
- unsigned long start;
+ __u64 start;
struct symbol *sym;
int line_len, len;
char symbol_type;
@@ -180,7 +148,7 @@
line[--line_len] = '\0'; /* \n */
- len = hex2long(line, &start);
+ len = hex2u64(line, &start);
len++;
if (len + 2 >= line_len)