mirror of
https://github.com/revanced/smali.git
synced 2025-05-09 10:54:29 +02:00
Add a new option to add a comment line with the code offset for each instruction
git-svn-id: https://smali.googlecode.com/svn/trunk@634 55b6fa8a-2a1e-11de-a435-ffa8d773f76a
This commit is contained in:
parent
5b908115c0
commit
2bdbf739bf
@ -41,6 +41,7 @@ import org.jf.dexlib.Debug.DebugInstructionIterator;
|
||||
import org.jf.dexlib.Util.AccessFlags;
|
||||
import org.antlr.stringtemplate.StringTemplateGroup;
|
||||
import org.antlr.stringtemplate.StringTemplate;
|
||||
import org.jf.dexlib.Util.Hex;
|
||||
import org.jf.dexlib.Util.SparseIntArray;
|
||||
|
||||
import java.util.*;
|
||||
@ -274,6 +275,11 @@ public class MethodDefinition {
|
||||
methodItems.add(new BlankMethodItem(stg, currentCodeAddress));
|
||||
}
|
||||
|
||||
if (baksmali.addCodeOffsets) {
|
||||
methodItems.add(new CommentMethodItem(stg, String.format("@%x", currentCodeAddress),
|
||||
currentCodeAddress, -1000));
|
||||
}
|
||||
|
||||
if (baksmali.registerInfo != 0 && !instruction.instruction.getFormat().variableSizeFormat) {
|
||||
printPreRegister.clear();
|
||||
printPostRegister.clear();
|
||||
|
@ -45,6 +45,7 @@ public class baksmali {
|
||||
public static boolean useLocalsDirective = false;
|
||||
public static boolean useSequentialLabels = false;
|
||||
public static boolean outputDebugInfo = true;
|
||||
public static boolean addCodeOffsets = false;
|
||||
public static int registerInfo = 0;
|
||||
public static String bootClassPath;
|
||||
public static DeodexUtil deodexUtil = null;
|
||||
@ -52,12 +53,13 @@ public class baksmali {
|
||||
public static void disassembleDexFile(DexFile dexFile, Deodexerant deodexerant, String outputDirectory,
|
||||
String bootClassPathDir, String bootClassPath, boolean noParameterRegisters,
|
||||
boolean useLocalsDirective, boolean useSequentialLabels,
|
||||
boolean outputDebugInfo, int registerInfo)
|
||||
boolean outputDebugInfo, boolean addCodeOffsets, int registerInfo)
|
||||
{
|
||||
baksmali.noParameterRegisters = noParameterRegisters;
|
||||
baksmali.useLocalsDirective = useLocalsDirective;
|
||||
baksmali.useSequentialLabels = useSequentialLabels;
|
||||
baksmali.outputDebugInfo = outputDebugInfo;
|
||||
baksmali.addCodeOffsets = addCodeOffsets;
|
||||
baksmali.registerInfo = registerInfo;
|
||||
baksmali.bootClassPath = bootClassPath;
|
||||
|
||||
|
@ -87,6 +87,7 @@ public class main {
|
||||
boolean useLocalsDirective = false;
|
||||
boolean useSequentialLabels = false;
|
||||
boolean outputDebugInfo = true;
|
||||
boolean addCodeOffsets = false;
|
||||
|
||||
int registerInfo = 0;
|
||||
|
||||
@ -138,6 +139,9 @@ public class main {
|
||||
case 'd':
|
||||
bootClassPathDir = commandLine.getOptionValue("d");
|
||||
break;
|
||||
case 'f':
|
||||
addCodeOffsets = true;
|
||||
break;
|
||||
case 'r':
|
||||
String[] values = commandLine.getOptionValues('r');
|
||||
|
||||
@ -262,7 +266,8 @@ public class main {
|
||||
|
||||
if (disassemble) {
|
||||
baksmali.disassembleDexFile(dexFile, deodexerant, outputDirectory, bootClassPathDir, bootClassPath,
|
||||
noParameterRegisters, useLocalsDirective, useSequentialLabels, outputDebugInfo, registerInfo);
|
||||
noParameterRegisters, useLocalsDirective, useSequentialLabels, outputDebugInfo, addCodeOffsets,
|
||||
registerInfo);
|
||||
}
|
||||
|
||||
if ((doDump || write) && !dexFile.isOdex()) {
|
||||
@ -415,6 +420,10 @@ public class main {
|
||||
.withArgName("DIR")
|
||||
.create("d");
|
||||
|
||||
Option codeOffsetOption = OptionBuilder.withLongOpt("code-offsets")
|
||||
.withDescription("add comments to the disassembly containing the code offset for each address")
|
||||
.create("f");
|
||||
|
||||
basicOptions.addOption(versionOption);
|
||||
basicOptions.addOption(helpOption);
|
||||
basicOptions.addOption(outputDirOption);
|
||||
@ -426,6 +435,7 @@ public class main {
|
||||
basicOptions.addOption(registerInfoOption);
|
||||
basicOptions.addOption(classPathOption);
|
||||
basicOptions.addOption(classPathDirOption);
|
||||
basicOptions.addOption(codeOffsetOption);
|
||||
|
||||
debugOptions.addOption(dumpOption);
|
||||
debugOptions.addOption(noDisassemblyOption);
|
||||
|
Loading…
x
Reference in New Issue
Block a user