0

As part of a migration to another cloud provider, we have found the need to be able to debug our .NET 2.1 application in a Kubernetes pod (running on mcr.microsoft.com/dotnet/core/aspnet:2.1) which I have been assigned to look into.

Our CI engine currently builds with "-c Release" but I've noticed the following wording on https://devblogs.microsoft.com/devops/debugging-net-core-on-unix-over-ssh/ :

For debugging, there are two important notes. First, it is much harder to debug retail-compiled code than debug-compiled code, so it is highly recommended to use the ‘Debug’ configuration. If you do need to use the ‘Release’ configuration, make sure to disable Tool->Options->Debugging->Just My Code.

I have done Java for longer than I care to think about (where most of the optimization happens inside the JVM at runtime), but I am unfamiliar with .NET, so I was wondering exactly why the release compiled code is harder to debug.

Is it simply because the compiler do the usual tricks like unrolling loops, evaluating string expressions and so on, or are there much deeper transformations happening under the covers? (Things like I've read that the Intel C++ compiler can interchange two loops if it means that the array traversal being done with them happens in a more cache efficient matter)

Thorbjørn Ravn Andersen
  • 73,784
  • 33
  • 194
  • 347
  • Code, compiled under the `Release` configuration, has a lot of optimizations, which is don't exists on `Debug` configuration. Have a look at existing threads, like [this](https://stackoverflow.com/questions/2446027/debug-vs-release-performance) or [this](https://stackoverflow.com/questions/4043821/performance-differences-between-debug-and-release-builds) to get some details – Pavel Anikhouski Feb 20 '20 at 11:04
  • It works like the JVM, [optimizations](https://stackoverflow.com/a/4045073/17034) are performed at runtime. Tools > Options > Debugging > General, ensure that "Suppress JIT optimization on module load" is turned on. That takes care of the randomness you'll get from optimizations. But you still have a problem with the debugging info file (the .pdb), a Release build is normally configured to remove source file and line number info. Building the project yourself instead of using the CI build is of course highly recommended. – Hans Passant Feb 20 '20 at 12:43

0 Answers0