开发者

exception ToString(): debug versus release mode

开发者 https://www.devze.com 2023-02-06 10:07 出处:网络
regarding th stack trace depth in debug and release mode. I have come to the following conclusion (calling exception.ToString()):

regarding th stack trace depth in debug and release mode. I have come to the following conclusion (calling exception.ToString()):

at debug mode you get the complete stack trace with line numbers (several fram开发者_开发问答es) at release mode instead complete stack trace you get only the throwing method in try block (single frame) with line numbers

-is that true ? -is there any way to get the complete stack tracve on release mode ?


You get line numbers in stack trace if you have the PDB file associated with your assembly. Even in Release builds, you can have the compiler to generate the PDB files and ship them alongside your assembly. You can use csc /debug:pdbonly when you're compiling your application. In Visual Studio 2010, you can use Project Properties -> Build -> Advanced -> Debug Info = pdb-only to achieve the same thing.

Update (stack trace depth):

You get full stack trace in Release builds. However, compilers may inline methods and optimize tail calls, making the stack trace different.


When you run in Debug mode there is a Debugger attached with your application which gets the stack trace with the help of the .pdb (Programme Debug Database) file. Where as in release mode we dont have a pdb or a debugger so couldnt get the Stack trace with line numbers.

The Debug configuration of your program is compiled with full symbolic debug information and no optimization. Optimization complicates debugging, because the relationship between source code and generated instructions is more complex.

The Release configuration of your program contains no symbolic debug information and is fully optimized. Debug information can be generated in Program Database Files (C++), depending on the compiler options that are used. Creating PDB files can be very useful if you later have to debug your release version.


Compiling in debug mode will include Debug statements as well as generate a *.pdb file, which actually "holds debugging and project state information that allows incremental linking of a debug configuration of your program". The depth of linking is dependent upon the depth of pdb files generated.

http://msdn.microsoft.com/en-us/library/ms241903.aspx

0

精彩评论

暂无评论...
验证码 换一张
取 消