> Alexander Kolbasov <akolb at eng.sun.com> writes:
> 
> > There are numerous cases in the kernel code where bitmaps are used to 
> > represent sets of non-negative integers (e.g. sets of CPU IDs). I suggest 
> > an 
> > RFE for a new command that will print such sets as a list of integers 
> > (possibly collapsing consecutive ranges to x-y).
> >
> > For example, it can be something like
> >
> > cpu_ready_set ::print_set
> > 0-32
> >
> > Do you think it is worth while and generic enough?
> >
> 
> This seems like it would be:
> CR 6265065 Add ::bitset dcmd to print bitsets
> 
> Or at least closely related to it.

Uff, I filed 6265065 a year ago and forgot about it by now :-). Seems that it 
didn't get any comments from MDB experts at the time. BTW, here is the full 
implementation from the bug report (missing the command inclusion in 
recognizable command list):

/* ARGSUSED */
int
bitset(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
{
        uint64_t set = (uint64_t)addr;
        uint64_t mask = 1;
        int i = 0;

        if (!(flags & DCMD_ADDRSPEC)) {
                mdb_warn("usage: set ::bitset");
                return (DCMD_ERR);
        }

        if (set == 0)
                return (DCMD_OK);

        for (; set != (uint64_t)0; i++, mask <<= 1) {
                if (set & mask) {
                        mdb_printf("%d ", i);
                        set &= ~mask;
                }
        }
        mdb_printf("\n");
        return (DCMD_OK);
}

This doesn't collapse ranges, though.

- Alexander Kolbasov


Reply via email to