1*795d594fSAndroid Build Coastguard Worker# breakpointlogger 2*795d594fSAndroid Build Coastguard Worker 3*795d594fSAndroid Build Coastguard Workerbreakpointlogger is a JVMTI agent that lets one set breakpoints that are logged 4*795d594fSAndroid Build Coastguard Workerwhen they are hit. 5*795d594fSAndroid Build Coastguard Worker 6*795d594fSAndroid Build Coastguard Worker# Usage 7*795d594fSAndroid Build Coastguard Worker### Build 8*795d594fSAndroid Build Coastguard Worker> `m libbreakpointlogger` # or 'm libbreakpointloggerd' with debugging checks enabled 9*795d594fSAndroid Build Coastguard Worker 10*795d594fSAndroid Build Coastguard WorkerThe libraries will be built for 32-bit, 64-bit, host and target. Below examples 11*795d594fSAndroid Build Coastguard Workerassume you want to use the 64-bit version. 12*795d594fSAndroid Build Coastguard Worker 13*795d594fSAndroid Build Coastguard Worker### Command Line 14*795d594fSAndroid Build Coastguard Worker 15*795d594fSAndroid Build Coastguard WorkerThe agent is loaded using -agentpath like normal. It takes arguments in the 16*795d594fSAndroid Build Coastguard Workerfollowing format: 17*795d594fSAndroid Build Coastguard Worker> `:class_descriptor:->:methodName::method_sig:@:breakpoint_location:,[...]` 18*795d594fSAndroid Build Coastguard Worker 19*795d594fSAndroid Build Coastguard Worker* The breakpoint\_location is a number that's a valid jlocation for the runtime 20*795d594fSAndroid Build Coastguard Worker being used. On ART this is a dex-pc. Dex-pcs can be found using tools such as 21*795d594fSAndroid Build Coastguard Worker dexdump and are uint16\_t-offsets from the start of the method. On other 22*795d594fSAndroid Build Coastguard Worker runtimes jlocations might represent other things. 23*795d594fSAndroid Build Coastguard Worker 24*795d594fSAndroid Build Coastguard Worker* Multiple breakpoints can be included in the options, separated with ','s. 25*795d594fSAndroid Build Coastguard Worker 26*795d594fSAndroid Build Coastguard Worker* Unlike with most normal debuggers the agent will load the class immediately to 27*795d594fSAndroid Build Coastguard Worker set the breakpoint. This means that classes might be initialized earlier than 28*795d594fSAndroid Build Coastguard Worker one might expect. This also means that one cannot set breakpoints on classes 29*795d594fSAndroid Build Coastguard Worker that cannot be found using standard or bootstrap classloader at startup. 30*795d594fSAndroid Build Coastguard Worker 31*795d594fSAndroid Build Coastguard Worker* Deviating from this format or including a breakpoint that cannot be found at 32*795d594fSAndroid Build Coastguard Worker startup will cause the runtime to abort. 33*795d594fSAndroid Build Coastguard Worker 34*795d594fSAndroid Build Coastguard Worker#### ART 35*795d594fSAndroid Build Coastguard Worker> `art -Xplugin:$ANDROID_HOST_OUT/lib64/libopenjdkjvmti.so '-agentpath:libbreakpointlogger.so=Lclass/Name;->methodName()V@0' -cp tmp/java/helloworld.dex -Xint helloworld` 36*795d594fSAndroid Build Coastguard Worker 37*795d594fSAndroid Build Coastguard Worker* `-Xplugin` and `-agentpath` need to be used, otherwise the agent will fail during init. 38*795d594fSAndroid Build Coastguard Worker* If using `libartd.so`, make sure to use the debug version of jvmti. 39*795d594fSAndroid Build Coastguard Worker 40*795d594fSAndroid Build Coastguard Worker#### RI 41*795d594fSAndroid Build Coastguard Worker> `java '-agentpath:libbreakpointlogger.so=Lclass/Name;->methodName()V@0' -cp tmp/helloworld/classes helloworld` 42*795d594fSAndroid Build Coastguard Worker 43*795d594fSAndroid Build Coastguard Worker### Output 44*795d594fSAndroid Build Coastguard WorkerA normal run will look something like this: 45*795d594fSAndroid Build Coastguard Worker 46*795d594fSAndroid Build Coastguard Worker % ./test/run-test --host --dev --with-agent 'libbreakpointlogger.so=LMain;->main([Ljava/lang/String;)V@0' 001-HelloWorld 47*795d594fSAndroid Build Coastguard Worker <normal output removed> 48*795d594fSAndroid Build Coastguard Worker dalvikvm32 W 10-25 10:39:09 18063 18063 breakpointlogger.cc:277] Breakpoint at location: 0x00000000 in method LMain;->main([Ljava/lang/String;)V (source: Main.java:13) thread: main 49*795d594fSAndroid Build Coastguard Worker Hello, world! 50*795d594fSAndroid Build Coastguard Worker 51*795d594fSAndroid Build Coastguard Worker % ./test/run-test --jvm --dev --with-agent 'libbreakpointlogger.so=LMain;->main([Ljava/lang/String;)V@0' 001-HelloWorld 52*795d594fSAndroid Build Coastguard Worker <normal output removed> 53*795d594fSAndroid Build Coastguard Worker java W 10-25 10:39:09 18063 18063 breakpointlogger.cc:277] Breakpoint at location: 0x00000000 in method LMain;->main([Ljava/lang/String;)V (source: Main.java:13) thread: main 54*795d594fSAndroid Build Coastguard Worker Hello, world! 55