1 /* 2 * Copyright (C) 2017 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.Field; 20 import java.lang.reflect.Method; 21 22 public class Trace { enableTracing(Class<?> methodClass, Method entryMethod, Method exitMethod, Method fieldAccess, Method fieldModify, Method singleStep, Thread thr)23 public static native void enableTracing(Class<?> methodClass, 24 Method entryMethod, 25 Method exitMethod, 26 Method fieldAccess, 27 Method fieldModify, 28 Method singleStep, 29 Thread thr); disableTracing(Thread thr)30 public static native void disableTracing(Thread thr); nativeEnableFramePopEvents()31 public static native void nativeEnableFramePopEvents(); 32 enableFieldTracing(Class<?> methodClass, Method fieldAccess, Method fieldModify, Thread thr)33 public static void enableFieldTracing(Class<?> methodClass, 34 Method fieldAccess, 35 Method fieldModify, 36 Thread thr) { 37 enableTracing(methodClass, null, null, fieldAccess, fieldModify, null, thr); 38 } 39 enableMethodTracing(Class<?> methodClass, Method entryMethod, Method exitMethod, Thread thr)40 public static void enableMethodTracing(Class<?> methodClass, 41 Method entryMethod, 42 Method exitMethod, 43 Thread thr) { 44 enableTracing(methodClass, entryMethod, exitMethod, null, null, null, thr); 45 } 46 enableFramePopEvents()47 public static void enableFramePopEvents() { 48 nativeEnableFramePopEvents(); 49 } 50 enableSingleStepTracing(Class<?> methodClass, Method singleStep, Thread thr)51 public static void enableSingleStepTracing(Class<?> methodClass, 52 Method singleStep, 53 Thread thr) { 54 enableTracing(methodClass, null, null, null, null, singleStep, thr); 55 } 56 watchFieldAccess(Field f)57 public static native void watchFieldAccess(Field f); watchFieldModification(Field f)58 public static native void watchFieldModification(Field f); watchAllFieldAccesses()59 public static native void watchAllFieldAccesses(); watchAllFieldModifications()60 public static native void watchAllFieldModifications(); 61 62 // the names, arguments, and even line numbers of these functions are embedded in the tests so we 63 // need to add to the bottom and not modify old ones to maintain compat. enableTracing2(Class<?> methodClass, Method entryMethod, Method exitMethod, Method fieldAccess, Method fieldModify, Method singleStep, Method ThreadStart, Method ThreadEnd, Thread thr)64 public static native void enableTracing2(Class<?> methodClass, 65 Method entryMethod, 66 Method exitMethod, 67 Method fieldAccess, 68 Method fieldModify, 69 Method singleStep, 70 Method ThreadStart, 71 Method ThreadEnd, 72 Thread thr); 73 } 74