# Copyright 2016-2017 ARM Limited # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # from trappy.ftrace import GenericFTrace import re SYSTRACE_EVENT = re.compile( r'^(?P[A-Z])(\|(?P\d+)\|(?P.*)(\|(?P\d+))?)?') class drop_before_trace(object): """Object that, when called, returns True if the line is not part of the trace We have to first look for the "" and then skip the headers that start with # """ def __init__(self): self.before_begin_trace = True self.before_script_trace_data = True self.before_actual_trace = True def __call__(self, line): if self.before_begin_trace: if line.startswith("") or \ line.startswith("Android System Trace"): self.before_begin_trace = False elif self.before_script_trace_data: if line.startswith(' """ return lambda x: not x.endswith("\n") def generate_data_dict(self, data_str): """ Custom parsing for systrace's userspace events """ data_dict = None match = SYSTRACE_EVENT.match(data_str) if match: data_dict = { 'event': match.group('event'), 'pid' : match.group('pid'), 'func' : match.group('func'), 'data' : match.group('data') } return data_dict