[Soot-list] LineNumber tag in Dava

David A Weiser DWEISER at uwyo.edu
Fri Mar 9 16:18:06 EST 2007


Is there a way to access lineNumbers in Dava?

I have the following bites of code when I'm traversing a Dava AST:

public void caseDefinitionStmt(DefinitionStmt s) {
	 //find all the use boxes that are only one variable
		 Iterator ubIt = s.getUseBoxes().iterator();
		 ArrayList varList = new ArrayList();
		 while(ubIt.hasNext()){
			 ValueBox vb = (ValueBox)ubIt.next();
			 if(vb.getValue().getUseBoxes().size() == 1){
				 getLineNumberFromVB(vb);
				 varList.add(vb);
			 }
		 }
.
.
.
}

private void getLineNumberFromVB(ValueBox vb) {
		LineNumberTag tag = (LineNumberTag)vb.getTag("LineNumberTag");
		 if (tag != null){
			 this.lineNumber = tag.getLineNumber();
			 this.testmsg("got a lineNumber: "+this.lineNumber);
		 }
		 else{
			 this.testmsg("failed to get linenumber in DefStmt");
		 }
}

Should I not be using ValueBoxes to get the linenumber?

Here's my main function that calls soot.Main:

  public static void main(String[] args) {
        soot.options.Options.v().setPhaseOption("cg", "verbose:true");
       
                
        soot.options.Options.v().set_keep_line_number(true);
        
        soot.options.Options.v().set_app(true);
        soot.options.Options.v().set_output_format(soot.options.Options.v().output_format_dava);

        soot.Main.main(args);

    }

What am I missing?
Dave

-----Original Message-----
From: soot-list-request at sable.mcgill.ca [mailto:soot-list-request at sable.mcgill.ca] 
Sent: Wednesday, February 28, 2007 6:44 PM
To: soot-list at sable.mcgill.ca
Subject: Soot-list Digest, Vol 22, Issue 24

Send Soot-list mailing list submissions to
	soot-list at sable.mcgill.ca

To subscribe or unsubscribe via the World Wide Web, visit
	http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
or, via email, send a message with subject or body 'help' to
	soot-list-request at sable.mcgill.ca

You can reach the person managing the list at
	soot-list-owner at sable.mcgill.ca

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Soot-list digest..."


Today's Topics:

   1. Re: Exception during "Using Soot as a Program Optimizer"
      tutorial (Eric Bodden)
   2. Re: Exception during "Using Soot as a Program Optimizer"
      tutorial (Ryan Rueth)


----------------------------------------------------------------------

Message: 1
Date: Wed, 28 Feb 2007 20:33:19 -0500
From: "Eric Bodden" <eric.bodden at mail.mcgill.ca>
Subject: Re: [Soot-list] Exception during "Using Soot as a Program
	Optimizer"	tutorial
To: "Ryan Rueth" <rrueth at gmail.com>
Cc: Soot list <soot-list at sable.mcgill.ca>
Message-ID:
	<804e3c660702281733q2edbea7bi9688e2908051117a at mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Ok, I just found out the following:

The "Scanner" class, which you were missing first, is in the polyglot
jar file. The "jasmin.Main" class is obviously part of Jasmin. So the
following works for me:

soy ~/temp $ java -cp
sootclasses-2.2.3.jar:jasminclasses-2.2.3.jar:polyglotclasses-1.3.2.jar:.
soot.Main -O Hello
Soot started on Wed Feb 28 20:31:05 EST 2007
Transforming Hello...
Writing to sootOutput/Hello.class
Soot finished on Wed Feb 28 20:31:07 EST 2007
Soot has run for 0 min. 1 sec.

