Can I set a breakpoint at a source code of managed application when I use WinDbg?

StackOverflow https://stackoverflow.com/questions/11462033

  •  20-06-2021
  •  | 
  •  

Вопрос

I tried to set a breakpoint using WinDbg at a source code of a c# application, but it didn’t work. Is there a way to set a breakpoint at a source code of managed application when I use WinDbg?

Repro step is the below:

1.Make a simple c# application

class Proram
{
  static void MyWrite(){
      Console.WriteLine("test");
  }
  static void Main(string[] args){
      Console.ReadLine();
      MyWrite();
  }
 }

2.Start the .NET application from WinDbg
3.Open its source file into WinDbg
4.Break execution (while the app in ReadLine())
5.Setup symbol path and load sos.dll
6.Set a breakpoint at Console.WriteLine("test") using F9
7.Execute "g" command
8.Error occurred

Unable to insert breakpoint 0 at <address>, Win32 error 0x998 
     "Invalid access to memory location."
bp0 at <address> failed
WaitForEvent failed

I have the app's private symbol, so I don't think this is a symbol related problem.

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

Решение

Use !sosex.mbp. For example, to break at myapp.cs, line 10: !mbp myapp.cs 10

You can download sosex for free from http://www.stevestechspot.com

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

Try:

0:000> sxe ld clrjit.dll

ModLoad: 72ea0000 72f1d000   C:\Windows\Microsoft.NET\Framework\v4.0.30319\clrjit.dll

0:000> .loadby sos clr

0:000> !bpmd SslStreamTest.exe SslStreamTest.Program.Main

Found 1 methods in module 00bb2edc…
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top