Batch files for CDB debugger
Introduction
Here is the list of batch files that accompany WinDbg the Easy Way article. This article introduces CDB debugger as an effective complement to Visual Studio debugger for various advanced debugging tasks. The only major obstacle on the way to using CDB effectively is the length of the command lines – too much typing has to be done. The batch files presented here solve this problem by hiding the complexities of CDB command line parameters behind a simple and easy-to-use interface. Here you can find more information about the approach used to wrap CDB commands with batch files.
Download
Download batch files(7 Kb)
How to use
The batch files cannot run successfully if cdb.exe cannot be found on the executable search path. Since CDB is distributed as part of Debugging Tools for Windows package, it is possible, for example, to add the location of cdb.exe to the executable search path using the following command:
PATH c:\dbgtools;%PATH%
(here c:\dbgtools represents the installation directory of Debugging Tools for Windows)
Additional information about setting up and configuring Debugging Tools for Windows can be found here.
The batch files support the following command line interface:
batchfile.bat TargetSpec [OtherOptions]
TargetSpec lets the user specify the target of the command. It can be an already running process, or a crash dump file. If an already running process is specified, the command is always executed in noninvasive mode.
The following values of TargetSpec can be used:
TargetSpec | Description | Example |
---|---|---|
Asks CDB to attach to the process with the specified process id. The process id can be obtained from Task Manager or other similar tool. | ||
Asks CDB to attach to the process with the specified name of its main executable (.exe). This option is usually more convenient than "-p Pid", because we usually know the name of our application's main executable, and do not have to look for it in Task Manager. But this option cannot be used if more than one process with the given executable name is currently running (CDB will report an error). | ||
Asks CDB to attach to the process that contains the specified service. For example, if you want to attach to, say, Windows Management Instrumentation service, you should use WinMgmt as the service name. | ||
Asks CDB to open the specified crash dump file. |
In the examples on this page, I will use only “-pn myapp.exe” TargetSpec. But unless explicitly stated otherwise, other values of TargetSpec can also be used.
All batch files print their output to the console and also save it in out.txt file in the current directory.
Batch files
Name | Usage / Description / Example |
---|---|
Prints call stacks of all threads in the target process. | |
Prints the call stack of the thread with the specified thread id. | |
Prints detailed information about all critical sections currently held by the threads of the process, including information about owner threads. | |
Prints the times spent by each of the process' threads executing user mode code. | |
Prints call stacks of all threads in the target process. For every function on every call stack, the number of bytes occupied by the function on the thread's stack is reported (in the first column). | |
Prints the call stack of the thread with the specified thread id. For every function on the call stack, the number of bytes occupied by the function on the thread's stack is reported (in the first column). | |
Creates a minidump of the target process. Parameters:
|
|
Creates a minidump of the target process. The name of the created dump file contains a suffix that reflects the time when the dump was created. Parameters:
|
|
Analyzes the specified crash dump and displays information about the current exception, including call stack and the values of function parameters and local variables at the moment of the exception. Here you can find more information about crash dump analysis. | |
Analyzes the specified crash dump and displays information about the exception specified by the address of its EXCEPTION_POINTERS structure, including call stack and the values of function parameters and local variables at the moment of the exception. Excptrsaddr parameter is used to specify the address of EXCEPTION_POINTERS structure passed as the first parameter to kernel32!UnhandledExceptionFilter function. Here you can find more information about crash dump analysis (search for DumpStackCtx to find additional information about using this batch file). |
|
Displays the virtual memory map of the target process. | |
Displays the virtual memory map of the target process. This batch file provides more detailed information than Vadump.bat, but works only on Windows XP and newer operating systems. | |
Displays the kind of virtual memory the specified address belongs to (for example, is it located in a heap, stack or an executable image). Addr parameter is used to specify the address. Works only on Windows XP and newer operating systems. | |
Displays the summary information about virtual memory usage of the target process. This batch file is especially useful when we are debugging a memory leak and want to determine what kind of memory is leaked (heap, stack, raw virtual memory, and so on). Works only on Windows XP and newer operating systems. | |
Prints the list of symbols with the specified name (wildcards can be used). The output is sorted by address. Here you can find more information about using this batch file and related commands. | |
The following command displays the list of all member functions and static data members of CMainFrame class defined in myapp.exe module:
|
|
Print the name and the start address of the symbol that occupies the specified address in memory. Information about the next symbol after the specified address is also reported. | |
Displays detailed layout of the specified data type, including offsets of class/structure members. The type name (typename) can be prefixed with the module name for further clarity (e.g. “myapp!CMyClass”). | |
Displays detailed layout of the specified object with the specified type. The object address is specified via Address parameter. The type name (typename) can be prefixed with the module name for further clarity (e.g. “myapp!CMyClass”). | |