Trace Debugging - llmhyy/microbat GitHub Wiki

Trace Collection

Our trace collection code is implemented through Java bytecode instrumentation. If you would like to debug the trace collection code, we recommend using Java remote debugging techniques. We illustrate the debugging methodology as follows:

1. Copy the command to run the agent:

Command

The following command is a typical example. Note that, you should pay attention to the whitespace if you are using Windows system. You need to quote the path to make the command run successfully.

"C:\Program Files\Java\jdk1.8.0_211\bin\java" -Xmx30g -XX:+UseG1GC -ea -noverify -javaagent:C:\Users\\"Yun Lin"\eclipse\committers-2020-06\eclipse\dropins\junit_lib\instrumentator.jar=precheck=false,java_home=C:\\"Program Files"\Java\jdk1.8.0_211,log=printProgress;error,working_dir=\D:\linyun\git_space\microbat_experiment\DebugExperiment,varLayer=3,includes=java.util.Stack;java.util.Vector;java.util.ArrayList,trace_recorder=FILE,expectedSteps=40,stepLimit=100000,require_method_split=false,class_path=\D:\linyun\git_space\microbat_experiment\DebugExperiment;\D:\linyun\git_space\microbat_experiment\DebugExperiment\src;C:\Users\\"Yun Lin"\eclipse\committers-2020-06\eclipse\dropins\junit_lib\junit.jar;C:\Users\\"Yun Lin"\eclipse\committers-2020-06\eclipse\dropins\junit_lib\org.hamcrest.core.jar;C:\Users\\"Yun Lin"\eclipse\committers-2020-06\eclipse\dropins\junit_lib\testrunner.jar;C:\Users\\"Yun Lin"\eclipse\committers-2020-06\eclipse\dropins\junit_lib\bcel-6.0.jar;C:\Users\\"Yun Lin"\eclipse\committers-2020-06\eclipse\dropins\junit_lib\javassist.jar;\D:\linyun\git_space\microbat_experiment\DebugExperiment\bin\,entry_point=exp5.e506.SimplifyThePathDebug.main([Ljava/lang/String;)V,dump_file_path=E:\Users\\"Yun Lin"\AppData\Local\Temp\trace6544578121698131036.exec,avoid_proxy_tostring=true -cp \D:\linyun\git_space\microbat_experiment\DebugExperiment;\D:\linyun\git_space\microbat_experiment\DebugExperiment\src;C:\Users\\"Yun Lin"\eclipse\committers-2020-06\eclipse\dropins\junit_lib\junit.jar;C:\Users\\"Yun Lin"\eclipse\committers-2020-06\eclipse\dropins\junit_lib\org.hamcrest.core.jar;C:\Users\\"Yun Lin"\eclipse\committers-2020-06\eclipse\dropins\junit_lib\testrunner.jar;C:\Users\\"Yun Lin"\eclipse\committers-2020-06\eclipse\dropins\junit_lib\bcel-6.0.jar;C:\Users\\"Yun Lin"\eclipse\committers-2020-06\eclipse\dropins\junit_lib\javassist.jar;\D:\linyun\git_space\microbat_experiment\DebugExperiment\bin\ exp5.e506.SimplifyThePathDebug

2. Remote debugging

Once we can run the agent command successfully, we can add remote-debugging command so that Eclipse can debug the instrumentation code. Here, we use the server mode to run the agent. The server port is 8000. We can use any port if it is not taken by some other process.

"C:\Program Files\Java\jdk1.8.0_211\bin\java" -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8000 ...

We can run the command now, the JVM will remind us that it is listening to a connection:

Eclipse Debugging Configuration

In Eclipse, we create a remote debugging configuration. We click debugging, then the breakpoint in instrumentation code will be triggered.

Eclipse Debugging Configuration

2. UI Support for debugging

We further support debugging Microbat instrumentator by clicking the "Run with debugging mode" in the preference.

Eclipse Debugging Configuration

When clicking the button, the breakpoints for Microbat instrumentator will be effective.