1*795d594fSAndroid Build Coastguard Worker# tifast 2*795d594fSAndroid Build Coastguard Worker 3*795d594fSAndroid Build Coastguard Workertifast is a JVMTI agent designed for profiling the performance impact listening 4*795d594fSAndroid Build Coastguard Workerto various JVMTI events. It is called tifast since none of the event handlers do 5*795d594fSAndroid Build Coastguard Workeranything meaning that it can be considered speed-of-light. 6*795d594fSAndroid Build Coastguard Worker 7*795d594fSAndroid Build Coastguard Worker# Usage 8*795d594fSAndroid Build Coastguard Worker### Build 9*795d594fSAndroid Build Coastguard Worker> `m libtifast` 10*795d594fSAndroid Build Coastguard Worker 11*795d594fSAndroid Build Coastguard WorkerThe libraries will be built for 32-bit, 64-bit, host and target. Below examples 12*795d594fSAndroid Build Coastguard Workerassume you want to use the 64-bit version. 13*795d594fSAndroid Build Coastguard Worker 14*795d594fSAndroid Build Coastguard WorkerUse `libtifasts` if you wish to build a version without non-NDK dynamic dependencies. 15*795d594fSAndroid Build Coastguard Worker 16*795d594fSAndroid Build Coastguard Worker### Command Line 17*795d594fSAndroid Build Coastguard Worker 18*795d594fSAndroid Build Coastguard WorkerThe agent is loaded using -agentpath like normal. It takes arguments in the 19*795d594fSAndroid Build Coastguard Workerfollowing format: 20*795d594fSAndroid Build Coastguard Worker> `[log,][EventName1[,EventName2[,...]]]` 21*795d594fSAndroid Build Coastguard Worker 22*795d594fSAndroid Build Coastguard Worker* If 'log' is the first argument the event handlers will LOG(INFO) when they are 23*795d594fSAndroid Build Coastguard Worker called. This behavior is static. The no-log methods have no branches and just 24*795d594fSAndroid Build Coastguard Worker immediately return. 25*795d594fSAndroid Build Coastguard Worker 26*795d594fSAndroid Build Coastguard Worker* If 'all' is one of the arguments all events the current runtime is capable of 27*795d594fSAndroid Build Coastguard Worker providing will be listened for and all other arguments (excepting 'log') will 28*795d594fSAndroid Build Coastguard Worker be ignored. 29*795d594fSAndroid Build Coastguard Worker 30*795d594fSAndroid Build Coastguard Worker* The event-names are the same names as are used in the jvmtiEventCallbacks 31*795d594fSAndroid Build Coastguard Worker struct. 32*795d594fSAndroid Build Coastguard Worker 33*795d594fSAndroid Build Coastguard Worker* All required capabilities are automatically gained. No capabilities other than 34*795d594fSAndroid Build Coastguard Worker those needed to listen for the events are gained. 35*795d594fSAndroid Build Coastguard Worker 36*795d594fSAndroid Build Coastguard Worker* Only events which do not require additional function calls to cause delivery 37*795d594fSAndroid Build Coastguard Worker and are sent more than once are supported. 38*795d594fSAndroid Build Coastguard Worker 39*795d594fSAndroid Build Coastguard Worker#### Supported events 40*795d594fSAndroid Build Coastguard Worker 41*795d594fSAndroid Build Coastguard WorkerThe following events may be listened for with this agent 42*795d594fSAndroid Build Coastguard Worker 43*795d594fSAndroid Build Coastguard Worker* `SingleStep` 44*795d594fSAndroid Build Coastguard Worker 45*795d594fSAndroid Build Coastguard Worker* `MethodEntry` 46*795d594fSAndroid Build Coastguard Worker 47*795d594fSAndroid Build Coastguard Worker* `MethodExit` 48*795d594fSAndroid Build Coastguard Worker 49*795d594fSAndroid Build Coastguard Worker* `NativeMethodBind` 50*795d594fSAndroid Build Coastguard Worker 51*795d594fSAndroid Build Coastguard Worker* `Exception` 52*795d594fSAndroid Build Coastguard Worker 53*795d594fSAndroid Build Coastguard Worker* `ExceptionCatch` 54*795d594fSAndroid Build Coastguard Worker 55*795d594fSAndroid Build Coastguard Worker* `ThreadStart` 56*795d594fSAndroid Build Coastguard Worker 57*795d594fSAndroid Build Coastguard Worker* `ThreadEnd` 58*795d594fSAndroid Build Coastguard Worker 59*795d594fSAndroid Build Coastguard Worker* `ClassLoad` 60*795d594fSAndroid Build Coastguard Worker 61*795d594fSAndroid Build Coastguard Worker* `ClassPrepare` 62*795d594fSAndroid Build Coastguard Worker 63*795d594fSAndroid Build Coastguard Worker* `ClassFileLoadHook` 64*795d594fSAndroid Build Coastguard Worker 65*795d594fSAndroid Build Coastguard Worker* `CompiledMethodLoad` 66*795d594fSAndroid Build Coastguard Worker 67*795d594fSAndroid Build Coastguard Worker* `CompiledMethodUnload` 68*795d594fSAndroid Build Coastguard Worker 69*795d594fSAndroid Build Coastguard Worker* `DynamicCodeGenerated` 70*795d594fSAndroid Build Coastguard Worker 71*795d594fSAndroid Build Coastguard Worker* `DataDumpRequest` 72*795d594fSAndroid Build Coastguard Worker 73*795d594fSAndroid Build Coastguard Worker* `MonitorContendedEnter` 74*795d594fSAndroid Build Coastguard Worker 75*795d594fSAndroid Build Coastguard Worker* `MonitorContendedEntered` 76*795d594fSAndroid Build Coastguard Worker 77*795d594fSAndroid Build Coastguard Worker* `MonitorWait` 78*795d594fSAndroid Build Coastguard Worker 79*795d594fSAndroid Build Coastguard Worker* `MonitorWaited` 80*795d594fSAndroid Build Coastguard Worker 81*795d594fSAndroid Build Coastguard Worker* `ResourceExhausted` 82*795d594fSAndroid Build Coastguard Worker 83*795d594fSAndroid Build Coastguard Worker* `VMObjectAlloc` 84*795d594fSAndroid Build Coastguard Worker 85*795d594fSAndroid Build Coastguard Worker* `GarbageCollectionStart` 86*795d594fSAndroid Build Coastguard Worker 87*795d594fSAndroid Build Coastguard Worker* `GarbageCollectionFinish` 88*795d594fSAndroid Build Coastguard Worker 89*795d594fSAndroid Build Coastguard Worker* `VMStart` 90*795d594fSAndroid Build Coastguard Worker 91*795d594fSAndroid Build Coastguard Worker* `VMInit` 92*795d594fSAndroid Build Coastguard Worker 93*795d594fSAndroid Build Coastguard Worker* `VMDeath` 94*795d594fSAndroid Build Coastguard Worker 95*795d594fSAndroid Build Coastguard WorkerAll other events cannot be listened for by this agent. Most of these missing 96*795d594fSAndroid Build Coastguard Workerevents either require the use of other functions in order to be called 97*795d594fSAndroid Build Coastguard Worker(`FramePop`, `ObjectFree`, etc). 98*795d594fSAndroid Build Coastguard Worker 99*795d594fSAndroid Build Coastguard Worker#### ART 100*795d594fSAndroid Build Coastguard Worker> `art -Xplugin:$ANDROID_HOST_OUT/lib64/libopenjdkjvmti.so '-agentpath:libtifast.so=MethodEntry' -cp tmp/java/helloworld.dex -Xint helloworld` 101*795d594fSAndroid Build Coastguard Worker 102*795d594fSAndroid Build Coastguard Worker* `-Xplugin` and `-agentpath` need to be used, otherwise the agent will fail during init. 103*795d594fSAndroid Build Coastguard Worker* If using `libartd.so`, make sure to use the debug version of jvmti. 104*795d594fSAndroid Build Coastguard Worker 105*795d594fSAndroid Build Coastguard Worker> `adb shell setenforce 0` 106*795d594fSAndroid Build Coastguard Worker> 107*795d594fSAndroid Build Coastguard Worker> `adb push $ANDROID_PRODUCT_OUT/system/lib64/libtifast.so /data/local/tmp/` 108*795d594fSAndroid Build Coastguard Worker> 109*795d594fSAndroid Build Coastguard Worker> `adb shell am start-activity --attach-agent /data/local/tmp/libtifast.so=MonitorWait,ClassPrepare some.debuggable.apps/.the.app.MainActivity` 110*795d594fSAndroid Build Coastguard Worker 111*795d594fSAndroid Build Coastguard Worker#### RI 112*795d594fSAndroid Build Coastguard Worker> `java '-agentpath:libtifast.so=MethodEntry' -cp tmp/helloworld/classes helloworld` 113