WinDbg is a kernel-mode and user-mode debugger that is included in Debugging Tools for Windows. Here we provide hands-on exercises that will help you get started using WinDbg as a user-mode debugger.
For information about how to get Debugging Tools for Windows, see Debugging Tools for Windows (WinDbg, KD, CDB, NTSD).
I'm a native developer switching to the Mac from Windows. I have a lot of experience debugging using Windbg (CDB-GUD on Emacs) and Visual Studio and was. Windbg Alternatives For Mac; Windbg Alternatives For Mac Free. Contents. Debuggers has related information at.
After you have installed the debugging tools, locate the installation directories for 64-bit (x64) and 32-bit (x86) versions of the tools. For example:
Navigate to your installation directory, and open WinDbg.exe.
The debugger documentation is also available on line here.
On the File menu, choose Open Executable. In the Open Executable dialog box, navigate to the folder that contains notepad.exe (for example, C:WindowsSystem32). For File name, enter notepad.exe. Click Open.
Near the bottom of the WinDbg window, in the command line, enter this command:
The output is similar to this:
The symbol search path tells WinDbg where to look for symbol (PDB) files. The debugger needs symbol files to obtain information about code modules (function names, variable names, and the like).
Enter this command, which tells WinDbg to do its initial finding and loading of symbol files:
To see the symbols for the Notepad.exe module, enter this command:
Note If you don't see any output, enter .reload again.
To see symbols in the Notepad.exe module that contain main, enter this command:
The output is similar to this:
To put a breakpoint at notepad!WinMain, enter this command:
To verify that your breakpoint was set, enter this command:
The output is similar to this:
To start Notepad running, enter this command:
Notepad runs until it comes to the WinMain function, and then breaks in to the debugger.
To see a list of code modules that are loaded in the Notepad process, enter this command:
The output is similar to this:
To see a stack trace, enter this command:
The output is similar to this:
To start Notepad running again, enter this command:
To break in to Notepad, choose Break from the Debug menu.
To set and verify a breakpoint at ZwWriteFile, enter these commands:
Enter g to start Notepad running again. In the Notepad window, enter some text and choose Save from the File menu. The running code breaks in when it comes to ZwCreateFile. Enter k to see the stack trace.
In the WinDbg window, just to the left of the command line, notice the processor and thread numbers. In this example the current processor number is 0, and the current thread number is 11. So we are looking at the stack trace for thread 11 (which happens to be running on processor 0).
To see a list of all threads in the Notepad process, enter this command (the tilde):
The output is similar to this:
In this example, there are 12 threads with indexes 0 through 11.
To look at the stack trace for thread 0, enter these commands: Auto clicker hrr 2 1 download for mac.
The output is similar to this:
To quit debugging and detach from the Notepad process, enter this command:
Suppose you have written and built this small console application.
For this exercise, we will assume that the built application (MyApp.exe) and the symbol file (MyApp.pdb) are in C:MyAppx64Debug. We will also assume that the application source code is in C:MyAppMyApp and that the target machine compiled MyApp.exe.
Open WinDbg.
On the File menu, choose Open Executable. In the Open Executable dialog box, navigate to C:MyAppx64Debug. For File name, enter MyApp.exe. Click Open.
Enter these commands:
.sympath+ C:MyAppx64Debug
Now WinDbg knows where to find symbols and source code for your application. In this case, the source code location doesn't need to be set with .srcpath because the symbols have fully qualified paths to the source files.
Enter these commands:
Your application breaks in to the debugger when it comes to its main function.
WinDbg displays your source code and the Command window.
On the Debug menu, choose Step Into (or press F11). Continue stepping until you have stepped into MyFunction. When you step into the line y = x / p2
, your application will crash and break in to the debugger. The output is similar to this:
Enter this command:
WinDbg displays an analysis of the problem (division by 0 in this case).