Esempio n. 1
0
    def _helper(self, node: drgn.Object, offset: int) -> Iterable[drgn.Object]:
        if node == drgn.NULL(sdb.prog, node.type_):
            return

        lchild = node.avl_child[0]
        yield from self._helper(lchild, offset)

        obj = drgn.Object(sdb.prog, type="void *", value=int(node) - offset)
        yield obj

        rchild = node.avl_child[1]
        yield from self._helper(rchild, offset)
Esempio n. 2
0
 def pretty_print(self, metaslabs, indent=0):
     first_time = True
     for msp in metaslabs:
         if not self.args.histogram and not self.args.weight:
             Metaslab.print_metaslab(msp, first_time, indent)
         if self.args.histogram:
             spacemap = msp.ms_sm
             if spacemap != drgn.NULL(sdb.prog, spacemap.type_):
                 histogram = spacemap.sm_phys.smp_histogram
                 print_histogram(histogram, 32, spacemap.sm_shift)
         if self.args.weight:
             Metaslab.metaslab_weight_print(msp, first_time, indent)
         first_time = False
Esempio n. 3
0
    def print_metaslab(msp, print_header, indent):
        spacemap = msp.ms_sm

        if print_header:
            print(
                "".ljust(indent),
                "ADDR".ljust(18),
                "ID".rjust(4),
                "OFFSET".rjust(16),
                "FREE".rjust(8),
                "FRAG".rjust(5),
                "UCMU".rjust(8),
            )
            print("".ljust(indent), "-" * 65)

        free = msp.ms_size
        if spacemap != drgn.NULL(sdb.prog, spacemap.type_):
            free -= spacemap.sm_phys.smp_alloc

        ufrees = msp.ms_unflushed_frees.rt_space
        uallocs = msp.ms_unflushed_allocs.rt_space
        free = free + ufrees - uallocs

        uchanges_free_mem = msp.ms_unflushed_frees.rt_root.bt_num_nodes
        uchanges_free_mem *= BTREE_LEAF_SIZE
        uchanges_alloc_mem = msp.ms_unflushed_allocs.rt_root.bt_num_nodes
        uchanges_alloc_mem *= BTREE_LEAF_SIZE
        uchanges_mem = uchanges_free_mem + uchanges_alloc_mem

        print(
            "".ljust(indent),
            hex(msp).ljust(16),
            str(int(msp.ms_id)).rjust(4),
            hex(msp.ms_start).rjust(16),
            nicenum(free).rjust(8),
            end="",
        )
        if msp.ms_fragmentation == -1:
            print("-".rjust(6), end="")
        else:
            print((str(int(msp.ms_fragmentation)) + "%").rjust(6), end="")
        print(nicenum(uchanges_mem).rjust(9))
Esempio n. 4
0
def get_typed_null(type_name: str) -> drgn.Object:
    global prog
    return drgn.NULL(prog, type_name)
Esempio n. 5
0
def is_null(obj: drgn.Object) -> bool:
    global prog
    return bool(obj == drgn.NULL(prog, obj.type_))