[mdb-discuss] Project Proposal: Scripting Languages for MDB

2008-02-25 Thread efi
That will be fantastic,

I have some forensics life data gathering perl scripts which use IPC to 
communicate with MDB and
gather the necessary data for parcing.

Direct invocation will be fantastic and greatly simplify the scripts and 
teh eventual memory footprint
of my scripts which is essecial.

Can I get a glimpse of what is done so far?

Looking Forward

Cheers
Efi/
Eric Schrock wrote:

>On Fri, Feb 22, 2008 at 05:30:37PM -0800, Alexandre Chartre wrote:
>  
>
>>  It's good to know that you already have a full C grammar/compiler using
>>CTF data. Having a built-in C-like language in mdb/kmdb will be great and
>>is definitively the goal to reach (I also had this idea but interfacing mdb
>>with Perl was much easier and quicker).
>>
>>  I think we can make that goal and the reflexion you are proposing part
>>of the project, this will help keep track of suggestions and we can study
>>what benefits are provided by languages mdb will be interfaced with. This
>>will also help define what would be useful for such a built-in language.
>>
>>  So the project can be twofold:
>>
>>  - provide information how scripting languages can be interfaced with
>>mdb and provide support for some languages.
>>
>>  - study and possibly implement a built-in language into mdb.
>>
>>  I propose to change the project description to:
>>
>>The purpose of this project is to add support for scripting languages
>>to the modular debugger (MDB). Support will be added as an interface
>>to some existing scripting languages and ultimately as a built-in
>>language into MDB.
>>
>>Scripting languages will use the MDB API so that MDB commands and 
>> functions
>>can be invoked from the scripting language. They will also use 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 scripting 
>> languages
>>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.
>>
>>
>
>+1 from me.
>
>- Eric
>
>--
>Eric Schrock, Fishworkshttp://blogs.sun.com/eschrock
>___
>mdb-discuss mailing list
>mdb-discuss at opensolaris.org
>  
>




[mdb-discuss] Project Proposal: Scripting Languages for MDB

2008-02-24 Thread Eric Schrock
On Fri, Feb 22, 2008 at 05:30:37PM -0800, Alexandre Chartre wrote:
> 
>   It's good to know that you already have a full C grammar/compiler using
> CTF data. Having a built-in C-like language in mdb/kmdb will be great and
> is definitively the goal to reach (I also had this idea but interfacing mdb
> with Perl was much easier and quicker).
> 
>   I think we can make that goal and the reflexion you are proposing part
> of the project, this will help keep track of suggestions and we can study
> what benefits are provided by languages mdb will be interfaced with. This
> will also help define what would be useful for such a built-in language.
> 
>   So the project can be twofold:
> 
>   - provide information how scripting languages can be interfaced with
> mdb and provide support for some languages.
> 
>   - study and possibly implement a built-in language into mdb.
> 
>   I propose to change the project description to:
> 
> The purpose of this project is to add support for scripting languages
> to the modular debugger (MDB). Support will be added as an interface
> to some existing scripting languages and ultimately as a built-in
> language into MDB.
> 
> Scripting languages will use the MDB API so that MDB commands and 
> functions
> can be invoked from the scripting language. They will also use 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 scripting 
> languages
> 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.

+1 from me.

- Eric

--
Eric Schrock, Fishworkshttp://blogs.sun.com/eschrock



[mdb-discuss] Project Proposal: Scripting Languages for MDB

2008-02-23 Thread John Levon
On Fri, Feb 22, 2008 at 03:49:20PM -0500, Peter Memishian wrote:

> I always get confused with these +1's -- according to poll.opensolaris.org,
> the only folks who actually get binding votes for mdb project proposals
> are Adam Leventhal, Eric Shrock, John Levon, Matt Simmons, and Mike Shapiro.

In that case, +1.

john



[mdb-discuss] Project Proposal: Scripting Languages for MDB

2008-02-22 Thread Dmitry.Samersoff
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 ($_ > 0x301)' | 
> ::ps
> SPID   PPID   PGIDSID   UID  FLAGS ADDR NAME
> R   7081  25390   7081   1277 0 0x4008 030136c7cba8 sh
> R  19508  18010  19508   1277 0 0x4008 030109b2e188 mdb
> R  19534   2605  19534498 78440 0x00014008 030136c7d5c0 man
> R  19541  19540  19534498 78440 0x4008 030136c7c190 less
> R  14686609  14686  14686 78440 0x4008 030109b2f5b8 cam
> R  14708  14686  14686  14686 78440 0x4008 030109b3cb98 acroread
> Z  14757  14708  14686  14686 0 0x10006008 030109b3c180 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


