From 111221644c5b7b1d4f426d02786aeebf1addc8f6 Mon Sep 17 00:00:00 2001 From: Dan Bornstein Date: Wed, 1 Dec 2010 12:30:21 -0800 Subject: 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 --- dexdump/DexDump.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'dexdump') 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, -- cgit v1.2.3