【发布时间】:2023-05-16 23:51:01
【问题描述】:
我想专门选择优化标志来防止 gdb 中的 <optimized out>
变量(参数),而不诉诸 -O0
。
我的背景是调试 glibc,它不能用 -O0
构建,因为它需要某种函数内联。但是我可以看到这通常很有用,例如在不完全影响性能的情况下启用有用的调试。
根据gcc -c -Q -O0 --help=optimizers
,除了-O0
(使用gcc 5.3.1)启用的优化标志外,-O1
还启用了以下31个优化标志:
-fbranch-count-reg
-fcombine-stack-adjustments
-fcompare-elim
-fcprop-registers
-fdefer-pop
-fforward-propagate
-fguess-branch-probability
-fif-conversion
-fif-conversion2
-finline-functions-called-once
-fipa-profile
-fipa-pure-const
-fipa-reference
-fmove-loop-invariants
-fshrink-wrap
-fsplit-wide-types
-fssa-phiopt
-ftree-bit-ccp
-ftree-ccp
-ftree-ch
-ftree-copy-prop
-ftree-copyrename
-ftree-dce
-ftree-dominator-opts
-ftree-dse
-ftree-fre
-ftree-pta
-ftree-sink
-ftree-slsr
-ftree-sra
-ftree-ter
注意:我知道选择性优化/易失性作为手动修复,但我正在寻找更通用的解决方案。
【问题讨论】:
标签: c debugging gcc gdb compiler-optimization