1 Reply Latest reply on Feb 21, 2013 4:10 AM by adinn

    Question about 'object-tracking'...

    jwin68-ffm

      Hi,

       

      Is there any way (built-in expressions or proven rules) to track application-events by matching a change of some objects variables/referenced objects (recursively!) ?

       

      What I mean is for example, "log every change to _any_ variable, starting at some ObjectA (log the call-stack at that moment)"

      ObjectA has some fields and reference to ObjectB, collection of ObjectC

      ObjectC has again references to .... an so on

       

      Is such a thing possible with byteman ?

       

      Best,

      Joerg

        • 1. Re: Question about 'object-tracking'...
          adinn

          Hi Joerg,

          J W wrote:

           

          Is there any way (built-in expressions or proven rules) to track application-events by matching a change of some objects variables/referenced objects (recursively!) ?

           

          What I mean is for example, "log every change to _any_ variable, starting at some ObjectA (log the call-stack at that moment)"

          ObjectA has some fields and reference to ObjectB, collection of ObjectC

          ObjectC has again references to .... an so on

           

          The short answer is no.

           

          If you want more detail . . . Essentially, Byteman rules operate at the class level because they are oriented around injection into a specific method. So, in general they can track and respond to a specific update to a specific type of object and are not necessarily going to avoid firing the rule (executing the DO part) to cases where the update applies ot a single instance.

           

          Of course, it may be possible to write rules which only fire in response to changes to a specific object (or even a tree of objects) but even when possible it will probably not be easy. Firstly, you would need to inject rules into every method which can modify an instance of the type you are interested in (or the set of types if you have a tree made up of multiple types).  Secodnly, your rule condition (the IF part) woudl need to employ a Java expression which was true if an donly if this was the instance you were interested in (ditto for all elements of the tree if you are looking at a hierarchy). Whether that is possible depends upon your application.

           

          Implementing the first requirement is the sort of thing an Aspect Oriented Programming (AOP) system is much better at than Byteman. Byteman is oriented towards making very specific changes -- that's by design, of course, because that means it has very low runtime costs, causing minimal pertubation to an app's behaviour, which is exactly what you want for fault injection testing both for unit testing and system testing. AOP systems are very good for making bulk changes across a code base to add behaviours orthogonal to the application itself (e.g. adding transactionality to a whole family of methods). That's generally a much less efficient thing to implement (indeed it is much better if  you can do it offline before execution) and radically alers the applicaion's memory footprint and timing (which you probably don't care about).

           

          My instinct is that implementing the second requirement will be very strongly dependent upon your application semantics. I don't have a formal proof of this but I suspect that for many programs there will be no way of knowing whether an object belongs to a given tree -- or, more generally, directed graph -- unless the program explicitly includes a graph tracing routine.

           

          Could you explain more about why you are asking this question? What is the problem motivating you to try a solution like this? Byteman may not be the tool you need  but, then again. maybe there is another solution which can use Byteman.

           

          regards,

           

           

          Andrew Dinn