[Soot-list] How to get the type of locals in a FlowAnalysis?

Eric Bodden bodden at st.informatik.tu-darmstadt.de
Wed Jun 23 05:18:01 EDT 2010


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
>


More information about the Soot-list mailing list