-- 
Dmitry Samersoff
J2SE Sustaining team, SPB04
* There will come soft rains ...



[mdb-discuss] Project Proposal: Scripting Languages for MDB

2008-02-22 Thread Alexander Kolbasov
With embedded scripting language it would be really great to have native 
support for lists and more powerful ::map and ::grep which will allow calling 
user-defined functions for list elements.

- akolb




[mdb-discuss] Project Proposal: Scripting Languages for MDB

2008-02-22 Thread Alexandre Chartre

  It's good to know that you already have a full C grammar/compiler using
CTF data. Having a built-in C-like language in mdb/kmdb will be great and
is definitively the goal to reach (I also had this idea but interfacing mdb
with Perl was much easier and quicker).

  I think we can make that goal and the reflexion you are proposing part
of the project, this will help keep track of suggestions and we can study
what benefits are provided by languages mdb will be interfaced with. This
will also help define what would be useful for such a built-in language.

  So the project can be twofold:

  - provide information how scripting languages can be interfaced with
mdb and provide support for some languages.

  - study and possibly implement a built-in language into mdb.

  I propose to change the project description to:

The purpose of this project is to add support for scripting languages
to the modular debugger (MDB). Support will be added as an interface
to some existing scripting languages and ultimately as a built-in
language into MDB.

Scripting languages will use the MDB API so that MDB commands and functions
can be invoked from the scripting language. They will also use 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 scripting languages
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.


alex.


Mike Shapiro wrote:
> On Fri, Feb 22, 2008 at 12:55:04PM -0800, Alexandre Chartre wrote:
>>> I see some merits here, but one possible area of consideration is that 
>>> mdb benefits from being basically syntax compatible with kmdb.   The 
>>> same dcmds that work in mdb generally are also available in kmdb.  I'd 
>>> hate to see mdb extended in ways which don't easily allow for the same 
>>> extensions to be done in kmdb.
>>   I totally agree with you, it is very upsetting to be used to some mdb
>> cmds and to discover it doesn't exist with kmdb. But in most cases you can
>> collect a crash dump and analysis it with mdb.
>>
>>> Of course, for stuff not related to kernel debugging, I probably care a 
>>> lot less.  Although, to be quite honest, mdb seems a lot less useful for 
>>> debugging userland programs, if only because tools like dbx and gdb seem 
>>> so much better suited to that particular task.
>>   That's also very useful for debugging kernel on live system or for crash
>> dump analysis. A big advantage is that you can change your commands very
>> quickly (for example if you change a structure while developing and you
>> want a quick command to see your change).
>>
>> alex.
> 
> When I originally designed MDB, it predated my work on CTF, and thus the
> native type system of the kernel was not available for use in the debugger.
> 
> I recall writing in my notebook at the time that ideally you want to be
> able to support the natural expressions of the language you're debugging,
> which for MDB is almost always C, with a mix of assembly and maybe C++.
> But mentally you are thinking in the C model since you're fundamentally
> doing systems-level debugging on a UNIX operating system.
> 
>>From this perspective, I always intended to revisit the language issue
> once we had the type information in place, but I've yet to find the time.
> One thing I can say is that I've always found it a bit cumbersome to
> try to retrofit the syntax and semantics of one language into another.
> 
> So while I'm a strong supporter for bridges to as many languages as people
> find useful for writing scripts such as the Perl example, I've always thought
> MDB would benefit from simply native C expression support with a very
> minor set of extensions to call dcmds and do a few of the existing things.
> 
> One idea I've wanted to play with is leveraging some of the DTrace work,
> in that I did go off and write a full C grammar/compiler using CTF data,
> so that already exists and could be leveraged.  Also I do want something
> that works the same way in kmdb and mdb.
> 
> My suggestion to the community is to start out by making a list of questions/
> examples of things you want to achieve in the debugger and modeling and
> comparing those using a variety of different syntaxes.
> 
> -Mike
> 



[mdb-discuss] Project Proposal: Scripting Languages for MDB

