Best practices and tools for debugging differences between Debug and Release builds?

后端 未结 6 2112
别跟我提以往
别跟我提以往 2021-02-14 00:29

I\'ve seen posts talk about what might cause differences between Debug and Release builds, but I don\'t think anybody has addressed from a development standpoint what is

6条回答
  •  情书的邮戳
    2021-02-14 01:19

    When debug and release differ it means:

    1. you code depends on the _DEBUG or similar macros (defined when compiling a debug version - no optimizations)
    2. your compiler has an optimization bug (I seen this few times)

    You can easily deal with (1) (code modification) but with (2) you will have to isolate the compiler bug. After isolating the bug you do a little "code rewriting" to get the compiler generate correct binary code (I did this a few times - the most difficult part is to isolate the bug).

    I can say that when enabling debug information for release version the debugging process works ... (though because of optimizations you might see some "strange" jumps when running).

    You will need to have some "black-box" tests for your application - valgrind is a solution in this case. These solutions help you find differences between release and debug (which is very important).

提交回复
热议问题