Advanced Debugging with WinDbg and SOS
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

Advanced Debugging with WinDbg and SOS

on

  • 4,478 views

In this talk, we look at WinDbg, a powerful debugger that can help resolve difficult errors in production environments. We use WinDbg to pinpoint stack traces given dump files generated in production, ...

In this talk, we look at WinDbg, a powerful debugger that can help resolve difficult errors in production environments. We use WinDbg to pinpoint stack traces given dump files generated in production, to find memory leak causes and inspect heap memory, and even to automatically walk objects and threads to find deadlocks.

Statistics

Views

Total Views
4,478
Views on SlideShare
2,570
Embed Views
1,908

Actions

Likes
2
Downloads
42
Comments
1

22 Embeds 1,908

http://blogs.microsoft.co.il 1255
http://cloud.feedly.com 207
http://feeds.feedburner.com 199
http://dotnet.dzone.com 91
http://www.newsblur.com 45
http://feedreader.com 34
http://inoreader.com 17
http://lanyrd.com 11
http://newsblur.com 9
http://www.inoreader.com 7
http://reader.aol.com 6
http://www.feedspot.com 6
http://digg.com 5
http://smashingreader.com 3
http://feedly.com 3
http://webcache.googleusercontent.com 2
http://www.dzone.com 2
http://tiriss.com 2
http://subscribe.ru 1
http://reader.inthemail.org 1
http://feedproxy.google.com 1
http://www.hanrss.com 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
  • where is video or audio associated with the presentation.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Advanced Debugging with WinDbg and SOS Presentation Transcript

  • 1. Sasha Goldshtein CTO Sela Group @goldshtn blog.sashag.net Advanced Debugging with WinDbg and SOS
  • 2. 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
  • 3. www.devconnections.com ADVANCED DEBUGGING WITH WINDBG AND SOS DUMPS 101
  • 4. 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.
  • 5. 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
  • 6. www.devconnections.com ADVANCED DEBUGGING WITH WINDBG AND SOS SYSINTERNALS PROCDUMP: TAKE DUMPS EASILY, ANYWHERE, AND WITH NO PUN INTENDED. Procdump -ma -e MyApp.exe Procdump -h -x C:tempmyapp.exe Procdump -c 90 -n 3 -s 5 MyApp.exe Procdump -e 1 1234
  • 7. www.devconnections.com ADVANCED DEBUGGING WITH WINDBG AND SOS CRASH ROOT CAUSE FROM A DUMP
  • 8. 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.
  • 9. 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
  • 10. www.devconnections.com ADVANCED DEBUGGING WITH WINDBG AND SOS 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 10
  • 11. 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) }
  • 12. 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.
  • 13. www.devconnections.com ADVANCED DEBUGGING WITH WINDBG AND SOS MEMORY LEAKS: THE HARD WAY
  • 14. 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
  • 15. www.devconnections.com ADVANCED DEBUGGING WITH WINDBG AND SOS DEADLOCKS
  • 16. 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
  • 17. www.devconnections.com ADVANCED DEBUGGING WITH WINDBG AND SOS ADDITIONAL REFERENCES
  • 18. www.devconnections.com ADVANCED DEBUGGING WITH WINDBG AND SOS THANK YOU! Sasha Goldshtein @goldshtn sashag@sela.co.il blog.sashag.net 18