Annotate the map section

This commit is contained in:
Ben Gruver 2013-02-26 22:49:55 -08:00
parent 90f8ea9f1e
commit 6fb7190811
2 changed files with 34 additions and 1 deletions

View File

@ -32,6 +32,7 @@
package org.jf.dexlib2.dexbacked.raw;
import org.jf.dexlib2.dexbacked.DexBackedDexFile;
import org.jf.dexlib2.util.AnnotatedBytes;
import javax.annotation.Nonnull;
@ -66,4 +67,35 @@ public class MapItem {
public int getOffset() {
return dexFile.readSmallUint(offset + OFFSET_OFFSET);
}
@Nonnull
public static SectionAnnotator getAnnotator() {
return new SectionAnnotator() {
@Nonnull @Override public String getItemName() {
return "map_item";
}
@Override
protected void annotateItem(@Nonnull AnnotatedBytes out, @Nonnull DexBackedDexFile dexFile, int itemIndex) {
int itemType = dexFile.readUshort(out.getCursor());
out.annotate(2, "type = 0x%x: %s", itemType, ItemType.getItemTypeName(itemType));
out.annotate(2, "unused");
int size = dexFile.readSmallUint(out.getCursor());
out.annotate(4, "size = %d", size);
int offset = dexFile.readSmallUint(out.getCursor());
out.annotate(4, "offset = 0x%x", offset);
}
@Override
public void annotateSection(@Nonnull AnnotatedBytes out, @Nonnull DexBackedDexFile dexFile, int itemCount) {
int mapItemCount = dexFile.readSmallUint(out.getCursor());
out.annotate(4, "size = %d", mapItemCount);
super.annotateSection(out, dexFile, mapItemCount);
}
};
}
}

View File

@ -78,7 +78,8 @@ public class RawDexFile {
static {
annotators = ImmutableMap.of(
ItemType.TYPE_LIST, TypeListItem.getAnnotator(),
ItemType.ANNOTATION_SET_REF_LIST, AnnotationSetRefList.getAnnotator());
ItemType.ANNOTATION_SET_REF_LIST, AnnotationSetRefList.getAnnotator(),
ItemType.MAP_LIST, MapItem.getAnnotator());
}
public void dumpTo(Writer out, int width) throws IOException {