I have an experimental prototype where you can evaluate any Perl expression from mdb. For example:
> ::walk proc | ::peval 'mdb_printf("%p\n", $_) if ($_ > 0x30100000000)' | ::ps S PID PPID PGID SID UID FLAGS ADDR NAME R 7081 25390 7081 1277 0 0x00004008 0000030136c7cba8 sh R 19508 18010 19508 1277 0 0x00004008 0000030109b2e188 mdb R 19534 2605 19534 498 78440 0x00014008 0000030136c7d5c0 man R 19541 19540 19534 498 78440 0x00004008 0000030136c7c190 less R 14686 609 14686 14686 78440 0x00004008 0000030109b2f5b8 cam R 14708 14686 14686 14686 78440 0x00004008 0000030109b3cb98 acroread Z 14757 14708 14686 14686 0 0x10006008 0000030109b3c180 lp This filter process address greater than 0x30100000000. You can also access types as Perl objects and thus use any Perl expression to access their data: > ::peval '$d = mdb_ctf_readvar("devnamesp") ; mdb_printf("dn_name = %x\n", > $d->{dn_flags} & 0x2)' dn_name = 2 Or you can write Perl script, for example test.pl: sub thread { my $addr = shift; my $t, $p, $cmd; $t = new CTF::pointer kthread_t, $addr; $p = $t->{t_procp}; $cmd = $p->{p_user}{u_comm}; mdb_printf "%p %hd %p %s\n", $t, $t->{t_pri}, $p, mdb_readstr($cmd); } and then invoke it from mdb: > t0::pcall thread 140a000 96 14382d8 sched But this is just early experiments and it still often crash mdb :-). alex. Jonathan Adams wrote: > On Wed, Oct 12, 2005 at 07:49:01PM +0100, Frank Hofmann - Solaris Sustaining > wrote: > >>Btw, is there an existing RFE against mdb asking to be able to >>use "::offsetof" and "::sizeof" in arithmetic expressions, to >>get better array handling support ? >> >>I.e. I'd like to look at specific elements of arrays, something >>like: >> >>*devnamesp+(20*::sizeof(struct devnames))::print struct devnames >> >>Or better: "*devnamesp[20]::print struct devnames", with typegraph >>help :) > > > You can just do: > > >>devnamesp::print [20] > > { > [20].dn_name = 0xffffffff82a46ba0 "hci1394" > ... > } > > > The main thing that has been talked about is '::deval', '::dmap', or > '::dprint', which would let you use D (as in Dtrace) expressions. It > might look something like: > > >>::dprint '`devnamesp[20]->dn_flags & 0x100' > > 0x100 > > > Cheers, > - jonathan >