Running and Debugging PerlRunning and Debugging Perl ... debugging
Advanced Debugging with WinDbg and SOS
-
Upload
sasha-goldshtein -
Category
Technology
-
view
4.375 -
download
1
description
Transcript of Advanced Debugging with WinDbg and SOS
![Page 1: Advanced Debugging with WinDbg and SOS](https://reader035.fdocuments.us/reader035/viewer/2022081512/555c4315d8b42a0b038b4f98/html5/thumbnails/1.jpg)
Sasha Goldshtein
CTOSela Group
@goldshtnblog.sashag.net
Advanced Debugging with
WinDbg and SOS
![Page 2: Advanced Debugging with WinDbg and SOS](https://reader035.fdocuments.us/reader035/viewer/2022081512/555c4315d8b42a0b038b4f98/html5/thumbnails/2.jpg)
www.devconnections.com
ADVANCED DEBUGGING WITH WINDBG AND SOS
AN HOUR FROM NOW,YOU’LL KNOW HOW TO:
Capture crash and hang dumps Pinpoint basic crash causes from
dumps Inspect heap objects and graphs to find
memory leaks Identify deadlocked threads
![Page 3: Advanced Debugging with WinDbg and SOS](https://reader035.fdocuments.us/reader035/viewer/2022081512/555c4315d8b42a0b038b4f98/html5/thumbnails/3.jpg)
www.devconnections.com
ADVANCED DEBUGGING WITH WINDBG AND SOS
DUMPS 101
![Page 4: Advanced Debugging with WinDbg and SOS](https://reader035.fdocuments.us/reader035/viewer/2022081512/555c4315d8b42a0b038b4f98/html5/thumbnails/4.jpg)
www.devconnections.com
ADVANCED DEBUGGING WITH WINDBG AND SOS
A DUMP IS A SNAPSHOT OF A RUNNING PROCESS. YOU CAN
SAVE IT, MOVE IT AROUND, AND ANALYZE IT LATER. YOU CAN’T
“DEBUG” IT.
![Page 5: Advanced Debugging with WinDbg and SOS](https://reader035.fdocuments.us/reader035/viewer/2022081512/555c4315d8b42a0b038b4f98/html5/thumbnails/5.jpg)
www.devconnections.com
ADVANCED DEBUGGING WITH WINDBG AND SOS
TWO TYPES OF DUMPS:
Crash Dump The program crashed
Hang Dump The program didn’t crash
Yet
![Page 6: Advanced Debugging with WinDbg and SOS](https://reader035.fdocuments.us/reader035/viewer/2022081512/555c4315d8b42a0b038b4f98/html5/thumbnails/6.jpg)
www.devconnections.com
ADVANCED DEBUGGING WITH WINDBG AND SOS
SYSINTERNALS PROCDUMP: TAKE DUMPS EASILY, ANYWHERE, AND
WITH NO PUN INTENDED.
Procdump -ma -e MyApp.exeProcdump -h -x C:\temp\myapp.exeProcdump -c 90 -n 3 -s 5 MyApp.exeProcdump -e 1 1234
![Page 7: Advanced Debugging with WinDbg and SOS](https://reader035.fdocuments.us/reader035/viewer/2022081512/555c4315d8b42a0b038b4f98/html5/thumbnails/7.jpg)
www.devconnections.com
ADVANCED DEBUGGING WITH WINDBG AND SOS
CRASH ROOT CAUSE FROM A DUMP
![Page 8: Advanced Debugging with WinDbg and SOS](https://reader035.fdocuments.us/reader035/viewer/2022081512/555c4315d8b42a0b038b4f98/html5/thumbnails/8.jpg)
www.devconnections.com
ADVANCED DEBUGGING WITH WINDBG AND SOS
DRAG AND DROP A DUMP FILE INTO VISUAL STUDIO. CLICK THE
GREEN BUTTON. VOILA, IT WORKS.*
* NITPICKER’S CORNER: YOU NEED SYMBOLS AND SOURCES TO BE LINED UP PROPERLY.
![Page 9: Advanced Debugging with WinDbg and SOS](https://reader035.fdocuments.us/reader035/viewer/2022081512/555c4315d8b42a0b038b4f98/html5/thumbnails/9.jpg)
www.devconnections.com
ADVANCED DEBUGGING WITH WINDBG AND SOS
“
”
YOU WILL INSTALL VISUAL STUDIO ON MY BOXEN OVER MY DEAD BODY. GOOD DAY.
I SAID “GOOD DAY”.
Joe the IT Admin
![Page 10: Advanced Debugging with WinDbg and SOS](https://reader035.fdocuments.us/reader035/viewer/2022081512/555c4315d8b42a0b038b4f98/html5/thumbnails/10.jpg)
www.devconnections.com
ADVANCED DEBUGGING WITH WINDBG AND SOS
10
ENTER:
WinDbg Lightweight GUI debugger
Super-scriptable
Super-extensible
Knows nothing about .NET
SOS WinDbg extension for .NET
Ships with .NET Framework
Or on the symbol server*
Knows all about .NET
* As of CLR 4.0, for GDR versions
![Page 11: Advanced Debugging with WinDbg and SOS](https://reader035.fdocuments.us/reader035/viewer/2022081512/555c4315d8b42a0b038b4f98/html5/thumbnails/11.jpg)
www.devconnections.com
ADVANCED DEBUGGING WITH WINDBG AND SOS
TAKE 2:
Drag and drop a dump file into WinDbg. Hmm. Now what?
!analyze -v !PrintException!CLRStack .load sosex!mk !mdt
.for (r $t0=@ebp; poi(@$t0)!=0; r $t0=poi(@$t0)) { !mln poi(@$t0+4) }
![Page 12: Advanced Debugging with WinDbg and SOS](https://reader035.fdocuments.us/reader035/viewer/2022081512/555c4315d8b42a0b038b4f98/html5/thumbnails/12.jpg)
www.devconnections.com
ADVANCED DEBUGGING WITH WINDBG AND SOS
MEMORY LEAKS: THE EASY WAY
Not in this talk. Shell out $500 for a decent memory profiler.
![Page 13: Advanced Debugging with WinDbg and SOS](https://reader035.fdocuments.us/reader035/viewer/2022081512/555c4315d8b42a0b038b4f98/html5/thumbnails/13.jpg)
www.devconnections.com
ADVANCED DEBUGGING WITH WINDBG AND SOS
MEMORY LEAKS: THE HARD WAY
![Page 14: Advanced Debugging with WinDbg and SOS](https://reader035.fdocuments.us/reader035/viewer/2022081512/555c4315d8b42a0b038b4f98/html5/thumbnails/14.jpg)
www.devconnections.com
ADVANCED DEBUGGING WITH WINDBG AND SOS
WHAT WE NEED:
1. A list of all heap objects
2. A diff of heap objects between dumps
3. Why these heap objects won’t go away
!dumpheap -stat !objsize!gcroot !refs
![Page 15: Advanced Debugging with WinDbg and SOS](https://reader035.fdocuments.us/reader035/viewer/2022081512/555c4315d8b42a0b038b4f98/html5/thumbnails/15.jpg)
www.devconnections.com
ADVANCED DEBUGGING WITH WINDBG AND SOS
DEADLOCKS
![Page 16: Advanced Debugging with WinDbg and SOS](https://reader035.fdocuments.us/reader035/viewer/2022081512/555c4315d8b42a0b038b4f98/html5/thumbnails/16.jpg)
www.devconnections.com
ADVANCED DEBUGGING WITH WINDBG AND SOS
WHAT WE NEED:
1. What is thread X waiting for
2. (Suppose it’s sync object Y)
3. Which thread owns sync object Y
!syncblk !mwaits!mlocks !dlk
![Page 17: Advanced Debugging with WinDbg and SOS](https://reader035.fdocuments.us/reader035/viewer/2022081512/555c4315d8b42a0b038b4f98/html5/thumbnails/17.jpg)
www.devconnections.com
ADVANCED DEBUGGING WITH WINDBG AND SOS
ADDITIONAL REFERENCES
![Page 18: Advanced Debugging with WinDbg and SOS](https://reader035.fdocuments.us/reader035/viewer/2022081512/555c4315d8b42a0b038b4f98/html5/thumbnails/18.jpg)
www.devconnections.com
ADVANCED DEBUGGING WITH WINDBG AND SOS
18
THANK YOU!
Sasha Goldshtein@goldshtn