aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/perf_counter/util/parse-events.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2009-06-01 16:50:19 -0400
committerIngo Molnar <mingo@elte.hu>2009-06-01 21:40:52 -0400
commita0055ae2a4e13db9534c438cf8f3896181da6afc (patch)
treedb47d0a2ad5bbd7c0c27d4e295ca8da68eacb3a2 /Documentation/perf_counter/util/parse-events.c
parentea5cc87c63b49c133d15ec2911bb2e49e8124516 (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/parse-events.c')
-rw-r--r--Documentation/perf_counter/util/parse-events.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/Documentation/perf_counter/util/parse-events.c b/Documentation/perf_counter/util/parse-events.c
index 88c903eb260a..2fdfd1d923f2 100644
--- a/Documentation/perf_counter/util/parse-events.c
+++ b/Documentation/perf_counter/util/parse-events.c
@@ -4,6 +4,7 @@
4#include "parse-options.h" 4#include "parse-options.h"
5#include "parse-events.h" 5#include "parse-events.h"
6#include "exec_cmd.h" 6#include "exec_cmd.h"
7#include "string.h"
7 8
8int nr_counters; 9int nr_counters;
9 10
@@ -105,22 +106,26 @@ static __u64 match_event_symbols(const char *str)
105 __u64 config, id; 106 __u64 config, id;
106 int type; 107 int type;
107 unsigned int i; 108 unsigned int i;
108 char mask_str[4]; 109 const char *sep, *pstr;
109 110
110 if (sscanf(str, "r%llx", &config) == 1) 111 if (str[0] == 'r' && hex2u64(str + 1, &config) > 0)
111 return config | PERF_COUNTER_RAW_MASK; 112 return config | PERF_COUNTER_RAW_MASK;
112 113
113 switch (sscanf(str, "%d:%llu:%2s", &type, &id, mask_str)) { 114 pstr = str;
114 case 3: 115 sep = strchr(pstr, ':');
115 if (strchr(mask_str, 'k')) 116 if (sep) {
117 type = atoi(pstr);
118 pstr = sep + 1;
119 id = atoi(pstr);
120 sep = strchr(pstr, ':');
121 if (sep) {
122 pstr = sep + 1;
123 if (strchr(pstr, 'k'))
116 event_mask[nr_counters] |= EVENT_MASK_USER; 124 event_mask[nr_counters] |= EVENT_MASK_USER;
117 if (strchr(mask_str, 'u')) 125 if (strchr(pstr, 'u'))
118 event_mask[nr_counters] |= EVENT_MASK_KERNEL; 126 event_mask[nr_counters] |= EVENT_MASK_KERNEL;
119 case 2: 127 }
120 return EID(type, id); 128 return EID(type, id);
121
122 default:
123 break;
124 } 129 }
125 130
126 for (i = 0; i < ARRAY_SIZE(event_symbols); i++) { 131 for (i = 0; i < ARRAY_SIZE(event_symbols); i++) {