GCC -g OPTION

本文详细介绍了GCC编译器中-g选项的功能,包括如何生成不同操作系统的调试信息(如stabs, COFF, XCOFF, DWARF),以及如何与优化选项-O配合使用。文章还解释了在使用-g选项时如何控制生成特定格式的调试信息。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

-g
Produce debugging information in the operating system's native format (stabs, COFF, XCOFF, or DWARF). GDB can work with this debugging information.

On most systems that use stabs format, -g enables use of extra debugging information that only GDB can use; this extra information makes debugging work better in GDB but will probably make other debuggers crash or refuse to read the program. If you want to control for certain whether to generate the extra information, use -gstabs+, -gstabs, -gxcoff+, -gxcoff, or -gvms (see below).

Unlike most other C compilers, GCC allows you to use -g with -O. The shortcuts taken by optimized code may occasionally produce surprising results: some variables you declared may not exist at all; flow of control may briefly move where you did not expect it; some statements may not be executed because they compute constant results or their values were already at hand; some statements may execute in different places because they were moved out of loops.

Nevertheless it proves possible to debug optimized output. This makes it reasonable to use the optimizer for programs that might have bugs.

The following options are useful when GCC is generated with the capability for more than one debugging format.

 

 

http://gcc.gnu.org/onlinedocs/gcc-3.4.4/gcc/Debugging-Options.html#Debugging-Options

http://gcc.gnu.org/onlinedocs/gcc-3.4.4/gcc/Option-Summary.html

中文:

http://hi.baidu.com/zarcoder/blog/item/05ec15f364b173ca0b46e03b.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值