diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2009-06-01 16:50:19 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-06-01 21:40:52 -0400 |
commit | a0055ae2a4e13db9534c438cf8f3896181da6afc (patch) | |
tree | db47d0a2ad5bbd7c0c27d4e295ca8da68eacb3a2 /Documentation/perf_counter/util/symbol.c | |
parent | ea5cc87c63b49c133d15ec2911bb2e49e8124516 (diff) |
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>
Diffstat (limited to 'Documentation/perf_counter/util/symbol.c')
-rw-r--r-- | Documentation/perf_counter/util/symbol.c | 38 |
1 files changed, 3 insertions, 35 deletions
diff --git a/Documentation/perf_counter/util/symbol.c b/Documentation/perf_counter/util/symbol.c index 47281210443d..31e8fae58426 100644 --- a/Documentation/perf_counter/util/symbol.c +++ b/Documentation/perf_counter/util/symbol.c | |||
@@ -1,5 +1,6 @@ | |||
1 | #include "util.h" | 1 | #include "util.h" |
2 | #include "../perf.h" | 2 | #include "../perf.h" |
3 | #include "string.h" | ||
3 | #include "symbol.h" | 4 | #include "symbol.h" |
4 | 5 | ||
5 | #include <libelf.h> | 6 | #include <libelf.h> |
@@ -122,39 +123,6 @@ size_t dso__fprintf(struct dso *self, FILE *fp) | |||
122 | return ret; | 123 | return ret; |
123 | } | 124 | } |
124 | 125 | ||
125 | static int hex(char ch) | ||
126 | { | ||
127 | if ((ch >= '0') && (ch <= '9')) | ||
128 | return ch - '0'; | ||
129 | if ((ch >= 'a') && (ch <= 'f')) | ||
130 | return ch - 'a' + 10; | ||
131 | if ((ch >= 'A') && (ch <= 'F')) | ||
132 | return ch - 'A' + 10; | ||
133 | return -1; | ||
134 | } | ||
135 | |||
136 | /* | ||
137 | * While we find nice hex chars, build a long_val. | ||
138 | * Return number of chars processed. | ||
139 | */ | ||
140 | static int hex2long(char *ptr, unsigned long *long_val) | ||
141 | { | ||
142 | const char *p = ptr; | ||
143 | *long_val = 0; | ||
144 | |||
145 | while (*p) { | ||
146 | const int hex_val = hex(*p); | ||
147 | |||
148 | if (hex_val < 0) | ||
149 | break; | ||
150 | |||
151 | *long_val = (*long_val << 4) | hex_val; | ||
152 | p++; | ||
153 | } | ||
154 | |||
155 | return p - ptr; | ||
156 | } | ||
157 | |||
158 | static int dso__load_kallsyms(struct dso *self, symbol_filter_t filter) | 126 | static int dso__load_kallsyms(struct dso *self, symbol_filter_t filter) |
159 | { | 127 | { |
160 | struct rb_node *nd, *prevnd; | 128 | struct rb_node *nd, *prevnd; |
@@ -166,7 +134,7 @@ static int dso__load_kallsyms(struct dso *self, symbol_filter_t filter) | |||
166 | goto out_failure; | 134 | goto out_failure; |
167 | 135 | ||
168 | while (!feof(file)) { | 136 | while (!feof(file)) { |
169 | unsigned long start; | 137 | __u64 start; |
170 | struct symbol *sym; | 138 | struct symbol *sym; |
171 | int line_len, len; | 139 | int line_len, len; |
172 | char symbol_type; | 140 | char symbol_type; |
@@ -180,7 +148,7 @@ static int dso__load_kallsyms(struct dso *self, symbol_filter_t filter) | |||
180 | 148 | ||
181 | line[--line_len] = '\0'; /* \n */ | 149 | line[--line_len] = '\0'; /* \n */ |
182 | 150 | ||
183 | len = hex2long(line, &start); | 151 | len = hex2u64(line, &start); |
184 | 152 | ||
185 | len++; | 153 | len++; |
186 | if (len + 2 >= line_len) | 154 | if (len + 2 >= line_len) |