1 #include <inttypes.h> 2 3 /* 4 * Dump the fixed-purpose ARM registers, along with some other info. 5 * 6 * This function MUST be compiled in ARM mode -- THUMB will yield bogus 7 * results. 8 * 9 * This will NOT preserve r0-r3/ip. 10 */ 11 void dvmMterpDumpArmRegs(uint32_t r0, uint32_t r1, uint32_t r2, uint32_t r3) 12 { 13 register uint32_t rPC asm("r4"); 14 register uint32_t rFP asm("r5"); 15 register uint32_t rGLUE asm("r6"); 16 register uint32_t rINST asm("r7"); 17 register uint32_t rIBASE asm("r8"); 18 register uint32_t r9 asm("r9"); 19 register uint32_t r10 asm("r10"); 20 21 //extern char dvmAsmInstructionStart[]; 22 23 printf("REGS: r0=%08x r1=%08x r2=%08x r3=%08x\n", r0, r1, r2, r3); 24 printf(" : rPC=%08x rFP=%08x rGLUE=%08x rINST=%08x\n", 25 rPC, rFP, rGLUE, rINST); 26 printf(" : rIBASE=%08x r9=%08x r10=%08x\n", rIBASE, r9, r10); 27 28 //MterpGlue* glue = (MterpGlue*) rGLUE; 29 //const Method* method = glue->method; 30 printf(" + self is %p\n", dvmThreadSelf()); 31 //printf(" + currently in %s.%s %s\n", 32 // method->clazz->descriptor, method->name, method->shorty); 33 //printf(" + dvmAsmInstructionStart = %p\n", dvmAsmInstructionStart); 34 //printf(" + next handler for 0x%02x = %p\n", 35 // rINST & 0xff, dvmAsmInstructionStart + (rINST & 0xff) * 64); 36 } 37 38 /* 39 * Dump the StackSaveArea for the specified frame pointer. 40 */ 41 void dvmDumpFp(void* fp, StackSaveArea* otherSaveArea) 42 { 43 StackSaveArea* saveArea = SAVEAREA_FROM_FP(fp); 44 printf("StackSaveArea for fp %p [%p/%p]:\n", fp, saveArea, otherSaveArea); 45 #ifdef EASY_GDB 46 printf(" prevSave=%p, prevFrame=%p savedPc=%p meth=%p curPc=%p\n", 47 saveArea->prevSave, saveArea->prevFrame, saveArea->savedPc, 48 saveArea->method, saveArea->xtra.currentPc); 49 #else 50 printf(" prevFrame=%p savedPc=%p meth=%p curPc=%p fp[0]=0x%08x\n", 51 saveArea->prevFrame, saveArea->savedPc, 52 saveArea->method, saveArea->xtra.currentPc, 53 *(u4*)fp); 54 #endif 55 } 56 57 /* 58 * Does the bulk of the work for common_printMethod(). 59 */ 60 void dvmMterpPrintMethod(Method* method) 61 { 62 /* 63 * It is a direct (non-virtual) method if it is static, private, 64 * or a constructor. 65 */ 66 bool isDirect = 67 ((method->accessFlags & (ACC_STATIC|ACC_PRIVATE)) != 0) || 68 (method->name[0] == '<'); 69 70 char* desc = dexProtoCopyMethodDescriptor(&method->prototype); 71 72 printf("<%c:%s.%s %s> ", 73 isDirect ? 'D' : 'V', 74 method->clazz->descriptor, 75 method->name, 76 desc); 77 78 free(desc); 79 } 80