• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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  */
dvmMterpDumpArmRegs(uint32_t r0,uint32_t r1,uint32_t r2,uint32_t r3)11 void dvmMterpDumpArmRegs(uint32_t r0, uint32_t r1, uint32_t r2, uint32_t r3)
12 {
13   // TODO: Clang does not support asm declaration syntax.
14 #ifndef __clang__
15     register uint32_t rPC       asm("r4");
16     register uint32_t rFP       asm("r5");
17     register uint32_t rSELF     asm("r6");
18     register uint32_t rINST     asm("r7");
19     register uint32_t rIBASE    asm("r8");
20     register uint32_t r9        asm("r9");
21     register uint32_t r10       asm("r10");
22 
23     //extern char dvmAsmInstructionStart[];
24 
25     printf("REGS: r0=%08x r1=%08x r2=%08x r3=%08x\n", r0, r1, r2, r3);
26     printf("    : rPC=%08x rFP=%08x rSELF=%08x rINST=%08x\n",
27         rPC, rFP, rSELF, rINST);
28     printf("    : rIBASE=%08x r9=%08x r10=%08x\n", rIBASE, r9, r10);
29 #endif
30 
31     //Thread* self = (Thread*) rSELF;
32     //const Method* method = self->method;
33     printf("    + self is %p\n", dvmThreadSelf());
34     //printf("    + currently in %s.%s %s\n",
35     //    method->clazz->descriptor, method->name, method->shorty);
36     //printf("    + dvmAsmInstructionStart = %p\n", dvmAsmInstructionStart);
37     //printf("    + next handler for 0x%02x = %p\n",
38     //    rINST & 0xff, dvmAsmInstructionStart + (rINST & 0xff) * 64);
39 }
40 
41 /*
42  * Dump the StackSaveArea for the specified frame pointer.
43  */
dvmDumpFp(void * fp,StackSaveArea * otherSaveArea)44 void dvmDumpFp(void* fp, StackSaveArea* otherSaveArea)
45 {
46     StackSaveArea* saveArea = SAVEAREA_FROM_FP(fp);
47     printf("StackSaveArea for fp %p [%p/%p]:\n", fp, saveArea, otherSaveArea);
48 #ifdef EASY_GDB
49     printf("  prevSave=%p, prevFrame=%p savedPc=%p meth=%p curPc=%p\n",
50         saveArea->prevSave, saveArea->prevFrame, saveArea->savedPc,
51         saveArea->method, saveArea->xtra.currentPc);
52 #else
53     printf("  prevFrame=%p savedPc=%p meth=%p curPc=%p fp[0]=0x%08x\n",
54         saveArea->prevFrame, saveArea->savedPc,
55         saveArea->method, saveArea->xtra.currentPc,
56         *(u4*)fp);
57 #endif
58 }
59 
60 /*
61  * Does the bulk of the work for common_printMethod().
62  */
dvmMterpPrintMethod(Method * method)63 void dvmMterpPrintMethod(Method* method)
64 {
65     /*
66      * It is a direct (non-virtual) method if it is static, private,
67      * or a constructor.
68      */
69     bool isDirect =
70         ((method->accessFlags & (ACC_STATIC|ACC_PRIVATE)) != 0) ||
71         (method->name[0] == '<');
72 
73     char* desc = dexProtoCopyMethodDescriptor(&method->prototype);
74 
75     printf("<%c:%s.%s %s> ",
76             isDirect ? 'D' : 'V',
77             method->clazz->descriptor,
78             method->name,
79             desc);
80 
81     free(desc);
82 }
83