C and C++ SoftBench User's Guide

Using SoftBench Debugger
Attaching the Debugger to a Running Program
Chapter 7222
Attaching the Debugger to a Running
Program
SoftBench Debugger allows you to debug a process that is already
running. For example, suppose you have a program that runs
continuously in the background. Occasionally it does something wrong.
Stopping the process and re-starting it in SoftBench Debugger can lose
valuable state information. You can instead attach SoftBench Debugger
to the process after it has encountered its error, and examine the data
structures to learn the cause of the behavior.
To debug the running program:
1. Start your program. Do whatever you normally do to get it to the
desired state.
2. Choose "File: Debug Running Process…".
3. Enter the full path name to your executable file in the "Executable"
input box.
4. Enter the process ID in the "Process ID (pid)" input box, or select
Find Matching Processes to have the debugger find the process for you. If
SoftBench Debugger finds only one matching process,it automatically
places the Process ID (pid) in the Process ID field. If SoftBench
Debugger finds more than one matching process, the debugger
displays all matching processes. Select the desired process from the
list.
5. Select OK.
6. Your program stops, and the PC Location display indicates the value
of the Program Counter (PC). The PC arrow might not be visible in
the Annotation Margin, depending on whether or not the PC is in a
debuggable procedure.
7. Use SoftBench Debugger to examine the program. All SoftBench
Debugger facilities are available for adopted processes. For example,
if the process pauses in a system library, you could move down in the
stack until you encounter a function in your code. You could then
examine the local variables in that function to determine how the
library function was called.
When you have finished debugging the process, you can release it so it
continues running normally by choosing "File: Free Running
Process".