Alexandre CHARTRE - Solaris Sustaining <Alexandre.Chartre at Sun.COM> writes:

>   Another problem is that I don't think you can easily write a ::lc
> command because the mdb API does not indicate when you reach the end
> of a pipe: a dcmd can find when it is invoked for the first element
> from a pipe (flags DCMD_PIPE|DCMD_LOOPFIRST) but nothing indicates the
> last element. On the other hand, you can easily write a ::listlen command.
>

Something along the lines of (quickly hashed together, caution...):

static int
cmd_linecount(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
{
        mdb_pipe_t p;

        if (!(flags & DCMD_PIPE))
                return (DCMD_USAGE);

        mdb_get_pipe(&p);
        mdb_printf("%d\n", p.pipe_len);
        return (DCMD_OK);
}

Seems like it should work:

> ::walk thread | ::lc
536
> ::walk thread ! wc -l
     537

-- Rich.

Reply via email to