Exemple #1
0
    def write_syscall_read(self, time_ms, cpu_id, delay, fd, buf, count, ret):
        event_entry = CTFWriter.Event(self.syscall_entry_read)
        self.clock.time = time_ms * 1000000
        self.set_int(event_entry.payload("_cpu_id"), cpu_id)
        self.set_int(event_entry.payload("_fd"), fd)
        self.set_int(event_entry.payload("_count"), count)
        self.stream.append_event(event_entry)

        event_exit = CTFWriter.Event(self.syscall_exit_read)
        self.clock.time = (time_ms + delay) * 1000000
        self.set_int(event_exit.payload("_cpu_id"), cpu_id)
        self.set_int(event_exit.payload("_buf"), buf)
        self.set_int(event_exit.payload("_ret"), ret)
        self.stream.append_event(event_exit)
        self.stream.flush()
Exemple #2
0
def create_stream_file(streamfile_dest, my_deque):

    writer = CTFWriter.Writer(streamfile_dest)
    clock = CTFWriter.Clock("A_clock")
    clock.description = "Simple clock"
    writer.add_clock(clock)

    writer.add_environment_field("Python_version", str(sys.version_info))
    stream_class = CTFWriter.StreamClass("test_stream")
    stream_class.clock = clock

    event_class = CTFWriter.EventClass("SimpleEvent")

    # Create a int32_t equivalent type
    int32_type = CTFWriter.IntegerFieldDeclaration(32)
    int32_type.signed = True
    event_class.add_field(int32_type, "value")

    # Create a int32_t equivalent type for the event_id_count
    int32_type = CTFWriter.IntegerFieldDeclaration(32)
    int32_type.signed = True
    event_class.add_field(int32_type, "event_id_count")

    stream_class.add_event_class(event_class)
    stream = writer.create_stream(stream_class)

    for item in my_deque:
        event = CTFWriter.Event(event_class)
        clock.time = item["timestamp"]
        integer_field = event.payload("value")
        integer_field.value = item["value"]
        integer_field = event.payload("event_id_count")
        integer_field.value = item["event_id_counter"]
        stream.append_event(event)
    stream.flush()
Exemple #3
0
 def write_softirq_exit(self, time_ms, cpu_id, vec):
     event = CTFWriter.Event(self.softirq_exit)
     self.clock.time = time_ms * 1000000
     self.set_int(event.payload("_cpu_id"), cpu_id)
     self.set_int(event.payload("_vec"), vec)
     self.stream.append_event(event)
     self.stream.flush()
Exemple #4
0
 def write_irq_handler_entry(self, time_ms, cpu_id, irq, name):
     event = CTFWriter.Event(self.irq_handler_entry)
     self.clock.time = time_ms * 1000000
     self.set_int(event.payload("_cpu_id"), cpu_id)
     self.set_int(event.payload("_irq"), irq)
     self.set_string(event.payload("_name"), name)
     self.stream.append_event(event)
     self.stream.flush()
Exemple #5
0
 def write_irq_handler_exit(self, time_ms, cpu_id, irq, ret):
     event = CTFWriter.Event(self.irq_handler_exit)
     self.clock.time = time_ms * 1000000
     self.set_int(event.payload("_cpu_id"), cpu_id)
     self.set_int(event.payload("_irq"), irq)
     self.set_int(event.payload("_ret"), ret)
     self.stream.append_event(event)
     self.stream.flush()
Exemple #6
0
    def write_syscall_open(self, time_ms, cpu_id, delay, filename, flags, mode,
                           ret):
        event = CTFWriter.Event(self.syscall_entry_open)
        self.clock.time = time_ms * 1000000
        self.set_int(event.payload("_cpu_id"), cpu_id)
        self.set_string(event.payload("_filename"), filename)
        self.set_int(event.payload("_flags"), flags)
        self.set_int(event.payload("_mode"), mode)
        self.stream.append_event(event)
        self.stream.flush()

        event = CTFWriter.Event(self.syscall_exit_open)
        self.clock.time = (time_ms + delay) * 1000000
        self.set_int(event.payload("_cpu_id"), cpu_id)
        self.set_int(event.payload("_ret"), ret)
        self.stream.append_event(event)
        self.stream.flush()
    def write_lttng_ust_statedump_debug_link(self, time_ms, cpu_id, vpid,
                                             baddr, crc, filename):
        event = CTFWriter.Event(self.lttng_ust_statedump_debug_link)

        event.payload("_baddr").value = baddr
        event.payload("_crc").value = crc
        event.payload("_filename").value = filename

        self._write_event(event, time_ms, cpu_id, vpid, 0)
