using ibm wala’s slicer for csci578 hw3
DESCRIPTION
Using IBM Wala’s Slicer for CSCI578 HW3. By Joshua Garcia. Some Requirements. Eclipse IDE SVN or Git Plugin for Eclipse (e.g. Subclipse at http://subclipse.tigris.org/). Getting the IBM Wala code. - PowerPoint PPT PresentationTRANSCRIPT
Using IBM Wala’s Slicer for CSCI578 HW3
By Joshua Garcia
Some Requirements
• Eclipse IDE• SVN or Git Plugin for Eclipse (e.g. Subclipse at
http://subclipse.tigris.org/)
Getting the IBM Wala code
• Check out all com.ibm.wala* projects form the trunk of the repository EXCEPT for com.ibm.wala.core.tests
• Import com.ibm.wala.core.tests from the zip file we provide
• Reference– A more general guide to starting with Wala:
http://wala.sourceforge.net/wiki/index.php/UserGuide:Getting_Started
Possible Building Problems• Some of the projects will have errors. I have errors in the following
Wala projects:– com.ibm.wala.cast.js.rhino.test– com.ibm.wala.cast.js.test– com.ibm.wala.ide.jsdt– com.ibm.wala.ide.tests
• However, you won’t be using all the code so it shouldn’t be a problem
• However, you should set your JDK compiler compliance level to 1.6– Click Window -> Preferences– Java -> Compiler– Set Compiler compliance level to 1.6
Configuring Properties Files
• Go to this page: http://wala.sourceforge.net/wiki/index.php/UserGuide:Getting_Started
• Follow the section called “Configuring WALA properties”
• Wait there’s more and it’s IMPORTANT – You need to set some properties in dat/wala.examples.properties as well– Just copy the wala.example.properties.sample file
and rename it
A Little About Slicing Before We Continue
• Given a statement and a subset of its variables, you can perform forward or backward slicing
• A slice is a set of statements that affect or are affected by the selected statement
• Forward slicing gives you the statements affected by your selected statement
• Backward slicing gives you the statements that affect the given statement
More on slicing, If You Are Interested
• http://www.grammatech.com/research/papers/slicing/slicingWhitepaper.html
• http://en.wikipedia.org/wiki/Program_slicing
Time To Slice Some Programs
• You should be able to run our customized PDFSliceMod drivers
• There are three launcher configuration you can modify and run as needed (one for each DEB application):– PDFSliceMod KLAX– PDFSliceMod specjms from stmts file– PDFSliceMod stoxx
• Simple way to get to these launcher configurations– Click Run -> Run Configurations– Under Java Application select the appropriate launcher
configuration
Customizing the launcher configuration
• The launcher configuration takes a few arguments• You can see these arguments from the Arguments tab of the launcher configuration • For example, for PDFSliceMod KLAX, here are the arguments
– -appJar ${workspace_loc}/com.ibm.wala.core.tests/apps/c2fw-original.jar -sliceCritFiles "${workspace_loc}/com.ibm.wala.core.tests/c2fw-mda-task0-search-deps-stmts.txt" -dd "no_base_no_heap" -cd "none" -dir "backwards" -pkgIncludes "Lc2/apps/klax"
• The arguments and what they do– appJar, the jar of the DEB application (no need to change it)– srcCaller, the method you will create the slice from– sliceCritFiles, file name of the file containing the input statements to the slicer– dir, “forward” or “backward” slice– pkgIncludes, which packages to analyze and show for output– For the remaining options take a look at
http://wala.sourceforge.net/wiki/index.php/UserGuide:Slicer• You may not need to change dd or cd, unless you think it will give you more accurate results• Changing dd or cd can make your program running for a very long time
• A slicer on our DEB applications can take minutes to run
Understanding the console output
• The slicer’s analysis starts from entry points in your program, which are set to all the methods of your selected class
• One statement can be broken up into multiple IR statements. For example line 70 of KLAX’s ChuteArtist class is made up of these statements (and some null statements):– 70 18 = invokevirtual < Application, Lc2/fw/Notification,
getParameter(Ljava/lang/String;)Ljava/lang/Object; > 2,16 @22 exception:17
– 70 19 = checkcast <Application,Ljava/lang/Integer>18 <Application,Ljava/lang/Integer>
– 70 21 = invokevirtual < Application, Ljava/lang/Integer, intValue()I > 19 @28 exception:20
More on console output• You get the statements of the slice and corresponding line numbers (if applicable):Printing slice with node number and line number:SLICE:
1, -1 NORMAL_RET_CALLER:Node: < Application, Lc2/apps/klax/comp/ChuteArtist, handle(Lc2/fw/Notification;)V > Context: Everywhere[1]5 = invokevirtual < Application, Lc2/fw/Notification, name()Ljava/lang/String; > 2 @1 exception:4
2, 66 NORMAL handle:8 = invokevirtual < Application, Ljava/lang/String, equals(Ljava/lang/Object;)Z > 5,6 @8 exception:7 Node: < Application, Lc2/apps/klax/comp/ChuteArtist, handle(Lc2/fw/Notification;)V > Context: Everywhere
3, -1 PARAM_CALLER:Node: < Application, Lc2/apps/klax/comp/ChuteArtist, handle(Lc2/fw/Notification;)V > Context: Everywhere[5]8 = invokevirtual < Application, Ljava/lang/String, equals(Ljava/lang/Object;)Z > 5,6 @8 exception:7 v5
4, 74 NORMAL handle:12 = invokevirtual < Application, Ljava/lang/String, equals(Ljava/lang/Object;)Z > 5,10 @56 exception:11 Node: < Application, Lc2/apps/klax/comp/ChuteArtist, handle(Lc2/fw/Notification;)V > Context: Everywhere
5, -1 PARAM_CALLER:Node: < Application, Lc2/apps/klax/comp/ChuteArtist, handle(Lc2/fw/Notification;)V > Context: Everywhere[29]12 = invokevirtual < Application, Ljava/lang/String, equals(Ljava/lang/Object;)Z > 5,10 @56 exception:11 v5
Node Numbers
Some IR statements have no corresponding line number
Node 2 corresponds to line 66 of ChuteArtist
How to read your slicePrinting slice with selected statements only:Lorg/spec/jms/eventhandler/sp/SP_CallForOffersEH:306 NORMAL handleMessage:4 = instanceof 2
<Application,Ljavax/jms/TextMessage> Node: < Application, Log/spec/jms/eventhandler/sp/SP_CallForOffersEH, handleMessage(Ljavax/jms/Message;)V > Context: Everywhere
Lorg/spec/jms/eventhandler/sp/SP_CallForOffersEH:306 NORMAL handleMessage:conditional branch(eq) 4,5 Node: < Application, Lorg/spec/jms/eventhandler/sp/SP_CallForOffersEH, handleMessage(Ljavax/jms/Message;)V > Context: Everywhere
Lorg/spec/jms/eventhandler/sp/SP_CallForOffersEH:308 NORMAL handleMessage:19 = checkcast <Application,Ljavax/jms/TextMessage>2 <Application,Ljavax/jms/TextMessage> Node: < Application, Lorg/spec/jms/eventhandler/sp/SP_CallForOffersEH, handleMessage(Ljavax/jms/Message;)V > Context: Everywhere
Lorg/spec/jms/eventhandler/sp/SP_CallForOffersEH:308 NORMAL handleMessage:21 = invokeinterface < Application, Ljavax/jms/TextMessage, getText()Ljava/lang/String; > 19 @12 exception:20 Node: < Application, Lorg/spec/jms/eventhandler/sp/SP_CallForOffersEH, handleMessage(Ljavax/jms/Message;)V > Context: Everywhere
Lorg/spec/jms/eventhandler/sp/SP_CallForOffersEH:308 NORMAL handleMessage:invokevirtual < Application, Lorg/spec/jms/eventhandler/sp/SP_CallForOffersEH, parseMessage(Ljava/lang/String;)V > 1,21 @17 exception:22 Node: < Application, Lorg/spec/jms/eventhandler/sp/SP_CallForOffersEH, handleMessage(Ljavax/jms/Message;)V > Context: Everywhere
Class Name Line No.
More Stuff You Might Need to Know
• How slices map to line numbers: http://wala.sourceforge.net/wiki/index.php/UserGuide:MappingToSourceCode#From_Slices_to_source_line_numbers
• Understanding the IR: http://wala.sourceforge.net/wiki/index.php/UserGuide:IR
Eclipse’s Reference-finding Feature
• Right click on method, variable, class, etc.– Select References -> Project, Hierarchy,
Workspace, or Working Set– You get list of references to your selection
• Or simply highlight the method, variable, class etc.– Press Ctrl+Shift+G