[Soot-list] How to get a "this" reference?
Kanad Sinha
kanad85 at gmail.com
Mon Jun 7 23:19:18 EDT 2010
Hi,
I've trying to post this message for a long time now. I apologise if I
am spamming everyone with this more than once.
First of all, apart from the fact that Soot is a great framework, I'd
like to commend you all on the great documentation that you've managed
to compile and maintain. Introducing myself to Soot has been far easier
than I imagined, even though I am new to Java.
I am trying to profile class files to record the run-time classes which
run the respective methods of an application. I went through your
profiling examples and they were a great help. I'm trying to do an
instrumentation in each method to insert some code:
Class temp = getClass(); // new local created via instrumentation
RecordData.reportRuntimeClass(temp); // RecordData is the
wrapper-class that has the static method to record the class in it
To do so, my code looks something like,
// Get the getClass() method
SootClass pClass = thisMethod.getDeclaringClass();
while(pClass.hasSuperclass())
{
pClass = pClass.getSuperclass();
}
SootMethod gcCall = pClass.getMethod("java.lang.Class getClass()");
// Assign "tmpClass = getClass();"
Local tmpClass = Jimple.v().newLocal("temp",
RefType.v("java.lang.Class"));
body.getLocals().add(tmpRef);
AssignStmt toAssign = Jimple.v().newAssignStmt(#####, \\ What to use
here, is what I haven't figured out
Jimple.v().newVirtualInvokeExpr(tmpRef,
gcCall.makeRef()));
// Call the recording method
InvokeExpr invExpr =
Jimple.v().newStaticInvokeExpr(reportRuntime.makeRef(), tmpClass);
Stmt invStmt = Jimple.v().newInvokeStmt(invExpr);
What should I use as the "base" of the virtual-invoke statement? I'm
guessing it should be a "this" pointer, but I haven't been able to
figure out how to obtain it at compile-time.
Any help would be appreciated. Thanks a lot,
Kanad.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.cs.mcgill.ca/pipermail/soot-list/attachments/20100607/c4496fd6/attachment.html
More information about the Soot-list
mailing list