def _define_base_types(self):
        self.int8_type = CTFWriter.IntegerFieldDeclaration(8)
        self.int8_type.signed = True
        self.int8_type.alignment = 8

        self.uint8_type = CTFWriter.IntegerFieldDeclaration(8)
        self.uint8_type.signed = False
        self.uint8_type.alignment = 8

        self.int32_type = CTFWriter.IntegerFieldDeclaration(32)
        self.int32_type.signed = True
        self.int32_type.alignment = 8

        self.uint32_type = CTFWriter.IntegerFieldDeclaration(32)
        self.uint32_type.signed = False
        self.uint32_type.alignment = 8

        self.uint64_type = CTFWriter.IntegerFieldDeclaration(64)
        self.uint64_type.signed = False
        self.uint64_type.alignment = 8

        self.uint64_hex_type = CTFWriter.IntegerFieldDeclaration(64)
        self.uint64_hex_type.signed = False
        self.uint64_hex_type.alignment = 8
        self.uint64_hex_type.base = 16

        self.string_type = CTFWriter.StringFieldDeclaration()
Ejemplo n.º 2
0
    def define_base_types(self):
        self.char8_type = CTFWriter.IntegerFieldDeclaration(8)
        self.char8_type.signed = True
        self.char8_type.encoding = CTFStringEncoding.UTF8
        self.char8_type.alignment = 8

        self.int16_type = CTFWriter.IntegerFieldDeclaration(16)
        self.int16_type.signed = True
        self.int16_type.alignment = 8

        self.uint16_type = CTFWriter.IntegerFieldDeclaration(16)
        self.uint16_type.signed = False
        self.uint16_type.alignment = 8

        self.int32_type = CTFWriter.IntegerFieldDeclaration(32)
        self.int32_type.signed = True
        self.int32_type.alignment = 8

        self.uint32_type = CTFWriter.IntegerFieldDeclaration(32)
        self.uint32_type.signed = False
        self.uint32_type.alignment = 8

        self.int64_type = CTFWriter.IntegerFieldDeclaration(64)
        self.int64_type.signed = True
        self.int64_type.alignment = 8

        self.uint64_type = CTFWriter.IntegerFieldDeclaration(64)
        self.uint64_type.signed = False
        self.uint64_type.alignment = 8

        self.array16_type = CTFWriter.ArrayFieldDeclaration(
            self.char8_type, 16)

        self.string_type = CTFWriter.StringFieldDeclaration()
Ejemplo n.º 3
0
def generate_composite_event(name, fields, static_fields):
    ev = CTFWriter.EventClass(name)
    for f in static_fields.keys():
        ev.add_field(CTFWriter.StringFieldDeclaration(), f)
    for f in fields:
        ev.add_field(CTFWriter.IntegerFieldDeclaration(32), f)
    return ev
Ejemplo n.º 4
0
            if isinstance(E[id], list):
                lst += E[id]
            else:
                lst.append(E[id])

    def instantiate(self):
        inst = {}
        for id, funcs in self.items():
            inst[id] = []
            for f in funcs:
                inst[id] = [f()]
        return inst


event_printf = CTFWriter.EventClass("printf")
event_printf.add_field(CTFWriter.StringFieldDeclaration(), "str")


class StdoutHandler(Handler):
    def __init__(self):
        self.str = ""

    @staticmethod
    def get_generated_events():
        return [event_printf]

    def consume(self, event):
        ev = None
        value = event["value"]
        if value not in (10, 13):
            self.str += chr(value)
Ejemplo n.º 5
0
int32_type.signed = True
int32_type.alignment = 8

uint32_type = CTFWriter.IntegerFieldDeclaration(32)
uint32_type.signed = False
uint32_type.alignment = 8

int64_type = CTFWriter.IntegerFieldDeclaration(64)
int64_type.signed = True
int64_type.alignment = 8

uint64_type = CTFWriter.IntegerFieldDeclaration(64)
uint64_type.signed = False
uint64_type.alignment = 8

string_type = CTFWriter.StringFieldDeclaration()


class CTFFilter():
    def __init__(self, args, handle, traces):
        self.args = args
        self.handle = handle
        self.traces = traces

        self.clock = CTFWriter.Clock('monotonic')
        self.clock.description = 'Monotonic Clock'
        self.clock.freq = 1000000000

        self.writer = CTFWriter.Writer(self.args.output)
        self.writer.add_clock(self.clock)