Who’s afraid of WinDbg

Download Who’s afraid of WinDbg

Post on 17-Jul-2015

697 views

Category:

Technology

5 download

Embed Size (px)

TRANSCRIPT

<p>Codevalue_template_New</p> <p>Dror Helperdrorh@codevalue.net | http://blog.drorhelper.com | @dhelper Whos afraid of WinDBG?</p> <p>1About.MeSenior consultant @CodeValue</p> <p>Developing software (professionally) since 2002Clean coderTest Driven Developer</p> <p>Blogger: http://blog.drorhelper.com</p> <p>How I Learned to Stop Worrying and Love WinDbg</p> <p>From Wikipedia Commons</p> <p>When we think about debuggingUnfortunately If (Production &amp;&amp; Visual studio){SysAdmin = VeryAngry;Customer != Permission;Application = NotWorking;Debug != DateTime.Now;}WinDbg to the rescuePost mortem analysis of crash/hang dumpsInspect heap and find memory leaksDiscover deadlocksLearn more about your application </p> <p>Basic commands| list all processes|. current process|s switch to process~ list all threads~. current thread~s switch to thread</p> <p>k call stack (unmanged)~* all threads~* k call stack for all threadsWait, youre forgot somethingFor proper debugging youll need symbolslm show all modules + symbol information.symfix + .reload f ld Loads symbols for the specified module</p> <p>Or use File Symbol file path</p> <p>ICanHasWindows!Improve your workspaceFully customizableWindows dockingTheme support!</p> <p>%ProgramFilesDir%\Windows Kits\8.1\Debuggers\x64\themes</p> <p>Part I Crash analysis11Analyzing Crush dumpA minidump is a snapshot of an application state:{Process(s)Thread(s)Module(s)Register(s)Memory infoHandlesCall stack}Creating MiniDumpsWinDbgTask Manager/ProcExADPlus (Debugging tools for windows)ProcDump (sysinternals)sos.dllWinDBG extensionKnows .NETShips with .NET framework/symbol server</p> <p>.loadby sos mscorwks (.net 3.5 or earlier).loadby sos clr (.net 4.0 or later)14Now what?Load MiniDump in WinDBGSymbols!Load sos.dll!analyze v</p> <p>More crash analysis commands (sos)!printexception!threads!dae (dump all exceptions)!dso (dump stack objects)!clrstack-p (shows parameters and values)-l (show locals)-a (same as p l)Part II - Investigating memory issues17Finding memory issuesLook at heapList all objectsDive in to see specific objectCompare with previous results</p> <p>!dumpheap -stat!dumpheap type!do!gcrootOther memory related commands!FinalizeQueue!objsize!GCHandleLeaks</p> <p>!dumpgen!gcgen!refs!mk!mdt19!FinalizeQueue show finalizer queue!threads show managed threads!objsize calculate real object size!GCHandleLeaks track down GCHandle leaks</p> <p>!finq/frq show finilizer/freachable queue!dumpgen Dumps the contents gen X !gcgen - GC generation of the specified object!refs - all references from/to object!mk - unmanaged and managed call stack!mdt - fields of an object or type</p> <p>19Part III deadlock detection20R1R2P2P1Deadlock detection.load \sosex.dll!dlkOther options:!syncblk/!DumpHeap thinlockPlain old !clrstack!mlocks!mwaits</p> <p>Making WinDBG user friendly(ier).cmdtree </p> <p>.prefer_dml 123Dror HelperC: 972.05.7668543e: drorh@codevalue.netB: blog.drorhelper.com</p>

Recommended

View more >