-
February 24th, 2012, 08:31 AM
#1
Variable context dumping
What is the proper way to dump all variables and execution path of a java program?
I'd like to do a general overall analysis on a set of source code.
Thanks
Jack
-
February 24th, 2012, 11:43 AM
#2
Re: Variable context dumping
You can dump the stack trace for the current thread by calling:
Code:
Thread.dumpStack();
There is no standard way to dump all variables. Do you mean all the variables in all existing objects (this could lead to an enormous dump) or just the variables in the current object. The later could easily be done by writing utility class with a single static dumpObject(Object obj) method into which you pass the object to dump. The method would then use reflection to find the variables in the object and the associated values.
-
February 26th, 2012, 08:38 AM
#3
Re: Variable context dumping
Hi, keang
Thanks for your help. I want to record all variables change and how the program flow to a file
like
In method A::B
line 1: a = 1 b = 2
line 2: a = 2 b = 3 c = 4
==Loop
line 1: a = 1 b = 2
etc that's what i am thinking about.
-
February 26th, 2012, 11:09 AM
#4
Re: Variable context dumping
To do that you will need to check out Java instrumentation.
-
February 26th, 2012, 11:32 AM
#5
Re: Variable context dumping
Alright, thanks a lot, I've flipped a few web pages and still don't understand how instrumentation is coded.
Could you please give an example?
Thanks
Jack
-
February 26th, 2012, 12:25 PM
#6
Re: Variable context dumping
I've never used it, I just know that debuggers use instrumentation.
-
February 27th, 2012, 02:18 AM
#7
Re: Variable context dumping
Thanks for your pointers
Have a nice day
Jack
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|