سؤال

I want to have a bit more of a look at the resulting ASM (F#->IL->ASM) that is generated for certain functions, purely out of curiosity & learning.

Answer in my mind is to use SOS.dll, but I have run into a bit of a hurdle...

Let us start with the most basic code in F#. File is named test.fs.

[<EntryPoint>]
  let main _ = 
    stdin.ReadLine()
    1

We are defining an entry point that takes 'a (constrained without telling us (?) to string array for obvious reasons (trivia: can't use "'a" in an entrypoint function?)). We then wait for user input. This makes it a lot easier to break manually in windbg. compile test.fs to produce test.exe

Open windbg, open test.exe inside windbg:

>!load C:\Windows\Microsoft.NET\Framework64\v4.0.30319\sos.dll
>g

Windbg will run our code and wait for the readline loop, we can then type something into the console window and windbg will exit.

Now, how do we place a breakpoint on main so that we can break before the readline loop?

>!bpmd test.exe Test.main; g

windbg will then enter the readline loop... I was expecting it to break before the readline loop, the breakpoint must be ill-defined. Following this I tried many variations of breakpoints: !bpmd test.exe Test.main; !bpmd test.exe Test; !bpmd test.exe main; !bpmd test.exe Main; !bpmd test.exe Main.test !bpmd test.exe Test... ect (but may have missed one) it is quite obvious I am doing something wrong, I have also tried using module xx = ...,

Question: Could anyone let me know how to place a breakpoint in F# managed code from within windbg using SOS extensions?

References:

http://winterdom.com/2011/06/having-fun-with-windbg

http://social.msdn.microsoft.com/Forums/en-US/clr/thread/a0ab6170-d53b-4c95-8f5e-efaf4e014fcd

http://blogs.msdn.com/b/vancem/archive/2006/09/05/742062.aspx

هل كانت مفيدة؟

المحلول

Try !sosex.mbm, which takes a method filter with */? wildcard syntax like the command line. Also try !sosex.mbp, which takes a source file, line number and optional column number. To disassemble, use !sos.dumpil or !sos.U. For an interleaved disassembly of source/IL/native, try out !sosex.muf.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top