2008-02-22 Thread Kevin Crowe
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 ($_ > 0x301)' | 
> ::ps
> SPID   PPID   PGIDSID   UID  FLAGS ADDR NAME
> R   7081  25390   7081   1277 0 0x4008 030136c7cba8 sh
> R  19508  18010  19508   1277 0 0x4008 030109b2e188 mdb
> R  19534   2605  19534498 78440 0x00014008 030136c7d5c0 man
> R  19541  19540  19534498 78440 0x4008 030136c7c190 less
> R  14686609  14686  14686 78440 0x4008 030109b2f5b8 cam
> R  14708  14686  14686  14686 78440 0x4008 030109b3cb98 acroread
> Z  14757  14708  14686  14686 0 0x10006008 030109b3c180 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
>   


-- 
 __
/_/\ Kevin Crowe
   / \\ \Sun Microsystems, Inc.
  /_\ \\ /   Continuation Engineering
 /_/ \/ / /  1 Network Drive
/_/ /   \//\ Burlington, MA 01803
\_\//\   / /Mailstop: UBUR03-405
 \_/ / /\ /  phone:  (781) 442-1378
  \_/ \\ \   fax:(781) 442-1612
   \_\ \\email:  kevin.crowe at east.sun.com
\_\/ web:www.sun.com





[mdb-discuss] Project Proposal: Scripting Languages for MDB

2008-02-22 Thread Peter Memishian

 > +1 from me.

I always get confused with these +1's -- according to poll.opensolaris.org,
the only folks who actually get binding votes for mdb project proposals
are Adam Leventhal, Eric Shrock, John Levon, Matt Simmons, and Mike Shapiro.

-- 
meem



[mdb-discuss] Project Proposal: Scripting Languages for MDB

2008-02-22 Thread Dave Marquardt
"Dmitry" == Dmitry Samersoff  writes:

Dmitry> Excellent idea but perl might be too big to carry with MDB.
Dmitry> Did you look at LUA ? (www.lua.org)

I think the project should enable multiple scripting languages, not
just Perl.  So if you want to make it work with LUA, have at it.

Dmitry> 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 ($_ > 0x301)' | 
>> > ::ps
>> SPID   PPID   PGIDSID   UID  FLAGS ADDR NAME
>> R   7081  25390   7081   1277 0 0x4008 030136c7cba8 sh
>> R  19508  18010  19508   1277 0 0x4008 030109b2e188 mdb
>> R  19534   2605  19534498 78440 0x00014008 030136c7d5c0 man
>> R  19541  19540  19534498 78440 0x4008 030136c7c190 less
>> R  14686609  14686  14686 78440 0x4008 030109b2f5b8 cam
>> R  14708  14686  14686  14686 78440 0x4008 030109b3cb98 acroread
>> Z  14757  14708  14686  14686 0 0x10006008 030109b3c180 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


Dmitry> -- 
Dmitry> Dmitry Samersoff
Dmitry> J2SE Sustaining team, SPB04
Dmitry> * There will come soft rains ...
Dmitry> ___
Dmitry> mdb-discuss mailing list
Dmitry> mdb-discuss at opensolaris.org



-- 
Dave Marquardt
Sun Microsystems, Inc.
Austin, TX
+1 512 401-1077 (SUN internal: x64077)



[mdb-discuss] Project Proposal: Scripting Languages for MDB

2008-02-22 Thread Dave Marquardt
"Alexandre" == Alexandre Chartre  writes:

Alexandre> Project Description:

Alexandre> The purpose of this project is to interface some scripting
Alexandre> languages with MDB so that these languages can be used to
Alexandre> develop new MDB commands.  Scripting languages will be
Alexandre> interfaced with the MDB C API so that MDB commands and
Alexandre> functions can be invoked from the scripting language. It
Alexandre> will also be interfaced with CTF type information so that
Alexandre> data structure can be directly accessed from the scripting
Alexandre> language.

Alexandre> This project will allow to write new MDB commands using a
Alexandre> scripting language instead of having to write and compile a
Alexandre> C module. Thus this will greatly reduce the time to write
Alexandre> new MDB commands.

I like this idea.  Question: Are the MDB API and CTF information
public?  Or are they private to ON?  If they're private to ON, would
this project work to make them public?

Alexandre> This project will initially interface the PERL language with MDB.

I'd like to do the same thing with Tcl, and I'm sure there will be
fans of Python and other scripting languages that will want to help.

This may solve one of the issues I've noticed in the past.  It would
be nice to save a pipeline of commands as a single command you could
use.  I've thought of adding a dcmd like "alias" or "proc" or "func"
to do this.

