Debugging with Visual Studio
1. Compile in a Debug mode
In order to debug TinyTracer with VisualStudio, we need to first compile it in a Debug mode.
Then we need to copy the compiled modules into the install32_64 directory, as in the following script:
2. Set the tool to the waiting mode
After that, we need to modify the script to run the TinyTracer (run_me.bat) to add there additional time before the execution is started.
We do it by adding to the Pin the parameter -pause_tool [seconds_to_wait]. Example:
Now we are ready to run our traced application, and attach the Visual Studio Debugger to it.
3. Open the code in Visual Studio
Let's open the source to TinyTracer project in Visual Studio, and get ready.
4. Start the tracing session
Now we can run an executable that we want to trace. Let's do it in the usual way, using the context menu. Since we modified the run script, the tracing won't start immediately, but wait the specified time.
5. Connect to the tracing session
This is the time to connect the Visual Studio Debugger. We should do it from the same Visual Studio instance where we opened the source. From the "Debug" menu we select "Attach to Process", and choose our traced application. The debugger attached, and we should see a new window, "Output". We will see there various logs. It should contain the line:
As the line states at this point we can already set the breakpoints that will be further hit. We do it on the Tiny Tracer source that we have previously opened.
After setting the breakpoints, we press F5 (or, click "Continue") and the application will resume. The breakpoints that we set on Tiny Tracer source will be triggered, and we can watch their execution context.