Hi Eugene,

Thanks for the quick reply. I have taken a look at the link which you provided and had another play around with the existing TPTP tools.

Firstly, on the technology side am I right in saying that TPTP currently uses JVMPI, is considering JVMTI and makes no use of java.lang.instrument?

On the functionality side I don't think the current TPTP tools quite meet either of my suggestions.

Textual Trace
The inspiration for this idea is that the coding standards at my job require me to add trace calls at the start/end of every function and at every branch. This looks like the following.

public void foo()
{
 TraceFn fn = Trace.beginfn();
 if (cond)
 {
   fn.normal("cond taken");
 }
 else
 {
    fn.normal("cond not taken");
 }
 fn.endfn();
}

When trace is enabled, this code can capture complete information about the control flow through code.

Adding this code manually is tedious and open to trace statements being missed. I think a far better solution is to write code without the trace and have the bytecode postprocessed to add the trace into any class which you are interested in. This has the side effect of allowing you to add trace to code in 3rd party libraries. Furthermore, once you have a mechanism for adding trace statements you can use this to inject other code. I used this recently to discover where a particular class in a 3rd party library was being constructed by instrumenting the class with code that output a stack trace when any of its methods were called (including its constructor).

I am able to use my prototype instrumentation outside of Eclipse by simply adding -javaagent:/path/to/my/agent.jar=my,agent,args. Is it possible to use any of the TPTP instrumentation outside of Eclipse?

Graphical Trace
TPTP _almost_ has the GUI side of this. The Thread Analysis was almost what I was thinking of. However, it would be nice if function calls could be displayed on the timeline so that it would be immediately obvious which functions were being executed at any time. On the recording side can you tell me whether it is possible to do the recording outside of Eclipse? I would ideally like a mechanism to make a recording on a server and then analyse the recording in Eclipse.

Regards,

MartinHR

Eugene Chan wrote:

Hi Martin,

Thanks first for your suggestion and ideas. TPTP Java profiler instruments target classes for profile event generation which is transferred back to Eclipse client with the help of Agent Controller. Events are presented in both textual and graphical ways. Optional profile to file function is available for direct saving of events. These are very close to what you have suggested in your email. TPTP does not currently support line level coverage with JVM 1.6 and above. In pervious release of TPTP where code coverage was supported, it is proven that test code coverage is a very good usage of combining the TPTP Test and Profiling functionality. Profiling 'breakpoint' was raised but it was not further discussed and planned due to the lack of resources in the project. As an open source project, TPTP welcomes community feedback and contribution. Most of your idea are already implemented in existing TPTP release and I suggest you to give it a try. Please let me know if you have any more question or discussion on your idea.

Detail of the project and technology used are available in TPTP webpage here <http://www.eclipse.org/tptp/platform/documents/design/arch_tptp_platform.php>[1].

[1] http://www.eclipse.org/tptp/platform/documents/design/arch_tptp_platform.php

Regards,
___________________________________________

Eugene Chan
IBM Canada Lab, Canada



From:   Martin Hare Robertson <mch...@googlemail.com>
To:     tptp-tracing-profiling-tools-dev@eclipse.org
Date:   02/22/2010 05:05 PM
Subject:        [tptp-tracing-profiling-tools-dev] Trace Development Ideas
Sent by:        tptp-tracing-profiling-tools-dev-boun...@eclipse.org


------------------------------------------------------------------------



Hi,

I am a Java developer who uses Eclipse every day in my job. I am
interested in contributing towards the development of some interesting
new features which I think would fit into the TPTP project. However, I
would like to get some feedback to help me improve my ideas before I
take this any further.

The two technologies which I have been playing with are the Java
Instrumentation API and ASM2 Bytecode processing library.

* http://java.sun.com/javase/6/docs/api/java/lang/instrument/package-summary.html
   * http://asm.ow2.org/

My ideas are all in the area of execution trace recording/processing.