+1 from me.
-- 
Dave Marquardt
Sun Microsystems, Inc.
Austin, TX
+1 512 401-1077 (SUN internal: x64077)



[mdb-discuss] Project Proposal: Scripting Languages for MDB

2008-02-22 Thread Mike Shapiro
On Fri, Feb 22, 2008 at 12:55:04PM -0800, Alexandre Chartre wrote:
> 
> > I see some merits here, but one possible area of consideration is that 
> > mdb benefits from being basically syntax compatible with kmdb.   The 
> > same dcmds that work in mdb generally are also available in kmdb.  I'd 
> > hate to see mdb extended in ways which don't easily allow for the same 
> > extensions to be done in kmdb.
> 
>   I totally agree with you, it is very upsetting to be used to some mdb
> cmds and to discover it doesn't exist with kmdb. But in most cases you can
> collect a crash dump and analysis it with mdb.
> 
> > Of course, for stuff not related to kernel debugging, I probably care a 
> > lot less.  Although, to be quite honest, mdb seems a lot less useful for 
> > debugging userland programs, if only because tools like dbx and gdb seem 
> > so much better suited to that particular task.
> 
>   That's also very useful for debugging kernel on live system or for crash
> dump analysis. A big advantage is that you can change your commands very
> quickly (for example if you change a structure while developing and you
> want a quick command to see your change).
> 
> alex.

When I originally designed MDB, it predated my work on CTF, and thus the
native type system of the kernel was not available for use in the debugger.

I recall writing in my notebook at the time that ideally you want to be
able to support the natural expressions of the language you're debugging,
which for MDB is almost always C, with a mix of assembly and maybe C++.
But mentally you are thinking in the C model since you're fundamentally
doing systems-level debugging on a UNIX operating system.

>From this perspective, I always intended to revisit the language issue
once we had the type information in place, but I've yet to find the time.
One thing I can say is that I've always found it a bit cumbersome to
try to retrofit the syntax and semantics of one language into another.

So while I'm a strong supporter for bridges to as many languages as people
find useful for writing scripts such as the Perl example, I've always thought
MDB would benefit from simply native C expression support with a very
minor set of extensions to call dcmds and do a few of the existing things.

One idea I've wanted to play with is leveraging some of the DTrace work,
in that I did go off and write a full C grammar/compiler using CTF data,
so that already exists and could be leveraged.  Also I do want something
that works the same way in kmdb and mdb.

My suggestion to the community is to start out by making a list of questions/
examples of things you want to achieve in the debugger and modeling and
comparing those using a variety of different syntaxes.

-Mike

-- 
Mike Shapiro, Solaris Kernel Development. blogs.sun.com/mws/



[mdb-discuss] Project Proposal: Scripting Languages for MDB

2008-02-22 Thread Alexandre Chartre

> I like this idea.  Question: Are the MDB API and CTF information
> public?  Or are they private to ON?  If they're private to ON, would
> this project work to make them public?

  The MDB API is public. CTF tools and API are private. We will certainly
need to check if we can get a public API for CTF. Currently I am using
the CTF API provided by mdb (mdb_ctf_* functions) so we may just need
MDB to provide a public API for CTF.

> Alexandre> This project will initially interface the PERL language with MDB.
> 
> I'd like to do the same thing with Tcl, and I'm sure there will be
> fans of Python and other scripting languages that will want to help.

  That's no problem, I am just more used to Perl that's why this is
the primary language.

> This may solve one of the issues I've noticed in the past.  It would
> be nice to save a pipeline of commands as a single command you could
> use.  I've thought of adding a dcmd like "alias" or "proc" or "func"
> to do this.

  You can definitively do that.

> +1 from me.

  Thanks,

alex.



[mdb-discuss] Project Proposal: Scripting Languages for MDB

2008-02-22 Thread Alexander Kolbasov
> 
>  > +1 from me.
> 
> I always get confused with these +1's -- according to poll.opensolaris.org,
> the only folks who actually get binding votes for mdb project proposals
> are Adam Leventhal, Eric Shrock, John Levon, Matt Simmons, and Mike Shapiro.

It is encouraging +1 then :-)




[mdb-discuss] Project Proposal: Scripting Languages for MDB

2008-02-22 Thread Alexandre Chartre

  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 ($_ > 0x301)' | 
