Home | History | Annotate | Download | only in mips
      1 /*
      2  * Copyright (C) 2008 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 #include <inttypes.h>
     18 
     19 /*
     20  * Dump the fixed-purpose MIPS registers, along with some other info.
     21  *
     22  */
     23 void dvmMterpDumpMipsRegs(uint32_t a0, uint32_t a1, uint32_t a2, uint32_t a3)
     24 {
     25     register uint32_t rPC       asm("s0");
     26     register uint32_t rFP       asm("s1");
     27     register uint32_t rSELF     asm("s2");
     28     register uint32_t rIBASE    asm("s3");
     29     register uint32_t rINST     asm("s4");
     30     register uint32_t rOBJ      asm("s5");
     31     register uint32_t rBIX      asm("s6");
     32     register uint32_t rTEMP	asm("s7");
     33 
     34     //extern char dvmAsmInstructionStart[];
     35 
     36     printf("REGS: a0=%08x a1=%08x a2=%08x a3=%08x\n", a0, a1, a2, a3);
     37     printf("    : rPC=%08x rFP=%08x rSELF=%08x rIBASE=%08x\n",
     38         rPC, rFP, rSELF, rIBASE);
     39     printf("    : rINST=%08x rOBJ=%08x rBIX=%08x rTEMP=%08x \n", rINST, rOBJ, rBIX, rTEMP);
     40 
     41     //Thread* self = (Thread*) rSELF;
     42     //const Method* method = self->method;
     43     printf("    + self is %p\n", dvmThreadSelf());
     44     //printf("    + currently in %s.%s %s\n",
     45     //    method->clazz->descriptor, method->name, method->signature);
     46     //printf("    + dvmAsmInstructionStart = %p\n", dvmAsmInstructionStart);
     47     //printf("    + next handler for 0x%02x = %p\n",
     48     //    rINST & 0xff, dvmAsmInstructionStart + (rINST & 0xff) * 64);
     49 }
     50 
     51 /*
     52  * Dump the StackSaveArea for the specified frame pointer.
     53  */
     54 void dvmDumpFp(void* fp, StackSaveArea* otherSaveArea)
     55 {
     56     StackSaveArea* saveArea = SAVEAREA_FROM_FP(fp);
     57     printf("StackSaveArea for fp %p [%p/%p]:\n", fp, saveArea, otherSaveArea);
     58 #ifdef EASY_GDB
     59     printf("  prevSave=%p, prevFrame=%p savedPc=%p meth=%p curPc=%p\n",
     60         saveArea->prevSave, saveArea->prevFrame, saveArea->savedPc,
     61         saveArea->method, saveArea->xtra.currentPc);
     62 #else
     63     printf("  prevFrame=%p savedPc=%p meth=%p curPc=%p fp[0]=0x%08x\n",
     64         saveArea->prevFrame, saveArea->savedPc,
     65         saveArea->method, saveArea->xtra.currentPc,
     66         *(u4*)fp);
     67 #endif
     68 }
     69 
     70 /*
     71  * Does the bulk of the work for common_printMethod().
     72  */
     73 void dvmMterpPrintMethod(Method* method)
     74 {
     75     /*
     76      * It is a direct (non-virtual) method if it is static, private,
     77      * or a constructor.
     78      */
     79     bool isDirect =
     80         ((method->accessFlags & (ACC_STATIC|ACC_PRIVATE)) != 0) ||
     81         (method->name[0] == '<');
     82 
     83     char* desc = dexProtoCopyMethodDescriptor(&method->prototype);
     84 
     85     printf("<%c:%s.%s %s> ",
     86             isDirect ? 'D' : 'V',
     87             method->clazz->descriptor,
     88             method->name,
     89             desc);
     90 
     91     free(desc);
     92 }
     93