[Soot-list] Help needed with ThreadLocalObjectsAnalysis

Richard L. Halpert richhal22 at gmail.com
Fri Sep 4 19:13:31 EDT 2009


That's right, I now remember that you have to call an mhp.print...
method of some sort to get the output I was looking for.  No need,
though; the ThreadLocalObjectsAnalysis output tells me what I really
needed to know.  Unfortunately, I agree with you that this result is
wrong.  I can try to investigate the problem early next week.  Aside
from diving into the code yourself, the only other thing I can think
that you could do is turn on some of the verbose output of TLO.  It's
possible to print out graphviz graphs of the analysis of each method,
which could definitely aid in debugging.

-Richard

On 9/4/09, Arie Zilberstein <arie.zilberstein at gmail.com> wrote:
> Hi,
>
>
>
> This is the relevant part of the output.
>
> The Publish class is the same as appears below. The Publish$1 class is the
> anonymous class which implements the Runner interface.
>
>
>
> [Call Graph] For information on where the call graph may be incomplete, use
> the verbose option to the cg phase.
>
> [Spark] Pointer Assignment Graph in 1.6 seconds.
>
> [Spark] Type masks in 0.4 seconds.
>
> [Spark] Pointer Graph simplified in 0.0 seconds.
>
> [Spark] Propagation in 51.1 seconds.
>
> [Spark] Solution found in 51.1 seconds.
>
> [local-objects] Analyzing local objects for cases.publish.Publish$1
>
> [local-objects]   preparing class             Sat Sep 05 01:47:11 GMT+02:00
> 2009
>
> [local-objects]   analyzing class             Sat Sep 05 01:47:11 GMT+02:00
> 2009
>
> [local-objects]   propagating over call graph Sat Sep 05 01:47:11 GMT+02:00
> 2009
>
> [local-objects]   finished at                 Sat Sep 05 01:47:11 GMT+02:00
> 2009
>
> [local-objects]   (#analyzed/#encountered): 8/16
>
> [local-objects] Analyzing local objects for cases.publish.Publish
>
> [local-objects]   preparing class             Sat Sep 05 01:47:11 GMT+02:00
> 2009
>
> [local-objects]   analyzing class             Sat Sep 05 01:47:11 GMT+02:00
> 2009
>
> [local-objects]   propagating over call graph Sat Sep 05 01:47:11 GMT+02:00
> 2009
>
> [local-objects]   finished at                 Sat Sep 05 01:47:11 GMT+02:00
> 2009
>
> [local-objects]   (#analyzed/#encountered): 26/58
>
>
>
>
>
> Best,
>
> Arie
>
>
>
> From: richardlhalpert at gmail.com [mailto:richardlhalpert at gmail.com] On Behalf
> Of Richard L. Halpert
> Sent: Friday, September 04, 2009 8:01 PM
> To: Arie Zilberstein
> Cc: Eric Bodden; soot-list at sable.mcgill.ca
> Subject: Re: [Soot-list] Help needed with ThreadLocalObjectsAnalysis
>
>
>
> Can you send the output of the MHP analysis and any other output you may be
> getting?  I think this could be a bug.
>
> -Richard
>
> On Fri, Sep 4, 2009 at 11:13 AM, Arie Zilberstein
> <arie.zilberstein at gmail.com> wrote:
>
> OK,
>
> ----------------> Tested class code: <-----------
> public class Publish {
>        public static void main(String[] args) {
>                Publish publish = new Publish();
>                invokeThreadAccessSharedDummy();
>                publish.test();
>        }
>
>        private static void invokeThreadAccessSharedDummy() {
>                Thread t = new Thread(new Runnable() {
>
>                        @Override
>                        public void run() {
>                                sharedDummy.integer = 20;
>                                System.out.println("in thread!");
>                        }
>                });
>                t.start();
>
>        }
>
>        Dummy d;
>        static Dummy sharedDummy;
>
>        private void test() {
>
>                // d is local
>                d = new Dummy();
>                d.integer = 5;
>
>                // publish d
>                sharedDummy = d;
>
>                // d is now shared
>                d.integer = 10;
>        }
> }
>
> ----------------> Class invoking TLOA <-------------
> public class ThreadLocalSceneTransformer extends SceneTransformer {
>
>        private static Transformer instance = new
> ThreadLocalSceneTransformer();
>        private ThreadLocalObjectsAnalysis tloa;
>
>        public static Transformer v() {
>                return instance;
>        }
>
>        private ThreadLocalObjectsAnalysis getTLOA() {
>
>                MhpTester mhp = new SynchObliviousMhpAnalysis();
>                ThreadLocalObjectsAnalysis tloa = new
> ThreadLocalObjectsAnalysis(mhp);
>
>                return tloa;
>        }
>
>        @Override
>        protected void internalTransform(String phaseName, Map options) {
>                tloa = getTLOA();
>                iterateAllMethods();
>        }
>
>        private void iterateAllMethods() {
>
>                // Find methods
>                Iterator<SootClass> getClassesIt =
> Scene.v().getApplicationClasses()
>                                .iterator();
>                while (getClassesIt.hasNext()) {
>                        SootClass appClass = getClassesIt.next();
>                        Iterator<SootMethod> getMethodsIt =
> appClass.getMethods()
>                                        .iterator();
>                        while (getMethodsIt.hasNext()) {
>                                SootMethod method = getMethodsIt.next();
>                                analyzeMethod(method);
>                        }
>                }
>        }
>
>        private void analyzeMethod(SootMethod method) {
>                if (!method.hasActiveBody()) {
>                        return;
>                }
>                Body activeBody = method.getActiveBody();
>
>                List<ValueBox> useAndDefBoxes =
> activeBody.getUseAndDefBoxes();
>                for (ValueBox valueBox : useAndDefBoxes) {
>                        Value value = valueBox.getValue();
>                        if (value instanceof FieldRef) {
>                                analyzeField(method, value);
>                        }
>                }
>        }
>
>        private void analyzeField(SootMethod method, Value value) {
>                FieldRef fr = (FieldRef) value;
>                boolean fieldIsThreadLocal = tloa.isObjectThreadLocal(fr,
> method);
>                if (fieldIsThreadLocal) {
>                        // DISCOVERED A THREAD LOCAL FIELD, KEEP IT IN
> DATABASE HERE...
>                }
>        }
>
> }
> ----------------------------------------------
>
> I inject the new transformer in the recommended way.
> I use the following parameters on the main() method:
>
> -cp <folder> -process-dir <folder> -d <output-folder> -pp -w -p cg.spark
> enabled:true -p jb use-original-names:true -app -keep-bytecode-offset
> -main-class Publish
>
>
>
> Best,
> Arie
>
>
>
> -----Original Message-----
> From: eric.bodden at googlemail.com [mailto:eric.bodden at googlemail.com] On
> Behalf Of Eric Bodden
> Sent: Friday, September 04, 2009 6:51 PM
> To: Arie Zilberstein
> Cc: soot-list at sable.mcgill.ca
> Subject: Re: [Soot-list] Help needed with ThreadLocalObjectsAnalysis
>
> Arie can you send us the complete examples? It's hard to tell form the
> code fragment you send. In those cases details usually count.
>
> Eric
>
> 2009/9/4 Arie Zilberstein <arie.zilberstein at gmail.com>:
>> Hi,
>>
>>
>>
>> I'm experimenting with soot's ThreadLocalObjectsAnalysis class.
>>
>>
>>
>> I want to find out if a field of an object is thread-local or
> thread-shared
>> within a method. I realize that this may change over the lifetime of a
>> single method. Look at this example:
>>
>>
>>
>> Dummy d;
>>
>> static Dummy sharedDummy;
>>
>>
>>
>> private void test() {
>>
>>       d = new Dummy(); // d is thread-local
>>
>>       d.integer = 5;
>>
>>
>>
>>       sharedDummy = d; // publish d; it is not thread-shared
>>
>>       d.integer = 10;
>>
>> }
>>
>>
>>
>> I used the ThreadLocalObjectsAnalysis object, hoping that it would
> determine
>> that the second write to d (d.integer=10) is to a field which is
>> thread-shared, but for some reason, it deduced that the field is
>> thread-local.
>>
>>
>>
>> I'm using the object like this:
>>
>> MhpTester mhp = new SynchObliviousMhpAnalysis();
>>
>>             ThreadLocalObjectsAnalysis tloa = new
>> ThreadLocalObjectsAnalysis(mhp);
>>
>>             // later, given a value from a method
>>
>> boolean fieldIsThreadLocal = tloa.isObjectThreadLocal(value, method);
>>
>>
>>
>>
>>
>> I should note that, just before calling test(), I'm starting a thread
> which
>> deliberately sets sharedDummy.integer to 20. That's why I expect the
> object
>> stored in sharedDummy to be thread-shared.
>>
>>
>>
>> I would appreciate any help! Is this my misunderstanding? or a problem?
>>
>>
>>
>> Best,
>>
>> Arie
>>
>>
>>
>>
>>
>> _______________________________________________
>> Soot-list mailing list
>> Soot-list at sable.mcgill.ca
>> http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
>>
>>
>
>
>
> --
> Eric Bodden
> Software Technology Group, Technische Universität Darmstadt, Germany
> Tel: +49 6151 16-5478    Fax: +49 6151 16-5410
> Mailing Address: S2|02 A209, Hochschulstraße 10, 64289 Darmstadt
>
> _______________________________________________
> Soot-list mailing list
> Soot-list at sable.mcgill.ca
> http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
>
>
>
>

-- 
Sent from my mobile device


More information about the Soot-list mailing list