[Soot-list] Access parameter in created method
Eric Bodden
eric.bodden at ec-spride.de
Sun Dec 16 04:03:53 EST 2012
Hi Jörg.
The tutorial contains this code:
// insert "tmpRef.println("Hello world!")"
{
SootMethod toCall = Scene.v().getMethod
("<java.io.PrintStream: void println(java.lang.String)>");
units.add(Jimple.v().newInvokeStmt
(Jimple.v().newVirtualInvokeExpr
(tmpRef, toCall.makeRef(), StringConstant.v("Hello world!"))));
}
Simply replace StringConstant.v("Hello world!") by the local variable
that references your parameter. That local you need to initialize at
the beginning of the method using a parameterref as the tutorial also
shows:
units.add(Jimple.v().newIdentityStmt(arg,
Jimple.v().newParameterRef(ArrayType.v
(RefType.v("java.lang.String"), 1), 0)));
Eric
On 14 December 2012 14:31, Jörg Schad <joerg.schad at gmail.com> wrote:
> Hi,
> sorry upfront for a beginners question...
>
> I created a class similar to the example "Creating a class from scratch with
> Soot" (http://www.sable.mcgill.ca/soot/tutorial/createclass/index.html).
> Now I am wondering how I can access (or print for example) the parameters
> inside such method.
>
> Could anyone provide a simple example of how to print a String parameter for
> example or point me to further documentation?
>
> Thanks a lot
> JS84
>
> _______________________________________________
> Soot-list mailing list
> Soot-list at sable.mcgill.ca
> http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
>
--
Eric Bodden, Ph.D., http://sse.ec-spride.de/ http://bodden.de/
Head of Secure Software Engineering Group at EC SPRIDE
Tel: +49 6151 16-75422 Fax: +49 6151 16-72051
Room 3.2.14, Mornewegstr. 30, 64293 Darmstadt
More information about the Soot-list
mailing list