|
From: dongyu s. <sun...@ya...> - 2008-10-27 18:06:48
|
Hi,
I am testing the DFSPathFinder on a InterprocedureCFG. I have a simple test program like following
public class HelloWorld {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
HelloWorld h=new HelloWorld();
int i[]=new int[0];
int i2=i.length;
int i3=i2;
int i4=i3;
i=null;
h.sayHello("hi ");
}
public void sayHello(String greeting)
{
TestClass testClas=new TestClass();
String test="test";
if(greeting =="")
{
System.out.println(greeting);
// testClas.method1_1(greeting);
say1();
}
else
{
System.out.println(test);
// testClas.method2(test);
say2();
}
}
void say1()
{
System.out.println("say1()");
}
void say2()
{
System.out.println("say2()");
}
}
I first constructed the InterprocedureCFG from the CallGraph, then I use the DSFPathFinder on this InterprocedureCFG to try to find any path between the call to say1() to the call to say2().
In above helloWorld class, as this two function call are on the two branches of the if statement, I didn't expect any path to exist between them, but suprisingly I got one path like following when run the DSFPathFinder.
the line with issBlk===>.. is produced by printing the toString() output of each of the
BasicBlockInContext<ISSABasicBlock>
the line witn ins (...) is the toString() output of each instruction in each of the
BasicBlockInContext<ISSABasicBlock>. the number in the bracket is the line number in the source code.
---------------------------------------------------------------------
issBlk===>BB[SSA:12..13]5 - simple.HelloWorld.sayHello(Ljava/lang/String;)V
ins ( 29 ): invokevirtual < Application, Lsimple/HelloWorld, say1()V > 1 @25 exception:13
def Value String : v13
use Value String : v1
loca name ( this )
issBlk===>BB[SSA:-1..-2]0 - simple.HelloWorld.say1()V
issBlk===>BB[SSA:0..2]1 - simple.HelloWorld.say1()V
ins ( 43 ): 3 = getstatic < Application, Ljava/lang/System, out, <Application,Ljava/io/PrintStream> >
def Value String : v3
ins ( 43 ): invokevirtual < Application, Ljava/io/PrintStream, println(Ljava/lang/String;)V > 3,4 @5 exception:5
def Value String : v5
use Value String : v3
use Value String : v4:#say1()
issBlk===>BB[SSA:-1..-2]0 - java.io.PrintStream.println(Ljava/lang/String;)V
issBlk===>BB[SSA:0..3]1 - java.io.PrintStream.println(Ljava/lang/String;)V
issBlk===>BB[SSA:4..6]2 - java.io.PrintStream.println(Ljava/lang/String;)V
issBlk===>BB[SSA:7..8]3 - java.io.PrintStream.println(Ljava/lang/String;)V
issBlk===>BB[SSA:9..10]4 - java.io.PrintStream.println(Ljava/lang/String;)V
issBlk===>BB[SSA:11..11]5 - java.io.PrintStream.println(Ljava/lang/String;)V
issBlk===>BB[SSA:17..17]8 - java.io.PrintStream.println(Ljava/lang/String;)V
issBlk===>BB[SSA:-1..-2]9 - java.io.PrintStream.println(Ljava/lang/String;)V
issBlk===>BB[SSA:18..19]8 - simple.HelloWorld.sayHello(Ljava/lang/String;)V
ins ( 35 ): invokevirtual < Application, Lsimple/HelloWorld, say2()V > 1 @39 exception:10
def Value String : v10
use Value String : v1
loca name ( this )
It seems that the path is from the call to say1() go into the function definition of say(), then come out and jump on to the call to say2().. Is this path right in a CFG?
thanks
dongyu
|