summaryrefslogtreecommitdiffstats
path: root/dexdump
diff options
context:
space:
mode:
authorDan Bornstein <danfuzz@android.com>2010-12-01 12:30:21 -0800
committerDan Bornstein <danfuzz@android.com>2010-12-01 12:47:45 -0800
commit111221644c5b7b1d4f426d02786aeebf1addc8f6 (patch)
tree31115dc6d484bd9b4877ed41e5ad3c5eb380605b /dexdump
parentfe9382b46660cb240a99efb7ac772db7b2f4ab21 (diff)
downloadandroid_dalvik-111221644c5b7b1d4f426d02786aeebf1addc8f6.tar.gz
android_dalvik-111221644c5b7b1d4f426d02786aeebf1addc8f6.tar.bz2
android_dalvik-111221644c5b7b1d4f426d02786aeebf1addc8f6.zip
Add more "extended opcode" structure to libdex.
Although we don't yet generate any of the extended opcodes, this change makes it a bit easier to add them. In particular, we now differentiate between the raw opcode in a code unit and an associated "packed opcode number." The packed opcode space is densely populated in the range 0x000-0x1ff (though there will still be a few unused slots), whereas the raw opcode values are sparse throughout the range 0x0000-0xffff. The OpCode enum is redefined/clarified to have packed, not sparse, opcode values. Change-Id: Ie3208a258648fbf044d344646f66c49ad24c31b2
Diffstat (limited to 'dexdump')
-rw-r--r--dexdump/DexDump.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/dexdump/DexDump.c b/dexdump/DexDump.c
index 3950a81d0..158ac0c0e 100644
--- a/dexdump/DexDump.c
+++ b/dexdump/DexDump.c
@@ -1070,10 +1070,17 @@ void dumpBytecodes(DexFile* pDexFile, const DexMethod* pDexMethod)
insnIdx = 0;
while (insnIdx < (int) pCode->insnsSize) {
int insnWidth;
- OpCode opCode;
DecodedInstruction decInsn;
u2 instr;
+ /*
+ * Note: This code parallels the function
+ * dexGetInstrOrTableWidth() in InstrUtils.c, but this version
+ * can deal with data in either endianness.
+ *
+ * TODO: Figure out if this really matters, and possibly change
+ * this to just use dexGetInstrOrTableWidth().
+ */
instr = get2LE((const u1*)insns);
if (instr == kPackedSwitchSignature) {
insnWidth = 4 + get2LE((const u1*)(insns+1)) * 2;
@@ -1083,10 +1090,10 @@ void dumpBytecodes(DexFile* pDexFile, const DexMethod* pDexMethod)
int width = get2LE((const u1*)(insns+1));
int size = get2LE((const u1*)(insns+2)) |
(get2LE((const u1*)(insns+3))<<16);
- // The plus 1 is to round up for odd size and width
+ // The plus 1 is to round up for odd size and width.
insnWidth = 4 + ((size * width) + 1) / 2;
} else {
- opCode = instr & 0xff;
+ OpCode opCode = dexOpCodeFromCodeUnit(instr);
insnWidth = dexGetInstrWidth(opCode);
if (insnWidth == 0) {
fprintf(stderr,