[Soot-list] Understand how use soot properly and why two identical method have different representation

Dario Amoroso d'Aragona darioamorosodaragona at gmail.com
Wed Mar 13 10:30:58 EDT 2019


Hi everyone,
i'm a little confusing and i want to understand how use soot correctly.
I need to use soot to compare two java project, (so one version of a
project with the next version of the same project).
I would like to the body of each SootMethod is a DavaBody but if use Dava i
have some problem, so for now i use Baf.
For the first project:
1. I set soot options with a String Array and i call
Options.v().parse(options).
The options that i set are:
  List<String> argsList = new ArrayList<>();
        argsList.add("-w"); // whole program mode
        argsList.add("-no-bodies-for-excluded"); //don't load bodies for
excluded classes, so for non-application-classes
        argsList.add("-allow-phantom-refs"); // allow to don't load some
classes (it's necessary for "no-bodies-for-excluded" option)
        argsList.add("-f");
        argsList.add("baf");
        argsList.add("-cp");// Soot class-paths
        argsList.add(classpath);
        argsList.add("-process-dir");
        argsList.add(target);
2. call Scene.v().loadNecessaryClasses();
4. call PackManager.v().runPacks();

Than i call soot.G.reset();
 For second project the first and second previous point are the same:

3 i add this:
 Transform preprocessingTransfrom = new Transform("wjtp.refresolve", new
SceneTransformer() {
            @Override
            protected void internalTransform(String phaseName, Map options)
{
                LOGGER.info("rta call graph building...");
                Transform sparkTranform = new Transform("cg.spark", null);
                PhaseOptions.v().setPhaseOption(sparkTranform,
"enabled:true"); //enable spark transformation
                PhaseOptions.v().setPhaseOption(sparkTranform,
"apponly:true");
                PhaseOptions.v().setPhaseOption(sparkTranform, "rta:true");
//enable rta mode for call-graph
                PhaseOptions.v().setPhaseOption(sparkTranform,
"verbose:false");
                PhaseOptions.v().setPhaseOption(sparkTranform,
"on-fly-cg:false"); //disable default call-graph construction mode (soot
not permitted to use rta and on-fly-cg options together)
                PhaseOptions.v().setPhaseOption(sparkTranform,
"force-gc:true"); //force call a System.cg() to increase tue available
space on garbage collector

           //     Map<String, String> opt =
PhaseOptions.v().getPhaseOptions(sparkTranform);
           //     sparkTransform(sparkTranform, opt);
                CallGraph c = Scene.v().getCallGraph(); //take the
call-graph builded
                setCallGraph(c); //set the callgraph as call-graph of this
project

            }
        });
        Pack wjpppack = PackManager.v().getPack("wjtp");
           wjpppack.add(preprocessingTransfrom);



4. and then i call, as before,  PackManager.v().runPacks();

Obviously i save all SootMethods and SootClass of the first and second
project in two different data structure.

it's all right?

If yes, i can't understand why if  have two SootMethod, one of the first
project and one of the second project, in java file are identical (and i
pass to soot class file compiled with the same jre), but they in Baf have
two different representation, in particular all in the two methods are
equal except some variables name, so i have in one "$r14
:= @caughtexception" and in the other "$r15 := @caughtexception", or "load
$r16" and "load $r10". There are some representation that it's better? With
Jimple and Shimple i have the same problem.
If i try to use dava, that have a renamer pack, setting  "-f dava
db.renamer enabled:true" soot option,  i have some exception (it's
indifferent if i enable db.renamer or not), in particular with inner class,
for example:

