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 /* 18 * Dalvik interpreter public definitions. 19 */ 20 #ifndef DALVIK_INTERP_INTERP_H_ 21 #define DALVIK_INTERP_INTERP_H_ 22 23 /* 24 * Stash the dalvik PC in the frame. Called during interpretation. 25 */ 26 INLINE void dvmExportPC(const u2* pc, const u4* fp) 27 { 28 SAVEAREA_FROM_FP(fp)->xtra.currentPc = pc; 29 } 30 31 /* 32 * Extract the Dalvik opcode 33 */ 34 #define GET_OPCODE(_inst) (((_inst & 0xff) == OP_DISPATCH_FF) ? \ 35 (0x100 + ((_inst >> 8) & 0xff)) : (_inst & 0xff)) 36 37 /* 38 * Interpreter entry point. Call here after setting up the interpreted 39 * stack (most code will want to get here via dvmCallMethod().) 40 */ 41 void dvmInterpret(Thread* thread, const Method* method, JValue* pResult); 42 43 /* 44 * Throw an exception for a problem detected by the verifier. 45 * 46 * This is called from the handler for the throw-verification-error 47 * instruction. "method" is the method currently being executed. 48 */ 49 extern "C" void dvmThrowVerificationError(const Method* method, 50 int kind, int ref); 51 52 /* 53 * One-time initialization and shutdown. 54 */ 55 bool dvmBreakpointStartup(void); 56 void dvmBreakpointShutdown(void); 57 void dvmInitInterpreterState(Thread* self); 58 59 /* 60 * Breakpoint implementation. 61 */ 62 void dvmInitBreakpoints(); 63 void dvmAddBreakAddr(Method* method, unsigned int instrOffset); 64 void dvmClearBreakAddr(Method* method, unsigned int instrOffset); 65 bool dvmAddSingleStep(Thread* thread, int size, int depth); 66 void dvmClearSingleStep(Thread* thread); 67 68 /* 69 * Recover the opcode that was replaced by a breakpoint. 70 */ 71 extern "C" u1 dvmGetOriginalOpcode(const u2* addr); 72 73 /* 74 * Flush any breakpoints associated with methods in "clazz". 75 */ 76 void dvmFlushBreakpoints(ClassObject* clazz); 77 78 /* 79 * Debugger support 80 */ 81 extern "C" void dvmCheckBefore(const u2 *dPC, u4 *fp, Thread* self); 82 extern "C" void dvmReportExceptionThrow(Thread* self, Object* exception); 83 extern "C" void dvmReportPreNativeInvoke(const Method* methodToCall, Thread* self, u4* fp); 84 extern "C" void dvmReportPostNativeInvoke(const Method* methodToCall, Thread* self, u4* fp); 85 extern "C" void dvmReportInvoke(Thread* self, const Method* methodToCall); 86 extern "C" void dvmReportReturn(Thread* self); 87 88 /* 89 * InterpBreak & subMode control 90 */ 91 void dvmDisableSubMode(Thread* thread, ExecutionSubModes subMode); 92 extern "C" void dvmEnableSubMode(Thread* thread, ExecutionSubModes subMode); 93 void dvmDisableAllSubMode(ExecutionSubModes subMode); 94 void dvmEnableAllSubMode(ExecutionSubModes subMode); 95 void dvmAddToSuspendCounts(Thread* thread, int delta, int dbgDelta); 96 void dvmCheckInterpStateConsistency(); 97 void dvmInitializeInterpBreak(Thread* thread); 98 99 /* 100 * Register a callback to occur at the next safe point for a single thread. 101 * If funct is NULL, the previous registration is cancelled. 102 * 103 * The callback prototype is: 104 * bool funct(Thread* thread, void* arg) 105 * 106 * If funct returns false, the callback will be disarmed. If true, 107 * it will stay in effect. 108 */ 109 void dvmArmSafePointCallback(Thread* thread, SafePointCallback funct, 110 void* arg); 111 112 113 #ifndef DVM_NO_ASM_INTERP 114 extern void* dvmAsmInstructionStart[]; 115 extern void* dvmAsmAltInstructionStart[]; 116 #endif 117 118 #endif // DALVIK_INTERP_INTERP_H_ 119