首页 > 移动平台 > 详细

C: release & debug differences (might apply to all programming languages)

时间:2017-12-21 20:35:20      阅读:322      评论:0      收藏:0      [点我收藏+]

Sometimes we build a program as release and when debugging, some variables cannot be printed out, and displayed as optimized out. That is because the debugger(gdb) always prints a variable which locates on the stack, or resides in memory. But in release programs, variables might be optimized to only reside in register (or sometimes not exist and be pre-calculated into other variables when compiling). So print a variable which does not exist (in memory) always get you nothing. So this time we need to learn some asm and print the related register. Also, specify a variable as ‘volatile‘ should prevent the compiler from optimizing the specified variable out from the memory.

When talking about release & debug version of programs, both symbols and debug-info can reside in every object-file/executable, there is no difference between debug & release when talking about symbols or debuginfos. Play around with stacks, abi & asm are very important debugging release programs. But keep in mind symbols and debug-infos are different. Symbols in object files/executables tells us which memory has the name of "a"; Debuginfos  give sources. So in CentOS, installing a debuginfo of a certain package means we can then debug into the package functions (obtained the sourced version of the package libraries).

C: release & debug differences (might apply to all programming languages)

原文:http://www.cnblogs.com/sansna/p/8082278.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!