Source Code Navigation Using the Windbg SOS Extension

I recently switched from native to managed code programming. I am using .NET.

Since I used Windbg for some time, I want to use it to debug managed code.

My search led me to the SOS (Son of Strike) extension, which seems to have quite powerful commands.

Despite the fact that I understand most of the commands used in SOS, I can’t find a way to correctly execute the source code, just like I could use the p and t commands for my own code.

This makes the debugging process difficult, and I really want to execute the code when debugging it.

I worked a bit on this and found that this is possible with Windbg version 6.7.05.0, in which MS seems to have released integrated debugging, but rolled back in later versions.

However, I am very interested in being able to go through the "source" code live while debugging through SOS. Especially because it really hinders my debugging experience right now.

Is there any way to achieve this?

Any help on how to do this (or practical workarounds) is appreciated.

+7
source share
3 answers

Windbg shines when analyzing mini-disks of a broken process. However, this is not a managed debugger.

You can get your cake and eat it by loading SOS in Visual Studio. This allows you to use the usual debugging tools available in the managed debugger, as well as the diagnostics that you can get from SOS. Several restrictions apply:

  • You must enable unmanaged debugging, Project + Properties, Debug tab, check the option
  • VS is a 32-bit process, so you can only use the 32-bit version of SOS. Project + Properties, Build, make sure you select x86 if you are using the 64-bit version of Windows.

Start debugging and switch to immediate Windows. Type .load sos.dll , you should see a message like extension C:\Windows\Microsoft.NET\Framework\v4.0.30319\sos.dll loaded . Enter! Help and make sure that you see the listed SOS commands.

+6
source

Try to use! sosex.mt and! sosex.mgu. The 'p' command should work as declared.

+5
source

If you want to connect the source code to windbg, you can follow these steps:

  • Go to File-> Source File Path, select the folder with the source files.
  • Go to View-> Call Stack, it will open a new window.
  • Go to the call stack and click on the corresponding entry, it will open a window with a code browser.
0
source

All Articles