[Soot-list] Obtaining the JimpleLocal from a ValueBox

Andrew Santosa santosa_1999 at yahoo.com
Thu Oct 1 07:53:29 EDT 2015


Java variable name information is not even included in the bytecode when compiled without-g:vars option; see Java Reflection: How to get the name of a variable?

|   |
|   |  |   |   |   |   |   |
| Java Reflection: How to get the name of a variable?Using Java Reflection, is it possible to get the name of a local variable? For example, if I have this: Foo b = new Foo(); Foo a = new Foo(); Foo r = new Foo(); is ... |
|  |
| View on stackoverflow.com | Preview by Yahoo |
|  |
|   |

 I don't know enough to be able to tell if Soot can take advantage of Java variable names in thebytecode whenever they are available for creating Jimple code with Java variable names. It seems
it might be not too complicated to support this feature in the future if it's not already supported.
The expression "a * b" in balloon in Eclipse in Figure 5 of the Soot Survivor's Guide http://www.brics.dk/SootGuide/sootsurvivorsguide.pdf seems to suggest that it is possibleto obtain Java variable names for annotating the bytecode. However, as yet I am not ableto run Soot's Eclipse plugin and I do not know how Eclipse plugins work.
Best,Andrew

     On Thursday, 1 October 2015, 8:43, Jason Ott <jott002 at ucr.edu> wrote:
   

 One last question regarding this topic:
In the native Java, "getFlashlightEnabled()" looks like this:public boolean getFlashlightEnabled() {    try {        FileInputStream fis = new FileInputStream(FLASHLIGHT_FILE);        int result = fis.read();        fis.close();        return (result != '0');    } catch (Exception e) {        return false;    }}
Now, I know I can get the value of $r3 without a problem, but is there any way for me to get the *java variable name*(fis) and not the jimple name ($r3)?  My gut is no, as that is lost by the jimple conversion.  I've looked at baf, shimple, and gimple, and they all seem to lose the Java-based variable name in the conversion.
Thanks,Jason
On Wed, Sep 30, 2015 at 9:25 AM, Jason Ott <jott002 at ucr.edu> wrote:

You are correct.  Thank you.  I'm not sure how I missed that; I have the code that outputs that exact information.
On Wed, Sep 30, 2015 at 1:06 AM, Andrew Santosa <santosa_1999 at yahoo.com> wrote:

Given invkExpr of type InvokeExprBox is the invocation expression of the special invocation statement,
we can obtain the list of use boxes within the expression in the following way:
List<ValueBox> boxesList = invkExpr.getValue().getUseBoxes();
One of the boxes in boxesList should be the local that you want.
Best,
Andrew
 


     On Wednesday, 30 September 2015, 10:38, Jason Ott <jott002 at ucr.edu> wrote:
   

 I have the following Jimple:
 public boolean getFlashlightEnabled()    {        com.android.server.lights.LightsService$1 r0;        int i0;        java.io.FileInputStream $r1, r3; // I'm interested in this        java.lang.Exception $r2;        boolean $z0;        r0 := @this: com.android.server.lights.LightsService$1;     label1:        $r1 = new java.io.FileInputStream;        specialinvoke $r1.<java.io.FileInputStream: void <init>(java.lang.String)>("/sys/class/leds/spotlight/brightness");  // But my interest in $r1 and r3 are predicated upon this        r3 = $r1;        i0 = virtualinvoke r3.<java.io.FileInputStream: int read()>();        virtualinvoke r3.<java.io.FileInputStream: void close()>();        if i0 == 48 goto label2;        $z0 = 1;        goto label3;     label2:        $z0 = 0;     label3:        return $z0;     label4:        $r2 := @caughtexception;        return 0;        catch java.lang.Exception from label1 to label3 with label4;    }
You can see that I am interested in the variable that, in some way or another, uses the "/sys/class/leds/spotlight/brightness" string.  Thus, I am interested in the variable $r1.  But I don't know that I'm interested in $r1 until I see that $r1 is using the string that I am interested.
Now I know that $r1 is a local, more specifically a LinkedRValueBox.  I know that the string, "/sys/class/..." is an ImmediateBox, which is leveraged in an InvokeExprBox (specialinvoke $r1...).  What I cannot seem to manage to figure out is how to derive the Local $r1 variable from either the InvokeExprBox or the ImmediateBox.  Neither of them have any formal link to $r1 (a Local) other than by parsing the string representation of them and then going through the Locals looking for what you want.
So my question is: Is there a way to get the Local from the InvokeExprBox or the ImmediateBox in this case, or the general case?  I can only get ValueBoxes from anything which is of ValueBox, as defined by the ValueBox interface.
Thanks.
_______________________________________________
Soot-list mailing list
Soot-list at CS.McGill.CA
https://mailman.CS.McGill.CA/mailman/listinfo/soot-list


   





  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://mailman.CS.McGill.CA/pipermail/soot-list/attachments/20151001/68e18415/attachment.html 


More information about the Soot-list mailing list