| 1 |
/* |
| 2 |
* Copyright (C) 2011 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 |
public class Test1936 { |
| 20 |
public static void foo() {} |
| 21 |
|
| 22 |
public static void NotifyThreadEnd(Thread me) { |
| 23 |
// Don't actually do anything. |
| 24 |
foo(); |
| 25 |
} |
| 26 |
|
| 27 |
public static void NotifyMethodEntry(Object o) { |
| 28 |
System.out.println("Entered " + o.toString()); |
| 29 |
Thread me = Thread.currentThread(); |
| 30 |
System.out.println(String.format( |
| 31 |
"Thread: %s\n" + |
| 32 |
" | alive: %b\n" + |
| 33 |
" | interrupted: %b\n" + |
| 34 |
" | daemon: %b\n" + |
| 35 |
" | group: %s\n", |
| 36 |
me.getName(), me.isAlive(), me.isInterrupted(), me.isDaemon(), me.getThreadGroup())); |
| 37 |
} |
| 38 |
|
| 39 |
public static native void waitForever(); |
| 40 |
private static void setupTracing(Thread target) throws Exception { |
| 41 |
Trace.disableTracing(target); |
| 42 |
Trace.enableTracing2( |
| 43 |
Test1936.class, |
| 44 |
Test1936.class.getDeclaredMethod("NotifyMethodEntry", Object.class), |
| 45 |
/*exit*/null, |
| 46 |
/*field_access*/null, |
| 47 |
/*field_modify*/null, |
| 48 |
/*single_step*/null, |
| 49 |
/*thread_start*/null, |
| 50 |
Test1936.class.getDeclaredMethod("NotifyThreadEnd", Thread.class), |
| 51 |
target); |
| 52 |
} |
| 53 |
|
| 54 |
|
| 55 |
public static void run() throws Exception { |
| 56 |
Thread t = new Thread(() -> { |
| 57 |
try { |
| 58 |
setupTracing(Thread.currentThread()); |
| 59 |
foo(); |
| 60 |
} catch (Exception e) { |
| 61 |
System.out.println("Caught exception " + e + "!"); |
| 62 |
e.printStackTrace(); |
| 63 |
} |
| 64 |
}, "test-thread"); |
| 65 |
t.start(); |
| 66 |
t.join(); |
| 67 |
} |
| 68 |
} |