On 2/28/07, Eric Bodden <eric.bodden at mail.mcgill.ca> wrote:
> Ok, I just found out the following:
>
> The "Scanner" class, which you were missing first, is in the polyglot
> jar file. The "jasmin.Main" class is obviously part of Jasmin. So the
> following works for me:
>
> soy ~/temp $ java -cp
> sootclasses-2.2.3.jar:jasminclasses-2.2.3.jar:polyglotclasses-1.3.2.jar:.
> soot.Main -O Hello
> Soot started on Wed Feb 28 20:31:05 EST 2007
> Transforming Hello...
> Writing to sootOutput/Hello.class
> Soot finished on Wed Feb 28 20:31:07 EST 2007
> Soot has run for 0 min. 1 sec.
>
> Eric
>
> On 2/28/07, Ryan Rueth <rrueth at gmail.com> wrote:
> > I tried running Soot with the java -cp set as you said, but then I received
> > the following exception:
> >
> > sslab04 [~/Soot/Soot_Tutorials/intro] > java -cp
> > /homes/rrueth/Soot/sootclasses-2.2.3.jar:. soot.Main -O Hello
> >  Soot started on Wed Feb 28 20:07:03 EST 2007
> > Transforming Hello...
> > Writing to sootOutput/Hello.class
> > Exception in thread "main" java.lang.NoClassDefFoundError: jasmin/Main
> >         at soot.util.JasminOutputStream.flush
> > (JasminOutputStream.java:35)
> >         at
> > sun.nio.cs.StreamEncoder$CharsetSE.implFlush(StreamEncoder.java:410)
> >         at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:152)
> >         at java.io.OutputStreamWriter.flush
> > (OutputStreamWriter.java:213)
> >         at java.io.PrintWriter.flush(PrintWriter.java:270)
> >         at soot.PackManager.writeClass(PackManager.java:812)
> >         at soot.PackManager.writeOutput(PackManager.java:408)
> >          at soot.PackManager.writeOutput(PackManager.java:360)
> >         at soot.Main.run(Main.java:204)
> >         at soot.Main.main(Main.java:146)
> >
> > Which is why I originally added
> > /homes/rrueth/Soot/jasminclasses- 2.2.3.jar to my
> > classpath.  So, I tried to run Soot again with:
> >
> > java -cp
> > /homes/rrueth/Soot/sootclasses-2.2.3.jar:/homes/rrueth/Soot/jasminclasses-2.2.3.jar:.
> > soot.Main -O Hello
> >
> > But then I received the same java_cups/runtime/Scanner exception again.
> >
> > Thanks,
> > Ryan
> >
> >
> > On 2/28/07, Eric Bodden <eric.bodden at mail.mcgill.ca> wrote:
> > > This has to be a classpath issue. I assume your JVM gets confused
> > > because you have JAR files with a potentially overlapping but
> > > inconsistent set of classes on your classpath.
> > >
> > > Could you try with this command line?
> > >
> > > java -cp /homes/rrueth/Soot/sootclasses- 2.2.3.jar:. soot.Main -O Hello
> > >
> > > Eric
> > >
> > > On 2/28/07, Ryan Rueth <rrueth at gmail.com> wrote:
> > > > I'm currently trying to get acquainted with Soot; and thus, I'm starting
> > to
> > > > run through some of the posted tutorials.  Upon executing "java
> > soot.Main -O
> > > > Hello" at the beginning of the "Using Soot as a Program Optimizer"
> > tutorial,
> > > > I received the below exception.  I've also displayed my CLASSPATH
> > settings
> > > > at the bottom of the page as well.  Does anyone know what might be going
> > > > wrong here?
> > > >
> > > > Thanks,
> > > > Ryan
> > > >
> > > > sslab04 [~/Soot/Soot_Tutorials/intro] > java soot.Main -O Hello
> > > > Soot started on Wed Feb 28 19:35:20 EST 2007
> > > > Transforming Hello...
> > > > Writing to sootOutput/Hello.class
> > > > Exception in thread "main" java.lang.NoClassDefFoundError:
> > > > java_cup/runtime/Scanner
> > > >         at java.lang.ClassLoader.defineClass1(Native
> > > > Method)
> > > >         at
> > > > java.lang.ClassLoader.defineClass(ClassLoader.java:620)
> > > >         at java.security.SecureClassLoader.defineClass
> > > > (SecureClassLoader.java:124)
> > > >         at
> > > >
> > java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
> > > >         at
> > > >
> > java.net.URLClassLoader.access$100(URLClassLoader.java:56)
> > > >         at java.net.URLClassLoader$1.run( URLClassLoader.java:195)
> > > >         at
> > > > java.security.AccessController.doPrivileged(Native
> > Method)
> > > >         at
> > > > java.net.URLClassLoader.findClass(URLClassLoader.java
> > :188)
> > > >         at java.lang.ClassLoader.loadClass(ClassLoader.java :306)
> > > >         at
> > > >
> > sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
> > > >         at java.lang.ClassLoader.loadClass(ClassLoader.java :251)
> > > >         at
> > > >
> > java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
> > > >         at jasmin.ClassFile.readJasmin(ClassFile.java:1045)
> > > >         at jasmin.Main.assemble(Main.java:24)
> > > >         at
> > > >
> > soot.util.JasminOutputStream.flush(JasminOutputStream.java:35)
> > > >         at sun.nio.cs.StreamEncoder$CharsetSE.implFlush
> > > > (StreamEncoder.java:410)
> > > >         at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java :152)
> > > >         at
> > > >
> > java.io.OutputStreamWriter.flush(OutputStreamWriter.java:213)
> > > >         at java.io.PrintWriter.flush(PrintWriter.java :270)
> > > >         at soot.PackManager.writeClass(PackManager.java :812)
> > > >         at soot.PackManager.writeOutput(PackManager.java:408)
> > > >         at soot.PackManager.writeOutput(PackManager.java:360)
> > > >         at soot.Main.run (Main.java:204)
> > > >         at soot.Main.main (Main.java:146)
> > > > sslab04 [~/Soot/Soot_Tutorials/intro] >
> > > > sslab04 [~/Soot/Soot_Tutorials/intro] > echo $CLASSPATH
> > > > .:/homes/cs352/.classes:/homes/rrueth/Soot/sootclasses-
> > > >
> > 2.2.3.jar:/homes/rrueth/Soot/jasminclasses-2.2.3.jar:/homes/rrueth/polygotclasses-1.3.2.jar:./opt/sun-jdk-1.5.0.06/lib/rt.jar
> > > > sslab04 [~/Soot/Soot_Tutorials/intro] >
> > > > sslab04 [~/Soot/Soot_Tutorials/intro] >
> > > >
> > > >
> > > > _______________________________________________
> > > > Soot-list mailing list
> > > > Soot-list at sable.mcgill.ca
> > > > http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
> > > >
> > > >
> > >
> > >
> > > --
> > > Eric Bodden
> > > Sable Research Group
> > > McGill University, Montréal, Canada
> > >
> >
> >
>
>
> --
> Eric Bodden
> Sable Research Group
> McGill University, Montréal, Canada
>


