Alex Light | b4e6507 | 2019-04-25 15:10:32 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2019 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 | package art; |
| 18 | |
| 19 | import java.lang.reflect.Executable; |
| 20 | import java.lang.reflect.Field; |
| 21 | |
| 22 | /** |
| 23 | * A set of functions to request events that suspend the thread they trigger on. |
| 24 | */ |
| 25 | public final class SuspendEvents { |
| 26 | /** |
| 27 | * Sets up the suspension support. Must be called at the start of the test. |
| 28 | */ |
| 29 | public static native void setupTest(); |
| 30 | |
| 31 | public static native void setupSuspendBreakpointFor(Executable meth, long loc, Thread thr); |
| 32 | public static native void clearSuspendBreakpointFor(Thread thr); |
| 33 | |
| 34 | public static native void setupSuspendSingleStepAt(Executable meth, long loc, Thread thr); |
| 35 | public static native void clearSuspendSingleStepFor(Thread thr); |
| 36 | |
| 37 | public static native void setupFieldSuspendFor(Class klass, Field f, boolean access, Thread thr); |
| 38 | public static native void clearFieldSuspendFor(Thread thr); |
| 39 | |
| 40 | public static native void setupSuspendMethodEvent(Executable meth, boolean enter, Thread thr); |
| 41 | public static native void clearSuspendMethodEvent(Thread thr); |
| 42 | |
| 43 | public static native void setupSuspendExceptionEvent( |
| 44 | Executable meth, boolean is_catch, Thread thr); |
| 45 | public static native void clearSuspendExceptionEvent(Thread thr); |
| 46 | |
| 47 | public static native void setupSuspendPopFrameEvent( |
| 48 | int offset, Executable breakpointFunction, Thread thr); |
| 49 | public static native void clearSuspendPopFrameEvent(Thread thr); |
| 50 | |
| 51 | public static final int EVENT_TYPE_CLASS_LOAD = 55; |
| 52 | public static final int EVENT_TYPE_CLASS_PREPARE = 56; |
| 53 | public static native void setupSuspendClassEvent( |
| 54 | int eventType, String[] interestingNames, Thread thr); |
| 55 | public static native void clearSuspendClassEvent(Thread thr); |
| 56 | |
| 57 | public static native void setupWaitForNativeCall(Thread thr); |
| 58 | public static native void clearWaitForNativeCall(Thread thr); |
| 59 | |
| 60 | /** |
| 61 | * Waits for the given thread to be suspended. |
| 62 | * @param thr the thread to wait for. |
| 63 | */ |
| 64 | public static native void waitForSuspendHit(Thread thr); |
| 65 | } |