Debugging in .NET in Release mode

前端 未结 3 1283
萌比男神i
萌比男神i 2021-01-12 09:18

Some time ago I\'ve read an article on CLR, where author showed that if a project is compiled in DEBUG mode, before each operator comes a NOP command, thus allowing to debug

3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-12 09:44

    Debugging .net code so that you can step through the source code while it is executed usually requires three things:

    • Symbols (the related .pdb file) that were built along with the assembly .dll or .exe
    • Source (the related .cs, .vb, etc. files)
    • The executing machine code must be unoptimized

    Symbols are controlled by the /debug:{full | pdbonly} flag. If you specify /debug:full (even in a release build, with compiler optimizations turned off) you may attach to an already running process and step through code. If you have /debug:pdbonly, then you must use the debugger to start the program (and cannot view symbols when attaching to an already running process).

    Optimization is controlled granularly by the /debug compiler option, but can be further controlled by the /optimize-.

提交回复
热议问题