2.2. WineDbg's modes of invocation

2.2.1. Starting a process

Any application (either a Windows' native executable, or a Winelib application) can be run through WineDbg. Command line options and tricks are the same as for wine:

winedbg telnet.exe
winedbg "hl.exe -windowed"
        

2.2.2. Attaching

WineDbg can also be launched without any command line argument: WineDbg is started without any attached process. You can get a list of running W-processes (and their wpid's) using the walk process command, and then, with the attach command, pick up the wpid of the W-process you want to debug. This is (for now) a neat feature for the following reasons:

2.2.3. On exceptions

When something goes wrong, Windows tracks this as an exception. Exceptions exist for segmentation violation, stack overflow, division by zero...

When an exception occurs, Wine checks if the W-process is debugged. If so, the exception event is sent to the debugger, which takes care of it: end of the story. This mechanism is part of the standard Windows' debugging API.

If the W-process is not debugged, Wine tries to launch a debugger. This debugger (normally WineDbg, see III Configuration for more details), at startup, attaches to the W-process which generated the exception event. In this case, you are able to look at the causes of the exception, and either fix the causes (and continue further the execution) or dig deeper to understand what went wrong.

If WineDbg is the standard debugger, the pass and cont commands are the two ways to let the process go further for the handling of the exception event.

To be more precise on the way Wine (and Windows) generates exception events, when a fault occurs (segmentation violation, stack overflow...), the event is first sent to the debugger (this is known as a first chance exception). The debugger can give two answers:

2.2.4. Interrupting

You can stop the debugger while it's running by hitting Ctrl-C in its window. This will stop the debugged process, and let you manipulate the current context

2.2.5. Quitting

Wine supports the new XP APIs, allowing for a debugger to detach from a program being debugged (see detach command). Unfortunately, as the debugger cannot, for now, neither clear its internal information, nor restart a new process, the debugger, after detaching itself, cannot do much except being quitted.