1*795d594fSAndroid Build Coastguard Worker /* 2*795d594fSAndroid Build Coastguard Worker * Copyright (C) 2019 The Android Open Source Project 3*795d594fSAndroid Build Coastguard Worker * 4*795d594fSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License"); 5*795d594fSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License. 6*795d594fSAndroid Build Coastguard Worker * You may obtain a copy of the License at 7*795d594fSAndroid Build Coastguard Worker * 8*795d594fSAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0 9*795d594fSAndroid Build Coastguard Worker * 10*795d594fSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software 11*795d594fSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS, 12*795d594fSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*795d594fSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and 14*795d594fSAndroid Build Coastguard Worker * limitations under the License. 15*795d594fSAndroid Build Coastguard Worker */ 16*795d594fSAndroid Build Coastguard Worker 17*795d594fSAndroid Build Coastguard Worker package art; 18*795d594fSAndroid Build Coastguard Worker 19*795d594fSAndroid Build Coastguard Worker import java.lang.reflect.Executable; 20*795d594fSAndroid Build Coastguard Worker import java.lang.reflect.Field; 21*795d594fSAndroid Build Coastguard Worker 22*795d594fSAndroid Build Coastguard Worker /** 23*795d594fSAndroid Build Coastguard Worker * A set of functions to request events that suspend the thread they trigger on. 24*795d594fSAndroid Build Coastguard Worker */ 25*795d594fSAndroid Build Coastguard Worker public final class SuspendEvents { 26*795d594fSAndroid Build Coastguard Worker /** 27*795d594fSAndroid Build Coastguard Worker * Sets up the suspension support. Must be called at the start of the test. 28*795d594fSAndroid Build Coastguard Worker */ setupTest()29*795d594fSAndroid Build Coastguard Worker public static native void setupTest(); 30*795d594fSAndroid Build Coastguard Worker setupSuspendBreakpointFor(Executable meth, long loc, Thread thr)31*795d594fSAndroid Build Coastguard Worker public static native void setupSuspendBreakpointFor(Executable meth, long loc, Thread thr); clearSuspendBreakpointFor(Thread thr)32*795d594fSAndroid Build Coastguard Worker public static native void clearSuspendBreakpointFor(Thread thr); 33*795d594fSAndroid Build Coastguard Worker setupSuspendSingleStepAt(Executable meth, long loc, Thread thr)34*795d594fSAndroid Build Coastguard Worker public static native void setupSuspendSingleStepAt(Executable meth, long loc, Thread thr); clearSuspendSingleStepFor(Thread thr)35*795d594fSAndroid Build Coastguard Worker public static native void clearSuspendSingleStepFor(Thread thr); 36*795d594fSAndroid Build Coastguard Worker setupFieldSuspendFor(Class klass, Field f, boolean access, Thread thr)37*795d594fSAndroid Build Coastguard Worker public static native void setupFieldSuspendFor(Class klass, Field f, boolean access, Thread thr); clearFieldSuspendFor(Thread thr)38*795d594fSAndroid Build Coastguard Worker public static native void clearFieldSuspendFor(Thread thr); 39*795d594fSAndroid Build Coastguard Worker setupSuspendMethodEvent(Executable meth, boolean enter, Thread thr)40*795d594fSAndroid Build Coastguard Worker public static native void setupSuspendMethodEvent(Executable meth, boolean enter, Thread thr); clearSuspendMethodEvent(Thread thr)41*795d594fSAndroid Build Coastguard Worker public static native void clearSuspendMethodEvent(Thread thr); 42*795d594fSAndroid Build Coastguard Worker setupSuspendExceptionEvent( Executable meth, boolean is_catch, Thread thr)43*795d594fSAndroid Build Coastguard Worker public static native void setupSuspendExceptionEvent( 44*795d594fSAndroid Build Coastguard Worker Executable meth, boolean is_catch, Thread thr); clearSuspendExceptionEvent(Thread thr)45*795d594fSAndroid Build Coastguard Worker public static native void clearSuspendExceptionEvent(Thread thr); 46*795d594fSAndroid Build Coastguard Worker setupSuspendPopFrameEvent( int offset, Executable breakpointFunction, Thread thr)47*795d594fSAndroid Build Coastguard Worker public static native void setupSuspendPopFrameEvent( 48*795d594fSAndroid Build Coastguard Worker int offset, Executable breakpointFunction, Thread thr); clearSuspendPopFrameEvent(Thread thr)49*795d594fSAndroid Build Coastguard Worker public static native void clearSuspendPopFrameEvent(Thread thr); 50*795d594fSAndroid Build Coastguard Worker 51*795d594fSAndroid Build Coastguard Worker public static final int EVENT_TYPE_CLASS_LOAD = 55; 52*795d594fSAndroid Build Coastguard Worker public static final int EVENT_TYPE_CLASS_PREPARE = 56; setupSuspendClassEvent( int eventType, String[] interestingNames, Thread thr)53*795d594fSAndroid Build Coastguard Worker public static native void setupSuspendClassEvent( 54*795d594fSAndroid Build Coastguard Worker int eventType, String[] interestingNames, Thread thr); clearSuspendClassEvent(Thread thr)55*795d594fSAndroid Build Coastguard Worker public static native void clearSuspendClassEvent(Thread thr); 56*795d594fSAndroid Build Coastguard Worker setupWaitForNativeCall(Thread thr)57*795d594fSAndroid Build Coastguard Worker public static native void setupWaitForNativeCall(Thread thr); clearWaitForNativeCall(Thread thr)58*795d594fSAndroid Build Coastguard Worker public static native void clearWaitForNativeCall(Thread thr); 59*795d594fSAndroid Build Coastguard Worker 60*795d594fSAndroid Build Coastguard Worker /** 61*795d594fSAndroid Build Coastguard Worker * Waits for the given thread to be suspended. 62*795d594fSAndroid Build Coastguard Worker * @param thr the thread to wait for. 63*795d594fSAndroid Build Coastguard Worker */ waitForSuspendHit(Thread thr)64*795d594fSAndroid Build Coastguard Worker public static native void waitForSuspendHit(Thread thr); 65*795d594fSAndroid Build Coastguard Worker } 66