blob: 5626160d737641cf4eb1ba0d306081105c7071b8 [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
Carl Shapirodabd15a2011-04-13 20:14:49 -070023#ifdef __cplusplus
24extern "C" {
25#endif
26
The Android Open Source Projectf6c38712009-03-03 19:28:47 -080027/*
buzbee9a3147c2011-03-02 15:43:48 -080028 * Stash the dalvik PC in the frame. Called during interpretation.
29 */
30INLINE 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 Projectf6c38712009-03-03 19:28:47 -080042 * Interpreter entry point. Call here after setting up the interpreted
43 * stack (most code will want to get here via dvmCallMethod().)
44 */
45void dvmInterpret(Thread* thread, const Method* method, JValue* pResult);
46
47/*
Andy McFadden3a1aedb2009-05-07 13:30:23 -070048 * Throw an exception for a problem detected by the verifier.
Andy McFaddenb51ea112009-05-08 16:50:17 -070049 *
50 * This is called from the handler for the throw-verification-error
51 * instruction. "method" is the method currently being executed.
Andy McFadden3a1aedb2009-05-07 13:30:23 -070052 */
Andy McFaddenb51ea112009-05-08 16:50:17 -070053void dvmThrowVerificationError(const Method* method, int kind, int ref);
Andy McFadden3a1aedb2009-05-07 13:30:23 -070054
55/*
Andy McFadden96516932009-10-28 17:39:02 -070056 * One-time initialization and shutdown.
57 */
58bool dvmBreakpointStartup(void);
59void dvmBreakpointShutdown(void);
buzbee9f601a92011-02-11 17:48:20 -080060void dvmInitInterpreterState(Thread* self);
Andy McFadden96516932009-10-28 17:39:02 -070061
62/*
63 * Breakpoint implementation.
The Android Open Source Projectf6c38712009-03-03 19:28:47 -080064 */
65void dvmInitBreakpoints();
Andy McFadden96516932009-10-28 17:39:02 -070066void dvmAddBreakAddr(Method* method, unsigned int instrOffset);
67void dvmClearBreakAddr(Method* method, unsigned int instrOffset);
The Android Open Source Projectf6c38712009-03-03 19:28:47 -080068bool dvmAddSingleStep(Thread* thread, int size, int depth);
69void dvmClearSingleStep(Thread* thread);
70
Andy McFadden96516932009-10-28 17:39:02 -070071/*
72 * Recover the opcode that was replaced by a breakpoint.
73 */
Dan Bornstein9a1f8162010-12-01 17:02:26 -080074u1 dvmGetOriginalOpcode(const u2* addr);
Andy McFadden96516932009-10-28 17:39:02 -070075
76/*
Andy McFaddend22748a2010-04-22 17:08:11 -070077 * Flush any breakpoints associated with methods in "clazz".
Andy McFadden96516932009-10-28 17:39:02 -070078 */
Andy McFaddend22748a2010-04-22 17:08:11 -070079void dvmFlushBreakpoints(ClassObject* clazz);
Andy McFadden96516932009-10-28 17:39:02 -070080
buzbeecb3081f2011-01-14 13:37:31 -080081/*
buzbee9a3147c2011-03-02 15:43:48 -080082 * Debugger support
83 */
buzbee94d65252011-03-24 16:41:03 -070084void dvmCheckBefore(const u2 *dPC, u4 *fp, Thread* self);
buzbee99e3e6e2011-03-29 10:26:07 -070085void dvmReportExceptionThrow(Thread* self, Object* exception);
86void dvmReportPreNativeInvoke(const Method* methodToCall, Thread* self);
87void dvmReportPostNativeInvoke(const Method* methodToCall, Thread* self);
buzbee9a3147c2011-03-02 15:43:48 -080088void dvmReportInvoke(Thread* self, const Method* methodToCall);
buzbee99e3e6e2011-03-29 10:26:07 -070089void dvmReportReturn(Thread* self);
buzbee9a3147c2011-03-02 15:43:48 -080090
91/*
buzbeecb3081f2011-01-14 13:37:31 -080092 * Update interpBreak
93 */
buzbee9a3147c2011-03-02 15:43:48 -080094void dvmUpdateInterpBreak(Thread* thread, int newBreak, int newMode,
95 bool enable);
96void dvmAddToSuspendCounts(Thread* thread, int delta, int dbgDelta);
buzbee99e3e6e2011-03-29 10:26:07 -070097void dvmCheckInterpStateConsistency();
98void dvmInitializeInterpBreak(Thread* thread);
buzbee9a3147c2011-03-02 15:43:48 -080099
100/*
101 * Update interpBreak for all threads
102 */
103void dvmUpdateAllInterpBreak(int newBreak, int newMode, bool enable);
buzbeecb3081f2011-01-14 13:37:31 -0800104
buzbee94d65252011-03-24 16:41:03 -0700105/*
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 */
115void dvmArmSafePointCallback(Thread* thread, SafePointCallback funct,
116 void* arg);
117
118
buzbeea7d59bb2011-02-24 09:38:17 -0800119#ifndef DVM_NO_ASM_INTERP
120extern void* dvmAsmInstructionStart[];
121extern void* dvmAsmAltInstructionStart[];
122#endif
123
Carl Shapirodabd15a2011-04-13 20:14:49 -0700124#ifdef __cplusplus
125}
126#endif
127
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800128#endif /*_DALVIK_INTERP_INTERP*/