[Soot-list] Re: Question about Soot Eclipse plugin

Yonghee Shin yshin2 at ncsu.edu
Tue Jun 5 23:58:46 EDT 2007


Thanks. It works now. However, I added the src directory to the 
classpath of Eclipse project, not in the plugin.xml file.
When I followed the explanation in 
http://www.sable.mcgill.ca/soot/eclipse/different-main.html, Soot didn't 
include the new classpath defined in the plugin.xml.

Yonghee

Ondrej Lhotak wrote:
> The 0's for spos and epos suggest that Soot is processing .class files
> rather than the .java source files. spos and epos indicate the column
> positions in which a tag should be displayed. A .class file contains
> information about the source line from which each expression was
> compiled, but not the column, which is why Soot sets them to zero.
>
> In order for Soot to process the .java source files, they must be
> available on the Soot classpath. You need to give Soot a --cp option
> listing the directories in which the source files are found. As you can
> see, the Eclipse plugin does this for you if you execute Soot using
> the dialog: the --cp entry below includes the directory 
> Z:\projects\projects-soot\AddAttributes\src
>
> The intended way to execute Soot-based tools that have their own main
> class from within Eclipse is to still use the Soot dialog, but specify
> the new main class in the Soot Main Class page of the dialog. See:
> http://www.sable.mcgill.ca/soot/eclipse/different-main.html
>
> On Mon, Jun 04, 2007 at 11:12:43PM -0400, Yonghee Shin wrote:
>   
>> Dear Dr. Lhotak,
>>
>> Thanks for your reply.
>>
>> First I checked the npcoloror option in the soot configuration dialog for
>> Foo.java file and the soot command displayed in the sootoutput window
>> within Eclipse is as follows:
>> ---------
>> Starting ...soot.Main --d
>> Z:\projects\projects-soot\AddAttributes\sootOutput --src-prec java --p
>> jap.npcolorer enabled:true --xml-attributes --cp
>> Z:\projects\projects-soot\AddAttributes\src;C:\Program
>> Files\Java\jre1.5.0_07\lib\rt.jar;C:\Program
>> Files\Java\jre1.5.0_07\lib\jsse.jar;C:\Program
>> Files\Java\jre1.5.0_07\lib\jce.jar;C:\Program
>> Files\Java\jre1.5.0_07\lib\charsets.jar;C:\Program
>> Files\Java\jre1.5.0_07\lib\ext\dnsns.jar;C:\Program
>> Files\Java\jre1.5.0_07\lib\ext\localedata.jar;C:\Program
>> Files\Java\jre1.5.0_07\lib\ext\QTJava.zip;C:\Program
>> Files\Java\jre1.5.0_07\lib\ext\sunjce_provider.jar;C:\Program
>> Files\Java\jre1.5.0_07\lib\ext\sunpkcs11.jar;C:\eclipse322\plugins\ca.mcgill.sable.soot_2.2.2\jasminclasses-2.2.2.jar;C:\eclipse322\plugins\ca.mcgill.sable.soot_2.2.2\polyglotclasses-1.3.2.jar;C:\eclipse322\plugins\ca.mcgill.sable.soot_2.2.2\sootclasses-2.2.2.jar;C:\eclipse322\plugins\ca.mcgill.sable.soot_2.2.2\soot-plugin.jar
>> --f J --keep-line-number Foo
>> Soot started on Mon Jun 04 23:05:04 EDT 2007
>> Transforming Foo...
>> Writing to Z:\projects\projects-soot\AddAttributes\sootOutput\Foo.jimple
>> Soot finished on Mon Jun 04 23:05:04 EDT 2007
>> Soot has run for 0 min. 0 sec.
>>
>> ---------
>>
>> The coloring worked correctly in this case. I attached the xml file
>> generated (Foo_EclipseDialog.xml).
>>
>> Then, instead of using soot configuration dialog, I made a separate Main
>> class to call the npcolorer in the main class
>> (NullPointerColorerMain.java) and ran the main class within Eclipse with
>> the following options:  "--src-prec java  --xml-attributes
>> --keep-line-number --f J Foo"
>>
>> With these options, Eclipse colored Foo.jimple but it didn't color the
>> Foo.java. An xml file (Foo_SeparateMain.xml) was generated with color
>> tags, but srcPos seemed incorrect.
>>
>> I've attached the files.
>> Would you let me know what I'm doing wrong?
>> If my explanation is not clear, please let me know.
>>
>> Thanks,
>> Yonghee
>>
>>
>>     
>>> Hello Yonghee...
>>>
>>> I haven't encountered a similar problem. Some more details would make it
>>> easier for me to help you diagnose the problem.
>>>
>>> On Fri, Jun 01, 2007 at 11:49:23PM -0400, Yonghee Shin wrote:
>>>       
>>>> I'm trying to use Soot eclipse plugin and encountered a problem in using
>>>> ColorTag. Could you help me with this problem?
>>>>
>>>> Soot works differently when I use the soot configuration dialog box in
>>>> Eclipse and when I use my own Main class which adds a new transformer to
>>>> the jap pack.
>>>>         
>>> I don't fully understand. Are you using the Soot configuration dialog
>>> box in both cases, but specifying your own Main class within the dialog?
>>> Or how are you invoking Soot with your own Main class?
>>>
>>>       
>>>> For example, I used the NullPointerColorer class which is included in
>>>> Soot
>>>> package. When I used jap:npcolorer transformer by choosing the options
>>>> provided by soot eclipse plugin (soot->process source file -> run soot
>>>> ->
>>>> phase options -> jimple annotation pack -> null pointer colorer), the
>>>> java
>>>> source file was colored.
>>>>
>>>> However, when I called NullPointerColorer in my own Main class, only
>>>> jimple file was colored. Could you let me know what I'm doing wrong?
>>>>         
>>> A good way to begin narrowing this down would be to determine whether
>>> the problem is that Soot is not generating the colour tags, or whether
>>> Eclipse is not displaying them. Soot outputs the tag information in an
>>> XML file in the sootOutput directory. Look there and compare the XML
>>> files created in both cases. If they're the same, then the problem is
>>> in the Eclipse code that displays the tags; if they're different, then
>>> the problem is that Soot is not generating the tag information.
>>>
>>> Can you also provide the Soot command line being used to invoke Soot,
>>> and the options being passed to Soot? What does your custom Main class
>>> look like? Does it pass command line options to Soot?
>>>
>>> I'm copying this to the soot-list mailing list, in case someone there
>>> has encountered similar problems and can help.
>>>
>>> Ondrej
>>>
>>>       
>
>   
>> public class Foo {
>>
>> 	/**
>> 	 * @param args
>> 	 */
>> 	public static void main(String[] args) {
>> 		// TODO Auto-generated method stub
>> 		return;
>> 	}
>> 	
>> 	void footest() {
>> 		int[] c = new int[2];
>> 		c[0] = 1;
>> 	}
>> }
>>
>>
>> import soot.*;
>> import soot.tagkit.*;
>> import soot.toolkits.graph.*;
>> import java.util.*;
>> import soot.toolkits.scalar.*;
>> import soot.jimple.toolkits.annotation.nullcheck.*;
>> import soot.jimple.Stmt;
>>
>> public class NullPointerColorerMain
>> {
>>     public static void main(String[] args)
>>     {
>>         /* adds the transformer. */
>>         PackManager.v().getPack("jtp").add(new
>>                         Transform("jtp.annotexample",
>>                         		new NullPointerColorer()));
>>
>>         /* invokes Soot */
>>         soot.Main.main(args);
>>     }
>> }
>>
>> class NullPointerColorer extends BodyTransformer {
>>
>>
>> 	protected void internalTransform (Body b, String phaseName, Map options) {
>> 		
>> 		BranchedRefVarsAnalysis analysis = new BranchedRefVarsAnalysis (
>> 				new ExceptionalUnitGraph(b));
>>
>> 		Iterator it = b.getUnits().iterator();
>>
>> 		while (it.hasNext()) {
>> 			Stmt s = (Stmt)it.next();
>> 			
>> 			Iterator usesIt = s.getUseBoxes().iterator();
>> 			FlowSet beforeSet = (FlowSet)analysis.getFlowBefore(s);
>> 				
>> 			while (usesIt.hasNext()) {
>> 				ValueBox vBox = (ValueBox)usesIt.next();
>> 				addColorTags(vBox, beforeSet, s, analysis);
>> 			}
>>
>> 			Iterator defsIt = s.getDefBoxes().iterator();
>> 			FlowSet afterSet = (FlowSet)analysis.getFallFlowAfter(s);
>>
>> 			while (defsIt.hasNext()){
>> 				ValueBox vBox = (ValueBox)defsIt.next();
>> 				addColorTags(vBox, afterSet, s, analysis);
>> 			}
>> 		}
>>
>>         Iterator keysIt = b.getMethod().getDeclaringClass().getTags().iterator();
>>         boolean keysAdded = false;
>>         while (keysIt.hasNext()){
>>             Object next = keysIt.next();
>>             if (next instanceof KeyTag){
>>                 if (((KeyTag)next).analysisType().equals("NullCheckTag")){
>>                     keysAdded = true;  
>>                 }
>>             }
>>         }
>>         if (!keysAdded){
>>             b.getMethod().getDeclaringClass().addTag(new KeyTag(ColorTag.RED, "Nullness: Null", "NullCheckTag"));
>>             b.getMethod().getDeclaringClass().addTag(new KeyTag(ColorTag.GREEN, "Nullness: Not Null", "NullCheckTag"));
>>             b.getMethod().getDeclaringClass().addTag(new KeyTag(ColorTag.BLUE, "Nullness: Nullness Unknown", "NullCheckTag"));
>>         }
>> 	}
>> 	
>> 	private void addColorTags(ValueBox vBox, FlowSet set, Stmt s, BranchedRefVarsAnalysis analysis){
>> 		
>> 		Value val = vBox.getValue();
>> 		if (val.getType() instanceof RefLikeType) {
>> 			//G.v().out.println(val+": "+val.getClass().toString());
>> 		
>> 			int vInfo = analysis.anyRefInfo(val, set);
>>
>> 			switch (vInfo) {
>> 				case 1 : {
>> 					// analysis.kNull
>> 					s.addTag(new StringTag(val+": Null", "NullCheckTag"));
>> 					vBox.addTag(new ColorTag(ColorTag.RED, "NullCheckTag"));
>> 					break;
>> 						 }
>> 				case 2 : {
>> 					// analysis.kNonNull 
>> 					s.addTag(new StringTag(val+": NonNull", "NullCheckTag"));
>> 					vBox.addTag(new ColorTag(ColorTag.GREEN, "NullCheckTag"));
>> 					break;
>> 						 }
>> 				case 99 : {
>> 					// analysis.KTop:
>> 					s.addTag(new StringTag(val+": Nullness Unknown", "NullCheckTag"));
>> 					vBox.addTag(new ColorTag(ColorTag.BLUE, "NullCheckTag"));
>> 					break;
>> 						  }
>> 				case 0 : {
>> 					// analysis.kBottom
>> 					s.addTag(new StringTag(val+": Nullness Unknown", "NullCheckTag"));
>> 					vBox.addTag(new ColorTag(ColorTag.BLUE, "NullCheckTag"));
>> 					break;
>> 						 }
>> 			}
>> 		}
>> 		else {
>> 			
>> 		}
>> 	}
>> }
>> <?xml version="1.0" encoding="ISO-8859-1"?>
>> <attributes>
>> <attribute>
>> <srcPos sline="6" eline="6" spos="25" epos="38"/>
>> <jmpPos sline="0" eline="0" spos="0" epos="0"/>
>> <text info="@parameter0: java.lang.String[]: Nullness Unknown" aType="NullCheckTag"/>
>> <text info="args: Nullness Unknown" aType="NullCheckTag"/>
>> </attribute>
>> <attribute>
>> <srcPos sline="0" eline="0" spos="0" epos="0"/>
>> <jmpPos sline="0" eline="0" spos="0" epos="0"/>
>> <color r="174" g="210" b="255" fg="0" aType="NullCheckTag"/>
>> </attribute>
>> <attribute>
>> <srcPos sline="6" eline="6" spos="25" epos="38"/>
>> <jmpPos sline="0" eline="0" spos="0" epos="0"/>
>> <color r="174" g="210" b="255" fg="0" aType="NullCheckTag"/>
>> </attribute>
>> <attribute>
>> <srcPos sline="0" eline="0" spos="0" epos="0"/>
>> <jmpPos sline="0" eline="0" spos="0" epos="0"/>
>> <text info="@this: Foo: NonNull" aType="NullCheckTag"/>
>> <text info="this: NonNull" aType="NullCheckTag"/>
>> </attribute>
>> <attribute>
>> <srcPos sline="0" eline="0" spos="0" epos="0"/>
>> <jmpPos sline="0" eline="0" spos="0" epos="0"/>
>> <color r="45" g="255" b="84" fg="0" aType="NullCheckTag"/>
>> </attribute>
>> <attribute>
>> <srcPos sline="0" eline="0" spos="0" epos="0"/>
>> <jmpPos sline="0" eline="0" spos="0" epos="0"/>
>> <color r="45" g="255" b="84" fg="0" aType="NullCheckTag"/>
>> </attribute>
>> <attribute>
>> <srcPos sline="12" eline="12" spos="12" epos="22"/>
>> <jmpPos sline="0" eline="0" spos="0" epos="0"/>
>> <text info="newarray (int)[2]: NonNull" aType="NullCheckTag"/>
>> <text info="c: NonNull" aType="NullCheckTag"/>
>> </attribute>
>> <attribute>
>> <srcPos sline="12" eline="12" spos="8" epos="9"/>
>> <jmpPos sline="0" eline="0" spos="0" epos="0"/>
>> <color r="45" g="255" b="84" fg="0" aType="NullCheckTag"/>
>> </attribute>
>> <attribute>
>> <srcPos sline="12" eline="12" spos="12" epos="22"/>
>> <jmpPos sline="0" eline="0" spos="0" epos="0"/>
>> <color r="45" g="255" b="84" fg="0" aType="NullCheckTag"/>
>> </attribute>
>> <attribute>
>> <srcPos sline="13" eline="13" spos="2" epos="10"/>
>> <jmpPos sline="0" eline="0" spos="0" epos="0"/>
>> <text info="c: NonNull" aType="NullCheckTag"/>
>> </attribute>
>> <attribute>
>> <srcPos sline="13" eline="13" spos="2" epos="3"/>
>> <jmpPos sline="0" eline="0" spos="0" epos="0"/>
>> <color r="45" g="255" b="84" fg="0" aType="NullCheckTag"/>
>> </attribute>
>> <attribute>
>> <srcPos sline="0" eline="0" spos="0" epos="0"/>
>> <jmpPos sline="0" eline="0" spos="0" epos="0"/>
>> <text info="@this: Foo: NonNull" aType="NullCheckTag"/>
>> <text info="this: NonNull" aType="NullCheckTag"/>
>> </attribute>
>> <attribute>
>> <srcPos sline="0" eline="0" spos="0" epos="0"/>
>> <jmpPos sline="0" eline="0" spos="0" epos="0"/>
>> <color r="45" g="255" b="84" fg="0" aType="NullCheckTag"/>
>> </attribute>
>> <attribute>
>> <srcPos sline="0" eline="0" spos="0" epos="0"/>
>> <jmpPos sline="0" eline="0" spos="0" epos="0"/>
>> <color r="45" g="255" b="84" fg="0" aType="NullCheckTag"/>
>> </attribute>
>> <attribute>
>> <srcPos sline="1" eline="15" spos="7" epos="1"/>
>> <jmpPos sline="0" eline="0" spos="0" epos="0"/>
>> <text info="this: NonNull" aType="NullCheckTag"/>
>> </attribute>
>> <attribute>
>> <srcPos sline="0" eline="0" spos="0" epos="0"/>
>> <jmpPos sline="0" eline="0" spos="0" epos="0"/>
>> <color r="45" g="255" b="84" fg="0" aType="NullCheckTag"/>
>> </attribute>
>> <attribute>
>> <srcPos sline="6" eline="9" spos="15" epos="2"/>
>> <jmpPos sline="0" eline="0" spos="0" epos="0"/>
>> <text info="[args]" aType="ParamNamesTag"/>
>> </attribute>
>> <attribute>
>> <srcPos sline="11" eline="14" spos="1" epos="2"/>
>> <jmpPos sline="0" eline="0" spos="0" epos="0"/>
>> <text info="[]" aType="ParamNamesTag"/>
>> </attribute>
>> <attribute>
>> <srcPos sline="1" eline="15" spos="7" epos="1"/>
>> <jmpPos sline="0" eline="0" spos="0" epos="0"/>
>> <text info="[]" aType="ParamNamesTag"/>
>> </attribute>
>> <key red="255" green="0" blue="0" key="Nullness: Null" aType="NullCheckTag"/>
>> <key red="45" green="255" blue="84" key="Nullness: Not Null" aType="NullCheckTag"/>
>> <key red="174" green="210" blue="255" key="Nullness: Nullness Unknown" aType="NullCheckTag"/>
>> </attributes>
>> <?xml version="1.0" encoding="ISO-8859-1"?>
>> <attributes>
>> <attribute>
>> <srcPos sline="1" eline="1" spos="0" epos="0"/>
>> <jmpPos sline="0" eline="0" spos="0" epos="0"/>
>> <text info="@this: Foo: NonNull" aType="NullCheckTag"/>
>> <text info="r0: NonNull" aType="NullCheckTag"/>
>> </attribute>
>> <attribute>
>> <srcPos sline="0" eline="0" spos="0" epos="0"/>
>> <jmpPos sline="0" eline="0" spos="0" epos="0"/>
>> <color r="45" g="255" b="84" fg="0" aType="NullCheckTag"/>
>> </attribute>
>> <attribute>
>> <srcPos sline="0" eline="0" spos="0" epos="0"/>
>> <jmpPos sline="0" eline="0" spos="0" epos="0"/>
>> <color r="45" g="255" b="84" fg="0" aType="NullCheckTag"/>
>> </attribute>
>> <attribute>
>> <srcPos sline="1" eline="1" spos="0" epos="0"/>
>> <jmpPos sline="0" eline="0" spos="0" epos="0"/>
>> <text info="r0: NonNull" aType="NullCheckTag"/>
>> </attribute>
>> <attribute>
>> <srcPos sline="0" eline="0" spos="0" epos="0"/>
>> <jmpPos sline="0" eline="0" spos="0" epos="0"/>
>> <color r="45" g="255" b="84" fg="0" aType="NullCheckTag"/>
>> </attribute>
>> <attribute>
>> <srcPos sline="8" eline="8" spos="0" epos="0"/>
>> <jmpPos sline="0" eline="0" spos="0" epos="0"/>
>> <text info="@parameter0: java.lang.String[]: Nullness Unknown" aType="NullCheckTag"/>
>> <text info="r0: Nullness Unknown" aType="NullCheckTag"/>
>> </attribute>
>> <attribute>
>> <srcPos sline="0" eline="0" spos="0" epos="0"/>
>> <jmpPos sline="0" eline="0" spos="0" epos="0"/>
>> <color r="174" g="210" b="255" fg="0" aType="NullCheckTag"/>
>> </attribute>
>> <attribute>
>> <srcPos sline="0" eline="0" spos="0" epos="0"/>
>> <jmpPos sline="0" eline="0" spos="0" epos="0"/>
>> <color r="174" g="210" b="255" fg="0" aType="NullCheckTag"/>
>> </attribute>
>> <attribute>
>> <srcPos sline="12" eline="12" spos="0" epos="0"/>
>> <jmpPos sline="0" eline="0" spos="0" epos="0"/>
>> <text info="@this: Foo: NonNull" aType="NullCheckTag"/>
>> <text info="r0: NonNull" aType="NullCheckTag"/>
>> </attribute>
>> <attribute>
>> <srcPos sline="0" eline="0" spos="0" epos="0"/>
>> <jmpPos sline="0" eline="0" spos="0" epos="0"/>
>> <color r="45" g="255" b="84" fg="0" aType="NullCheckTag"/>
>> </attribute>
>> <attribute>
>> <srcPos sline="0" eline="0" spos="0" epos="0"/>
>> <jmpPos sline="0" eline="0" spos="0" epos="0"/>
>> <color r="45" g="255" b="84" fg="0" aType="NullCheckTag"/>
>> </attribute>
>> <attribute>
>> <srcPos sline="12" eline="12" spos="0" epos="0"/>
>> <jmpPos sline="0" eline="0" spos="0" epos="0"/>
>> <text info="newarray (int)[2]: NonNull" aType="NullCheckTag"/>
>> <text info="r1: NonNull" aType="NullCheckTag"/>
>> </attribute>
>> <attribute>
>> <srcPos sline="0" eline="0" spos="0" epos="0"/>
>> <jmpPos sline="0" eline="0" spos="0" epos="0"/>
>> <color r="45" g="255" b="84" fg="0" aType="NullCheckTag"/>
>> </attribute>
>> <attribute>
>> <srcPos sline="0" eline="0" spos="0" epos="0"/>
>> <jmpPos sline="0" eline="0" spos="0" epos="0"/>
>> <color r="45" g="255" b="84" fg="0" aType="NullCheckTag"/>
>> </attribute>
>> <attribute>
>> <srcPos sline="13" eline="13" spos="0" epos="0"/>
>> <jmpPos sline="0" eline="0" spos="0" epos="0"/>
>> <text info="r1: NonNull" aType="NullCheckTag"/>
>> </attribute>
>> <attribute>
>> <srcPos sline="0" eline="0" spos="0" epos="0"/>
>> <jmpPos sline="0" eline="0" spos="0" epos="0"/>
>> <color r="45" g="255" b="84" fg="0" aType="NullCheckTag"/>
>> </attribute>
>> <key red="255" green="0" blue="0" key="Nullness: Null" aType="NullCheckTag"/>
>> <key red="45" green="255" blue="84" key="Nullness: Not Null" aType="NullCheckTag"/>
>> <key red="174" green="210" blue="255" key="Nullness: Nullness Unknown" aType="NullCheckTag"/>
>> </attributes>
>>     



More information about the Soot-list mailing list