Example #1
0
    def do_modlist(self):
        fe.pause_vm()
        start_pslist = time.time()

        list_head = self.lookups["modules"]
        next_module = self.lookups["modules"]

        i = 0
        maxi = 100
        fe.log("starting MODLIST")
        while True:

            tmp_next = fe.read_addr_va(next_module, 0)

            if tmp_next & 0xffffffffffff == list_head or i > maxi:
                fe.log("ending loop at %d" % (i, ))
                end_pslist = time.time()
                break

            modname = fe.read_str_va(next_module + 16, 0)
            fe.log("%s" % (modname, ))

            next_module = tmp_next

            i += 1

        stop_pslist = time.time()
        fe.resume_vm()
        fe.log("modlist in {sec:.6f} seconds".format(sec=stop_pslist -
                                                     start_pslist))
Example #2
0
    def do_pslist(self):
        fe.pause_vm()
        start_pslist = time.time()

        list_head = self.lookups["init_task"] + self.lookups["tasks_offset"]
        cur_list_entry = list_head
        next_list_entry = fe.read_addr_va(list_head, 0)

        i = 0
        maxi = 100
        fe.log("starting PSLIST")
        while True:
            cur_proc = cur_list_entry - self.lookups["tasks_offset"]

            pid = fe.read_32_va(cur_proc + self.lookups["pid_offset"], 0)
            procname = fe.read_str_va(cur_proc + self.lookups["name_offset"], 0)
            fe.log("%5s %-16s" % (pid, procname))
            cur_list_entry = next_list_entry
            next_list_entry = fe.read_addr_va(cur_list_entry, 0)
            i += 1
            # fe.log('%s == %s?' % (hex(cur_list_entry), hex(list_head)))
            if cur_list_entry & 0xffffffffffff == list_head or i > maxi:
                # fe.log('ending loop at %d' % (i,))
                end_pslist = time.time()
                break

        stop_pslist = time.time()
        fe.resume_vm()
        fe.log("pslist in {sec:.2f} seconds".format(sec=stop_pslist - start_pslist))
    def do_batch_pslist(self, pause=False):
        if pause:
            fe.pause_vm()

        calls = 0
        procs = 0
        msgs = 0
        i = 0
        maxi = 100

        pido = self.lookups["pid_offset"]
        tasko = self.lookups["tasks_offset"]
        nameo = self.lookups["name_offset"]
        list_head = self.lookups["init_task"] + self.lookups["tasks_offset"]
        cur = list_head
        o = fe.batch_new()

        start_pslist = time.time()

        while True:

            o.reset()
            o.add("1", "READ_STR_VA", {
                "vaddr": cur + nameo - tasko,
                "pid": 0
            })  # current name
            o.add("2", "READ_32_VA", {
                "vaddr": cur + pido - tasko,
                "pid": 0
            })  # current pid
            o.add("3", "READ_ADDR_VA", {
                "vaddr": cur,
                "pid": 0
            })  # pointer to next ts
            fe.batch_send(o)
            calls += 3
            msgs += 1
            procs += 1

            for r in o.results():
                if r["name"] == "3":
                    cur = r["result"]
                # do something with result

            i += 1
            if cur & 0xffffffffffff == list_head or i > maxi:
                fe.log(f"ending loop at {i}")
                end_pslist = time.time()
                self.log.append(end_pslist - start_pslist)
                break

        self.calls.append(calls)
        self.procs.append(procs)
        self.msgs.append(msgs)

        if pause:
            fe.resume_vm()
    def timer_callback(self, ctx):

        timeit_on = False
        cprof_bo = False
        once = True

        if timeit_on:
            self.log = []
            self.msgs = []
            self.procs = []
            fe.log("prepping batch obj")
            self.prep_batch_pslist_self()
            fe.pause_vm()
            fe.log("running timeit")
            t = timeit.Timer(lambda: self.do_batch_pslist_new()).timeit(
                number=100)
            fe.log("done timeit")
            fe.resume_vm()
            t = t / 100.0
            fe.log("timeit pslist in {sec:.6f} seconds".format(sec=t))
            self.summarize()

        if once:
            fe.log("prepping batch obj")
            self.prep_batch_pslist_self()
            gc.disable()
            fe.log("running pipeline")
            self.do_batch_pslist_new(pause=False)
            fe.log("done pipeline")
            gc.enable()
            self.summarize()

        if cprof_bo:
            self.log = []
            self.msgs = []
            self.procs = []
            self.prep_batch_pslist_self()
            fe.pause_vm()
            cProfile.runctx(
                "self.do_batch_pslist_new()",
                globals(),
                locals(),
                filename="/home/micah/femain.pipeline.profile",
            )
            fe.resume_vm()
            self.summarize()

        fe.log("calls: %s" % self.calls)
        fe.log("procs: %s" % self.procs)

        fe.log("calling exit")
        fe.exit()
