For Perl, I am not proposing to embed it into MDB but to interface
perl with MDB. That means that you will need to have mdb and Perl
installed on your system, and mdb will actually invoke the Perl
library (libperl) through an mdb module.

  The advantage is that I don't change the mdb binary, I am just adding
a mdb module which will interact with Perl. The only drawback is that
this does not work with kmdb.

  Perl can be a first step (and the interface is already done), and
that's why I am proposing a very generic project title (Scripting
Languages for MDB) so that it can cover the integration (either
embedded or interfaced) of any other scripting language.


alex.


Dmitry.Samersoff wrote:
> Alexandre,
> 
> Excellent idea but perl might be too big to carry with MDB.
> Did you look at LUA ? (www.lua.org)
> 
> 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
> 
> 

Reply via email to