diff options
author | Peter Zijlstra <a.p.zijlstra@chello.nl> | 2009-06-18 03:44:20 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-06-18 03:46:00 -0400 |
commit | a73c7d84a1975b44c0ebd03c2dec288af1426349 (patch) | |
tree | 34f6f154ec63b04e75148cc022d8a18198857d33 /tools | |
parent | 7522060c95395f479ee4a6af3bbf9e097e92e48f (diff) |
perf_counter tools: Add and use isprint()
Introduce isprint() to print out raw event dumps to ASCII, etc.
(This is an extension to upstream Git's ctype.c.)
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
LKML-Reference: <new-submission>
[ removed openssl.h inclusion from util.h - it leaked ctype.h ]
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/builtin-report.c | 2 | ||||
-rw-r--r-- | tools/perf/util/ctype.c | 17 | ||||
-rw-r--r-- | tools/perf/util/util.h | 19 |
3 files changed, 20 insertions, 18 deletions
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index e14e98676171..9a3805f0c9f2 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c | |||
@@ -1285,7 +1285,7 @@ static void trace_event(event_t *event) | |||
1285 | for (j = 0; j < 15-(i & 15); j++) | 1285 | for (j = 0; j < 15-(i & 15); j++) |
1286 | cdprintf(" "); | 1286 | cdprintf(" "); |
1287 | for (j = 0; j < (i & 15); j++) { | 1287 | for (j = 0; j < (i & 15); j++) { |
1288 | if (issane(raw_event[i-15+j])) | 1288 | if (isprint(raw_event[i-15+j])) |
1289 | cdprintf("%c", raw_event[i-15+j]); | 1289 | cdprintf("%c", raw_event[i-15+j]); |
1290 | else | 1290 | else |
1291 | cdprintf("."); | 1291 | cdprintf("."); |
diff --git a/tools/perf/util/ctype.c b/tools/perf/util/ctype.c index b90ec004f29c..0b791bd346bc 100644 --- a/tools/perf/util/ctype.c +++ b/tools/perf/util/ctype.c | |||
@@ -11,16 +11,21 @@ enum { | |||
11 | D = GIT_DIGIT, | 11 | D = GIT_DIGIT, |
12 | G = GIT_GLOB_SPECIAL, /* *, ?, [, \\ */ | 12 | G = GIT_GLOB_SPECIAL, /* *, ?, [, \\ */ |
13 | R = GIT_REGEX_SPECIAL, /* $, (, ), +, ., ^, {, | * */ | 13 | R = GIT_REGEX_SPECIAL, /* $, (, ), +, ., ^, {, | * */ |
14 | P = GIT_PRINT_EXTRA, /* printable - alpha - digit - glob - regex */ | ||
15 | |||
16 | PS = GIT_SPACE | GIT_PRINT_EXTRA, | ||
14 | }; | 17 | }; |
15 | 18 | ||
16 | unsigned char sane_ctype[256] = { | 19 | unsigned char sane_ctype[256] = { |
20 | /* 0 1 2 3 4 5 6 7 8 9 A B C D E F */ | ||
21 | |||
17 | 0, 0, 0, 0, 0, 0, 0, 0, 0, S, S, 0, 0, S, 0, 0, /* 0.. 15 */ | 22 | 0, 0, 0, 0, 0, 0, 0, 0, 0, S, S, 0, 0, S, 0, 0, /* 0.. 15 */ |
18 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 16.. 31 */ | 23 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 16.. 31 */ |
19 | S, 0, 0, 0, R, 0, 0, 0, R, R, G, R, 0, 0, R, 0, /* 32.. 47 */ | 24 | PS,P, P, P, R, P, P, P, R, R, G, R, P, P, R, P, /* 32.. 47 */ |
20 | D, D, D, D, D, D, D, D, D, D, 0, 0, 0, 0, 0, G, /* 48.. 63 */ | 25 | D, D, D, D, D, D, D, D, D, D, P, P, P, P, P, G, /* 48.. 63 */ |
21 | 0, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, /* 64.. 79 */ | 26 | P, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, /* 64.. 79 */ |
22 | A, A, A, A, A, A, A, A, A, A, A, G, G, 0, R, 0, /* 80.. 95 */ | 27 | A, A, A, A, A, A, A, A, A, A, A, G, G, P, R, P, /* 80.. 95 */ |
23 | 0, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, /* 96..111 */ | 28 | P, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, /* 96..111 */ |
24 | A, A, A, A, A, A, A, A, A, A, A, R, R, 0, 0, 0, /* 112..127 */ | 29 | A, A, A, A, A, A, A, A, A, A, A, R, R, P, P, 0, /* 112..127 */ |
25 | /* Nothing in the 128.. range */ | 30 | /* Nothing in the 128.. range */ |
26 | }; | 31 | }; |
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index ce9b514f60a3..b8cfed776d81 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h | |||
@@ -100,11 +100,6 @@ | |||
100 | #include <iconv.h> | 100 | #include <iconv.h> |
101 | #endif | 101 | #endif |
102 | 102 | ||
103 | #ifndef NO_OPENSSL | ||
104 | #include <openssl/ssl.h> | ||
105 | #include <openssl/err.h> | ||
106 | #endif | ||
107 | |||
108 | /* On most systems <limits.h> would have given us this, but | 103 | /* On most systems <limits.h> would have given us this, but |
109 | * not on some systems (e.g. GNU/Hurd). | 104 | * not on some systems (e.g. GNU/Hurd). |
110 | */ | 105 | */ |
@@ -332,18 +327,20 @@ static inline int has_extension(const char *filename, const char *ext) | |||
332 | #undef tolower | 327 | #undef tolower |
333 | #undef toupper | 328 | #undef toupper |
334 | extern unsigned char sane_ctype[256]; | 329 | extern unsigned char sane_ctype[256]; |
335 | #define GIT_SPACE 0x01 | 330 | #define GIT_SPACE 0x01 |
336 | #define GIT_DIGIT 0x02 | 331 | #define GIT_DIGIT 0x02 |
337 | #define GIT_ALPHA 0x04 | 332 | #define GIT_ALPHA 0x04 |
338 | #define GIT_GLOB_SPECIAL 0x08 | 333 | #define GIT_GLOB_SPECIAL 0x08 |
339 | #define GIT_REGEX_SPECIAL 0x10 | 334 | #define GIT_REGEX_SPECIAL 0x10 |
335 | #define GIT_PRINT_EXTRA 0x20 | ||
336 | #define GIT_PRINT 0x3E | ||
340 | #define sane_istest(x,mask) ((sane_ctype[(unsigned char)(x)] & (mask)) != 0) | 337 | #define sane_istest(x,mask) ((sane_ctype[(unsigned char)(x)] & (mask)) != 0) |
341 | #define isascii(x) (((x) & ~0x7f) == 0) | 338 | #define isascii(x) (((x) & ~0x7f) == 0) |
342 | #define isspace(x) sane_istest(x,GIT_SPACE) | 339 | #define isspace(x) sane_istest(x,GIT_SPACE) |
343 | #define isdigit(x) sane_istest(x,GIT_DIGIT) | 340 | #define isdigit(x) sane_istest(x,GIT_DIGIT) |
344 | #define isalpha(x) sane_istest(x,GIT_ALPHA) | 341 | #define isalpha(x) sane_istest(x,GIT_ALPHA) |
345 | #define isalnum(x) sane_istest(x,GIT_ALPHA | GIT_DIGIT) | 342 | #define isalnum(x) sane_istest(x,GIT_ALPHA | GIT_DIGIT) |
346 | #define issane(x) sane_istest(x,GIT_SPACE | GIT_DIGIT | GIT_ALPHA | GIT_GLOB_SPECIAL | GIT_REGEX_SPECIAL) | 343 | #define isprint(x) sane_istest(x,GIT_PRINT) |
347 | #define is_glob_special(x) sane_istest(x,GIT_GLOB_SPECIAL) | 344 | #define is_glob_special(x) sane_istest(x,GIT_GLOB_SPECIAL) |
348 | #define is_regex_special(x) sane_istest(x,GIT_GLOB_SPECIAL | GIT_REGEX_SPECIAL) | 345 | #define is_regex_special(x) sane_istest(x,GIT_GLOB_SPECIAL | GIT_REGEX_SPECIAL) |
349 | #define tolower(x) sane_case((unsigned char)(x), 0x20) | 346 | #define tolower(x) sane_case((unsigned char)(x), 0x20) |