Example #5
0
    def do_dk_pslist(self, pause=False):
        if pause:
            fe.pause_vm()

        start_pslist = time.time()
        self.pslist = fe.process_list()

        self.procs.append(len(self.pslist))
        self.msgs.append(1)

        stop_pslist = time.time()
        self.log.append(stop_pslist - start_pslist)

        if pause:
            fe.resume_vm()
Example #6
0
    def __init__(self, ctx):
        fe.log("in pslist_dk constructor")
        fe.set_name("pslist_dk")

        e = {"event_type": fe.BE, "callback": self.be_callback}
        fe.event_register(e)
        self.pslist = {}
        self.log = []
        self.calls = []
        self.msgs = []
        self.procs = []

        timeit_on = False
        cprof = False

        if cprof:
            self.do_dk_pslist(pause=True)  # zmq warmup
            cProfile.runctx(
                "self.do_dk_pslist()",
                globals(),
                locals(),
                filename="/home/micah/femain.dk.profile",
            )

        if timeit_on:
            self.do_dk_pslist(pause=True)  # zmq warmup
            fe.pause_vm()
            t = timeit.Timer(lambda: self.do_dk_pslist()).timeit(number=100)
            t = t / 100.0
            fe.resume_vm()
            fe.log("timeit pslist in {sec:.6f} seconds".format(sec=t))
        else:
            self.pslist = {}
            gc.disable()
            self.do_dk_pslist(pause=True)
            gc.enable()
            fe.log(self.pslist)

        for l in self.log:
            fe.log(l)
        fe.log("calls: %s" % self.calls)
        fe.log("procs: %s" % self.procs)
        fe.log("msgs: %s" % self.msgs)
        fe.log("leaving pslist_dk constructor")
        fe.exit()
    def do_pslist(self, pause=False):
        if pause:
            fe.pause_vm()

        calls = 0
        procs = 0

        start_pslist = time.time()
        list_head = self.lookups["init_task"] + self.lookups["tasks_offset"]
        cur_list_entry = list_head
        next_list_entry = fe.read_addr_va(list_head, 0)
        calls += 1

        i = 0
        maxi = 100
        fe.log("starting PSLIST")
        while True:
            cur_proc = cur_list_entry - self.lookups["tasks_offset"]

            pid = fe.read_32_va(cur_proc + self.lookups["pid_offset"], 0)
            calls += 1
            procname = fe.read_str_va(cur_proc + self.lookups["name_offset"], 0)
            calls += 1
            fe.log("%5s %-16s" % (pid, procname))
            self.pslist[cur_proc] = (pid, procname)
            cur_list_entry = next_list_entry
            next_list_entry = fe.read_addr_va(cur_list_entry, 0)
            calls += 1
            i += 1
            fe.log("%s == %s?" % (hex(cur_list_entry), hex(list_head)))
            if cur_list_entry & 0xffffffffffff == list_head or i > maxi:
                fe.log("ending loop at %d" % (i,))
                end_pslist = time.time()
                # self.log.append(end_pslist-start_pslist)
                break
            procs += 1

        # self.calls.append(calls)
        # self.procs.append(procs)
        if pause:
            fe.resume_vm()

        fe.log("pslist in {sec:.6f} seconds".format(sec=end_pslist - start_pslist))
    def timer_callback(self, ctx):

        timeit_on = False
        cprof = False
        once = True

        if cprof:
            self.do_batch_pslist(pause=True)  # zmq warmup
            cProfile.runctx(
                "self.do_batch_pslist()",
                globals(),
                locals(),
                filename="/home/micah/femain.batch.profile",
            )

        if timeit_on:
            fe.log("warming up")
            self.do_batch_pslist(pause=True)  # zmq warmup
            fe.pause_vm()
            fe.log("running timeit")
            t = timeit.Timer(lambda: self.do_batch_pslist()).timeit(number=100)
            fe.log("done timeit")
            fe.resume_vm()
            t = t / 100.0
            fe.log("timeit pslist in {sec:.6f} seconds".format(sec=t))

        if once:
            self.pslist = {}
            gc.disable()
            self.do_batch_pslist(pause=True)
            gc.enable()
            # fe.log(self.pslist)

        for l in self.log:
            fe.log(l)
        fe.log("calls: %s" % self.calls)
        fe.log("procs: %s" % self.procs)
        fe.log("msgs: %s" % self.msgs)
        fe.log("leaving batching constructor")
        fe.exit()
    def do_batch_pslist_new(self, pause=False):
        if pause:
            fe.pause_vm()
        fe.log("batch_pslist_new")

        if self.o.state in [3, 4]:
            self.o.state = 2
        procs = 0
        start_pslist = time.time()

        fe.batch_send(self.o)

        stop_pslist = time.time()
        self.log.append(stop_pslist - start_pslist)
        self.procs.append(self.o.results_size())
        self.msgs.append(1)

        if pause:
            fe.resume_vm()

        fe.log("Results")
        for r in o.results():
            fe.log(r)