CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Dec 2010
    Posts
    907

    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

  2. #2
    Join Date
    May 2006
    Location
    UK
    Posts
    4,473

    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.
    Posting code? Use code tags like this: [code]...Your code here...[/code]
    Click here for examples of Java Code

  3. #3
    Join Date
    Dec 2010
    Posts
    907

    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.

  4. #4
    Join Date
    May 2006
    Location
    UK
    Posts
    4,473

    Re: Variable context dumping

    To do that you will need to check out Java instrumentation.
    Posting code? Use code tags like this: [code]...Your code here...[/code]
    Click here for examples of Java Code

  5. #5
    Join Date
    Dec 2010
    Posts
    907

    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

  6. #6
    Join Date
    May 2006
    Location
    UK
    Posts
    4,473

    Re: Variable context dumping

    I've never used it, I just know that debuggers use instrumentation.
    Posting code? Use code tags like this: [code]...Your code here...[/code]
    Click here for examples of Java Code

  7. #7
    Join Date
    Dec 2010
    Posts
    907

    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
  •  





Click Here to Expand Forum to Full Width

Featured