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

2

6

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.

Outlast answered 12/7, 2012 at 23:9 Comment(0)
T
1

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

Triparted answered 13/7, 2012 at 1:52 Comment(0)
I
2

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…
Incrust answered 7/6, 2015 at 17:44 Comment(0)
T
1

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

Triparted answered 13/7, 2012 at 1:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.