Xiliu Tang - Sun Microsystems - Beijing China
2005-Sep-09 09:54 UTC
[dtrace-discuss] how to tracing all the calls to a library?
Is there a method to tracing all the calls to a library? I know using pid provider can tracing calls to a library, but It can only tracing a special process, I want to trace all the calls in the system to a library? What can I do to reach this? Thanks, --Xiliu
Philip Beevers
2005-Sep-09 10:11 UTC
[dtrace-discuss] how to tracing all the calls to a library?
This is something I also wanted to do some time back. Clearly it''s not possible for the PID provider to do this as it stands; if it was possible to dynamically enable a probe you could potentially do this with a script that looked at every newly fork/exec''d process (or every process which loaded this library, if it''s dynamically linked). But it''s not... I think the your options are: * Writing a script to look for "candidate" processes periodically, invoking separate D scripts, or * Just defining some static probe points of your own in the library. If anyone else has a better solution to this, I''d love to hear it. Just dreaming for a moment - no idea how practical this is - but given that the PID provider changes the text of your binary when probes are enabled, is it possible in theory to do the same thing globally for code in a shared object? i.e. the provider would instrument the _shared_ text, rather than copying it and instrumenting it for a single process, as I guess it must do now? -- Philip Beevers Fidessa Infrastructure Development mailto:philip.beevers at fidessa.com phone: +44 1483 206571> -----Original Message----- > From: dtrace-discuss-bounces at opensolaris.org > [mailto:dtrace-discuss-bounces at opensolaris.org]On Behalf Of > Xiliu Tang - > Sun Microsystems - Beijing China > Sent: 09 September 2005 10:54 > To: dtrace-discuss at opensolaris.org > Subject: [dtrace-discuss] how to tracing all the calls to a library? > > > Is there a method to tracing all the calls to a library? > I know using pid provider can tracing calls to a library, > but It can only tracing a special process, I want to trace all > the calls in the system to a library? > What can I do to reach this? > Thanks, > --Xiliu > _______________________________________________ > dtrace-discuss mailing list > dtrace-discuss at opensolaris.org >****************************************************************** This message is intended only for the stated addressee(s) and may be confidential. Access to this email by anyone else is unauthorised. Any opinions expressed in this email do not necessarily reflect the opinions of royalblue. Any unauthorised disclosure, use or dissemination, either whole or in part is prohibited. If you are not the intended recipient of this message, please notify the sender immediately. ******************************************************************
sang-suan.gam
2005-Sep-09 10:54 UTC
[dtrace-discuss] how to tracing all the calls to a library?
Hi, not a tracing solution on par with dtrace, but you may want to try library interpositions. eg: if you''re interested in collecting stats for open(), you can 1. code your own version of open() (you''ll need to give it the same name, and pass it the same arguments), into a file my_open.c in the open() in my_open.c, code it to retrieve the symbol info for the actual open(), using dlsym(). collect the stats, and then invoke the actual open by using the handle returned from dlsym() earlier. 2. then compile and link it into libmyopen.so. 3. run the programs that you''re investigating after exporting LD_PRELOAD to point to your new library. $ export LD_PRELOAD=./libmyopen.so. $ run_any_programs $ ... hope this helps, cheers, sam | This is something I also wanted to do some time back. Clearly it''s not | possible for the PID provider to do this as it stands; if it was possible to | dynamically enable a probe you could potentially do this with a script that | looked at every newly fork/exec''d process (or every process which loaded | this library, if it''s dynamically linked). But it''s not... | | I think the your options are: | | * Writing a script to look for "candidate" processes periodically, invoking | separate D scripts, or | * Just defining some static probe points of your own in the library. | | If anyone else has a better solution to this, I''d love to hear it. | | Just dreaming for a moment - no idea how practical this is - but given that | the PID provider changes the text of your binary when probes are enabled, is | it possible in theory to do the same thing globally for code in a shared | object? i.e. the provider would instrument the _shared_ text, rather than | copying it and instrumenting it for a single process, as I guess it must do | now? | | -- | | Philip Beevers | Fidessa Infrastructure Development | | mailto:philip.beevers at fidessa.com | phone: +44 1483 206571 | | | > -----Original Message----- | > From: dtrace-discuss-bounces at opensolaris.org | > [mailto:dtrace-discuss-bounces at opensolaris.org]On Behalf Of | > Xiliu Tang - | > Sun Microsystems - Beijing China | > Sent: 09 September 2005 10:54 | > To: dtrace-discuss at opensolaris.org | > Subject: [dtrace-discuss] how to tracing all the calls to a library? | > | > | > Is there a method to tracing all the calls to a library? | > I know using pid provider can tracing calls to a library, | > but It can only tracing a special process, I want to trace all | > the calls in the system to a library? | > What can I do to reach this? | > Thanks, | > --Xiliu | > _______________________________________________ | > dtrace-discuss mailing list | > dtrace-discuss at opensolaris.org | > | | | ****************************************************************** | This message is intended only for the stated addressee(s) and | may be confidential. Access to this email by anyone else is | unauthorised. Any opinions expressed in this email do not | necessarily reflect the opinions of royalblue. Any unauthorised | disclosure, use or dissemination, either whole or in part is | prohibited. If you are not the intended recipient of this message, | please notify the sender immediately. | ****************************************************************** | | _______________________________________________ | dtrace-discuss mailing list | dtrace-discuss at opensolaris.org