private void addSourceFileTag(soot.SootClass sc) { if (fileName == null && zipFileName == null) { return; } soot.tagkit.SourceFileTag tag = null; if (sc.hasTag("SourceFileTag")) { tag = (soot.tagkit.SourceFileTag) sc.getTag("SourceFileTag"); } else { tag = new soot.tagkit.SourceFileTag(); sc.addTag(tag); } // Sets sourceFile only when it hasn't been set before if (tag.getSourceFile() == null) { String name = zipFileName == null ? new File(fileName).getName() : new File(zipFileName).getName(); tag.setSourceFile(name); } }
/** * adds source file tag to each sootclass */ protected static void addSourceFileTag(SootClass sc, String fileName) { soot.tagkit.SourceFileTag tag = null; if (sc.hasTag("SourceFileTag")) { return; // do not add tag if original class already has debug // information } else { tag = new soot.tagkit.SourceFileTag(); sc.addTag(tag); } tag.setSourceFile(fileName); } }
/** * @ast method * @aspect EmitJimple * @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddExtensions/JimpleBackend/EmitJimple.jrag:163 */ public void jimplify1phase2() { SootClass sc = getSootClassDecl(); sc.setResolvingLevel(SootClass.DANGLING); sc.setModifiers(sootTypeModifiers()); sc.setApplicationClass(); SourceFileTag st = new soot.tagkit.SourceFileTag(sourceNameWithoutPath()); st.setAbsolutePath(compilationUnit().pathName()); sc.addTag(st); if(hasSuperclass()) { sc.setSuperclass(superclass().getSootClassDecl()); } for(Iterator iter = interfacesIterator(); iter.hasNext(); ) { TypeDecl typeDecl = (TypeDecl)iter.next(); if(!sc.implementsInterface(typeDecl.getSootClassDecl().getName())) sc.addInterface(typeDecl.getSootClassDecl()); } if(isNestedType()) sc.setOuterClass(enclosingType().getSootClassDecl()); sc.setResolvingLevel(SootClass.HIERARCHY); super.jimplify1phase2(); sc.setResolvingLevel(SootClass.SIGNATURES); } /**
@Override public void visitSource(String source, String debug) { if (source != null) { klass.addTag(new SourceFileTag(source)); } }
private String findFileName(List<Tag> tags) { String fileName = null; for (Tag tag : tags) { if (tag instanceof SourceFileTag) { SourceFileTag t = (SourceFileTag) tag; if (t.getAbsolutePath() != null) { fileName = t.getAbsolutePath(); } else { if (t.getSourceFile() != null) { fileName = t.getSourceFile(); } } } else { // System.err.println("Unprocessed tag " + tag.getClass() + " - // " + tag); } } return fileName; }
/** * Writes out the information stored in the tags associated with the given statement * * @param builder * The builder used to generate the Dalvik method implementation * @param stmt * The statement for which to write out the tags */ protected void writeTagsForStatement(MethodImplementationBuilder builder, Stmt stmt) { List<Tag> tags = stmt.getTags(); for (Tag t : tags) { if (t instanceof LineNumberTag) { LineNumberTag lnt = (LineNumberTag) t; builder.addLineNumber(lnt.getLineNumber()); } else if (t instanceof SourceFileTag) { SourceFileTag sft = (SourceFileTag) t; builder.addSetSourceFile(new ImmutableStringReference(sft.getSourceFile())); } } }
public JVirtualInvokeExpr(Value base, SootMethodRef methodRef, List<? extends Value> args) { super(Jimple.v().newLocalBox(base), methodRef, new ValueBox[args.size()]); if (!Options.v().ignore_resolution_errors()) { // Check that the method's class is resolved enough methodRef.declaringClass().checkLevelIgnoreResolving(SootClass.HIERARCHY); // now check if the class is valid if (methodRef.declaringClass().isInterface()) { SootClass sc = methodRef.declaringClass(); String path = sc.hasTag("SourceFileTag") ? ((SourceFileTag) sc.getTag("SourceFileTag")).getAbsolutePath() : "uknown"; throw new RuntimeException("Trying to create virtual invoke expression for interface type (" + methodRef.declaringClass().getName() + " in file " + path + "). Use JInterfaceInvokeExpr instead!"); } } for (int i = 0; i < args.size(); i++) { this.argBoxes[i] = Jimple.v().newImmediateBox(args.get(i)); } }
/** * adds source file tag to each sootclass */ protected void addSourceFileTag(soot.SootClass sc) { soot.tagkit.SourceFileTag tag = null; if (sc.hasTag("SourceFileTag")) { tag = (soot.tagkit.SourceFileTag) sc.getTag("SourceFileTag"); } else { tag = new soot.tagkit.SourceFileTag(); sc.addTag(tag); } String name = Util.getSourceFileOfClass(sc); if (InitialResolver.v().classToSourceMap() != null) { if (InitialResolver.v().classToSourceMap().containsKey(name)) { name = InitialResolver.v().classToSourceMap().get(name); } } // the pkg is not included in the tag for some unknown reason // I think in this case windows uses the same slash - may cause // windows problems though int slashIndex = name.lastIndexOf("/"); if (slashIndex != -1) { name = name.substring(slashIndex + 1); } tag.setSourceFile(name); // sc.addTag(new soot.tagkit.SourceFileTag(name)); }
/** * @ast method * @aspect EmitJimple * @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddExtensions/JimpleBackend/EmitJimple.jrag:186 */ public void jimplify1phase2() { SootClass sc = getSootClassDecl(); sc.setResolvingLevel(SootClass.DANGLING); sc.setModifiers(sootTypeModifiers()); sc.setApplicationClass(); SourceFileTag st = new soot.tagkit.SourceFileTag(sourceNameWithoutPath()); st.setAbsolutePath(compilationUnit().pathName()); sc.addTag(st); sc.setSuperclass(typeObject().getSootClassDecl()); for(Iterator iter = superinterfacesIterator(); iter.hasNext(); ) { TypeDecl typeDecl = (TypeDecl)iter.next(); if(typeDecl != typeObject() && !sc.implementsInterface(typeDecl.getSootClassDecl().getName())) sc.addInterface(typeDecl.getSootClassDecl()); } if(isNestedType()) sc.setOuterClass(enclosingType().getSootClassDecl()); sc.setResolvingLevel(SootClass.HIERARCHY); super.jimplify1phase2(); sc.setResolvingLevel(SootClass.SIGNATURES); } /**
sc.addTag(new SourceFileTag(sourceFile));
if (c.hasTag("SourceFileTag")) { SourceFileTag sft = (SourceFileTag) c.getTag("SourceFileTag"); sourceFile = sft.getSourceFile();
if (sourceFileTag == null) { logger.info("Adding SourceFileTag for class {}", fullyQualifiedName); sourceFileTag = new SourceFileTag(); applicationClass.addTag(sourceFileTag); sourceFileTag.setSourceFile(newClassName);
t.setAbsolutePath(source.source().path()); } else { soot.tagkit.SourceFileTag t = new soot.tagkit.SourceFileTag(); t.setAbsolutePath(source.source().path()); sootClass.addTag(t);
logger.debug("" + "Warning: Class " + className + " has invalid SourceFile attribute (will be ignored)."); } else { bclass.addTag(new SourceFileTag(sourceFile, filePath));
String srcName = ((SourceFileTag) sootClass.getTag("SourceFileTag")).getSourceFile();
G.v().out.println( "Warning: Class "+className+" has invalid SourceFile attribute (will be ignored)." ); } else { bclass.addTag(new SourceFileTag( sourceFile ) );
/** * Emits the bytecode for the complete class */ protected void generateByteCode() { generateClassHeader(); // Retrieve information about the source of the class if (sc.hasTag("SourceFileTag") && !Options.v().no_output_source_file_attribute()) { String srcName = ((SourceFileTag) sc.getTag("SourceFileTag")).getSourceFile(); cv.visitSource(srcName, null); // TODO Correct value for the debug // argument } // Retrieve information about outer class if present if (sc.hasOuterClass() || sc.hasTag("EnclosingMethodTag") || sc.hasTag("OuterClassTag")) { generateOuterClassReference(); } // Retrieve information about annotations generateAnnotations(cv, sc); // Retrieve information about attributes generateAttributes(); // Retrieve information about inner classes generateInnerClassReferences(); // Generate fields generateFields(); // Generate methods generateMethods(); cv.visitEnd(); }
G.v().out.println( "Warning: Class "+className+" has invalid SourceFile attribute (will be ignored)." ); } else { bclass.addTag(new SourceFileTag( sourceFile ) );