Yes, because you can use any feature of Perl to easily parse a list of data structure. I have an example on the web page with the 'summary' Perl command which counts threads and and some interesting thread states:
> ::pcall summary Thread Summary Number of threads: 2259 SOBJSEM: 2 INTRSLP: 0 INTR: 20 USER: 54 SOBJRWL: 0 SWAPPED: 0 FUTURE: 0 SWAPRUN: 0 ONESEC: 0 SHUTTLE: 0 SOBJMTX: 0 ONEMIN: 0 SOBJCV: 2130 ONSWAPQ: 0 FIVMIN: 458 alex. Kevin Crowe wrote: > Hello Alex, > > So (just for examle) this scripting language proposal would be useful > if someone wanted to implement these RFE's without writing > dcmds?: > > 6428090* Synopsis:* mdb could be more helpful when troubleshooting hung or > slowly running systems > > 6474299* Synopsis:* ::whatthread would be more useful if it could take a > wildcard or do a string search perhaps > > > Thanks, > Kevin. > > > > > Alexandre Chartre wrote: >> Hi, >> >> I would like to propose a project to interface scripting languages with >> MDB. >> >> This is something I did a long time ago with interfacing PERL with MDB but >> I am now taking some time to make this an Open Solaris project so that this >> can be available to everybody. >> >> People from Sun can already take a look at the project on the internal >> web: http://jurassic.sfbay/~achartre/mdbperl/ and others can look for a >> short usage example at the bottom of this mail. >> >> Thanks, >> >> alex. >> >> ----- >> >> Project Description: >> >> The purpose of this project is to interface some scripting languages with >> MDB so that these languages can be used to develop new MDB commands. >> Scripting languages will be interfaced with the MDB C API so that MDB >> commands and functions can be invoked from the scripting language. It >> will also be interfaced with CTF type information so that data structure >> can be directly accessed from the scripting language. >> >> This project will allow to write new MDB commands using a scripting language >> instead of having to write and compile a C module. Thus this will greatly >> reduce the time to write new MDB commands. >> >> This project will initially interface the PERL language with MDB. >> >> >> Related past activities: >> >> The prototype of interfacing PERL with MDB is already ready. >> >> ----- >> >> MDB Perl Interface Example: >> >> # cat 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); >> >> } >> >> # mdb -k >> Loading modules: [ unix krtld genunix ufs_log ip usba s1394 nfs random ptm >> ipc lofs cpc logindmux ] >> >> > ::load perl >> Starting Perl interpreter >> >> > ::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 >> >> > ::pload test.pl >> Loaded Perl script test.pl >> >> > t0::pcall thread >> 140a000 96 14382d8 sched >> _______________________________________________ >> mdb-discuss mailing list >> mdb-discuss at opensolaris.org >> > >