C# : compiling with /debug+ /debug:pdbonly /optimize- is optimizing the runtime code
is it a bug? here is the code
static void Main(string[] args)
{
fun1();
}
static void fun1()
{
fun2();
}
static void fun2()
{
throw new Exception("test excepti开发者_如何学编程on");
}
build with the above option in VS 2008, with Optimize option not selected and Build advanced options debug info select pdbonly and check the stacktrace.
let me know u guys experience the same
Yes, using /debug:pdbonly is enough to convince the compiler that its okay to inline methods. It generates a different [DebuggableAttribute] into the assembly:
.custom instance void [mscorlib]System.Diagnostics.DebuggableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggableAttribute/DebuggingModes) = ( 01 00 06 01 00 00 00 00 )
Where /debug:full produces:
.custom instance void [mscorlib]System.Diagnostics.DebuggableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggableAttribute/DebuggingModes) = ( 01 00 07 01 00 00 00 00 )
If this is a problem, you'll need to explicitly disable inlining like this:
using System.Runtime.CompilerServices;
...
[MethodImpl(MethodImplOptions.NoInlining)]
static void fun1() {
fun2();
}
精彩评论