_Recording
_Using a combination of the Java Instrumentation API and ASM2 an Agent
can be used to rewrite class files to capture data about the code which
is executed. This should be stored as efficiently as possible in memory
and streamed to disk as the amount of data becomes too large. I have
implemented a basic prototype Agent that instruments Classfiles to write
trace output to a text file to show which lines of code were executed.
Here is some example output.

Added tracing to: gb.trace.test.TraceExample
No trace added to: gb.trace.agent.output.StdOutWriter
Mon Jan 18 10:00:46 GMT 2010: Branch:TraceExample.java:workMethod:24
Mon Jan 18 10:00:46 GMT 2010: Branch:TraceExample.java:workMethod:31
Mon Jan 18 10:00:46 GMT 2010: Exit:TraceExample.java:workMethod:33
Mon Jan 18 10:00:47 GMT 2010: Branch:TraceExample.java:workMethod:24
Mon Jan 18 10:00:47 GMT 2010: Branch:TraceExample.java:workMethod:31
Mon Jan 18 10:00:47 GMT 2010: Exit:TraceExample.java:workMethod:33

I have enjoyed playing with the Java Instrumentation API and ASM2 as it
feels like a very powerful thing to be able to rewrite Java class files
at startup but also at runtime.

_Processing_
In this section I will refer to a recording as an Execution Trace
Recording (ETR). I have made up this term. There are a number of
interesting things you could do with an ETR.

_-- Textual Trace__
_Output a single line of text listing the timestamp and line number for
each basic block (function, if/else etc) which was executed (See example
above).

_-- Graphical Trace
_Sometimes when trying to work out how some code works I find myself
stepping through the code to see which lines get hit. I could do this
automatically by running a code coverage tool but I don't just want to
know binary executed/not-executed information. I really want to know
what lines were executed and in which order. At a simple level I would
be happy with a list of function calls. It would be even better if I
could drill down into each function call to see which lines were
executed. It would also be good to be able to display the function calls
of multiple threads side by side. This would be a difficult UI to make
usable in situations with many threads. It may be sufficient to allow
particular threads to be added to a multi thread comparison view.

Another point is that I may only be interested in which parts of a
function were executed for a particular invocation of a function. This
would be really easy if I could start/stop the ETR recording while the
target application is still running. The use case I am imaging is
setting a break point part way through a JUnit test in Eclipse, pressing
a "Start Recording" button while the test is suspended, resuming
execution until another breakpoint is hit and pressing a "Stop
recording" button while the test is once again suspended. This kind of
runtime addition/removal of instrumentation is definitely possible with
the Java Instrumentation API (within limits).

_-- JUnit Integration
_Runtime Class rewriting would allow a test to include arbitrary checks
about whether particular bits of code were executed during a test. I am
imagining an API along the lines of
assertFunctionCalled("my.class.name","functionName"). This would be
useful for automated integration tests of large blocks of code where a
single return value could be returned as a result of multiple different
execution paths within the code under test.

_Summary_
These ideas are all pretty vague at this stage. I would love to hear
some feedback on the following points.

   * Are these good ideas?
   * Do you know of any commercial/open source products implementing
     any of this?
   * Does TPTP already enable any of this?
   * Do these ideas fit into the current plans for TPTP?
   * Do you have any suggestions to improve these ideas?

I look forward to hearing from you.

Thanks

MartinHR
_______________________________________________
tptp-tracing-profiling-tools-dev mailing list
tptp-tracing-profiling-tools-dev@eclipse.org
https://dev.eclipse.org/mailman/listinfo/tptp-tracing-profiling-tools-dev



------------------------------------------------------------------------

_______________________________________________
tptp-tracing-profiling-tools-dev mailing list
tptp-tracing-profiling-tools-dev@eclipse.org
https://dev.eclipse.org/mailman/listinfo/tptp-tracing-profiling-tools-dev

_______________________________________________
tptp-tracing-profiling-tools-dev mailing list
tptp-tracing-profiling-tools-dev@eclipse.org
https://dev.eclipse.org/mailman/listinfo/tptp-tracing-profiling-tools-dev

Reply via email to