diff options
| author | Steven Rostedt <srostedt@redhat.com> | 2009-10-14 15:30:00 -0400 |
|---|---|---|
| committer | Steven Rostedt <srostedt@redhat.com> | 2009-10-14 15:30:00 -0400 |
| commit | c567c87ee6ec9b585c9d2f8f87e86371a5bfcbb5 (patch) | |
| tree | 633e3c57251a91dccd3f77584f2cb6fea0f113b1 | |
| parent | 6c4594667bf6c66638766859d27266aba730eafb (diff) | |
make the code closer to what is in perf
Signed-off-by: Steven Rostedt <srostedt@redhat.com>
| -rw-r--r-- | parse-events.c | 52 | ||||
| -rw-r--r-- | parse-events.h | 2 | ||||
| -rw-r--r-- | trace-cmd.c | 2 |
3 files changed, 27 insertions, 29 deletions
diff --git a/parse-events.c b/parse-events.c index aef46c8..b86e349 100644 --- a/parse-events.c +++ b/parse-events.c | |||
| @@ -634,7 +634,7 @@ static enum event_type read_token_item(char **tok) | |||
| 634 | static int test_type(enum event_type type, enum event_type expect) | 634 | static int test_type(enum event_type type, enum event_type expect) |
| 635 | { | 635 | { |
| 636 | if (type != expect) { | 636 | if (type != expect) { |
| 637 | warn("Error: expected type %d but read %d", | 637 | warning("Error: expected type %d but read %d", |
| 638 | expect, type); | 638 | expect, type); |
| 639 | return -1; | 639 | return -1; |
| 640 | } | 640 | } |
| @@ -645,13 +645,13 @@ static int test_type_token(enum event_type type, char *token, | |||
| 645 | enum event_type expect, char *expect_tok) | 645 | enum event_type expect, char *expect_tok) |
| 646 | { | 646 | { |
| 647 | if (type != expect) { | 647 | if (type != expect) { |
| 648 | warn("Error: expected type %d but read %d", | 648 | warning("Error: expected type %d but read %d", |
| 649 | expect, type); | 649 | expect, type); |
| 650 | return -1; | 650 | return -1; |
| 651 | } | 651 | } |
| 652 | 652 | ||
| 653 | if (strcmp(token, expect_tok) != 0) { | 653 | if (strcmp(token, expect_tok) != 0) { |
| 654 | warn("Error: expected '%s' but read '%s'", | 654 | warning("Error: expected '%s' but read '%s'", |
| 655 | expect_tok, token); | 655 | expect_tok, token); |
| 656 | return -1; | 656 | return -1; |
| 657 | } | 657 | } |
| @@ -1074,7 +1074,7 @@ out_free: | |||
| 1074 | return EVENT_ERROR; | 1074 | return EVENT_ERROR; |
| 1075 | } | 1075 | } |
| 1076 | 1076 | ||
| 1077 | enum event_type | 1077 | static enum event_type |
| 1078 | process_array(struct event *event, struct print_arg *top, char **tok) | 1078 | process_array(struct event *event, struct print_arg *top, char **tok) |
| 1079 | { | 1079 | { |
| 1080 | struct print_arg *arg; | 1080 | struct print_arg *arg; |
| @@ -1086,7 +1086,7 @@ process_array(struct event *event, struct print_arg *top, char **tok) | |||
| 1086 | 1086 | ||
| 1087 | *tok = NULL; | 1087 | *tok = NULL; |
| 1088 | type = process_arg(event, arg, &token); | 1088 | type = process_arg(event, arg, &token); |
| 1089 | if (test_type_token(type, token, EVENT_OP, "]")) | 1089 | if (test_type_token(type, token, EVENT_OP, (char *)"]")) |
| 1090 | goto out_free; | 1090 | goto out_free; |
| 1091 | 1091 | ||
| 1092 | top->op.right = arg; | 1092 | top->op.right = arg; |
| @@ -1279,7 +1279,7 @@ process_op(struct event *event, struct print_arg *arg, char **tok) | |||
| 1279 | type = process_array(event, arg, tok); | 1279 | type = process_array(event, arg, tok); |
| 1280 | 1280 | ||
| 1281 | } else { | 1281 | } else { |
| 1282 | warn("unknown op '%s'", token); | 1282 | warning("unknown op '%s'", token); |
| 1283 | event->flags |= EVENT_FL_FAILED; | 1283 | event->flags |= EVENT_FL_FAILED; |
| 1284 | /* the arg is now the left side */ | 1284 | /* the arg is now the left side */ |
| 1285 | return EVENT_NONE; | 1285 | return EVENT_NONE; |
| @@ -1606,7 +1606,7 @@ process_paren(struct event *event, struct print_arg *arg, char **tok) | |||
| 1606 | if (type == EVENT_ERROR) | 1606 | if (type == EVENT_ERROR) |
| 1607 | return EVENT_ERROR; | 1607 | return EVENT_ERROR; |
| 1608 | 1608 | ||
| 1609 | if (test_type_token(type, token, EVENT_DELIM, ")")) { | 1609 | if (test_type_token(type, token, EVENT_DELIM, (char *)")")) { |
| 1610 | free_token(token); | 1610 | free_token(token); |
| 1611 | return EVENT_ERROR; | 1611 | return EVENT_ERROR; |
| 1612 | } | 1612 | } |
| @@ -1833,7 +1833,7 @@ static int event_read_print(struct event *event) | |||
| 1833 | goto concat; | 1833 | goto concat; |
| 1834 | } | 1834 | } |
| 1835 | 1835 | ||
| 1836 | if (test_type_token(type, token, EVENT_DELIM, ",")) | 1836 | if (test_type_token(type, token, EVENT_DELIM, (char *)",")) |
| 1837 | goto fail; | 1837 | goto fail; |
| 1838 | 1838 | ||
| 1839 | free_token(token); | 1839 | free_token(token); |
| @@ -1947,7 +1947,7 @@ static int trace_parse_common_type(void *data) | |||
| 1947 | static int type_size; | 1947 | static int type_size; |
| 1948 | 1948 | ||
| 1949 | return __parse_common(data, &type_size, &type_offset, | 1949 | return __parse_common(data, &type_size, &type_offset, |
| 1950 | "common_type"); | 1950 | (char *)"common_type"); |
| 1951 | } | 1951 | } |
| 1952 | 1952 | ||
| 1953 | static int parse_common_pid(void *data) | 1953 | static int parse_common_pid(void *data) |
| @@ -1956,7 +1956,7 @@ static int parse_common_pid(void *data) | |||
| 1956 | static int pid_size; | 1956 | static int pid_size; |
| 1957 | 1957 | ||
| 1958 | return __parse_common(data, &pid_size, &pid_offset, | 1958 | return __parse_common(data, &pid_size, &pid_offset, |
| 1959 | "common_pid"); | 1959 | (char *)"common_pid"); |
| 1960 | } | 1960 | } |
| 1961 | 1961 | ||
| 1962 | static int parse_common_pc(void *data) | 1962 | static int parse_common_pc(void *data) |
| @@ -1965,7 +1965,7 @@ static int parse_common_pc(void *data) | |||
| 1965 | static int pc_size; | 1965 | static int pc_size; |
| 1966 | 1966 | ||
| 1967 | return __parse_common(data, &pc_size, &pc_offset, | 1967 | return __parse_common(data, &pc_size, &pc_offset, |
| 1968 | "common_preempt_count"); | 1968 | (char *)"common_preempt_count"); |
| 1969 | } | 1969 | } |
| 1970 | 1970 | ||
| 1971 | static int parse_common_flags(void *data) | 1971 | static int parse_common_flags(void *data) |
| @@ -1974,7 +1974,7 @@ static int parse_common_flags(void *data) | |||
| 1974 | static int flags_size; | 1974 | static int flags_size; |
| 1975 | 1975 | ||
| 1976 | return __parse_common(data, &flags_size, &flags_offset, | 1976 | return __parse_common(data, &flags_size, &flags_offset, |
| 1977 | "common_flags"); | 1977 | (char *)"common_flags"); |
| 1978 | } | 1978 | } |
| 1979 | 1979 | ||
| 1980 | static int parse_common_lock_depth(void *data) | 1980 | static int parse_common_lock_depth(void *data) |
| @@ -1984,7 +1984,7 @@ static int parse_common_lock_depth(void *data) | |||
| 1984 | int ret; | 1984 | int ret; |
| 1985 | 1985 | ||
| 1986 | ret = __parse_common(data, &ld_size, &ld_offset, | 1986 | ret = __parse_common(data, &ld_size, &ld_offset, |
| 1987 | "common_lock_depth"); | 1987 | (char *)"common_lock_depth"); |
| 1988 | if (ret < 0) | 1988 | if (ret < 0) |
| 1989 | return -1; | 1989 | return -1; |
| 1990 | 1990 | ||
| @@ -2305,6 +2305,7 @@ static struct print_arg *make_bprint_args(char *fmt, void *data, int size, struc | |||
| 2305 | case 'u': | 2305 | case 'u': |
| 2306 | case 'x': | 2306 | case 'x': |
| 2307 | case 'i': | 2307 | case 'i': |
| 2308 | /* the pointers are always 4 bytes aligned */ | ||
| 2308 | bptr = (void *)(((unsigned long)bptr + 3) & | 2309 | bptr = (void *)(((unsigned long)bptr + 3) & |
| 2309 | ~3); | 2310 | ~3); |
| 2310 | switch (ls) { | 2311 | switch (ls) { |
| @@ -2418,9 +2419,6 @@ static void pretty_print(void *data, int size, struct event *event) | |||
| 2418 | int len; | 2419 | int len; |
| 2419 | int ls; | 2420 | int ls; |
| 2420 | 2421 | ||
| 2421 | if (strcmp(event->name,"mm_page_alloc") == 0) | ||
| 2422 | breakpoint(); | ||
| 2423 | |||
| 2424 | if (event->flags & EVENT_FL_ISFUNC) | 2422 | if (event->flags & EVENT_FL_ISFUNC) |
| 2425 | ptr = " %pF <-- %pF"; | 2423 | ptr = " %pF <-- %pF"; |
| 2426 | 2424 | ||
| @@ -2560,26 +2558,26 @@ static inline int log10_cpu(int nb) | |||
| 2560 | return 1; | 2558 | return 1; |
| 2561 | } | 2559 | } |
| 2562 | 2560 | ||
| 2563 | static void print_lat_fmt(void *data, int size) | 2561 | static void print_lat_fmt(void *data, int size __unused) |
| 2564 | { | 2562 | { |
| 2565 | unsigned int flags; | 2563 | unsigned int lat_flags; |
| 2566 | unsigned int pc; | 2564 | unsigned int pc; |
| 2567 | int lock_depth; | 2565 | int lock_depth; |
| 2568 | int hardirq; | 2566 | int hardirq; |
| 2569 | int softirq; | 2567 | int softirq; |
| 2570 | 2568 | ||
| 2571 | flags = parse_common_flags(data); | 2569 | lat_flags = parse_common_flags(data); |
| 2572 | pc = parse_common_pc(data); | 2570 | pc = parse_common_pc(data); |
| 2573 | lock_depth = parse_common_lock_depth(data); | 2571 | lock_depth = parse_common_lock_depth(data); |
| 2574 | 2572 | ||
| 2575 | hardirq = flags & TRACE_FLAG_HARDIRQ; | 2573 | hardirq = lat_flags & TRACE_FLAG_HARDIRQ; |
| 2576 | softirq = flags & TRACE_FLAG_SOFTIRQ; | 2574 | softirq = lat_flags & TRACE_FLAG_SOFTIRQ; |
| 2577 | 2575 | ||
| 2578 | printf("%c%c%c", | 2576 | printf("%c%c%c", |
| 2579 | (flags & TRACE_FLAG_IRQS_OFF) ? 'd' : | 2577 | (lat_flags & TRACE_FLAG_IRQS_OFF) ? 'd' : |
| 2580 | (flags & TRACE_FLAG_IRQS_NOSUPPORT) ? | 2578 | (lat_flags & TRACE_FLAG_IRQS_NOSUPPORT) ? |
| 2581 | 'X' : '.', | 2579 | 'X' : '.', |
| 2582 | (flags & TRACE_FLAG_NEED_RESCHED) ? | 2580 | (lat_flags & TRACE_FLAG_NEED_RESCHED) ? |
| 2583 | 'N' : '.', | 2581 | 'N' : '.', |
| 2584 | (hardirq && softirq) ? 'H' : | 2582 | (hardirq && softirq) ? 'H' : |
| 2585 | hardirq ? 'h' : softirq ? 's' : '.'); | 2583 | hardirq ? 'h' : softirq ? 's' : '.'); |
| @@ -2952,7 +2950,7 @@ void print_event(int cpu, void *data, int size, unsigned long long nsecs) | |||
| 2952 | 2950 | ||
| 2953 | event = trace_find_event(type); | 2951 | event = trace_find_event(type); |
| 2954 | if (!event) { | 2952 | if (!event) { |
| 2955 | warn("ug! no event found for type %d", type); | 2953 | warning("ug! no event found for type %d", type); |
| 2956 | return; | 2954 | return; |
| 2957 | } | 2955 | } |
| 2958 | 2956 | ||
| @@ -3215,13 +3213,13 @@ int parse_event_file(char *buf, unsigned long size, char *sys) | |||
| 3215 | 3213 | ||
| 3216 | ret = event_read_format(event); | 3214 | ret = event_read_format(event); |
| 3217 | if (ret < 0) { | 3215 | if (ret < 0) { |
| 3218 | warn("failed to read event format for %s", event->name); | 3216 | warning("failed to read event format for %s", event->name); |
| 3219 | goto event_failed; | 3217 | goto event_failed; |
| 3220 | } | 3218 | } |
| 3221 | 3219 | ||
| 3222 | ret = event_read_print(event); | 3220 | ret = event_read_print(event); |
| 3223 | if (ret < 0) { | 3221 | if (ret < 0) { |
| 3224 | warn("failed to read event print fmt for %s", event->name); | 3222 | warning("failed to read event print fmt for %s", event->name); |
| 3225 | goto event_failed; | 3223 | goto event_failed; |
| 3226 | } | 3224 | } |
| 3227 | 3225 | ||
diff --git a/parse-events.h b/parse-events.h index d044fd5..92248e5 100644 --- a/parse-events.h +++ b/parse-events.h | |||
| @@ -167,7 +167,7 @@ void trace_report(int argc, char **argv); | |||
| 167 | 167 | ||
| 168 | void die(char *fmt, ...); | 168 | void die(char *fmt, ...); |
| 169 | void *malloc_or_die(unsigned int size); | 169 | void *malloc_or_die(unsigned int size); |
| 170 | void warn(char *fmt, ...); | 170 | void warning(char *fmt, ...); |
| 171 | 171 | ||
| 172 | void parse_cmdlines(char *file, int size); | 172 | void parse_cmdlines(char *file, int size); |
| 173 | void parse_proc_kallsyms(char *file, unsigned int size); | 173 | void parse_proc_kallsyms(char *file, unsigned int size); |
diff --git a/trace-cmd.c b/trace-cmd.c index fe5284d..22c3df6 100644 --- a/trace-cmd.c +++ b/trace-cmd.c | |||
| @@ -151,7 +151,7 @@ void die(char *fmt, ...) | |||
| 151 | exit(ret); | 151 | exit(ret); |
| 152 | } | 152 | } |
| 153 | 153 | ||
| 154 | void warn(char *fmt, ...) | 154 | void warning(char *fmt, ...) |
| 155 | { | 155 | { |
| 156 | va_list ap; | 156 | va_list ap; |
| 157 | 157 | ||
