1#    Copyright 2017 ARM Limited, Google and contributors
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#     http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14#
15
16"""This module contains the class for representing a tracing_mark_write
17trace_event used for ftrace events injected from userspace.
18"""
19
20from trappy.base import Base
21from trappy.dynamic import register_ftrace_parser
22
23class TracingMarkWrite(Base):
24    """Parse tracing_mark_write events that couldn't be matched with more specific unique words
25       This class is always used as a fallback if nothing more specific could match the particular
26       tracing_mark_write event.
27    """
28
29    unique_word = "tracing_mark_write"
30
31    def generate_data_dict(self, data_str):
32        if self.tracer:
33            data_dict = self.tracer.generate_data_dict(data_str)
34            if data_dict:
35                return data_dict
36
37        data_dict = { 'string': data_str }
38        return data_dict
39
40    def __init__(self):
41        super(TracingMarkWrite, self).__init__(fallback=True)
42
43register_ftrace_parser(TracingMarkWrite)
44