diff options
author | Johannes Berg <johannes@sipsolutions.net> | 2009-12-06 11:12:56 -0500 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2009-12-07 12:34:47 -0500 |
commit | a4619e35c7667fd5a502ec41c2fff88296c93e64 (patch) | |
tree | ff495bc5af4f8bb79ce13be12d19e157218d0f14 | |
parent | dacd5dd2bfe3331e325c2f3a6fc044d3fa6fd03c (diff) |
Add work around for event output bug in older kernels
Older kernels have a bug that prints out the macro name instead of
what it should represent. This breaks parsing the data from userspace.
This especially affects the mac80211 trace events.
This adds a work around in the tool to handle the bug when executed
on older kernels.
See Linux kernel commit 811cb50baf63461ce0bdb234927046131fc7fa8b
for details.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
-rw-r--r-- | parse-events.c | 49 |
1 files changed, 48 insertions, 1 deletions
diff --git a/parse-events.c b/parse-events.c index fe683c9..df6ad6e 100644 --- a/parse-events.c +++ b/parse-events.c | |||
@@ -463,6 +463,26 @@ static enum event_type get_type(int ch) | |||
463 | return EVENT_OP; | 463 | return EVENT_OP; |
464 | } | 464 | } |
465 | 465 | ||
466 | static void __push_char(char c) | ||
467 | { | ||
468 | if (input_buf_ptr <= 0) | ||
469 | die("too much pushback"); | ||
470 | input_buf[--input_buf_ptr] = c; | ||
471 | } | ||
472 | |||
473 | static void __push_str(char *s) | ||
474 | { | ||
475 | char *e = s; | ||
476 | |||
477 | while (*e++) | ||
478 | /* nothing */; | ||
479 | e--; | ||
480 | while (s != e) { | ||
481 | e--; | ||
482 | __push_char(*e); | ||
483 | } | ||
484 | } | ||
485 | |||
466 | static int __read_char(void) | 486 | static int __read_char(void) |
467 | { | 487 | { |
468 | if (input_buf_ptr >= input_buf_siz) | 488 | if (input_buf_ptr >= input_buf_siz) |
@@ -622,6 +642,33 @@ static enum event_type __read_token(char **tok) | |||
622 | if (!*tok) | 642 | if (!*tok) |
623 | return EVENT_NONE; | 643 | return EVENT_NONE; |
624 | 644 | ||
645 | if (type == EVENT_ITEM) { | ||
646 | /* | ||
647 | * Older versions of the kernel has a bug that | ||
648 | * creates invalid symbols and will break the mac80211 | ||
649 | * parsing. This is a work around to that bug. | ||
650 | * | ||
651 | * See Linux kernel commit: | ||
652 | * 811cb50baf63461ce0bdb234927046131fc7fa8b | ||
653 | */ | ||
654 | if (strcmp(*tok, "LOCAL_PR_FMT") == 0) { | ||
655 | free(*tok); | ||
656 | *tok = NULL; | ||
657 | __push_str("\"\%s\" "); | ||
658 | return __read_token(tok); | ||
659 | } else if (strcmp(*tok, "STA_PR_FMT") == 0) { | ||
660 | free(*tok); | ||
661 | *tok = NULL; | ||
662 | __push_str("\" sta:%pM\" "); | ||
663 | return __read_token(tok); | ||
664 | } else if (strcmp(*tok, "VIF_PR_FMT") == 0) { | ||
665 | free(*tok); | ||
666 | *tok = NULL; | ||
667 | __push_str("\" vif:%p(%d)\" "); | ||
668 | return __read_token(tok); | ||
669 | } | ||
670 | } | ||
671 | |||
625 | return type; | 672 | return type; |
626 | } | 673 | } |
627 | 674 | ||
@@ -2015,7 +2062,7 @@ static int event_read_print(struct event *event) | |||
2015 | if (type == EVENT_NONE) | 2062 | if (type == EVENT_NONE) |
2016 | return 0; | 2063 | return 0; |
2017 | 2064 | ||
2018 | /* Handle concatination of print lines */ | 2065 | /* Handle concatenation of print lines */ |
2019 | if (type == EVENT_DQUOTE) { | 2066 | if (type == EVENT_DQUOTE) { |
2020 | char *cat; | 2067 | char *cat; |
2021 | 2068 | ||