Hi, I am trying to use dtrace to replace/override function return value, e.g. force strlen to return 3 always. However, so far I can not find way to do this in ''return'' probe (from ''pid'' provider). I tried to play with ''copyout'' and ''arg0'' but it seems I miss something - can anyone help me with working example? thanks a lot, -katya
Roch Bourbonnais - Performance Engineering
2006-May-04 15:36 UTC
[dtrace-discuss] How to override return value
If you find a way; please file a bug quickly because DTrace is just not designed to do this ;-) The feature has been requested a few times but it really goes against one principle of DTrace: inspect the system as it is with as little intrusion as possible. So one day, we can speculate that a cousin project re-using similar technology might take shape to do what you want but then again it might not. What are you trying to do ? Could there be some other way ? -r Ekaterina Pavlova writes: > Hi, > > I am trying to use dtrace to replace/override function return value, > e.g. force strlen to return 3 always. > > However, so far I can not find way to do this in ''return'' probe (from > ''pid'' provider). > I tried to play with ''copyout'' and ''arg0'' but it seems I miss something > - can anyone help me with working example? > > > thanks a lot, > -katya > > _______________________________________________ > dtrace-discuss mailing list > dtrace-discuss at opensolaris.org
Isn''t this exactly what the destructive option was for, ala http://blogs.sun.com/roller/page/jonh?entry=it_s_been_a_long Roch Bourbonnais - Performance Engineering wrote:> > If you find a way; please file a bug quickly because > DTrace is just not designed to do this ;-) > > The feature has been requested a few times but it really > goes against one principle of DTrace: inspect the system as > it is with as little intrusion as possible. > > So one day, we can speculate that a cousin project re-using > similar technology might take shape to do what you want but > then again it might not. > > What are you trying to do ? Could there be some other way ? > > -r > > > Ekaterina Pavlova writes: > > Hi, > > > > I am trying to use dtrace to replace/override function return value, > > e.g. force strlen to return 3 always. > > > > However, so far I can not find way to do this in ''return'' probe (from > > ''pid'' provider). > > I tried to play with ''copyout'' and ''arg0'' but it seems I miss > something > > - can anyone help me with working example? > > > > > > thanks a lot, > > -katya > > > > _______________________________________________ > > dtrace-discuss mailing list > > dtrace-discuss at opensolaris.org > > _______________________________________________ > dtrace-discuss mailing list > dtrace-discuss at opensolaris.org >
Hi Katya, To actually modify the return value we''d need to implement this RFE: 5005776 uregs[] array should be writable with destructive actions enabled You can use copyout() to modify other bits of data, but not the actual registers or arguments. Adam On Wed, May 03, 2006 at 01:06:17AM +0400, Ekaterina Pavlova wrote:> Hi, > > I am trying to use dtrace to replace/override function return value, > e.g. force strlen to return 3 always. > > However, so far I can not find way to do this in ''return'' probe (from > ''pid'' provider). > I tried to play with ''copyout'' and ''arg0'' but it seems I miss something > - can anyone help me with working example? > > > thanks a lot, > -katya > > _______________________________________________ > dtrace-discuss mailing list > dtrace-discuss at opensolaris.org-- Adam Leventhal, Solaris Kernel Development http://blogs.sun.com/ahl