About Me ·
At GROSSWEBER we practice what we preach. We offer trainings for modern software technologies like Behavior Driven Development, Clean Code and Git. Our staff is fluent in a variety of languages, including English.
I just finished watching Ingo Rammer’s sessions on debugging from NDC 2010:
While I consider myself experienced in debugging with Visual Studio I still didn’t know the Ctrl+B trick Ingo shows in the first session to create breakpoint groups, for example to break on all methods named WriteLine.
Ingo’s second session goes into detail how to start with WinDbg. During his talk Ingo wrote down quite a lot of WinDbg commands that I copied and extended a bit for my own reference.
# Use debugger according to architecture that is being debugged.
# Drag exe onto WinDbg to start debugging.
# Debugging services:
# 1. Using Global Flags
# - On "Image File" tab, enter service exe
# - Set debugger to cdb.exe -server tcp:port=1234
# 2. Start service
# 3. Start WinDbg
# - connect to remote session: tcp:server=localhost,port=1234
# Also works (unsecured) over networks
.loadby sos mscorwks # CLR 2
.loadby sos clr # CLR 4, both after the debuggee has loaded the CLR
.chain # Shows loaded extensions
sxe <event code> # Stop
sxn <event code> # Notify
sxi <event code> # Ignore
# ... on <event code> exceptions (for example, <event code> = clr)
g # Go
.cls # Clear screen
!pe # Print exception
!clrstack # Display stack trace
!clrstack -a # Stack trace with additional information (parameters and locals)
# If there is no stack information the JIT optimized the code away (i.e. inlining).
!dumpstack # Another way to get the stack trace
!u <address> # Unassemble code at <address>
# Look for calls into managed code (to the right) to find the line/call that caused the exception.
# <assembly>_ni = Native image
!do <address> # Dump object
!da <address> # Dump array
# To copy addresses: Left double-click a numeric value, double right-click to copy it to the command line.
~ # Show all (managed and unmanaged) threads
!threads # Show managed threads
~2s # Switch to thread 2 (#2 in the unnamed column)
!runaway # Show thread execution times (user-mode) - to find hanging threads
!dumpheap # Show heap information, 1 line per instance
!dumpheap -stat # Heap statistics, most memory-consuming at the bottom. MT = class "pointer"
!dumpheap -stat -type TextBox # Show instances of classes containing "TextBox"
!dumpheap -type TextBox
!dumpheap -mt <type> # Dumps all instances of "TextBox" or <type>
!gcroot <address> # Why is the instance at <address> in memory?
# Domain = new GC root that reference <address> (~ static instance)
# Ignore WeakReferences, look for (pinned) references
# Create dumps from code:
[DllImport("DbgHelp.dll", SetLastError = true]
static extern bool MiniDumpWriteDump(
int dumpType, // 0x0 or 0x6 for managed code
a@href@title, blockquote@cite, em, strike, strong, sub, sup, u
Page rendered at Friday, October 21, 2016 6:43:07 PM (W. Europe Daylight Time, UTC+02:00)
newtelligence dasBlog 2.3.257.0
© Copyright 2016, admin
The opinions expressed herein are my own personal opinions and do not represent
my employer's view in any way.