15 November 2007

SOS your Visual Studio

 If you as a developer are interested in taking quick peeks into memory allocation you can load SOS (Son Of Strike) in Visual Studio to do that. SOS is written as a WinDbg extension but can load in Visual Studio and do most of the stuff.

To begin with you will have to go to the Properties of the project and check "Enable unmanaged code debugging" under the Debug options. Once you hit a breakpoint you can load SOS in the Immediate Window (Ctrl+Alt+I). It is similar to working with WinDbg you use the .load command to load the extension.

.load sos

SOS_load

 

Once loaded you can start running standard SOS commands (Use !heap for all SOS commands).

SOS_commands

 

  If you want to switch the thread context you will have to use the Threads Window(Ctrl+Alt+H) All you need to do is double click on the Thread in the Thread Window. You can use the thread ID to match the !threads output to the Threads Window.

SOS_Thread ID

 

A couple of commands like !vmmap will error out in Visual Studio

"Extension is using a feature which Visual Studio does not implement."

Also note that by default with ASP.NET projects you are debugging the Cassini process. You can also attach to a IIS worker process running your code and break into it.

Bookmark and Share
Filed under: , ,
 

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# MSDN Blog Postings » SOS your Visual Studio said:

PingBack from http://msdnrss.thecoderblogs.com/2007/11/15/sos-your-visual-studio/

15 November 07 at 5:26 PM
# Jeff R said:

Note that you must be attached with "Native" enabled as a debugging type, in addition to "Managed" debugging to load the SOS dll, even if you have built your project with the "allow unmanaged debugging" checkbox selected.

09 March 09 at 5:10 PM
# Thottam R. Sriram said:

I found this blog post from Shawn Burke to be very useful. Comes in handy if you have to step through

08 May 09 at 3:37 PM
# Jialiang said:

考虑一下如下两个问题:Q1:HowtofindtheliveSqlDataReaderfromaSqlConnectionobject.Q2:HowtofindallS...

10 June 09 at 10:32 AM

Leave a Comment

Comment Policy: No HTML allowed. URIs and line breaks are converted automatically. Your e–mail address will not show up on any public page.

(required) 
(optional)
(required) 

  
Enter Code Here: Required
Page view tracker