[Soot-list] How to modify soot method to generate this kind of IR code?

DING SUN xyz031702 at hotmail.com
Wed Jun 23 08:05:29 EDT 2010


Dear All
     I'm using soot (I'm using Jimple format) for inter-procedure analysis 
(forward sequence). I met a case:
void main(){
   int p1=2;
   int p2=3;
   int result= f1( f2(p1), f3(p2));

}

f1(int x, int y), f2(int x), f3(int x) are all normal functions.

If I want to analysis f1(), I must known its parameters' actual values, 
which are return values from f2() and f3() respectively.

So I think the proper call sequence shall be :  main--> 
f2()-->main-->f3() --> main-->f1()-->main()
In another word, is it possible to transform the above piece of code into 
the following IR code ?:

void main(){
   int p1=2;
   int p2=3;
   int f1p1=f2(p1);
   int f1p2=f3(p2);
   int result= f1( f1p1, f1p2);
}

Would you suggest me a good way to solve this?

Best Regards,
Ding Sun
--------------------------------------------------
From: "Eric Bodden" <bodden at st.informatik.tu-darmstadt.de>
Sent: Wednesday, June 23, 2010 5:18 PM
To: "Jochen Wuttke" <wuttkej at usi.ch>
Cc: <soot-list at sable.mcgill.ca>
Subject: Re: [Soot-list] How to get the type of locals in a FlowAnalysis?

> Hi Jochen.
>
> The problem is that in bytecode different primitive type are mangled
> together: byte, short, boolean and int all become int in bytecode.
> Soot therefore includes a special range analysis that attempts to
> re-construct the best, i.e. most narrow type possible. Sometimes this
> analysis may be too good and give you a type that is more narrow than
> the one that was in the original source code.
>
> Would it be possible for you to analyze the program's source code,
> instead of the bytecode? I am reasonably sure that in this case Soot
> will just use the exact types that it finds in the source.
>
> Eric
>
> P.S. Sorry but I know nothing about the AST metrics.
>
> --
> Dr. 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
>
>
>
> On 23 June 2010 10:03, Jochen Wuttke <wuttkej at usi.ch> wrote:
>> Hi,
>>
>> I'm trying to build a very simple analysis that effectively counts the
>> number and type of local variables occurring in a method.
>> I tried to use the normal ExceptionalUnitGraph to extract this
>> information. However, when I run the analysis on the following method,
>> the variable 'x' is reported to have type 'byte', not 'int'. Guessing
>> from the documentation of some of the phase options to Soot, it looks
>> like the standard type assigner does not care about the declared type
>> of locals, but tries to infer the minimum size the actually values fit
>> in. So in my case, byte rather than int, because I only assign a small
>> numeric value.
>>
>> After digging a little in the API of Soot I saw that there is a
>> package soot.tootlkits.astmetrics that seems to contain a bunch of
>> things working on the AST provided by Polyglot. Is there a way that I
>> can hook up my own AST metric and run it together with the others? I
>> guess that could solve my problem?
>>
>> Thanks for any advice,
>> Jochen
>>
>>
>>        public void hasOnlyPrimitives() {
>>                int x = 9;
>>                long y = 0;
>>                x++;
>>                y += x;
>>        }
>>
>> _______________________________________________
>> Soot-list mailing list
>> Soot-list at sable.mcgill.ca
>> http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
>>
> _______________________________________________
> 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