blob: b6919af1531977a0312d236e5f0408769a947864 [file] [log] [blame]
The Android Open Source Projectf6c38712009-03-03 19:28:47 -08001/*
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 McFadden96516932009-10-28 17:39:02 -070016
The Android Open Source Projectf6c38712009-03-03 19:28:47 -080017/*
18 * Dalvik interpreter public definitions.
19 */
20#ifndef _DALVIK_INTERP_INTERP
21#define _DALVIK_INTERP_INTERP
22
23/*
buzbee9a3147c2011-03-02 15:43:48 -080024 * Stash the dalvik PC in the frame. Called during interpretation.
25 */
26INLINE 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 Projectf6c38712009-03-03 19:28:47 -080038 * Interpreter entry point. Call here after setting up the interpreted
39 * stack (most code will want to get here via dvmCallMethod().)
40 */
41void dvmInterpret(Thread* thread, const Method* method, JValue* pResult);
42
43/*
Andy McFadden3a1aedb2009-05-07 13:30:23 -070044 * Throw an exception for a problem detected by the verifier.
Andy McFaddenb51ea112009-05-08 16:50:17 -070045 *
46 * This is called from the handler for the throw-verification-error
47 * instruction. "method" is the method currently being executed.
Andy McFadden3a1aedb2009-05-07 13:30:23 -070048 */
Andy McFaddenb51ea112009-05-08 16:50:17 -070049void dvmThrowVerificationError(const Method* method, int kind, int ref);
Andy McFadden3a1aedb2009-05-07 13:30:23 -070050
51/*
Andy McFadden96516932009-10-28 17:39:02 -070052 * One-time initialization and shutdown.
53 */
54bool dvmBreakpointStartup(void);
55void dvmBreakpointShutdown(void);
buzbee9f601a92011-02-11 17:48:20 -080056void dvmInitInterpreterState(Thread* self);
Andy McFadden96516932009-10-28 17:39:02 -070057
58/*
59 * Breakpoint implementation.
The Android Open Source Projectf6c38712009-03-03 19:28:47 -080060 */
61void dvmInitBreakpoints();
Andy McFadden96516932009-10-28 17:39:02 -070062void dvmAddBreakAddr(Method* method, unsigned int instrOffset);
63void dvmClearBreakAddr(Method* method, unsigned int instrOffset);
The Android Open Source Projectf6c38712009-03-03 19:28:47 -080064bool dvmAddSingleStep(Thread* thread, int size, int depth);
65void dvmClearSingleStep(Thread* thread);
66
Andy McFadden96516932009-10-28 17:39:02 -070067/*
68 * Recover the opcode that was replaced by a breakpoint.
69 */
Dan Bornstein9a1f8162010-12-01 17:02:26 -080070u1 dvmGetOriginalOpcode(const u2* addr);
Andy McFadden96516932009-10-28 17:39:02 -070071
72/*
Andy McFaddend22748a2010-04-22 17:08:11 -070073 * Flush any breakpoints associated with methods in "clazz".
Andy McFadden96516932009-10-28 17:39:02 -070074 */
Andy McFaddend22748a2010-04-22 17:08:11 -070075void dvmFlushBreakpoints(ClassObject* clazz);
Andy McFadden96516932009-10-28 17:39:02 -070076
buzbeecb3081f2011-01-14 13:37:31 -080077/*
buzbee9a3147c2011-03-02 15:43:48 -080078 * Debugger support
79 */
80void dvmUpdateDebugger(const Method* method, const u2* pc, const u4* fp,
81 bool methodEntry, Thread* self);
buzbee94d65252011-03-24 16:41:03 -070082void dvmCheckBefore(const u2 *dPC, u4 *fp, Thread* self);
buzbee9a3147c2011-03-02 15:43:48 -080083void dvmReportExceptionThrow(Thread* self, const Method* curMethod,
84 const u2* pc, void* fp);
85void dvmReportPreNativeInvoke(const u2* pc, Thread* self,
86 const Method* methodToCall);
87void dvmReportPostNativeInvoke(const u2* pc, Thread* self,
88 const Method* methodToCall);
89void dvmReportInvoke(Thread* self, const Method* methodToCall);
90void dvmReportReturn(Thread* self, const u2* pc, const u4* prevFP);
91
92/*
buzbeecb3081f2011-01-14 13:37:31 -080093 * Update interpBreak
94 */
buzbee9a3147c2011-03-02 15:43:48 -080095void dvmUpdateInterpBreak(Thread* thread, int newBreak, int newMode,
96 bool enable);
97void dvmAddToSuspendCounts(Thread* thread, int delta, int dbgDelta);
98
99/*
100 * Update interpBreak for all threads
101 */
102void dvmUpdateAllInterpBreak(int newBreak, int newMode, bool enable);
buzbeecb3081f2011-01-14 13:37:31 -0800103
buzbee94d65252011-03-24 16:41:03 -0700104/*
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 */
114void dvmArmSafePointCallback(Thread* thread, SafePointCallback funct,
115 void* arg);
116
117
buzbeea7d59bb2011-02-24 09:38:17 -0800118#ifndef DVM_NO_ASM_INTERP
119extern void* dvmAsmInstructionStart[];
120extern void* dvmAsmAltInstructionStart[];
121#endif
122
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800123#endif /*_DALVIK_INTERP_INTERP*/