| The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 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 | */ |
| Andy McFadden | 9651693 | 2009-10-28 17:39:02 -0700 | [diff] [blame] | 16 | |
| The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 17 | /* |
| 18 | * Dalvik interpreter public definitions. |
| 19 | */ |
| 20 | #ifndef _DALVIK_INTERP_INTERP |
| 21 | #define _DALVIK_INTERP_INTERP |
| 22 | |
| 23 | /* |
| buzbee | 9a3147c | 2011-03-02 15:43:48 -0800 | [diff] [blame] | 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 | /* |
| The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 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 | /* |
| Andy McFadden | 3a1aedb | 2009-05-07 13:30:23 -0700 | [diff] [blame] | 44 | * Throw an exception for a problem detected by the verifier. |
| Andy McFadden | b51ea11 | 2009-05-08 16:50:17 -0700 | [diff] [blame] | 45 | * |
| 46 | * This is called from the handler for the throw-verification-error |
| 47 | * instruction. "method" is the method currently being executed. |
| Andy McFadden | 3a1aedb | 2009-05-07 13:30:23 -0700 | [diff] [blame] | 48 | */ |
| Andy McFadden | b51ea11 | 2009-05-08 16:50:17 -0700 | [diff] [blame] | 49 | void dvmThrowVerificationError(const Method* method, int kind, int ref); |
| Andy McFadden | 3a1aedb | 2009-05-07 13:30:23 -0700 | [diff] [blame] | 50 | |
| 51 | /* |
| Andy McFadden | 9651693 | 2009-10-28 17:39:02 -0700 | [diff] [blame] | 52 | * One-time initialization and shutdown. |
| 53 | */ |
| 54 | bool dvmBreakpointStartup(void); |
| 55 | void dvmBreakpointShutdown(void); |
| buzbee | 9f601a9 | 2011-02-11 17:48:20 -0800 | [diff] [blame] | 56 | void dvmInitInterpreterState(Thread* self); |
| Andy McFadden | 9651693 | 2009-10-28 17:39:02 -0700 | [diff] [blame] | 57 | |
| 58 | /* |
| 59 | * Breakpoint implementation. |
| The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 60 | */ |
| 61 | void dvmInitBreakpoints(); |
| Andy McFadden | 9651693 | 2009-10-28 17:39:02 -0700 | [diff] [blame] | 62 | void dvmAddBreakAddr(Method* method, unsigned int instrOffset); |
| 63 | void dvmClearBreakAddr(Method* method, unsigned int instrOffset); |
| The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 64 | bool dvmAddSingleStep(Thread* thread, int size, int depth); |
| 65 | void dvmClearSingleStep(Thread* thread); |
| 66 | |
| Andy McFadden | 9651693 | 2009-10-28 17:39:02 -0700 | [diff] [blame] | 67 | /* |
| 68 | * Recover the opcode that was replaced by a breakpoint. |
| 69 | */ |
| Dan Bornstein | 9a1f816 | 2010-12-01 17:02:26 -0800 | [diff] [blame] | 70 | u1 dvmGetOriginalOpcode(const u2* addr); |
| Andy McFadden | 9651693 | 2009-10-28 17:39:02 -0700 | [diff] [blame] | 71 | |
| 72 | /* |
| Andy McFadden | d22748a | 2010-04-22 17:08:11 -0700 | [diff] [blame] | 73 | * Flush any breakpoints associated with methods in "clazz". |
| Andy McFadden | 9651693 | 2009-10-28 17:39:02 -0700 | [diff] [blame] | 74 | */ |
| Andy McFadden | d22748a | 2010-04-22 17:08:11 -0700 | [diff] [blame] | 75 | void dvmFlushBreakpoints(ClassObject* clazz); |
| Andy McFadden | 9651693 | 2009-10-28 17:39:02 -0700 | [diff] [blame] | 76 | |
| buzbee | cb3081f | 2011-01-14 13:37:31 -0800 | [diff] [blame] | 77 | /* |
| buzbee | 9a3147c | 2011-03-02 15:43:48 -0800 | [diff] [blame] | 78 | * Debugger support |
| 79 | */ |
| 80 | void dvmUpdateDebugger(const Method* method, const u2* pc, const u4* fp, |
| 81 | bool methodEntry, Thread* self); |
| buzbee | 94d6525 | 2011-03-24 16:41:03 -0700 | [diff] [blame] | 82 | void dvmCheckBefore(const u2 *dPC, u4 *fp, Thread* self); |
| buzbee | 9a3147c | 2011-03-02 15:43:48 -0800 | [diff] [blame] | 83 | void dvmReportExceptionThrow(Thread* self, const Method* curMethod, |
| 84 | const u2* pc, void* fp); |
| 85 | void dvmReportPreNativeInvoke(const u2* pc, Thread* self, |
| 86 | const Method* methodToCall); |
| 87 | void dvmReportPostNativeInvoke(const u2* pc, Thread* self, |
| 88 | const Method* methodToCall); |
| 89 | void dvmReportInvoke(Thread* self, const Method* methodToCall); |
| 90 | void dvmReportReturn(Thread* self, const u2* pc, const u4* prevFP); |
| 91 | |
| 92 | /* |
| buzbee | cb3081f | 2011-01-14 13:37:31 -0800 | [diff] [blame] | 93 | * Update interpBreak |
| 94 | */ |
| buzbee | 9a3147c | 2011-03-02 15:43:48 -0800 | [diff] [blame] | 95 | void dvmUpdateInterpBreak(Thread* thread, int newBreak, int newMode, |
| 96 | bool enable); |
| 97 | void dvmAddToSuspendCounts(Thread* thread, int delta, int dbgDelta); |
| 98 | |
| 99 | /* |
| 100 | * Update interpBreak for all threads |
| 101 | */ |
| 102 | void dvmUpdateAllInterpBreak(int newBreak, int newMode, bool enable); |
| buzbee | cb3081f | 2011-01-14 13:37:31 -0800 | [diff] [blame] | 103 | |
| buzbee | 94d6525 | 2011-03-24 16:41:03 -0700 | [diff] [blame] | 104 | /* |
| 105 | * Register a callback to occur at the next safe point for a single thread. |
| 106 | * If funct is NULL, the previous registration is cancelled. |
| 107 | * |
| 108 | * The callback prototype is: |
| 109 | * bool funct(Thread* thread, void* arg) |
| 110 | * |
| 111 | * If funct returns false, the callback will be disarmed. If true, |
| 112 | * it will stay in effect. |
| 113 | */ |
| 114 | void dvmArmSafePointCallback(Thread* thread, SafePointCallback funct, |
| 115 | void* arg); |
| 116 | |
| 117 | |
| buzbee | a7d59bb | 2011-02-24 09:38:17 -0800 | [diff] [blame] | 118 | #ifndef DVM_NO_ASM_INTERP |
| 119 | extern void* dvmAsmInstructionStart[]; |
| 120 | extern void* dvmAsmAltInstructionStart[]; |
| 121 | #endif |
| 122 | |
| The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 123 | #endif /*_DALVIK_INTERP_INTERP*/ |