[Wala-wala] I feel terribly unproductive

183 views
Skip to first unread message

João Macedo

unread,
May 6, 2013, 12:43:38 PM5/6/13
to WALA discussion and Q&A

I've been trying to look at the code in the JUnit tests and make some sense of what I see... Debugging.. See what the variables have inside.. Looking at  the different classes in java doc..
But this is painful, and I barely made any progress.

For instance, this is the first test in the JavaIRTests class.
I realize that Source#Simple1#doStuff#(I)V", "prod" references a variable inside a method.. 24 is a line

But what is a SourceMapAssertion?
and what does  EdgeAssertions.make do?

Test public void testSimple1() {
    List<? extends IRAssertion> assertions = Arrays.asList(
        new SourceMapAssertion("Source#Simple1#doStuff#(I)V", "prod", 24),
        new SourceMapAssertion("Source#Simple1#doStuff#(I)V", "j", 23), 
        new SourceMapAssertion("Source#Simple1#main#([Ljava/lang/String;)V", "s", 32), 
        new SourceMapAssertion("Source#Simple1#main#([Ljava/lang/String;)V", "i", 28), 
        new SourceMapAssertion("Source#Simple1#main#([Ljava/lang/String;)V", "sum", 29), 
        EdgeAssertions.make("Source#Simple1#main#([Ljava/lang/String;)V", "Source#Simple1#doStuff#(I)V"), 
        EdgeAssertions.make("Source#Simple1#instanceMethod1#()V", "Source#Simple1#instanceMethod2#()V"));

    // this needs soure positions to work too
    runTest(singleTestSrc(), rtJar, simpleTestEntryPoint(), assertions, true);
  }

I'm not even completely sure if WALA will provide the help I was expecting...
For instance..I thought it would be more inter operable with JDT 

For anyone who might wanna help, here is my previous email describing the kind of things I want to do. I just wanted some indication on where to start, and a confirmation if WALA fits my needs, so I can move on in case it doesn't.