15:22:23.835 [main] DEBUG s.j.t.c.OnFlyCallGraphBuilder - [Call Graph] For
information on where the call graph may be incomplete,use the verbose
option to the cg phase.
15:22:27.983 [Thread-6] DEBUG soot.PackManager - Decompiling
org.apache.commons.configuration.AbstractConfiguration$2...
15:22:27.986 [Thread-7] DEBUG soot.PackManager - Decompiling
org.apache.commons.configuration.AbstractConfiguration...
15:22:27.985 [Thread-8] DEBUG soot.PackManager - Decompiling
org.apache.commons.configuration.AbstractFileConfiguration...
15:22:27.982 [Thread-5] DEBUG soot.PackManager - Decompiling
org.apache.commons.configuration.AbstractConfiguration$1...
Setting declaring class of methodint
<init>(org.apache.commons.configuration.AbstractConfiguration,DavaSuperHandler)
Setting declaring class of methodint
<init>(org.apache.commons.configuration.AbstractConfiguration,DavaSuperHandler)
15:22:28.263 [Thread-6] ERROR h.solver.CountingThreadPoolExecutor - Worker
thread execution failed: Attempting to add method DavaSuperHandler
preInit(org.apache.commons.configuration.AbstractConfiguration) to class
org.apache.commons.configuration.AbstractConfiguration$2, but the class
already has a method with that signature.
java.lang.RuntimeException: Attempting to add method DavaSuperHandler
preInit(org.apache.commons.configuration.AbstractConfiguration) to class
org.apache.commons.configuration.AbstractConfiguration$2, but the class
already has a method with that signature.
at soot.SootClass.addMethod(SootClass.java:707) ~[soot-3.3.0.jar:na]
at soot.PackManager.runBodyPacks(PackManager.java:1052) ~[soot-3.3.0.jar:na]
at soot.PackManager.lambda$runBodyPacks$0(PackManager.java:660)
~[soot-3.3.0.jar:na]
at soot.PackManager$$Lambda$1/302869695.run(Unknown Source) ~[na:na]
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
~[na:1.8.0_40]
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
[na:1.8.0_40]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_40]
Exception in thread "Thread-6" java.lang.RuntimeException: Attempting to
add method DavaSuperHandler
preInit(org.apache.commons.configuration.AbstractConfiguration) to class
org.apache.commons.configuration.AbstractConfiguration$2, but the class
already has a method with that signature.
at soot.SootClass.addMethod(SootClass.java:707)
at soot.PackManager.runBodyPacks(PackManager.java:1052)
at soot.PackManager.lambda$runBodyPacks$0(PackManager.java:660)
at soot.PackManager$$Lambda$1/302869695.run(Unknown Source)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Exception in thread "main" 15:22:28.265 [Thread-5] ERROR
h.solver.CountingThreadPoolExecutor - Worker thread execution failed:
already declared: preInit
java.lang.RuntimeException: already declared: preInit
at soot.SootClass.addMethod(SootClass.java:693) ~[soot-3.3.0.jar:na]
at soot.PackManager.runBodyPacks(PackManager.java:1052) ~[soot-3.3.0.jar:na]
at soot.PackManager.lambda$runBodyPacks$0(PackManager.java:660)
~[soot-3.3.0.jar:na]
at soot.PackManager$$Lambda$1/302869695.run(Unknown Source) ~[na:na]
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
~[na:1.8.0_40]
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
[na:1.8.0_40]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_40]
Exception in thread "Thread-5" java.lang.RuntimeException: already
declared: preInit
at soot.SootClass.addMethod(SootClass.java:693)
at soot.PackManager.runBodyPacks(PackManager.java:1052)
at soot.PackManager.lambda$runBodyPacks$0(PackManager.java:660)
at soot.PackManager$$Lambda$1/302869695.run(Unknown Source)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
java.lang.RuntimeException: already declared: preInit
at soot.SootClass.addMethod(SootClass.java:693)
at soot.PackManager.runBodyPacks(PackManager.java:1052)
at soot.PackManager.lambda$runBodyPacks$0(PackManager.java:660)
at soot.PackManager$$Lambda$1/302869695.run(Unknown Source)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
15:22:28.288 [Thread-7] ERROR h.solver.CountingThreadPoolExecutor - Worker
thread execution failed: null
java.util.ConcurrentModificationException: null
at soot.util.HashChain$LinkIterator.hasNext(HashChain.java:563)
~[soot-3.3.0.jar:na]
at
soot.dava.toolkits.base.finders.ExceptionFinder.preprocess(ExceptionFinder.java:105)
~[soot-3.3.0.jar:na]
at soot.dava.DavaBody.<init>(DavaBody.java:324) ~[soot-3.3.0.jar:na]
at soot.dava.Dava.newBody(Dava.java:87) ~[soot-3.3.0.jar:na]
at soot.PackManager.runBodyPacks(PackManager.java:1039) ~[soot-3.3.0.jar:na]
at soot.PackManager.lambda$runBodyPacks$0(PackManager.java:660)
~[soot-3.3.0.jar:na]
at soot.PackManager$$Lambda$1/302869695.run(Unknown Source) ~[na:na]
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
~[na:1.8.0_40]
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
[na:1.8.0_40]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_40]
Exception in thread "Thread-7" java.util.ConcurrentModificationException
at soot.util.HashChain$LinkIterator.hasNext(HashChain.java:563)
at
soot.dava.toolkits.base.finders.ExceptionFinder.preprocess(ExceptionFinder.java:105)
at soot.dava.DavaBody.<init>(DavaBody.java:324)
at soot.dava.Dava.newBody(Dava.java:87)
at soot.PackManager.runBodyPacks(PackManager.java:1039)
at soot.PackManager.lambda$runBodyPacks$0(PackManager.java:660)
at soot.PackManager$$Lambda$1/302869695.run(Unknown Source)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
15:22:28.293 [Thread-8] ERROR h.solver.CountingThreadPoolExecutor - Worker
thread execution failed: null
java.util.ConcurrentModificationException: null
at soot.util.HashChain$LinkIterator.hasNext(HashChain.java:563)
~[soot-3.3.0.jar:na]
at
soot.dava.toolkits.base.finders.ExceptionFinder.preprocess(ExceptionFinder.java:105)
~[soot-3.3.0.jar:na]
at soot.dava.DavaBody.<init>(DavaBody.java:324) ~[soot-3.3.0.jar:na]
at soot.dava.Dava.newBody(Dava.java:87) ~[soot-3.3.0.jar:na]
at soot.PackManager.runBodyPacks(PackManager.java:1039) ~[soot-3.3.0.jar:na]
at soot.PackManager.lambda$runBodyPacks$0(PackManager.java:660)
~[soot-3.3.0.jar:na]
at soot.PackManager$$Lambda$1/302869695.run(Unknown Source) ~[na:na]
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
~[na:1.8.0_40]
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
[na:1.8.0_40]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_40]
Exception in thread "Thread-8" java.util.ConcurrentModificationException
at soot.util.HashChain$LinkIterator.hasNext(HashChain.java:563)
at
soot.dava.toolkits.base.finders.ExceptionFinder.preprocess(ExceptionFinder.java:105)
at soot.dava.DavaBody.<init>(DavaBody.java:324)
at soot.dava.Dava.newBody(Dava.java:87)
at soot.PackManager.runBodyPacks(PackManager.java:1039)
at soot.PackManager.lambda$runBodyPacks$0(PackManager.java:660)
at soot.PackManager$$Lambda$1/302869695.run(Unknown Source)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

Somebody can help me?!

-- 
https://www.facebook.com/scattiperanima
<https://www.facebook.com/scattiperanima?ref=hl> - Il mio compito è arduo,
si tratta di fermare un istante con un click...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.CS.McGill.CA/pipermail/soot-list/attachments/20190313/689dc743/attachment-0001.html>


More information about the Soot-list mailing list