/** * Position Tag Adder */ public static void addPosTag(soot.tagkit.Host host, int sc, int ec) { host.addTag(new soot.tagkit.SourcePositionTag(sc, ec)); }
/** * Line Tag Adder */ public static void addLineTag(soot.tagkit.Host host, int sLine, int eLine) { host.addTag(new soot.tagkit.SourceLineNumberTag(sLine, eLine)); }
public static void addMethodPosTag(soot.tagkit.Host meth, int start, int end) { meth.addTag(new soot.tagkit.SourcePositionTag(start, end)); }
/** * @see FieldVisitor#visitAttribute(Attribute) * @see MethodVisitor#visitAttribute(Attribute) * @see ClassVisitor#visitAttribute(Attribute) */ public void visitAttribute(Attribute attr) { // SA, 2017-07-21: As of ASM 5.1, there is no better way to obtain // attribute values. byte[] value = null; try { Field fld = Attribute.class.getDeclaredField("value"); fld.setAccessible(true); value = (byte[]) fld.get(attr); } catch (Exception ex) { // Just carry on } host.addTag(new GenericAttribute(attr.type, value)); } }
/** * Converts field annotations from Dexlib to Jimple * * @param h * @param f */ public void handleFieldAnnotation(Host h, Field f) { Set<? extends Annotation> aSet = f.getAnnotations(); if (aSet != null && !aSet.isEmpty()) { List<Tag> tags = handleAnnotation(aSet, null); if (tags != null) { for (Tag t : tags) { if (t != null) { h.addTag(t); } } } } }
/** * Tag the passed host with: - this instructions line number (if one is set) - the original bytecode offset * * @param host * the host to tag */ protected void addTags(Host host) { Options options = Options.v(); if (options.keep_line_number() && lineNumber != -1) { host.addTag(new LineNumberTag(lineNumber)); host.addTag(new SourceLineNumberTag(lineNumber)); } if (options.keep_offset()) { host.addTag(new BytecodeOffsetTag(codeAddress)); } }
/** * Finds a VisibilityAnnotationTag attached to a given Host with the appropriate visibility, or adds one if no such tag is * attached. * * @param h * an Host * @param visibility * a visibility level, taken from soot.tagkit.AnnotationConstants * @return */ private VisibilityAnnotationTag findOrAdd(Host h, int visibility) { ArrayList<VisibilityAnnotationTag> va_tags = new ArrayList<VisibilityAnnotationTag>(); for (Tag t : h.getTags()) { if (t instanceof VisibilityAnnotationTag) { VisibilityAnnotationTag vat = (VisibilityAnnotationTag) t; if (vat.getVisibility() == visibility) { va_tags.add(vat); } } } if (va_tags.isEmpty()) { VisibilityAnnotationTag vat = new VisibilityAnnotationTag(visibility); h.addTag(vat); return vat; } // return the first visibility annotation with the right visibility return (va_tags.get(0)); }
/** * @see FieldVisitor#visitAnnotation(String, boolean) * @see MethodVisitor#visitAnnotation(String, boolean) * @see ClassVisitor#visitAnnotation(String, boolean) */ public AnnotationVisitor visitAnnotation(final String desc, boolean visible) { VisibilityAnnotationTag tag; if (visible) { tag = visibleTag; if (tag == null) { visibleTag = tag = new VisibilityAnnotationTag(AnnotationConstants.RUNTIME_VISIBLE); host.addTag(tag); } } else { tag = invisibleTag; if (tag == null) { invisibleTag = tag = new VisibilityAnnotationTag(AnnotationConstants.RUNTIME_INVISIBLE); host.addTag(tag); } } scb.addDep(AsmUtil.toQualifiedName(desc.substring(1, desc.length() - 1))); final VisibilityAnnotationTag _tag = tag; return new AnnotationElemBuilder() { @Override public void visitEnd() { AnnotationTag annotTag = new AnnotationTag(desc, elems); _tag.addAnnotation(annotTag); } }; }
public static void addMethodLineTag(soot.tagkit.Host host, int sline, int eline) { if (soot.options.Options.v().keep_line_number()) { host.addTag(new soot.tagkit.SourceLineNumberTag(sline, eline)); } }
public static void addLnPosTags(soot.tagkit.Host host, int sline, int eline, int spos, int epos) { if (soot.options.Options.v().keep_line_number()) { host.addTag(new soot.tagkit.SourceLnPosTag(sline, eline, spos, epos)); } }
private void addAnnotationVisibilityAttribute(Host host, attribute_info attribute, ClassFile coffiClass, Collection<Type> references) { VisibilityAnnotationTag tag; if (attribute instanceof RuntimeVisibleAnnotations_attribute) { tag = new VisibilityAnnotationTag(AnnotationConstants.RUNTIME_VISIBLE); RuntimeVisibleAnnotations_attribute attr = (RuntimeVisibleAnnotations_attribute) attribute; addAnnotations(attr.number_of_annotations, attr.annotations, coffiClass, tag, references); } else { tag = new VisibilityAnnotationTag(AnnotationConstants.RUNTIME_INVISIBLE); RuntimeInvisibleAnnotations_attribute attr = (RuntimeInvisibleAnnotations_attribute) attribute; addAnnotations(attr.number_of_annotations, attr.annotations, coffiClass, tag, references); } host.addTag(tag); }
public static void addLnPosTags(soot.tagkit.Host host, polyglot.util.Position pos) { if (pos != null) { if (soot.options.Options.v().keep_line_number()) { if (pos.file() != null) { host.addTag( new soot.tagkit.SourceLnNamePosTag(pos.file(), pos.line(), pos.endLine(), pos.column(), pos.endColumn())); } else { host.addTag(new soot.tagkit.SourceLnPosTag(pos.line(), pos.endLine(), pos.column(), pos.endColumn())); } } } }
/** * Line Tag Adder */ public static void addLineTag(soot.tagkit.Host host, polyglot.ast.Node node) { if (soot.options.Options.v().keep_line_number()) { if (node.position() != null) { host.addTag(new soot.tagkit.SourceLineNumberTag(node.position().line(), node.position().line())); } } }
private void addAnnotationVisibilityParameterAttribute(Host host, attribute_info attribute, ClassFile coffiClass, Collection<Type> references) { VisibilityParameterAnnotationTag tag; if (attribute instanceof RuntimeVisibleParameterAnnotations_attribute) { RuntimeVisibleParameterAnnotations_attribute attr = (RuntimeVisibleParameterAnnotations_attribute) attribute; tag = new VisibilityParameterAnnotationTag(attr.num_parameters, AnnotationConstants.RUNTIME_VISIBLE); for (int i = 0; i < attr.num_parameters; i++) { parameter_annotation pAnnot = attr.parameter_annotations[i]; VisibilityAnnotationTag vTag = new VisibilityAnnotationTag(AnnotationConstants.RUNTIME_VISIBLE); addAnnotations(pAnnot.num_annotations, pAnnot.annotations, coffiClass, vTag, references); tag.addVisibilityAnnotation(vTag); } } else { RuntimeInvisibleParameterAnnotations_attribute attr = (RuntimeInvisibleParameterAnnotations_attribute) attribute; tag = new VisibilityParameterAnnotationTag(attr.num_parameters, AnnotationConstants.RUNTIME_INVISIBLE); for (int i = 0; i < attr.num_parameters; i++) { parameter_annotation pAnnot = attr.parameter_annotations[i]; VisibilityAnnotationTag vTag = new VisibilityAnnotationTag(AnnotationConstants.RUNTIME_INVISIBLE); addAnnotations(pAnnot.num_annotations, pAnnot.annotations, coffiClass, vTag, references); tag.addVisibilityAnnotation(vTag); } } host.addTag(tag); }
private void addAnnotationVisibilityAttribute(Host host, attribute_info attribute, ClassFile coffiClass, List references){ VisibilityAnnotationTag tag; if (attribute instanceof RuntimeVisibleAnnotations_attribute){ tag = new VisibilityAnnotationTag(AnnotationConstants.RUNTIME_VISIBLE); RuntimeVisibleAnnotations_attribute attr = (RuntimeVisibleAnnotations_attribute)attribute; addAnnotations(attr.number_of_annotations, attr.annotations, coffiClass, tag, references); } else { tag = new VisibilityAnnotationTag(AnnotationConstants.RUNTIME_INVISIBLE); RuntimeInvisibleAnnotations_attribute attr = (RuntimeInvisibleAnnotations_attribute)attribute; addAnnotations(attr.number_of_annotations, attr.annotations, coffiClass, tag, references); } host.addTag(tag); }
private void addAnnotationVisibilityAttribute(Host host, attribute_info attribute, ClassFile coffiClass, List references){ VisibilityAnnotationTag tag; if (attribute instanceof RuntimeVisibleAnnotations_attribute){ tag = new VisibilityAnnotationTag(AnnotationConstants.RUNTIME_VISIBLE); RuntimeVisibleAnnotations_attribute attr = (RuntimeVisibleAnnotations_attribute)attribute; addAnnotations(attr.number_of_annotations, attr.annotations, coffiClass, tag, references); } else { tag = new VisibilityAnnotationTag(AnnotationConstants.RUNTIME_INVISIBLE); RuntimeInvisibleAnnotations_attribute attr = (RuntimeInvisibleAnnotations_attribute)attribute; addAnnotations(attr.number_of_annotations, attr.annotations, coffiClass, tag, references); } host.addTag(tag); }
private void addAnnotationVisibilityParameterAttribute(Host host, attribute_info attribute, ClassFile coffiClass, List references){ VisibilityParameterAnnotationTag tag; if (attribute instanceof RuntimeVisibleParameterAnnotations_attribute){ RuntimeVisibleParameterAnnotations_attribute attr = (RuntimeVisibleParameterAnnotations_attribute)attribute; tag = new VisibilityParameterAnnotationTag(attr.num_parameters, AnnotationConstants.RUNTIME_VISIBLE); for (int i = 0; i < attr.num_parameters; i++){ parameter_annotation pAnnot = attr.parameter_annotations[i]; VisibilityAnnotationTag vTag = new VisibilityAnnotationTag(AnnotationConstants.RUNTIME_VISIBLE); addAnnotations(pAnnot.num_annotations, pAnnot.annotations, coffiClass, vTag, references); tag.addVisibilityAnnotation(vTag); } } else { RuntimeInvisibleParameterAnnotations_attribute attr = (RuntimeInvisibleParameterAnnotations_attribute)attribute; tag = new VisibilityParameterAnnotationTag(attr.num_parameters, AnnotationConstants.RUNTIME_INVISIBLE); for (int i = 0; i < attr.num_parameters; i++){ parameter_annotation pAnnot = attr.parameter_annotations[i]; VisibilityAnnotationTag vTag = new VisibilityAnnotationTag(AnnotationConstants.RUNTIME_INVISIBLE); addAnnotations(pAnnot.num_annotations, pAnnot.annotations, coffiClass, vTag, references); tag.addVisibilityAnnotation(vTag); } } host.addTag(tag); }
private void addAnnotationVisibilityParameterAttribute(Host host, attribute_info attribute, ClassFile coffiClass, List references){ VisibilityParameterAnnotationTag tag; if (attribute instanceof RuntimeVisibleParameterAnnotations_attribute){ RuntimeVisibleParameterAnnotations_attribute attr = (RuntimeVisibleParameterAnnotations_attribute)attribute; tag = new VisibilityParameterAnnotationTag(attr.num_parameters, AnnotationConstants.RUNTIME_VISIBLE); for (int i = 0; i < attr.num_parameters; i++){ parameter_annotation pAnnot = attr.parameter_annotations[i]; VisibilityAnnotationTag vTag = new VisibilityAnnotationTag(AnnotationConstants.RUNTIME_VISIBLE); addAnnotations(pAnnot.num_annotations, pAnnot.annotations, coffiClass, vTag, references); tag.addVisibilityAnnotation(vTag); } } else { RuntimeInvisibleParameterAnnotations_attribute attr = (RuntimeInvisibleParameterAnnotations_attribute)attribute; tag = new VisibilityParameterAnnotationTag(attr.num_parameters, AnnotationConstants.RUNTIME_INVISIBLE); for (int i = 0; i < attr.num_parameters; i++){ parameter_annotation pAnnot = attr.parameter_annotations[i]; VisibilityAnnotationTag vTag = new VisibilityAnnotationTag(AnnotationConstants.RUNTIME_INVISIBLE); addAnnotations(pAnnot.num_annotations, pAnnot.annotations, coffiClass, vTag, references); tag.addVisibilityAnnotation(vTag); } } host.addTag(tag); }