0

Is it possible to step through the code of a dll built in release mode that is optimized and has a pdb file that was generated with the pdb-only option? (Here it says that pdb-only vs full makes no difference though.)

I've read multiple times that dlls built in release mode can be debugged if there are pdbs available (here, here, here, here,or here) .

With Visual Studio I only managed to debug (step into the code) a C# console project in release mode when I unchecked Optimize code. Do those answers that say it's possible simply assume that optimization is off or is there some other method?

The first linked answer says that it makes post-mortem debugging easier. So I included a throw statement and then ran the release mode exe directly without Visual Studio. I got the "has stopped working" dialog and when I chose to debug with Visual Studio all I got was

Your app has entered a break state, but there is no code to show because all threads were executing external code.

I didn't see any code although the thrown exception comes directly from my code that has an appropriate pdb-file and not from some other referenced dll.

Edit Here it says that I should get the stack traces with pdb-only but the Call Stack window only shows [External Code].

Maybe Visual Studio is just the wrong tool to get an actual debugging experience?

Community
  • 1
  • 1
user764754
  • 3,865
  • 2
  • 39
  • 55
  • That's just a little too late to start debugging. Your code isn't executing anymore and it is running inside the Windows crash handler. You'll never get any source code because of *pdb-only*, with some luck you can see *something* if you look in the debugger's Call Stack window. Enable unmanaged debugging and the Microsoft Symbol Server to improve that luck. – Hans Passant Oct 12 '16 at 12:29
  • @HansPassant If I never get source code then what is pdb-only good for with release builds? Does it increase the "luck"? When I run it with Visual Studio I also can't get it to debug or show any code after the exception. – user764754 Oct 12 '16 at 13:01
  • It is good for setting breakpoints, that's all. – Hans Passant Oct 12 '16 at 13:19
  • @HansPassant Those breakpoints are only hit for me with unoptimized code. Is this normal? Because if so then the default project settings (pdb-only in conjunction with optimization on) would make no sense. – user764754 Oct 12 '16 at 13:28
  • It is not abnormal, the basic job of the optimizer is to inline or remove code when it can. You can only get guesses when you don't show anything, good luck with it. – Hans Passant Oct 12 '16 at 13:31

0 Answers0