[Soot-list] How to determine whether there exists a use for a variable definition later on in the cfg

John Dean jdean4 at kc.rr.com
Fri Jul 27 13:24:00 EDT 2012


Phil (and anyone else?),
Thanks for the suggestion!

Fortuanately, I've already borrowed/written code to detect loops.

I think you are saying that if I use the default equals method from the
Object class (which tests for the same reference address) to compare one of
the retrieved units from getUsesOf() with each unit in the loop, equals will
return true only if the units are the same exact unit reference (both from
within the loop)? Is that right?

So, for example, if there's an x = y statement inside the loop and there's
also an x = y statement outside of the loop, then those 2 statements will
return false when compared using the equals method. Or better yet, I suppose
I can use List's contains method with my list of loop statements to test
whether a retrieved statement (from getUsesOf) is in my list of loop
statements. That should work because the contains method relies on the
equals method.

Does it sound like I'm on the right track?

Thanks,
John

-----Original Message-----
From: phil.pratt.szeliga at gmail.com [mailto:phil.pratt.szeliga at gmail.com] On
Behalf Of Phil Pratt-Szeliga
Sent: Friday, July 27, 2012 11:58 AM
To: john.dean at park.edu
Cc: Cheng Zhang; soot-list at sable.mcgill.ca
Subject: Re: [Soot-list] How to determine whether there exists a use for a
variable definition later on in the cfg

John,

You could try to use code from here [1] to detect loops and then do equality
comparisons.

Phil Pratt-Szeliga
Syracuse University

[1]
https://bitbucket.org/pcpratts/cfg_array/src/72bf281c1adf/version4/Analyzer/
src/edu/syr/pcpratts/useproto/analyzer/loops

On Fri, Jul 27, 2012 at 12:50 PM, John Dean <jdean4 at kc.rr.com> wrote:
> Thanks, Cheng!
>
>
>
> Anyone (including Cheng, of course),
>
> If I use SimpleLocalUses.getUsesOf(unit), according to the api, it 
> retrieves a list of units that use the definition in the unit arg, but 
> I need to know where the retrieved units come from (specifically, I 
> need to know if any of them come from outside the loop that contains 
> the variable's definition). I know the blocks and statements that are 
> inside the loop, but I don't know how to tell whether the units 
> retrieved from SimpleLocalUses.getUsesOf(unit) are in the loop's blocks or
in outside blocks.
>
>
>
> Suggestions?
>
>
>
> Thanks,
>
> John
>
>
>
> From: Cheng Zhang [mailto:cheng.zhang.stap at gmail.com]
> Sent: Friday, July 27, 2012 10:38 AM
> To: john.dean at park.edu
> Cc: soot-list at sable.mcgill.ca
> Subject: Re: [Soot-list] How to determine whether there exists a use 
> for a variable definition later on in the cfg
>
>
>
> Hi John,
>
>
>
> You may use the existing classes, like SimpleLocalDefs or 
> SmartLocalDefs, to do your work.
>
>
>
> Best,
>
> Cheng
>
>
>
> On Fri, Jul 27, 2012 at 11:16 PM, John Dean <jdean4 at kc.rr.com> wrote:
>
> Hi all,
>
> For a given instruction's definition within a loop, I need to 
> determine whether there exists a use for that definition outside of 
> the loop. By "definition," I mean a variable is assigned a value. By 
> "use," I mean the variable is accessed at some later point in the flow of
the method's CFG.
> I've already been able to gather the instructions in a loop, so I 
> don't need help with that.
>
> I've looked through the soot api, and the only strategy I can come up 
> with is to find all the instructions in the cfg that might follow the 
> variable definition's instruction (while ignoring the instructions in 
> the loop, of course). And to do that, I would call 
> cfg.getSuccsOf(unit) recursively and avoid infinite recursive loops by 
> storing all the found instructions in a list and only adding new
instructions if they're not in the list already.
>
> That seems like a lot of work on my part, and I don't want to reinvent 
> the wheel if there's a better way. Any suggestions?
>
> Thanks,
> john
>
> _______________________________________________
> Soot-list mailing list
> Soot-list at sable.mcgill.ca
> http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
>
>



More information about the Soot-list mailing list