Unable to debug application in release mode even with DebugType = full

We are creating a solution for Release, but when trying to connect using a professional studio 2010, not a single thread shows information about the stack, nor can any breakpoint be set, etc.

The goal is to connect Visual Studio / JIT Debugger to the running process, with as many optimization benefits as possible.

Most of our searches come down to "compiling with debug: full" and you can debug it, but that doesn't seem to be the case, I believe JIT optimizes the code at runtime and therefore we cannot debug, is that true? Is it possible to compile and tell JIT about downplaying optimizations and enable debugging? (while maintaining other optimizations)

UPDATE

using @HansPassant's answer, I looked at the modules and saw that although pdbs are in the same directory as the binaries, in fact, no debug symbols were loaded. I also saw that my libraries are marked as "User Code" - "NO", which is probably the reason that it did not load automatically. By loading characters manually And by disabling "my-only-code" , I was also able to set breakpoints and view stacks.

Question: Why is my code not marked as User Code? is this normal behavior Can I customize this to my builds in some way to avoid this?

+7
c # clr visual-studio-2010 release visual-studio-debugging
source share
1 answer

Debugging optimized code is not a big pleasure. You probably might have a problem with setting breakpoints, maybe the method was built in. And checking local variables and method arguments can cause the debugger to become severe when the variable is optimized for storage in the cpu register.

Nevertheless, you can, however, check call stacks, you will see methods that did not fall into the stack trace. The main mistakes you can make:

  • When connecting a debugger, you can select the type of debugger. Be sure to select "Managed", you will not use it for your own debugger
  • make sure that you are looking at the correct thread, the program may be damaged in any place. Use Debug + Windows + Threads to select the appropriate thread
  • make sure you are really broken in the place of your code. You can easily get into the Windows operating system DLL or using the framework method, there will be very little to see when this happens. Tools + Options, Debugging, Symbols, and enabling the symbol server so that the stack traces that started inside Windows are accurate.
  • the debugger should be able to find PDB files. Use the Debug + Windows + modules, you will see the assemblies loaded into the process. First make sure that the one you want to debug is loaded. Right-click on it and select "Symbol Download Information". It shows you where it is looking for a PDB file.
  • the "only my code" parameter can greatly affect you, you are likely to come across significant pieces of code that are not yours. Tools + Options, Debugging, General and disable this option.
+13
source share

All Articles