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    */
setupTest()29   public static native void setupTest();
30 
setupSuspendBreakpointFor(Executable meth, long loc, Thread thr)31   public static native void setupSuspendBreakpointFor(Executable meth, long loc, Thread thr);
clearSuspendBreakpointFor(Thread thr)32   public static native void clearSuspendBreakpointFor(Thread thr);
33 
setupSuspendSingleStepAt(Executable meth, long loc, Thread thr)34   public static native void setupSuspendSingleStepAt(Executable meth, long loc, Thread thr);
clearSuspendSingleStepFor(Thread thr)35   public static native void clearSuspendSingleStepFor(Thread thr);
36 
setupFieldSuspendFor(Class klass, Field f, boolean access, Thread thr)37   public static native void setupFieldSuspendFor(Class klass, Field f, boolean access, Thread thr);
clearFieldSuspendFor(Thread thr)38   public static native void clearFieldSuspendFor(Thread thr);
39 
setupSuspendMethodEvent(Executable meth, boolean enter, Thread thr)40   public static native void setupSuspendMethodEvent(Executable meth, boolean enter, Thread thr);
clearSuspendMethodEvent(Thread thr)41   public static native void clearSuspendMethodEvent(Thread thr);
42 
setupSuspendExceptionEvent( Executable meth, boolean is_catch, Thread thr)43   public static native void setupSuspendExceptionEvent(
44       Executable meth, boolean is_catch, Thread thr);
clearSuspendExceptionEvent(Thread thr)45   public static native void clearSuspendExceptionEvent(Thread thr);
46 
setupSuspendPopFrameEvent( int offset, Executable breakpointFunction, Thread thr)47   public static native void setupSuspendPopFrameEvent(
48       int offset, Executable breakpointFunction, Thread thr);
clearSuspendPopFrameEvent(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;
setupSuspendClassEvent( int eventType, String[] interestingNames, Thread thr)53   public static native void setupSuspendClassEvent(
54       int eventType, String[] interestingNames, Thread thr);
clearSuspendClassEvent(Thread thr)55   public static native void clearSuspendClassEvent(Thread thr);
56 
setupWaitForNativeCall(Thread thr)57   public static native void setupWaitForNativeCall(Thread thr);
clearWaitForNativeCall(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    */
waitForSuspendHit(Thread thr)64   public static native void waitForSuspendHit(Thread thr);
65 }
66