[Soot-list] Def Use analysis on Groovy Classes (Bytecode)
Eric Bodden
eric.bodden at ec-spride.de
Wed Sep 12 14:50:53 EDT 2012
Hello.
I think this is rather a question for the Groovy list. It's an issue
with the Groovy compiler, not an issue that Soot could solve.
On another note: why do you need line numbers to compute def-use chains?
Cheers,
Eric
On 11 September 2012 20:29, Pauline Anthonysamy
<anthonys at comp.lancs.ac.uk> wrote:
> Hello Everyone,
>
> I implemented a method which generates def - use chain for a method. Below
> is my method:
>
> private HashMap<Integer, HashSet<Integer>> getDUChains(SootMethod m) {
> HashMap<Integer, HashSet<Integer>> duChains = new HashMap<Integer,
> HashSet<Integer>>();
>
> Body b = m.retrieveActiveBody();
> UnitGraph graph = new CompleteUnitGraph(b);
> SimpleLiveLocals s = new SimpleLiveLocals(graph);
>
> Iterator<Unit> gIt = graph.iterator();
>
> // generate du-pairs
> while (gIt.hasNext()) {
> Unit defUnit = gIt.next();
>
> SmartLocalDefs des = new SmartLocalDefs(graph, s); // defs of
> local variables
> SimpleLocalUses uses = new SimpleLocalUses(graph, des);
>
> List<UnitValueBoxPair> ul = uses.getUsesOf(defUnit);
> if (ul != null && ul.size() != 0) {
> // defs in this unit have some uses
> int defLine =
> Integer.parseInt(defUnit.getTag("LineNumberTag").toString());
> HashSet<Integer> useLines = duChains.get(defLine); // save
> my use lines
> if (useLines == null) {
> useLines = new HashSet<Integer>();
> }
>
> // all uses lines here
> for (UnitValueBoxPair vbp : ul) {
> String use =
> vbp.getUnit().getTag("LineNumberTag").toString(); //
> useLines.add(Integer.parseInt(use));
> }
>
> duChains.put(defLine, useLines);
> }
> }
> return duChains;
> }
>
>
> The method works for Java classes but not on Groovy as the
> "defUnit.getTag("LineNumberTag").toString()" throws a NullPointerException.
> I remember reading somewhere that Groovy Bytecode does not keep the source
> code line numbers. Is this true? If yes, is there a way to get pass this? I
> am not sure how I can proceed from here. Any help would be very much
> appreciated!
>
> Many Thanks,
> -Pauline
>
> --
> Pauline Anthonysamy
> PhD Candidate
>
> Lancaster University
> Lancaster, United Kingdom
>
> Email: anthonys at comp.lancs.ac.uk
> Phone: +44 (01524) 510346
> WWW: http://www.comp.lancs.ac.uk/~anthonys
>
>
>
> _______________________________________________
> Soot-list mailing list
> Soot-list at sable.mcgill.ca
> http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
>
--
Eric Bodden, Ph.D., http://sse.ec-spride.de/ http://bodden.de/
Head of Secure Software Engineering Group at EC SPRIDE
Tel: +49 6151 16-75422 Fax: +49 6151 16-72051
Room 3.2.14, Mornewegstr. 30, 64293 Darmstadt
More information about the Soot-list
mailing list