Table of Contents

Debugging multiple processes

WinGDB allows you to debug multiple processes at once. These processes can be either on single or multiple machines. Also various target platforms might be intermixed during single debugging session: processes on remote Linux, local Windows machine, embedded devices or even native Visual Studio processes. These processes can communicate. This gives you a way to debug complex distributed systems.

Prerequisites

In order to debug multiple processes, hou first have to disable the Break all processes when one process breaks option. This Visual Studio option is not supported and when enabled, will make debugging impossible. Also when this option is disabled, Visual Studio allows to control each process independently, which is desirable.

Multiple processes config

If you use Visual Studio 2008, be aware of the fact that multiple problems and bugs related to multiprocess debugging were reported. It is recommended to install Service Pack 1 as well as the following hotfix available from Microsoft:

http://support.microsoft.com/kb/957912

Please read carefully the description of the hotfix. In case of similar problems still occurring, it is recommended to try newer version of Visual Studio (2010 or 2012).

Usage

In order to debug multiple processes, just start several instances of the debugger. You can use any method available in Visual Studio for that: attaching or starting the program in debug mode. You can start either Visual Studio debugger or WinGDB debugger, or even a debugger for another language (e.g. C#).

You can use the Processes window available in Visual Studio to manage multiple processes. The window can be accessed using the Debug/Windows/Processes menu option. It shows process list and offers several options to break, continue or detach from a process.

Processes window

Note that for independent control of each process, you must use CurrentProcess variants of stepping commands. Default ones will affect all processes simultanously, which is usually not the expected behavior. Unfortunately this is the way it works in Visual Studio. The proper "current process only" variants are accessible from the toolbar in Processes window. You can also reassign the keys using Customize menu. Look for the following command names: Debug.StepIntoCurrentProcess, Debug.StepOutCurrentProcess, and Debug.StepOverCurrentProcess.

Each debugged process has its own console. In order to show the console for particular process, select the process in Processes window and use the Show process console option from WinGDB menu. You can have several console windows on screen simultaneously. The console window can display process id in the title bar. In some scenarios the process identifier is not known from the beginning. If the PID does not appear, click Refresh button.

Implementation considerations

Currently multiple processes are debugged with multiple GDB instances (one for each process). The feature does not use multiple inferiors in single GDB instance. Although it consumes more resources, such a way is more reliable and available through more platforms, as not every GDB port supports multiple inferiors.

Limitations

Breakpoint filters are not implemented yet.


Copyright (C) 2008-2016 SOFT-ERG. All rights reserved.