Exemple #8
0
 def write_netif_receive_skb(self, time_ms, cpu_id, skbaddr, len, name):
     event = CTFWriter.Event(self.netif_receive_skb)
     self.clock.time = time_ms * 1000000
     self.set_int(event.payload("_cpu_id"), cpu_id)
     self.set_int(event.payload("_skbaddr"), skbaddr)
     self.set_int(event.payload("_len"), len)
     self.set_string(event.payload("_name"), name)
     self.stream.append_event(event)
     self.stream.flush()
Exemple #9
0
 def write_sched_waking(self, time_ms, cpu_id, comm, tid, prio, target_cpu):
     event = CTFWriter.Event(self.sched_waking)
     self.clock.time = time_ms * 1000000
     self.set_int(event.payload("_cpu_id"), cpu_id)
     self.set_char_array(event.payload("_comm"), comm)
     self.set_int(event.payload("_tid"), tid)
     self.set_int(event.payload("_prio"), prio)
     self.set_int(event.payload("_target_cpu"), target_cpu)
     self.stream.append_event(event)
     self.stream.flush()
Exemple #10
0
 def consume(self, event):
     ev = None
     value = event["value"]
     if value not in (10, 13):
         self.str += chr(value)
     if value == 10:
         self.str += chr(0)
         ev = CTFWriter.Event(event_printf)
         ev.payload("str").value = self.str
         self.str = ""
     return ev
Exemple #11
0
 def write_lttng_statedump_file_descriptor(self, time_ms, cpu_id, pid, fd,
                                           flags, fmode, filename):
     event = CTFWriter.Event(self.lttng_statedump_file_descriptor)
     self.clock.time = time_ms * 1000000
     self.set_int(event.payload("_cpu_id"), cpu_id)
     self.set_int(event.payload("_pid"), pid)
     self.set_int(event.payload("_fd"), fd)
     self.set_int(event.payload("_flags"), flags)
     self.set_int(event.payload("_fmode"), fmode)
     self.set_string(event.payload("_filename"), filename)
     self.stream.append_event(event)
     self.stream.flush()
Exemple #12
0
        def consume(self, event):
            ev = None
            self.values.append(event["value"])
            if len(self.values) == len(self.fields):
                ev = CTFWriter.Event(CompositeHandler.event)
                for name, value in self.static_fields.items():
                    ev.payload(name).value = value

                for name, value in dict(zip(self.fields, self.values)).items():
                    ev.payload(name).value = value

            return ev
Exemple #13
0
 def write_block_rq_complete(self, time_ms, cpu_id, dev, sector, nr_sector,
                             errors, rwbs, _cmd_length, cmd):
     event = CTFWriter.Event(self.block_rq_complete)
     self.clock.time = time_ms * 1000000
     self.set_int(event.payload("_cpu_id"), cpu_id)
     self.set_int(event.payload("_dev"), dev)
     self.set_int(event.payload("_sector"), sector)
     self.set_int(event.payload("_nr_sector"), nr_sector)
     self.set_int(event.payload("_errors"), errors)
     self.set_int(event.payload("_rwbs"), rwbs)
     self.set_int(event.payload("__cmd_length"), _cmd_length)
     self.set_char_array(event.payload("_cmd"), cmd)
     self.stream.append_event(event)
     self.stream.flush()
    def write_lttng_ust_statedump_build_id(self, time_ms, cpu_id, vpid, baddr,
                                           build_id):
        build_id = list(binascii.unhexlify(build_id))

        event = CTFWriter.Event(self.lttng_ust_statedump_build_id)

        event.payload("_baddr").value = baddr
        event.payload("__build_id_length").value = len(build_id)

        build_id_field = event.payload("_build_id")
        build_id_field.length = event.payload("__build_id_length")

        for i, value in enumerate(build_id):
            build_id_field.field(i).value = value

        self._write_event(event, time_ms, cpu_id, vpid, 0)
Exemple #15
0
 def write_block_rq_issue(self, time_ms, cpu_id, dev, sector, nr_sector,
                          bytes, tid, rwbs, _cmd_length, cmd, comm):
     event = CTFWriter.Event(self.block_rq_issue)
     self.clock.time = time_ms * 1000000
     self.set_int(event.payload("_cpu_id"), cpu_id)
     self.set_int(event.payload("_dev"), dev)
     self.set_int(event.payload("_sector"), sector)
     self.set_int(event.payload("_nr_sector"), nr_sector)
     self.set_int(event.payload("_bytes"), bytes)
     self.set_int(event.payload("_tid"), tid)
     self.set_int(event.payload("_rwbs"), rwbs)
     self.set_int(event.payload("__cmd_length"), _cmd_length)
     self.set_char_array(event.payload("_cmd"), cmd)
     self.set_char_array(event.payload("_comm"), comm)
     self.stream.append_event(event)
     self.stream.flush()
    def write_lttng_ust_statedump_bin_info(self,
                                           time_ms,
                                           cpu_id,
                                           vpid,
                                           baddr,
                                           memsz,
                                           path,
                                           is_pic=False,
                                           has_build_id=False,
                                           has_debug_link=False):
        event = CTFWriter.Event(self.lttng_ust_statedump_bin_info)

        event.payload("_baddr").value = baddr
        event.payload("_memsz").value = memsz
        event.payload("_path").value = path
        event.payload("_is_pic").value = 1 if is_pic else 0
        event.payload("_has_build_id").value = 1 if has_build_id else 0
        event.payload("_has_debug_link").value = 1 if has_debug_link else 0

        self._write_event(event, time_ms, cpu_id, vpid, 0)
