| 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 { |
| 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); |
| 30 |
public static native void disableTracing(Thread thr); |
| 31 |
|
| 32 |
public static void enableFieldTracing(Class<?> methodClass, |
| 33 |
Method fieldAccess, |
| 34 |
Method fieldModify, |
| 35 |
Thread thr) { |
| 36 |
enableTracing(methodClass, null, null, fieldAccess, fieldModify, null, thr); |
| 37 |
} |
| 38 |
|
| 39 |
public static void enableMethodTracing(Class<?> methodClass, |
| 40 |
Method entryMethod, |
| 41 |
Method exitMethod, |
| 42 |
Thread thr) { |
| 43 |
enableTracing(methodClass, entryMethod, exitMethod, null, null, null, thr); |
| 44 |
} |
| 45 |
|
| 46 |
public static void enableSingleStepTracing(Class<?> methodClass, |
| 47 |
Method singleStep, |
| 48 |
Thread thr) { |
| 49 |
enableTracing(methodClass, null, null, null, null, singleStep, thr); |
| 50 |
} |
| 51 |
|
| 52 |
public static native void watchFieldAccess(Field f); |
| 53 |
public static native void watchFieldModification(Field f); |
| 54 |
public static native void watchAllFieldAccesses(); |
| 55 |
public static native void watchAllFieldModifications(); |
| 56 |
|
| 57 |
// the names, arguments, and even line numbers of these functions are embedded in the tests so we |
| 58 |
// need to add to the bottom and not modify old ones to maintain compat. |
| 59 |
public static native void enableTracing2(Class<?> methodClass, |
| 60 |
Method entryMethod, |
| 61 |
Method exitMethod, |
| 62 |
Method fieldAccess, |
| 63 |
Method fieldModify, |
| 64 |
Method singleStep, |
| 65 |
Method ThreadStart, |
| 66 |
Method ThreadEnd, |
| 67 |
Thread thr); |
| 68 |
} |