[Soot-list] About accessing local variables in soot

David Mohr dmohr at cs.unm.edu
Fri Oct 2 17:03:23 EDT 2009


On Fri, Oct 2, 2009 at 6:15 AM, LuoQingZhou <seriousamlqz at yahoo.cn> wrote:
>
> Hi guys,
>
> I have some questions about accessing local variables in a method.
>
> The first one is there a way of instrumentation to get all values of local variables of a method at run time? And then reset those local variables in the next run? Seems impossible cause maybe it will violate the security constraints of JVM, but I'm not sure...

Sorry, I don't quite understand what you are trying to do. What
defines "the next run"?

> The second is, with the option -p jb use-orginal-names, how does soot do when there are two identical local variables in different scope? For example
>
>   {
>    String a = new String ("a");
>    System.out.println(a);
>
>   }
>   String a = new String ("b");
>   System.out.println(a);
>
> In this code snippet I use body.getLocals() to see all locals, and there is only one 'a':
>
> Local name: a
> Local type: java.lang.String
>
> (When the second 'a' is changed to another type, it would list all those two 'a')

I looked into this issue and the reason can be found by inspecting the
byte code that gets generated for the example above. There really is
only one local variable, the java compiler seems to "reuse" the first
definition of a. I think in one of my test cases that even happened
when a later had a different type - probably because it had the same
storage size, but I'm not 100% certain right now.

~David


More information about the Soot-list mailing list