Exemple #17
0
 def write_lttng_statedump_process_state(self, time_ms, cpu_id, tid, vtid,
                                         pid, vpid, ppid, vppid, name, type,
                                         mode, submode, status, ns_level):
     event = CTFWriter.Event(self.lttng_statedump_process_state)
     self.clock.time = time_ms * 1000000
     self.set_int(event.payload("_cpu_id"), cpu_id)
     self.set_int(event.payload("_tid"), tid)
     self.set_int(event.payload("_vtid"), vtid)
     self.set_int(event.payload("_pid"), pid)
     self.set_int(event.payload("_vpid"), vpid)
     self.set_int(event.payload("_ppid"), ppid)
     self.set_int(event.payload("_vppid"), vppid)
     self.set_char_array(event.payload("_name"), name)
     self.set_int(event.payload("_type"), type)
     self.set_int(event.payload("_mode"), mode)
     self.set_int(event.payload("_submode"), submode)
     self.set_int(event.payload("_status"), status)
     self.set_int(event.payload("_ns_level"), ns_level)
     self.stream.append_event(event)
     self.stream.flush()
def write_sched_switch(time_ms,
                       cpu_id,
                       prev_comm,
                       prev_tid,
                       next_comm,
                       next_tid,
                       prev_prio=20,
                       prev_state=1,
                       next_prio=20):
    event = CTFWriter.Event(sched_switch)
    clock.time = time_ms * 1000000
    set_char_array(event.payload("_prev_comm"), prev_comm)
    set_int(event.payload("_prev_tid"), prev_tid)
    set_int(event.payload("_prev_prio"), prev_prio)
    set_int(event.payload("_prev_state"), prev_state)
    set_char_array(event.payload("_next_comm"), next_comm)
    set_int(event.payload("_next_tid"), next_tid)
    set_int(event.payload("_next_prio"), next_prio)
    set_int(event.payload("_cpu_id"), cpu_id)
    stream.append_event(event)
    stream.flush()
Exemple #19
0
def load_numbers(filename):
    global number_of_events
    in_file = open(filename, "r")  # apro il file
    while 1:
        in_line = in_file.readline()  # leggo il file per linee
        if len(
                in_line
        ) == 0:  # se è pari a 0, vuol dire che ho finito di leggere ed esco
            break

        # tolgo l'ultimo elemento perchè è quello che manda a capo
        in_line = in_line[:-1]
        # splitto contenuto linea dividendo elementi separati da spazio
        [ID, ts] = str.split(in_line, " ")
        event = btw.Event(event_class)  # creo un evento
        # setto il payload per l'ID (cast altrimenti non va)
        event.payload('ID_field').value = int(ID)
        event.payload('timestamp_field').value = int(
            ts)  # setto payload per timestamp
        # append our event to stream_profiler_1 stream
        stream.append_event(event)
        number_of_events += 1
    in_file.close()
Exemple #20
0
    def process_event(self, event):
        if self.args.discard and event.name == self.args.name\
           or not self.args.discard and event.name != self.args.name:
            return

        if event.name in ['lttng_statedump_start', 'lttng_statedump_end',
                          'sys_unknown', 'sys_geteuid', 'sys_getuid',
                          'sys_getegid']:
            return

        self.clock.time = event.timestamp
        writeable_event = CTFWriter.Event(self.event_classes[event.name])

        field_names = event.field_list_with_scope(CTFScope.EVENT_FIELDS)

        for field_name in field_names:
            self.set_field(writeable_event, field_name, event[field_name])

        try:
            self.stream.append_event(writeable_event)
        except ValueError:
            print(event.name)
            pass
 def write_lttng_ust_statedump_end(self, time_ms, cpu_id, vpid):
     event = CTFWriter.Event(self._lttng_ust_statedump_end)
     self._write_event(event, time_ms, cpu_id, vpid, 0)
 def write_dummy_event(self, time_ms, cpu_id, vpid, ip):
     event = CTFWriter.Event(self._dummy_event)
     self._write_event(event, time_ms, cpu_id, vpid, ip)
Exemple #23
0
def write_dummy_event(time_ms, dummy_field):
    event = CTFWriter.Event(dummy_event)
    clock.time = time_ms * 1000000
    set_char_array(event.payload("dummy_field"), dummy_field)
    stream.append_event(event)