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