[Soot-list] Instrumenting JRE classes using Soot

Sai Zhang racezhang at gmail.com
Wed Apr 21 13:31:41 EDT 2010


Hi all:

For some reason, I need to instrument some jre classes (residing in rt.jar)
for doing
dynamic analysis using Soot. It is a pretty simple analysis, and will never
touch
some "dangerous" classes like java.lang.Object, java.lang.Class. etc. I can
foresee that
all classes I need to instrument are inside java.util package.

For instance, what I am doing is to add "profiling code" before and after
each method call like:

java.util.Vector..

int size() {
    Tracer.startCall("size()");

    //the method body

    Tracer.endCall("size()");
}

//Tracer is a simple class to keep track of traces


Implementing such analysis is not hard, but I am wondering is there any
convenient way to
"deploy" such  changes. Normally, we unzip the rt.jar, do instrumentation,
and get a set of instrumented classes.
We can either:
(1) pack the instrumented classes into the rt.jar (but that could be a bit
problematic, at least on
my laptop. an exception is thrown when initializing the JVM, it can not find
the class Tracer!!!)
(2) reset the BootClasspath to point to the instrumented classes dir.

For me, only (2) works! I am curious what is the best practice to use Soot
for jre class instrumentation?

thanks


--Sai Zhang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.cs.mcgill.ca/pipermail/soot-list/attachments/20100421/40a39553/attachment.html 


More information about the Soot-list mailing list