Possibilty to return variable value ?

  2 posts   Feedicon  
Replies: 1 - Last Post: February 10, 2010 11:59
by: m_hess
showing 1 - 2 of 2
 
Posted: February 09, 2010 16:38 by joachimhskeie
Hello,

Is it possible to return the value of a variable inside the instrumented application ?

If I have the following application:

public class simpleApp {
   private String message = "Hello World";

   public static void main(String[] args) {
        System.out.println(message);
   }
}



If I were to instrument this application with a BTrace agent, is it possible for BTrace to get hold of the contents of the "message" variable ?
 
Posted: February 10, 2010 11:59 by m_hess
I believe it is possible, but it depends on when you want your probe to be triggered.

In your given example, you could either want to fire the probe when the field "message" is set, or when it is used as a method prarameter.

For the parameter scenario, you can simply define a probe method which matches your methods name (e.g. println), and then have a String argument to this method. Check out AllCalls2.java in the samples folder of the btrace distribution.

For the field I think it should work the same, but you have to use another location (Kind.FIELD_SET) to catch it.

bye, Michael
Replies: 1 - Last Post: February 10, 2010 11:59
by: m_hess
  • Mysql
  • Glassfish
  • Jruby
  • Rails
  • Nblogo
Terms of Use; Privacy Policy;
© 2010, Oracle Corporation and/or its affiliates
(revision 20120127.ac94057)
 
 
Close
loading
Please Confirm
Close