Вопрос

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

Since i have been using Windbg for quite some time , i want to use it for managed code debugging as well.

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

Even though i understand most of the commands being used in SOS, i am unable to find a way to properly step through source code, just as i could do using the p and t instructions for native code.

This makes the debugging experience difficult, and I really want to step through code while debugging it.

I researched a bit on this and found that this was possible using the 6.7.05.0 version of Windbg in which MS seemed to have released integrated managed debugging, but rolled back in the later versions.

Nevertheless, i am very interested in being able to step through "source" code live while debugging through SOS. Specially because it is really hindering my debugging experience right now.

Is there a way to achieve this?

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

Это было полезно?

Решение

Windbg shines at analyzing minidumps of a crashed process. It is however not a managed debugger.

You can have your cake and eat it too by loading SOS in Visual Studio. Which permits using the normal debugging tools you have available in the managed debugger, plus the diagnostics you can get out of SOS. A few restrictions apply:

  • You must enable unmanaged debugging, Project + Properties, Debug tab, tick the option
  • VS is a 32-bit process so you can only use the 32-bit version of SOS. Project + Properties, Build tab, ensure you've got x86 selected if you are using the 64-bit version of Windows.

Start debugging and switch to the Immediate Windows. Type .load sos.dll, you should see an message like extension C:\Windows\Microsoft.NET\Framework\v4.0.30319\sos.dll loaded. Type !help and verify that you see the SOS commands listed.

Другие советы

Try using !sosex.mt and !sosex.mgu. The 'p' command should work as advertised.

If what you want is to hookup source code to windbg you could follow those steps:

  1. Go to File->Source File Path, select folder with source files.
  2. Go to View->Call Stack, it will open a new window.
  3. Navigate in the call stack and click on the relevant entry, it will open a window with the code browser.
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top