public void defaultCase(Node node) { if (node instanceof TQuotedName || node instanceof TFullIdentifier || node instanceof TIdentifier || node instanceof TStringConstant || node instanceof TIntegerConstant || node instanceof TFloatConstant || node instanceof TAtIdentifier) { if (debug) G.v().out.println("Default case -pushing token:" + ((Token) node).getText()); String tokenString = ((Token) node).getText(); if (node instanceof TStringConstant || node instanceof TQuotedName) { tokenString = tokenString.substring(1, tokenString.length() - 1); } if (node instanceof TIdentifier || node instanceof TFullIdentifier || node instanceof TQuotedName || node instanceof TStringConstant) { try { tokenString = StringTools.getUnEscapedStringOf(tokenString); } catch (RuntimeException e) { G.v().out.println(tokenString); throw e; } } mProductions.addLast(tokenString); } }
private void analyzeLocal(SootMethod method, Value value) { Local l = (Local) value; boolean objIsThreadLocal = tloa.isObjectThreadLocal(l, method); if (objIsThreadLocal) { G.v().out.println("[lg.tlo] LOCAL " + l.toString() + " is thread-local in method " + method); } else { G.v().out.println("[lg.tlo] LOCAL " + l.toString() + " is thread-shared in method " + method); } }
private void analyzeField(SootMethod method, Value value) { FieldRef fr = (FieldRef) value; boolean fieldIsThreadLocal = tloa.isObjectThreadLocal(fr, method); if (fieldIsThreadLocal) { G.v().out.println("[lg.tlo] FIELD " + fr.toString() + " is thread-local in method " + method); } else { G.v() .out .println("[lg.tlo] FIELD " + fr.toString() + " is thread-shared in method " + method); } }
public StronglyConnectedComponentsBV(BitVector typeVariableList, TypeResolverBV resolver) throws TypeException { this.resolver = resolver; variables = typeVariableList; black = new TreeSet(); finished = new LinkedList(); for (BitSetIterator i = variables.iterator(); i.hasNext(); ) { TypeVariableBV var = resolver.typeVariableForId(i.next()); if (!black.contains(var)) { black.add(var); dfsg_visit(var); } } black = new TreeSet(); for (Iterator i = finished.iterator(); i.hasNext(); ) { TypeVariableBV var = (TypeVariableBV) i.next(); if (!black.contains(var)) { current_tree = new LinkedList(); forest.add(current_tree); black.add(var); dfsgt_visit(var); } } for (Iterator i = forest.iterator(); i.hasNext(); ) { LinkedList list = (LinkedList) i.next(); TypeVariableBV previous = null; StringBuffer s = null; if (DEBUG) { s = new StringBuffer("scc:\n"); } for (Iterator j = list.iterator(); j.hasNext(); ) { TypeVariableBV current = (TypeVariableBV) j.next(); if (DEBUG) { s.append(" " + current + "\n"); } if (previous == null) { previous = current; } else { try { previous = previous.union(current); } catch (TypeException e) { if (DEBUG) { G.v().out.println(s); } throw e; } } } } }
/** * Instruments the runtime version of the program. * * @param mainclass */ public static void transformRuntimeVersion(String mainclass) { PackManager.v().getPack("jtp").add(new Transform("jtp.intrumenter", SymbBodyPass.v())); setOptions(mainclass, false); Scene.v() .setSootClassPath( System.getProperty("sun.boot.class.path") + File.pathSeparator + System.getProperty("java.class.path")); Scene.v().loadClassAndSupport(runtimeClass); try { // ** instrument runtime version String outpath = getOutputDir(); String[] args1 = getArgs(mainclass, outpath); soot.Main.main(args1); System.err.println("***** Runtime version generated *****\n"); // reset soot parameters soot.G.reset(); bbIdCounter = 0; } catch (Exception e) { System.err.println(">> Exception: " + e.getMessage()); e.printStackTrace(); } }
public TypeNode(int id, Type type) { this.id = id; this.type = type; if (DEBUG) { G.v().out.println("creating node " + this); } }
public static void main(String[] args) { soot.G .v() .PackManager() .getPack("tag") .add(new soot.Transform("tag.null", new NullTagAggregator())); soot.Main.main(args); }
private static void initializeSoot(Clazzes clazzes) { soot.G.reset(); Options.v().set_output_format(Options.output_format_jimple); Options.v().set_include_all(true); Options.v().set_print_tags_in_output(true); Options.v().set_allow_phantom_refs(true); Options.v().set_keep_line_number(true); Options.v().set_soot_classpath(getSootClasspath(clazzes)); /* * Enable the use-original-names phase to merge local variables and * verbose logging for debugging purposes only. */ // Options.v().set_verbose(true); // Options.v().setPhaseOption("jb", "use-original-names:true"); /* * Disable the jb.dae phase (DeadAssignmentEliminator) since it removes * LDC instructions which would have thrown a NoClassDefFoundError. * TODO: Report this to soot as a bug? */ Options.v().setPhaseOption("jb.dae", "enabled:false"); /* * Disable the jb.uce phase (UnreachableCodeEliminator) since it seems * to remove try-catch blocks which catches a non-existing Throwable * class. This should generate a NoClassDefFoundError at runtime but * with the UCE in place no exception is thrown. */ Options.v().setPhaseOption("jb.uce", "enabled:false"); /* * Enable jap.npc (NullPointerChecker) and jap.abc (ArrayBoundsChecker) * phases in the annotation pack. The annotation pack is enabled by * default but all its phases are disabled by default. */ Options.v().setPhaseOption("jap.npc", "enabled:true"); Options.v().setPhaseOption("jap.abc", "enabled:true"); /* * Enable the jop (Jimple optimization) pack but disable all phases for * now. */ Options.v().setPhaseOption("jop", "enabled:true"); Options.v().setPhaseOption("jop.cse", "enabled:false"); Options.v().setPhaseOption("jop.bcm", "enabled:false"); Options.v().setPhaseOption("jop.lcm", "enabled:false"); Options.v().setPhaseOption("jop.cp", "enabled:false"); Options.v().setPhaseOption("jop.cpf", "enabled:false"); Options.v().setPhaseOption("jop.cbf", "enabled:false"); Options.v().setPhaseOption("jop.dae", "enabled:false"); Options.v().setPhaseOption("jop.nce", "enabled:false"); Options.v().setPhaseOption("jop.uce1", "enabled:false"); Options.v().setPhaseOption("jop.ubf1", "enabled:false"); Options.v().setPhaseOption("jop.uce2", "enabled:false"); Options.v().setPhaseOption("jop.ubf2", "enabled:false"); Options.v().setPhaseOption("jop.ule", "enabled:false"); Scene.v().loadNecessaryClasses(); }
@Override protected void runInternal() { // don't print crap to screen! G.v().out = new PrintStream(NullOutputStream.NULL_OUTPUT_STREAM); Scene.v().loadDynamicClasses(); setSparkPointsToAnalysis(); // other passes can print crap now G.v().out = System.out; ptsProvider = (PAG) Scene.v().getPointsToAnalysis(); typeManager = ptsProvider.getTypeManager(); // cache the call graph callGraph = Scene.v().getCallGraph(); createNewToAllocMap(); /* for (SootMethod method : getReachableMethods()) { Set<MethodOrMethodContext> mcs = getMethodContexts(method); if (mcs.size() > 30) System.out.println(method + " " + mcs.size()); } */ // dumpReachablesAndAllocNodes(); // dumpCallGraphReachablesCSV(); // dumpOutdegreesCSV(); if (Config.v().dumpPta) { dumpPTA(Project.v().getOutputDir() + File.separator + "pta.txt"); } if (Config.v().dumpCallGraph) { // dumpCallGraph(Project.v().getOutputDir() + File.separator + "callgraph.dot"); String fileName = String.format("callgraph%d.txt", runCount++); dumpTextGraph(Project.v().getOutputDir() + File.separator + fileName); } // System.out.println(SparkEvaluator.v().toString()); }
/** * Performs the work that is required to construct any sort of <tt>UnitGraph</tt>. * * @param body The body of the method for which to construct a control flow graph. */ protected UnitGraph(Body body) { this.body = body; unitChain = body.getUnits(); method = body.getMethod(); if (Options.v().verbose()) G.v() .out .println( "[" + method.getName() + "] Constructing " + this.getClass().getName() + "..."); }
@Override public void execute() throws MojoExecutionException { G.reset(); String classpath = getCompileClasspath(); getLog().info(String.format("Using transform classpath: %s", classpath)); Options.v().set_soot_classpath(classpath); Options.v().set_process_dir(asList(getProcessDirectory())); Options.v().set_output_dir(getOutputDirectory()); SimulationTransform.main(null); }
@BeforeClass public static void initializeSoot() throws IOException { soot.G.reset(); Options.v().set_output_format(Options.output_format_jimple); Options.v().set_include_all(true); Options.v().set_print_tags_in_output(true); Options.v().set_allow_phantom_refs(true); Options.v() .set_soot_classpath( System.getProperty("sun.boot.class.path") + ":" + System.getProperty("java.class.path")); Scene.v().loadNecessaryClasses(); }
/** * Traverse the statements in the given body, looking for aggregation possibilities; that is, * given a def d and a use u, d has no other uses, u has no other defs, collapse d and u. * * <p>option: only-stack-locals; if this is true, only aggregate variables starting with $ */ protected void internalTransform(Body b, String phaseName, Map<String, String> options) { StmtBody body = (StmtBody) b; boolean onlyStackVars = PhaseOptions.getBoolean(options, "only-stack-locals"); int aggregateCount = 1; if (Options.v().time()) Timers.v().aggregationTimer.start(); boolean changed = false; Map<ValueBox, Zone> boxToZone = new HashMap<ValueBox, Zone>(body.getUnits().size() * 2 + 1, 0.7f); // Determine the zone of every box { Zonation zonation = new Zonation(body); for (Unit u : body.getUnits()) { Zone zone = zonation.getZoneOf(u); for (ValueBox box : u.getUseBoxes()) { boxToZone.put(box, zone); } for (ValueBox box : u.getDefBoxes()) { boxToZone.put(box, zone); } } } do { if (Options.v().verbose()) G.v() .out .println( "[" + body.getMethod().getName() + "] Aggregating iteration " + aggregateCount + "..."); // body.printTo(new java.io.PrintWriter(G.v().out, true)); changed = internalAggregate(body, boxToZone, onlyStackVars); aggregateCount++; } while (changed); if (Options.v().time()) Timers.v().aggregationTimer.end(); }
private boolean callEdgesReasonable() { Set<VarNode> vars = contextSensitiveAssignEdges.keySet(); for (VarNode node : vars) { ArraySet<AssignEdge> assigns = contextSensitiveAssignEdges.get(node); for (AssignEdge edge : assigns) { if (edge.isCallEdge()) { if (edge.getCallSite() == null) { G.v().out.println(edge + " is weird!!"); return false; } } } } return true; }
protected void print_cfg(Body body) { DirectedGraph<Unit> graph = graphtype.buildGraph(body); DotGraph canvas = graphtype.drawGraph(drawer, graph, body); String methodname = body.getMethod().getSubSignature(); String filename = soot.SourceLocator.v().getOutputDir(); if (filename.length() > 0) { filename = filename + java.io.File.separator; } filename = filename + methodname.replace(java.io.File.separatorChar, '.') + DotGraph.DOT_EXTENSION; G.v().out.println("Generate dot file in " + filename); canvas.plot(filename); }
protected Node[] lookup(Map<Object, Object> m, Object key) { Object valueList = m.get(key); if (valueList == null) { return EMPTY_NODE_ARRAY; } if (valueList instanceof Set) { try { m.put(key, valueList = ((Set) valueList).toArray(EMPTY_NODE_ARRAY)); } catch (Exception e) { for (Iterator it = ((Set) valueList).iterator(); it.hasNext(); ) { G.v().out.println(" " + it.next()); } throw new RuntimeException(" " + valueList + e); } } Node[] ret = (Node[]) valueList; return ret; }
private static void usage() { G.v() .out .println( "Usage:\n" + " java soot.util.CFGViewer [soot options] [CFGViewer options] [class[:method]]...\n\n" + " CFGViewer options:\n" + " (When specifying the value for an '=' option, you only\n" + " need to type enough characters to specify the choice\n" + " unambiguously, and case is ignored.)\n" + "\n" + " --alt-classpath PATH :\n" + " specifies the classpath from which to load classes\n" + " that implement graph types whose names begin with 'Alt'.\n" + " --graph={" + CFGGraphType.help(0, 70, " ".length()) + "} :\n" + " show the specified type of graph.\n" + " Defaults to " + defaultGraph + ".\n" + " --ir={" + CFGIntermediateRep.help(0, 70, " ".length()) + "} :\n" + " create the CFG from the specified intermediate\n" + " representation. Defaults to " + defaultIR + ".\n" + " --brief :\n" + " label nodes with the unit or block index,\n" + " instead of the text of their statements.\n" + " --multipages :\n" + " produce dot file output for multiple 8.5x11\" pages.\n" + " By default, a single page is produced.\n" + " --help :\n" + " print this message.\n" + "\n" + " Particularly relevant soot options (see \"soot --help\" for details):\n" + " --soot-class-path PATH\n" + " --show-exception-dests\n" + " --throw-analysis {pedantic|unit}\n" + " --omit-excepting-unit-edges\n" + " --trim-cfgs\n"); }
protected void internalTransform(Body body, String phaseName, Map options) { if (Options.v().verbose()) G.v().out.println("[" + body.getMethod().getName() + "] Tightening trap boundaries..."); Chain trapChain = body.getTraps(); Chain unitChain = body.getUnits(); if (trapChain.size() > 0) { ExceptionalUnitGraph graph = new ExceptionalUnitGraph(body); for (Iterator trapIt = trapChain.iterator(); trapIt.hasNext(); ) { Trap trap = (Trap) trapIt.next(); Unit firstTrappedUnit = trap.getBeginUnit(); Unit firstTrappedThrower = null; Unit firstUntrappedUnit = trap.getEndUnit(); Unit lastTrappedUnit = (Unit) unitChain.getPredOf(firstUntrappedUnit); Unit lastTrappedThrower = null; for (Unit u = firstTrappedUnit; u != null && u != firstUntrappedUnit; u = (Unit) unitChain.getSuccOf(u)) { if (mightThrowTo(graph, u, trap)) { firstTrappedThrower = u; break; } } if (firstTrappedThrower != null) { for (Unit u = lastTrappedUnit; u != null; u = (Unit) unitChain.getPredOf(u)) { if (mightThrowTo(graph, u, trap)) { lastTrappedThrower = u; break; } } } if (firstTrappedThrower != null && firstTrappedUnit != firstTrappedThrower) { trap.setBeginUnit(firstTrappedThrower); } if (lastTrappedThrower == null) { lastTrappedThrower = firstTrappedUnit; } if (lastTrappedUnit != lastTrappedThrower) { trap.setEndUnit((Unit) unitChain.getSuccOf(lastTrappedThrower)); } } } }
/** * Computes the analysis given a UnitGraph computed from a method body. It is recommended that a * ExceptionalUnitGraph (or similar) be provided for correct results in the case of exceptional * control flow. * * @param g a graph on which to compute the analysis. * @see ExceptionalUnitGraph */ public SimpleLiveLocals(UnitGraph graph) { if (Options.v().time()) Timers.v().liveTimer.start(); if (Options.v().verbose()) G.v() .out .println( "[" + graph.getBody().getMethod().getName() + "] Constructing SimpleLiveLocals..."); SimpleLiveLocalsAnalysis analysis = new SimpleLiveLocalsAnalysis(graph); if (Options.v().time()) Timers.v().livePostTimer.start(); // Build unitToLocals map { unitToLocalsAfter = new HashMap<Unit, List>(graph.size() * 2 + 1, 0.7f); unitToLocalsBefore = new HashMap<Unit, List>(graph.size() * 2 + 1, 0.7f); Iterator unitIt = graph.iterator(); while (unitIt.hasNext()) { Unit s = (Unit) unitIt.next(); FlowSet set = (FlowSet) analysis.getFlowBefore(s); unitToLocalsBefore.put(s, Collections.unmodifiableList(set.toList())); set = (FlowSet) analysis.getFlowAfter(s); unitToLocalsAfter.put(s, Collections.unmodifiableList(set.toList())); } } if (Options.v().time()) Timers.v().livePostTimer.end(); if (Options.v().time()) Timers.v().liveTimer.end(); }
protected void internalTransform(String phaseName, Map options) { if (Options.v().verbose()) G.v().out.println("Transforming all classes in the Scene to Shimple..."); // *** FIXME: Add debug output to indicate which class/method is being shimplified. // *** FIXME: Is ShimpleTransformer the right solution? The call graph may deem // some classes unreachable. Iterator classesIt = Scene.v().getClasses().iterator(); while (classesIt.hasNext()) { SootClass sClass = (SootClass) classesIt.next(); if (sClass.isPhantom()) continue; Iterator methodsIt = sClass.getMethods().iterator(); while (methodsIt.hasNext()) { SootMethod method = (SootMethod) methodsIt.next(); if (!method.isConcrete()) continue; if (method.hasActiveBody()) { Body body = method.getActiveBody(); ShimpleBody sBody = null; if (body instanceof ShimpleBody) { sBody = (ShimpleBody) body; if (!sBody.isSSA()) sBody.rebuild(); } else { sBody = Shimple.v().newBody(body); } method.setActiveBody(sBody); } else { MethodSource ms = new ShimpleMethodSource(method.getSource()); method.setSource(ms); } } } }
/* file = modifier* file_type class_name extends_clause? implements_clause? file_body; */ public void inAFile(AFile node) { if (debug) G.v().out.println("reading class " + node.getClassName()); }
public static Aggregator v() { return G.v().soot_jimple_toolkits_base_Aggregator(); }
/** * This method pushes all newExpr down to be the stmt directly before every invoke of the init * only if they are in the types list */ public void internalTransform(Body b, String phaseName, Map options) { JimpleBody body = (JimpleBody) b; if (Options.v().verbose()) G.v().out.println("[" + body.getMethod().getName() + "] Folding Jimple constructors..."); Chain units = body.getUnits(); List<Unit> stmtList = new ArrayList<Unit>(); stmtList.addAll(units); Iterator<Unit> it = stmtList.iterator(); Iterator<Unit> nextStmtIt = stmtList.iterator(); // start ahead one nextStmtIt.next(); SmartLocalDefs localDefs = SmartLocalDefsPool.v().getSmartLocalDefsFor(body); UnitGraph graph = localDefs.getGraph(); LocalUses localUses = new SimpleLocalUses(graph, localDefs); /* fold in NewExpr's with specialinvoke's */ while (it.hasNext()) { Stmt s = (Stmt) it.next(); if (!(s instanceof AssignStmt)) continue; /* this should be generalized to ArrayRefs */ // only deal with stmts that are an local = newExpr Value lhs = ((AssignStmt) s).getLeftOp(); if (!(lhs instanceof Local)) continue; Value rhs = ((AssignStmt) s).getRightOp(); if (!(rhs instanceof NewExpr)) continue; // check if very next statement is invoke --> // this indicates there is no control flow between // new and invoke and should do nothing if (nextStmtIt.hasNext()) { Stmt next = (Stmt) nextStmtIt.next(); if (next instanceof InvokeStmt) { InvokeStmt invoke = (InvokeStmt) next; if (invoke.getInvokeExpr() instanceof SpecialInvokeExpr) { SpecialInvokeExpr invokeExpr = (SpecialInvokeExpr) invoke.getInvokeExpr(); if (invokeExpr.getBase() == lhs) { break; } } } } // check if new is in the types list - only process these if (!types.contains(((NewExpr) rhs).getType())) continue; List lu = localUses.getUsesOf(s); Iterator luIter = lu.iterator(); boolean MadeNewInvokeExpr = false; while (luIter.hasNext()) { Unit use = ((UnitValueBoxPair) (luIter.next())).unit; if (!(use instanceof InvokeStmt)) continue; InvokeStmt is = (InvokeStmt) use; if (!(is.getInvokeExpr() instanceof SpecialInvokeExpr) || lhs != ((SpecialInvokeExpr) is.getInvokeExpr()).getBase()) continue; // make a new one here AssignStmt constructStmt = Jimple.v() .newAssignStmt(((DefinitionStmt) s).getLeftOp(), ((DefinitionStmt) s).getRightOp()); constructStmt.setRightOp(Jimple.v().newNewExpr(((NewExpr) rhs).getBaseType())); MadeNewInvokeExpr = true; // redirect jumps use.redirectJumpsToThisTo(constructStmt); // insert new one here units.insertBefore(constructStmt, use); constructStmt.addTag(s.getTag("SourceLnPosTag")); } if (MadeNewInvokeExpr) { units.remove(s); } } }
/** * Returns the single instance of <code>ThrowableSet.Manager</code>. * * @return Soot's <code>ThrowableSet.Manager</code>. */ public static Manager v() { return G.v().soot_toolkits_exceptions_ThrowableSet_Manager(); }
public static LineNumberAdder v() { return G.v().soot_jimple_toolkits_annotation_LineNumberAdder(); }
@Override public Object execute(ExecutionEvent event) throws ExecutionException { // TODO: this wrapping try is for debug only. Remove later. final int TIMES = 10; List<Long> runsTimer = new ArrayList<Long>(TIMES); for (int i = 0; i < TIMES; i++) { long startTimer = System.currentTimeMillis(); try { ISelection selection = HandlerUtil.getCurrentSelectionChecked(event); Shell shell = HandlerUtil.getActiveShellChecked(event); if (!(selection instanceof ITextSelection)) throw new ExecutionException("Not a text selection"); IFile textSelectionFile = (IFile) HandlerUtil.getActiveEditorChecked(event).getEditorInput().getAdapter(IFile.class); ITextSelection textSelection = (ITextSelection) selection; SelectionNodesVisitor selectionNodesVisitor = new SelectionNodesVisitor(textSelection); ICompilationUnit compilationUnit = JavaCore.createCompilationUnitFrom(textSelectionFile); ASTParser parser = ASTParser.newParser(AST.JLS3); parser.setSource(compilationUnit); parser.setKind(ASTParser.K_COMPILATION_UNIT); parser.setResolveBindings(true); CompilationUnit jdtCompilationUnit = (CompilationUnit) parser.createAST(null); jdtCompilationUnit.accept(selectionNodesVisitor); Set<ASTNode> selectionNodes = selectionNodesVisitor.getNodes(); System.out.println("Selection" + selectionNodes); IFeatureExtracter extracter = CIDEFeatureExtracterFactory.getInstance().newExtracter(); String correspondentClasspath = MethodDeclarationSootMethodBridge.getCorrespondentClasspath(textSelectionFile); SootManager.configure(correspondentClasspath); MethodDeclaration methodDeclaration = MethodDeclarationSootMethodBridge.getParentMethod(selectionNodes.iterator().next()); String declaringMethodClass = methodDeclaration.resolveBinding().getDeclaringClass().getQualifiedName(); MethodDeclarationSootMethodBridge mdsm = new MethodDeclarationSootMethodBridge(methodDeclaration); SootMethod sootMethod = SootManager.getMethodBySignature( declaringMethodClass, mdsm.getSootMethodSubSignature()); Body body = sootMethod.retrieveActiveBody(); Collection<Unit> unitsInSelection = ASTNodeUnitBridge.getUnitsFromLines( ASTNodeUnitBridge.getLinesFromASTNodes(selectionNodes, jdtCompilationUnit), body); if (unitsInSelection.isEmpty()) { System.out.println("the selection doesn't map to any Soot Unit"); return null; } FeatureModelInstrumentorTransformer instrumentorTransformer = new FeatureModelInstrumentorTransformer(extracter, correspondentClasspath); instrumentorTransformer.transform2(body, correspondentClasspath); FeatureTag<Set<String>> bodyFeatureTag = (FeatureTag<Set<String>>) body.getTag("FeatureTag"); BriefUnitGraph bodyGraph = new BriefUnitGraph(body); LiftedReachingDefinitions reachingDefinitions = new LiftedReachingDefinitions(bodyGraph, bodyFeatureTag.getFeatures()); reachingDefinitions.execute(); Map<Pair<Unit, Set<String>>, Set<Unit>> createProvidesConfigMap = createProvidesConfigMap(unitsInSelection, reachingDefinitions, body); System.out.println(createProvidesConfigMap); String message = createMessage(createProvidesConfigMap); // EmergentPopup.pop(shell, message); } catch (Exception ex) { ex.printStackTrace(); } finally { G.v().reset(); } long estimatedTime = System.currentTimeMillis() - startTimer; runsTimer.add(estimatedTime); } System.out.println(runsTimer); return null; }
public static NullType v() { return G.v().soot_NullType(); }
private NumericConstant getArrayElement(Number element, DexBody body, int arrayRegister) { List<DexlibAbstractInstruction> instructions = body.instructionsBefore(this); Set<Integer> usedRegisters = new HashSet<Integer>(); usedRegisters.add(arrayRegister); Type elementType = null; Outer: for (DexlibAbstractInstruction i : instructions) { if (usedRegisters.isEmpty()) break; for (int reg : usedRegisters) if (i instanceof NewArrayInstruction) { NewArrayInstruction newArrayInstruction = (NewArrayInstruction) i; Instruction22c instruction22c = (Instruction22c) newArrayInstruction.instruction; if (instruction22c.getRegisterA() == reg) { ArrayType arrayType = (ArrayType) DexType.toSoot((TypeReference) instruction22c.getReference()); elementType = arrayType.getElementType(); break Outer; } } // // look for obsolete registers // for (int reg : usedRegisters) { // if (i.overridesRegister(reg)) { // usedRegisters.remove(reg); // break; // there can't be more than one obsolete // } // } // look for new registers for (int reg : usedRegisters) { int newRegister = i.movesToRegister(reg); if (newRegister != -1) { usedRegisters.add(newRegister); usedRegisters.remove(reg); break; // there can't be more than one new } } } if (elementType == null) { // throw new InternalError("Unable to find array type to type array elements!"); G.v() .out .println( "Warning: Unable to find array type to type array elements! Array was not defined! (obfuscated bytecode?)"); return null; } NumericConstant value; if (elementType instanceof BooleanType) { value = IntConstant.v(element.intValue()); IntConstant ic = (IntConstant) value; if (!(ic.value == 0 || ic.value == 1)) { throw new RuntimeException("ERROR: Invalid value for boolean: " + value); } } else if (elementType instanceof ByteType) { value = IntConstant.v(element.byteValue()); } else if (elementType instanceof CharType || elementType instanceof ShortType) { value = IntConstant.v(element.shortValue()); } else if (elementType instanceof DoubleType) { value = DoubleConstant.v(Double.longBitsToDouble(element.longValue())); } else if (elementType instanceof FloatType) { value = FloatConstant.v(Float.intBitsToFloat(element.intValue())); } else if (elementType instanceof IntType) { value = IntConstant.v(element.intValue()); } else if (elementType instanceof LongType) { value = LongConstant.v(element.longValue()); } else { throw new RuntimeException( "Invalid Array Type occured in FillArrayDataInstruction: " + elementType); } Debug.printDbg("array element: ", value); return value; }
public static ShimpleTransformer v() { return G.v().soot_shimple_ShimpleTransformer(); }
public static DavaStaticBlockCleaner v() { return G.v().soot_dava_DavaStaticBlockCleaner(); }