| 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 | |
| Carl Shapiro | dabd15a | 2011-04-13 20:14:49 -0700 | [diff] [blame] | 23 | #ifdef __cplusplus |
| 24 | extern "C" { |
| 25 | #endif |
| 26 | |
| The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 27 | /* |
| buzbee | 9a3147c | 2011-03-02 15:43:48 -0800 | [diff] [blame] | 28 | * Stash the dalvik PC in the frame. Called during interpretation. |
| 29 | */ |
| 30 | INLINE void dvmExportPC(const u2* pc, const u4* fp) |
| 31 | { |
| 32 | SAVEAREA_FROM_FP(fp)->xtra.currentPc = pc; |
| 33 | } |
| 34 | |
| 35 | /* |
| 36 | * Extract the Dalvik opcode |
| 37 | */ |
| 38 | #define GET_OPCODE(_inst) (((_inst & 0xff) == OP_DISPATCH_FF) ? \ |
| 39 | (0x100 + ((_inst >> 8) & 0xff)) : (_inst & 0xff)) |
| 40 | |
| 41 | /* |
| The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 42 | * Interpreter entry point. Call here after setting up the interpreted |
| 43 | * stack (most code will want to get here via dvmCallMethod().) |
| 44 | */ |
| 45 | void dvmInterpret(Thread* thread, const Method* method, JValue* pResult); |
| 46 | |
| 47 | /* |
| Andy McFadden | 3a1aedb | 2009-05-07 13:30:23 -0700 | [diff] [blame] | 48 | * Throw an exception for a problem detected by the verifier. |
| Andy McFadden | b51ea11 | 2009-05-08 16:50:17 -0700 | [diff] [blame] | 49 | * |
| 50 | * This is called from the handler for the throw-verification-error |
| 51 | * instruction. "method" is the method currently being executed. |
| Andy McFadden | 3a1aedb | 2009-05-07 13:30:23 -0700 | [diff] [blame] | 52 | */ |
| Andy McFadden | b51ea11 | 2009-05-08 16:50:17 -0700 | [diff] [blame] | 53 | void dvmThrowVerificationError(const Method* method, int kind, int ref); |
| Andy McFadden | 3a1aedb | 2009-05-07 13:30:23 -0700 | [diff] [blame] | 54 | |
| 55 | /* |
| Andy McFadden | 9651693 | 2009-10-28 17:39:02 -0700 | [diff] [blame] | 56 | * One-time initialization and shutdown. |
| 57 | */ |
| 58 | bool dvmBreakpointStartup(void); |
| 59 | void dvmBreakpointShutdown(void); |
| buzbee | 9f601a9 | 2011-02-11 17:48:20 -0800 | [diff] [blame] | 60 | void dvmInitInterpreterState(Thread* self); |
| Andy McFadden | 9651693 | 2009-10-28 17:39:02 -0700 | [diff] [blame] | 61 | |
| 62 | /* |
| 63 | * Breakpoint implementation. |
| The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 64 | */ |
| 65 | void dvmInitBreakpoints(); |
| Andy McFadden | 9651693 | 2009-10-28 17:39:02 -0700 | [diff] [blame] | 66 | void dvmAddBreakAddr(Method* method, unsigned int instrOffset); |
| 67 | void dvmClearBreakAddr(Method* method, unsigned int instrOffset); |
| The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 68 | bool dvmAddSingleStep(Thread* thread, int size, int depth); |
| 69 | void dvmClearSingleStep(Thread* thread); |
| 70 | |
| Andy McFadden | 9651693 | 2009-10-28 17:39:02 -0700 | [diff] [blame] | 71 | /* |
| 72 | * Recover the opcode that was replaced by a breakpoint. |
| 73 | */ |
| Dan Bornstein | 9a1f816 | 2010-12-01 17:02:26 -0800 | [diff] [blame] | 74 | u1 dvmGetOriginalOpcode(const u2* addr); |
| Andy McFadden | 9651693 | 2009-10-28 17:39:02 -0700 | [diff] [blame] | 75 | |
| 76 | /* |
| Andy McFadden | d22748a | 2010-04-22 17:08:11 -0700 | [diff] [blame] | 77 | * Flush any breakpoints associated with methods in "clazz". |
| Andy McFadden | 9651693 | 2009-10-28 17:39:02 -0700 | [diff] [blame] | 78 | */ |
| Andy McFadden | d22748a | 2010-04-22 17:08:11 -0700 | [diff] [blame] | 79 | void dvmFlushBreakpoints(ClassObject* clazz); |
| Andy McFadden | 9651693 | 2009-10-28 17:39:02 -0700 | [diff] [blame] | 80 | |
| buzbee | cb3081f | 2011-01-14 13:37:31 -0800 | [diff] [blame] | 81 | /* |
| buzbee | 9a3147c | 2011-03-02 15:43:48 -0800 | [diff] [blame] | 82 | * Debugger support |
| 83 | */ |
| buzbee | 94d6525 | 2011-03-24 16:41:03 -0700 | [diff] [blame] | 84 | void dvmCheckBefore(const u2 *dPC, u4 *fp, Thread* self); |
| buzbee | 99e3e6e | 2011-03-29 10:26:07 -0700 | [diff] [blame] | 85 | void dvmReportExceptionThrow(Thread* self, Object* exception); |
| 86 | void dvmReportPreNativeInvoke(const Method* methodToCall, Thread* self); |
| 87 | void dvmReportPostNativeInvoke(const Method* methodToCall, Thread* self); |
| buzbee | 9a3147c | 2011-03-02 15:43:48 -0800 | [diff] [blame] | 88 | void dvmReportInvoke(Thread* self, const Method* methodToCall); |
| buzbee | 99e3e6e | 2011-03-29 10:26:07 -0700 | [diff] [blame] | 89 | void dvmReportReturn(Thread* self); |
| buzbee | 9a3147c | 2011-03-02 15:43:48 -0800 | [diff] [blame] | 90 | |
| 91 | /* |
| buzbee | cb3081f | 2011-01-14 13:37:31 -0800 | [diff] [blame] | 92 | * Update interpBreak |
| 93 | */ |
| buzbee | 9a3147c | 2011-03-02 15:43:48 -0800 | [diff] [blame] | 94 | void dvmUpdateInterpBreak(Thread* thread, int newBreak, int newMode, |
| 95 | bool enable); |
| 96 | void dvmAddToSuspendCounts(Thread* thread, int delta, int dbgDelta); |
| buzbee | 99e3e6e | 2011-03-29 10:26:07 -0700 | [diff] [blame] | 97 | void dvmCheckInterpStateConsistency(); |
| 98 | void dvmInitializeInterpBreak(Thread* thread); |
| buzbee | 9a3147c | 2011-03-02 15:43:48 -0800 | [diff] [blame] | 99 | |
| 100 | /* |
| 101 | * Update interpBreak for all threads |
| 102 | */ |
| 103 | void dvmUpdateAllInterpBreak(int newBreak, int newMode, bool enable); |
| buzbee | cb3081f | 2011-01-14 13:37:31 -0800 | [diff] [blame] | 104 | |
| buzbee | 94d6525 | 2011-03-24 16:41:03 -0700 | [diff] [blame] | 105 | /* |
| 106 | * Register a callback to occur at the next safe point for a single thread. |
| 107 | * If funct is NULL, the previous registration is cancelled. |
| 108 | * |
| 109 | * The callback prototype is: |
| 110 | * bool funct(Thread* thread, void* arg) |
| 111 | * |
| 112 | * If funct returns false, the callback will be disarmed. If true, |
| 113 | * it will stay in effect. |
| 114 | */ |
| 115 | void dvmArmSafePointCallback(Thread* thread, SafePointCallback funct, |
| 116 | void* arg); |
| 117 | |
| 118 | |
| buzbee | a7d59bb | 2011-02-24 09:38:17 -0800 | [diff] [blame] | 119 | #ifndef DVM_NO_ASM_INTERP |
| 120 | extern void* dvmAsmInstructionStart[]; |
| 121 | extern void* dvmAsmAltInstructionStart[]; |
| 122 | #endif |
| 123 | |
| Carl Shapiro | dabd15a | 2011-04-13 20:14:49 -0700 | [diff] [blame] | 124 | #ifdef __cplusplus |
| 125 | } |
| 126 | #endif |
| 127 | |
| The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 128 | #endif /*_DALVIK_INTERP_INTERP*/ |