-- 
Eric Bodden
Sable Research Group
McGill University, Montréal, Canada


------------------------------

Message: 2
Date: Wed, 28 Feb 2007 20:44:06 -0500
From: "Ryan Rueth" <rrueth at gmail.com>
Subject: Re: [Soot-list] Exception during "Using Soot as a Program
	Optimizer"	tutorial
To: "Eric Bodden" <eric.bodden at mail.mcgill.ca>
Cc: Soot list <soot-list at sable.mcgill.ca>
Message-ID:
	<7d5710350702281744y70f52fedy15b0bdf433151dd at mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

Thanks Eric.  It looks like I was just missing an "l" in "polyglotclasses"
in my classpath.  Everything works now.

Thanks again,
Ryan

On 2/28/07, Eric Bodden <eric.bodden at mail.mcgill.ca> wrote:
>
> Ok, I just found out the following:
>
> The "Scanner" class, which you were missing first, is in the polyglot
> jar file. The "jasmin.Main" class is obviously part of Jasmin. So the
> following works for me:
>
> soy ~/temp $ java -cp
> sootclasses-2.2.3.jar:jasminclasses-2.2.3.jar:polyglotclasses-1.3.2.jar:.
> soot.Main -O Hello
> Soot started on Wed Feb 28 20:31:05 EST 2007
> Transforming Hello...
> Writing to sootOutput/Hello.class
> Soot finished on Wed Feb 28 20:31:07 EST 2007
> Soot has run for 0 min. 1 sec.
>
> On 2/28/07, Eric Bodden <eric.bodden at mail.mcgill.ca> wrote:
> > Ok, I just found out the following:
> >
> > The "Scanner" class, which you were missing first, is in the polyglot
> > jar file. The "jasmin.Main" class is obviously part of Jasmin. So the
> > following works for me:
> >
> > soy ~/temp $ java -cp
> > sootclasses-2.2.3.jar:jasminclasses-2.2.3.jar:polyglotclasses-1.3.2.jar:
> .
> > soot.Main -O Hello
> > Soot started on Wed Feb 28 20:31:05 EST 2007
> > Transforming Hello...
> > Writing to sootOutput/Hello.class
> > Soot finished on Wed Feb 28 20:31:07 EST 2007
> > Soot has run for 0 min. 1 sec.
> >
> > Eric
> >
> > On 2/28/07, Ryan Rueth <rrueth at gmail.com> wrote:
> > > I tried running Soot with the java -cp set as you said, but then I
> received
> > > the following exception:
> > >
> > > sslab04 [~/Soot/Soot_Tutorials/intro] > java -cp
> > > /homes/rrueth/Soot/sootclasses-2.2.3.jar:. soot.Main -O Hello
> > >  Soot started on Wed Feb 28 20:07:03 EST 2007
> > > Transforming Hello...
> > > Writing to sootOutput/Hello.class
> > > Exception in thread "main" java.lang.NoClassDefFoundError: jasmin/Main
> > >         at soot.util.JasminOutputStream.flush
> > > (JasminOutputStream.java:35)
> > >         at
> > > sun.nio.cs.StreamEncoder$CharsetSE.implFlush(StreamEncoder.java:410)
> > >         at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:152)
> > >         at java.io.OutputStreamWriter.flush
> > > (OutputStreamWriter.java:213)
> > >         at java.io.PrintWriter.flush(PrintWriter.java:270)
> > >         at soot.PackManager.writeClass(PackManager.java:812)
> > >         at soot.PackManager.writeOutput(PackManager.java:408)
> > >          at soot.PackManager.writeOutput(PackManager.java:360)
> > >         at soot.Main.run(Main.java:204)
> > >         at soot.Main.main(Main.java:146)
> > >
> > > Which is why I originally added
> > > /homes/rrueth/Soot/jasminclasses- 2.2.3.jar to my
> > > classpath.  So, I tried to run Soot again with:
> > >
> > > java -cp
> > > /homes/rrueth/Soot/sootclasses-
> 2.2.3.jar:/homes/rrueth/Soot/jasminclasses-2.2.3.jar:.
> > > soot.Main -O Hello
> > >
> > > But then I received the same java_cups/runtime/Scanner exception
> again.
> > >
> > > Thanks,
> > > Ryan
> > >
> > >
> > > On 2/28/07, Eric Bodden <eric.bodden at mail.mcgill.ca> wrote:
> > > > This has to be a classpath issue. I assume your JVM gets confused
> > > > because you have JAR files with a potentially overlapping but
> > > > inconsistent set of classes on your classpath.
> > > >
> > > > Could you try with this command line?
> > > >
> > > > java -cp /homes/rrueth/Soot/sootclasses- 2.2.3.jar:. soot.Main -O
> Hello
> > > >
> > > > Eric
> > > >
> > > > On 2/28/07, Ryan Rueth <rrueth at gmail.com> wrote:
> > > > > I'm currently trying to get acquainted with Soot; and thus, I'm
> starting
> > > to
> > > > > run through some of the posted tutorials.  Upon executing "java
> > > soot.Main -O
> > > > > Hello" at the beginning of the "Using Soot as a Program Optimizer"
> > > tutorial,
> > > > > I received the below exception.  I've also displayed my CLASSPATH
> > > settings
> > > > > at the bottom of the page as well.  Does anyone know what might be
> going
> > > > > wrong here?
> > > > >
> > > > > Thanks,
> > > > > Ryan
> > > > >
> > > > > sslab04 [~/Soot/Soot_Tutorials/intro] > java soot.Main -O Hello
> > > > > Soot started on Wed Feb 28 19:35:20 EST 2007
> > > > > Transforming Hello...
> > > > > Writing to sootOutput/Hello.class
> > > > > Exception in thread "main" java.lang.NoClassDefFoundError:
> > > > > java_cup/runtime/Scanner
> > > > >         at java.lang.ClassLoader.defineClass1(Native
> > > > > Method)
> > > > >         at
> > > > > java.lang.ClassLoader.defineClass(ClassLoader.java:620)
> > > > >         at java.security.SecureClassLoader.defineClass
> > > > > (SecureClassLoader.java:124)
> > > > >         at
> > > > >
> > > java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
> > > > >         at
> > > > >
> > > java.net.URLClassLoader.access$100(URLClassLoader.java:56)
> > > > >         at java.net.URLClassLoader$1.run( URLClassLoader.java:195)
> > > > >         at
> > > > > java.security.AccessController.doPrivileged(Native
> > > Method)
> > > > >         at
> > > > > java.net.URLClassLoader.findClass(URLClassLoader.java
> > > :188)
> > > > >         at java.lang.ClassLoader.loadClass(ClassLoader.java :306)
> > > > >         at
> > > > >
> > > sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
> > > > >         at java.lang.ClassLoader.loadClass(ClassLoader.java :251)
> > > > >         at
> > > > >
> > > java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
> > > > >         at jasmin.ClassFile.readJasmin(ClassFile.java:1045)
> > > > >         at jasmin.Main.assemble(Main.java:24)
> > > > >         at
> > > > >
> > > soot.util.JasminOutputStream.flush(JasminOutputStream.java:35)
> > > > >         at sun.nio.cs.StreamEncoder$CharsetSE.implFlush
> > > > > (StreamEncoder.java:410)
> > > > >         at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java :152)
> > > > >         at
> > > > >
> > > java.io.OutputStreamWriter.flush(OutputStreamWriter.java:213)
> > > > >         at java.io.PrintWriter.flush(PrintWriter.java :270)
> > > > >         at soot.PackManager.writeClass(PackManager.java :812)
> > > > >         at soot.PackManager.writeOutput(PackManager.java:408)
> > > > >         at soot.PackManager.writeOutput(PackManager.java:360)
> > > > >         at soot.Main.run (Main.java:204)
> > > > >         at soot.Main.main (Main.java:146)
> > > > > sslab04 [~/Soot/Soot_Tutorials/intro] >
> > > > > sslab04 [~/Soot/Soot_Tutorials/intro] > echo $CLASSPATH
> > > > > .:/homes/cs352/.classes:/homes/rrueth/Soot/sootclasses-
> > > > >
> > >
> 2.2.3.jar:/homes/rrueth/Soot/jasminclasses-2.2.3.jar:/homes/rrueth/polygotclasses-1.3.2.jar:./opt/sun-jdk-1.5.0.06/lib/rt.jar
> > > > > sslab04 [~/Soot/Soot_Tutorials/intro] >
> > > > > sslab04 [~/Soot/Soot_Tutorials/intro] >
> > > > >
> > > > >
> > > > > _______________________________________________
> > > > > Soot-list mailing list
> > > > > Soot-list at sable.mcgill.ca
> > > > > http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
> > > > >
> > > > >
> > > >
> > > >
> > > > --
> > > > Eric Bodden
> > > > Sable Research Group
> > > > McGill University, Montréal, Canada
> > > >
> > >
> > >
> >
> >
> > --
> > Eric Bodden
> > Sable Research Group
> > McGill University, Montréal, Canada
> >
>
>
> --
> Eric Bodden
> Sable Research Group
> McGill University, Montréal, Canada
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.CS.McGill.CA/pipermail/soot-list/attachments/20070228/3996e09a/attachment.htm

------------------------------

_______________________________________________
Soot-list mailing list
Soot-list at sable.mcgill.ca
http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list


End of Soot-list Digest, Vol 22, Issue 24
*****************************************


More information about the Soot-list mailing list