install and how to use windbg on win 10 pro

select this link

 

  • how to use windbg to debug c# program

befor debug c# program , also called as  “Managed Code” ,  need load sos.dll ,

in my machine , it located at C:\Windows\Microsoft.NET\Framework64\v4.0.30319

 

From article :  https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/debugging-managed-code

a)  First write a console c# program

 

 

b)  build and run it in command line , then  open “windbg(X86)” , and attach to this process , then type this command :

in my machine , output is :

it show DAC  and CLR are all loaded

c) set symbol path ,  in my case , use

 

c)

 

  • commandshow all loaded DLL


     

show all method table of attached program

the output like this :

With the method table address we can examine all the fuctions defined in the method. by using command

033b4d40  is a example method address , it depend on your output

it output like this :

 

if want to set a breakpoint at method “sendTwoTimes”

could use this command



when reach breakpoint ,  type

to display strack info , notice kL  ,  L  is upcase


view and edit registers


open registers  window

Alt+4 


call trace


 

 

  • Ref articles

https://blogs.msdn.microsoft.com/kaevans/2011/04/11/intro-to-windbg-for-net-developers/

https://blogs.msdn.microsoft.com/kristoffer/2007/01/02/setting-a-breakpoint-in-managed-code-using-windbg/