码迷,mamicode.com
首页 > 移动开发 > 详细

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

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

标签:exe   his   files   rar   ted   ogr   debugger   app   gpo   

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)

标签:exe   his   files   rar   ted   ogr   debugger   app   gpo   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!