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()
def add_array_field(self, event_class, field): array_type = CTFWriter.ArrayFieldDeclaration(char8_type, field.length) event_class.add_field(array_type, '_' + field.name)
char8_type.encoding = CTFStringEncoding.UTF8 char8_type.alignment = 8 int32_type = CTFWriter.IntegerFieldDeclaration(32) 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 array_type = CTFWriter.ArrayFieldDeclaration(char8_type, 16) sched_switch = CTFWriter.EventClass("sched_switch") sched_switch.add_field(array_type, "_prev_comm") sched_switch.add_field(int32_type, "_prev_tid") sched_switch.add_field(int32_type, "_prev_prio") sched_switch.add_field(int64_type, "_prev_state") sched_switch.add_field(array_type, "_next_comm") sched_switch.add_field(int32_type, "_next_tid") sched_switch.add_field(int32_type, "_next_prio") sched_switch.add_field(uint32_type, "_cpu_id") stream_class.add_event_class(sched_switch) stream = writer.create_stream(stream_class)
def add_string_field(self, event_class, field): string_type = CTFWriter.ArrayFieldDeclaration(char8_type, 16) event_class.add_field(string_type, '_' + field.name)