From bc6e46cce9e2f6e4555a2c6cff1521a522156c6d Mon Sep 17 00:00:00 2001 From: NĂ©lio Laranjeiro Date: Mon, 13 Jul 2009 16:56:36 +0200 Subject: *tools/trace: * Added the possibility to add a callback file containing the function to decode traces. See the example/trace.trc to use it, the file containing the callback must be provided using the -c option in the interpretor. --- tools/trace/lib/parser.g | 7 ++++++- tools/trace/lib/traceclass.py | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'tools/trace/lib') diff --git a/tools/trace/lib/parser.g b/tools/trace/lib/parser.g index 2cee66b5..ba4e974f 100644 --- a/tools/trace/lib/parser.g +++ b/tools/trace/lib/parser.g @@ -12,6 +12,7 @@ parser TraceParser: token PARAM: "[a-zA-Z_1-9]+" token LENGTH: "[1-2-4]" token STRING: "\".*\"" + token CB: "[a-zA-Z_]+" token SPACE: " " rule parser: START {{ my_list = list() }} @@ -24,9 +25,13 @@ parser TraceParser: ( param SPACE {{ e.param_add (param[0], param[1]) }} )* ( string {{ e.string_set (string) }} - )* + )? + ( cb {{ e.callback = cb }} + )? "\n" {{ return e }} rule param: PARAM SPACE LENGTH {{ return [PARAM.strip(), int(LENGTH.strip())] }} rule string: STRING {{ return (STRING.strip()) }} + + rule cb: "\[" CB "\]" {{ return (CB.strip()) }} diff --git a/tools/trace/lib/traceclass.py b/tools/trace/lib/traceclass.py index 4c194c73..27b9ba53 100644 --- a/tools/trace/lib/traceclass.py +++ b/tools/trace/lib/traceclass.py @@ -21,6 +21,7 @@ class TraceEvent: self.__name = name self.__param_list = list() self.__string = "" + self.callback = None def name (self): return self.__name @@ -28,7 +29,7 @@ class TraceEvent: def param_add (self, name, length): param = TraceParam (name, length) self.__param_list.append(param) - + def param_get (self, pos): if pos <= len (self.__param_list): return self.__param_list[pos] -- cgit v1.2.3