Some more instrumentation, and playing around with chopping (chops when double-click...
[eclipsethinslicer.git] / Svelte / src / edu / berkeley / cs / bodik / svelte / experimental / autodebug / InstrumentationSet.java
blob6026db2b23c11b651f9eab7ade00ec669ebd2c08
1 package edu.berkeley.cs.bodik.svelte.experimental.autodebug;
3 import java.util.ArrayList;
4 import java.util.Collection;
5 import java.util.HashSet;
6 import java.util.Hashtable;
8 import com.ibm.wala.ipa.slicer.NormalStatement;
9 import com.ibm.wala.ipa.slicer.ParamCaller;
10 import com.ibm.wala.ipa.slicer.Statement;
11 import com.ibm.wala.ssa.SSAInstruction;
12 import com.ibm.wala.ssa.SSAPutInstruction;
13 import com.ibm.wala.ssa.SSAReturnInstruction;
15 public class InstrumentationSet {
16 HashSet<String> fullyQualifiedClassNames;
17 Hashtable<String,ArrayList<InstrumentationPoint>> methodsToIPs;
18 public InstrumentationSet() {
19 fullyQualifiedClassNames = new HashSet<String>();
20 methodsToIPs = new Hashtable<String,ArrayList<InstrumentationPoint>>();
23 private void addInstrumentationPoint(String methodSignature,InstrumentationPoint ip) {
24 methodSignature = methodSignature.replace("/",".");
25 ArrayList<InstrumentationPoint> methodsIPs = methodsToIPs.get(methodSignature);
26 if ( methodsIPs == null ) {
27 methodsIPs = new ArrayList<InstrumentationPoint>();
28 methodsToIPs.put(methodSignature, methodsIPs);
30 methodsIPs.add(ip);
33 public boolean toBeInstrumented(String methodSignature) {
34 return methodsToIPs.containsKey(methodSignature.replace("/","."));
37 public ArrayList<InstrumentationPoint> instrumentationPointsForMethod(String methodSignature) {
38 return methodsToIPs.get(methodSignature.replace("/","."));
41 public void addInstrumentationPoint(Statement statement) {
42 InstrumentationPoint newIP = null;
43 if ( statement instanceof NormalStatement ) {
44 SSAInstruction instr = ((NormalStatement)statement).getInstruction();
45 if ( instr instanceof SSAPutInstruction || instr instanceof SSAReturnInstruction )
46 newIP = new InstrumentationPoint.PrintTopOfStackIP(statement);
48 } else if ( statement instanceof ParamCaller ) {
49 newIP = new InstrumentationPoint.ParamCallerIP(statement);
51 if ( newIP != null ) {
52 addInstrumentationPoint(statement.getNode().getMethod().getSignature(), newIP);
53 String classname = statement.getNode().getMethod().getDeclaringClass().getName().toString();
54 fullyQualifiedClassNames.add(classname);
58 public Collection<String> getFullyQualifiedClassNames() {
59 return fullyQualifiedClassNames;