I'm trying to detect certain types of bad smells in java source code. Some of these detentions imply, for instance, finding out, for a certain variable X of a statement in the code, every other variable which may play a role into changing variable X value. This is a typical operation doable over a Data flow graph of a java program... (Finding which variables a variable depends or may depend on... or which variables a variable may influence).
Another operation I would need is for instance, determining whether exists a possible execution flow, such as a certain method is never called. (This could be used, for instance, to find out whether a variable is always initialized with a setValue(v) method). I guess I could use the control flow graph for this.
Slicing is also an operation I will probably will want to use in the future.
Eclipse's AST api is very usefull, but these operations can't be done in a trivial way with just it.  
So basically, I would like to be able to generate the control flow graph, data flow graph, .. and run some analysis operations over them and integrate those analysis with an eclipse plugin I'm developing. Hopefully I can easily cross information from some tests I do using eclipse's AST api with wala? (I suspect WALA uses eclipse AST even thought I'm not sure)
The javadoc of the Graph class in WALA makes me think that there's a lot of interesting and useful stuff to explore...


Marc-André Laverdière

unread,
May 6, 2013, 1:42:35 PM5/6/13
to WALA discussion and Q&A
Hello,

While I cannot give a good walla answer, I feel like suggesting to do what I did, which is to use soot
--
Marc-André Laverdière
PhD Candidate - Doctorant
Sent from a mobile device - please excuse the brevity

>------------------------------------------------------------------------
>
>------------------------------------------------------------------------------
>Introducing AppDynamics Lite, a free troubleshooting tool for Java/.NET
>Get 100% visibility into your production application - at no cost.
>Code-level diagnostics for performance bottlenecks with <2% overhead
>Download for free and get started troubleshooting in minutes.
>http://p.sf.net/sfu/appdyn_d2d_ap1
>
>------------------------------------------------------------------------
>
>_______________________________________________
>Wala-wala mailing list
>Wala...@lists.sourceforge.net
>https://lists.sourceforge.net/lists/listinfo/wala-wala


------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and
their applications. This 200-page book is written by three acclaimed
leaders in the field. The early access version is available now.
Download your free book today! http://p.sf.net/sfu/neotech_d2d_may
_______________________________________________
Wala-wala mailing list
Wala...@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wala-wala

Manu Sridharan

unread,
May 6, 2013, 6:56:57 PM5/6/13
to WALA discussion and Q&A

Hi there,

So, you may want to look through the WALA tutorial slides as a start:

http://wala.sourceforge.net/wiki/index.php/Tutorial

Hopefully that will give a reasonable overview of how the system works.  For data flow graphs and data flow analysis, you can check out the IntrapocReachingDefs analysis as an example:

https://github.com/wala/WALA/blob/master/com.ibm.wala.core.tests/src/com/ibm/wala/examples/analysis/dataflow/IntraprocReachingDefs.java

There are also interprocedural versions, both context-insensitive and context-sensitive:

https://github.com/wala/WALA/blob/master/com.ibm.wala.core.tests/src/com/ibm/wala/examples/analysis/dataflow/ContextInsensitiveReachingDefs.java
https://github.com/wala/WALA/blob/master/com.ibm.wala.core.tests/src/com/ibm/wala/examples/analysis/dataflow/ContextSensitiveReachingDefs.java

All of these analyses operate on WALA IRs, which provide control-flow graphs for methods:

http://wala.sourceforge.net/wiki/index.php/UserGuide:IR

And here's some info on the slicer:

http://wala.sourceforge.net/wiki/index.php/UserGuide:Slicer

In terms of JDT compatibility, I think all of the above should work with the JDT front-end.  For the slicing functionality, you'll want to look at AstJavaSlicer:

https://github.com/wala/WALA/blob/master/com.ibm.wala.cast.java/src/com/ibm/wala/cast/java/ipa/slicer/AstJavaSlicer.java

Since the WALA analyses operate on the IR, you'll need to map analysis results back to the source code, for which we have decent support:

http://wala.sourceforge.net/wiki/index.php/UserGuide:MappingToSourceCode

Anyway, hopefully that's enough to get you going.  If you have further questions, let us know.

--Manu

-------------------------------------------
Manu Sridharan
IBM T.J. Watson Research Center
http://researcher.ibm.com/view.php?person=us-msridhar

Inactive hide details for João Macedo ---05/06/2013 09:44:05 AM---I've been trying to look at the code in the JUnit tests and mJoão Macedo ---05/06/2013 09:44:05 AM---I've been trying to look at the code in the JUnit tests and make some sense of what I see... Debuggi

------------------------------------------------------------------------------
Introducing AppDynamics Lite, a free troubleshooting tool for Java/.NET
Get 100% visibility into your production application - at no cost.
Code-level diagnostics for performance bottlenecks with <2% overhead
Download for free and get started troubleshooting in minutes.

João Macedo

unread,
May 9, 2013, 6:58:14 PM5/9/13
to WALA discussion and Q&A
Hey. Thanks for your reply and your patience with me. 
I know I'm always asking basic questions but hopefully I'll get somewhere and those questions will start to become more interesting...

The .pdf slides were great. They helped me clear my mind a little..

I'm trying to code the most simple thing possible with WALA now.
I'm stuck at the very start, trying to figure out how to start... I have a simple project with simple classes and methods and I want to execute some kind of analysis on it. Something simple... The point here is knowing how to reference the project/class files/zip project/jar, something which I didn't quite get yet. The JUnit tests had some kind of zip project loading but I found it quite hard to understand.

My first question is: which options are avaiable to me? Have the project that I want to analyze as a jar file, a zip file...? What about the active IProject in a eclipse plugin ? (this would be the one I am more interested in).  

Anyway, in the slides, in the "Building a Call Graph" section, I can see this:
AnalysisScope scope = AnalysisScopeReader.makeJavaBinaryAnalysisScope(jarFile, null);

I tried it (this is a class used in the eclipse plugin i'm writing):
public class First {
public void go(){
try {
AnalysisScope scope = AnalysisScopeReader.makeJavaBinaryAnalysisScope("TesteWALA.jar", null);
} catch (IOException e) {
e.printStackTrace();
}
}
}

TesteWala.jar is the jar file of the project I want to analyze. I've tried putting it inside my eclipse workspace and also inside the plugin project folder, but I get exceptions when trying to execute that line. So I guess something is wrong, probably the path, or maybe that isn't supposed to be a path at all..

Any suggestions?

By the way, the code in that slide I mentioned is always the start point for any analysis, right? Thanks.



------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and
their applications. This 200-page book is written by three acclaimed
leaders in the field. The early access version is available now.
Download your free book today! http://p.sf.net/sfu/neotech_d2d_may
_______________________________________________
graycol.gif

Manu Sridharan

unread,
May 22, 2013, 12:35:43 PM5/22/13
to WALA discussion and Q&A

Hi there,

So, the slides in the WALA tutorial focus on analyzing Java bytecode, accessed via the file system or class loaders.  So, for your example code, you either need to have TesteWALA.jar in the classpath, or you need to give an absolute path to the file.  

If you want to analyze an Eclipse project from an Eclipse plug-in, you probably want to use a class like com.ibm.wala.cast.java.client.JDTJavaSourceAnalysisEngine.  You can construct an object using the relevant IJavaProject, and then get an AnalysisScope using the makeAnalysisScope() method.  The whole AnalysisEngine type hierarchy is a bit complex, but you can look at this code to see how it builds a call graph builder and call graph:

https://github.com/wala/WALA/blob/master/com.ibm.wala.core/src/com/ibm/wala/client/AbstractAnalysisEngine.java#L295

We should write some better documentation on analyzing Eclipse projects; it's on the TODO list.  

Thanks,


Manu

-------------------------------------------
Manu Sridharan
IBM T.J. Watson Research Center
http://researcher.ibm.com/view.php?person=us-msridhar


Inactive hide details for João Macedo ---05/09/2013 03:59:09 PM---Hey. Thanks for your reply and your patience with me. I know João Macedo ---05/09/2013 03:59:09 PM---Hey. Thanks for your reply and your patience with me. I know I'm always asking basic questions but h

Reply all
Reply to author
Forward
0 new messages