>> ::ps
>> SPID   PPID   PGIDSID   UID  FLAGS ADDR NAME
>> R   7081  25390   7081   1277 0 0x4008 030136c7cba8 sh
>> R  19508  18010  19508   1277 0 0x4008 030109b2e188 mdb
>> R  19534   2605  19534498 78440 0x00014008 030136c7d5c0 man
>> R  19541  19540  19534498 78440 0x4008 030136c7c190 less
>> R  14686609  14686  14686 78440 0x4008 030109b2f5b8 cam
>> R  14708  14686  14686  14686 78440 0x4008 030109b3cb98 acroread
>> Z  14757  14708  14686  14686 0 0x10006008 030109b3c180 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
>>   
> 
> 



[mdb-discuss] Project Proposal: Scripting Languages for MDB

2008-02-22 Thread Alexandre Chartre

> I see some merits here, but one possible area of consideration is that 
> mdb benefits from being basically syntax compatible with kmdb.   The 
> same dcmds that work in mdb generally are also available in kmdb.  I'd 
> hate to see mdb extended in ways which don't easily allow for the same 
> extensions to be done in kmdb.

  I totally agree with you, it is very upsetting to be used to some mdb
cmds and to discover it doesn't exist with kmdb. But in most cases you can
collect a crash dump and analysis it with mdb.


> Of course, for stuff not related to kernel debugging, I probably care a 
> lot less.  Although, to be quite honest, mdb seems a lot less useful for 
> debugging userland programs, if only because tools like dbx and gdb seem 
> so much better suited to that particular task.

  That's also very useful for debugging kernel on live system or for crash
dump analysis. A big advantage is that you can change your commands very
quickly (for example if you change a structure while developing and you
want a quick command to see your change).

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 ($_ > 
 0x301)' | ::ps
 SPID   PPID   PGIDSID   UID  FLAGS ADDR NAME
 R   7081  25390   7081   1277 0 0x4008 030136c7cba8 sh
 R  19508  18010  19508   1277 0 0x4008 030109b2e188 mdb
 R  19534   2605  19534498 78440 0x00014008 030136c7d5c0 man
 R  19541  19540  19534498 78440 0x4008 030136c7c190 less
 R  14686609  14686  14686 78440 0x4008 030109b2f5b8 cam
 R  14708  14686  14686  14686 78440 0x4008 030109b3cb98 
 acroread
 Z  14757  14708  14686  14686 0 0x10006008 030109b3c180 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
   
>>> 
>> ___
>> mdb-discuss mailing list
>> mdb-discuss at opensolaris.org
>>   
> 



[mdb-discuss] Project Proposal: Scripting Languages for MDB

2008-02-22 Thread Alexander Kolbasov
+1 from me.

- akolb




[mdb-discuss] Project Proposal: Scripting Languages for MDB

2008-02-22 Thread Alexandre Chartre

  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 ($_ > 
>> 0x301)' | ::ps
>> SPID   PPID   PGIDSID   UID  FLAGS ADDR NAME
>> R   7081  25390   7081   1277 0 0x4008 030136c7cba8 sh
>> R  19508  18010  19508   1277 0 0x4008 030109b2e188 mdb
>> R  19534   2605  19534498 78440 0x00014008 030136c7d5c0 man
>> R  19541  19540  19534498 78440 0x4008 030136c7c190 less
>> R  14686609  14686  14686 78440 0x4008 030109b2f5b8 cam
>> R  14708  14686  14686  14686 78440 0x4008 030109b3cb98 acroread
>> Z  14757  14708  14686  14686 0 0x10006008 030109b3c180 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
> 
> 



[mdb-discuss] Project Proposal: Scripting Languages for MDB

2008-02-22 Thread Alexandre Chartre

  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 ($_ > 0x301)' | ::ps
SPID   PPID   PGIDSID   UID  FLAGS ADDR NAME
R   7081  25390   7081   1277 0 0x4008 030136c7cba8 sh
R  19508  18010  19508   1277 0 0x4008 030109b2e188 mdb
R  19534   2605  19534498 78440 0x00014008 030136c7d5c0 man
R  19541  19540  19534498 78440 0x4008 030136c7c190 less
R  14686609  14686  14686 78440 0x4008 030109b2f5b8 cam
R  14708  14686  14686  14686 78440 0x4008 030109b3cb98 acroread
Z  14757  14708  14686  14686 0 0x10006008 030109b3c180 lp

 > ::pload test.pl
Loaded Perl script test.pl

 > t0::pcall thread
140a000 96 14382d8 sched