GCC -g VS -g3 GDB标志:有什么区别? [英] GCC -g vs -g3 GDB Flag: What is the Difference?

查看:1652
本文介绍了GCC -g VS -g3 GDB标志:有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在编译的C源$ C ​​$ c。与海湾合作委员会要么铛或者,我总是用 -g 标记生成GDB调试信息。

的gcc -o -g的HelloWorld helloworld.c

我注意到,有些人建议 -g3 来代替。是什么 -g -g3 标记之间的区别?也有之间的差异 -g -ggdb


解决方案

文档


  

-g


  
  

产生操作系统的本地格式(刺,COFF,XCOFF,或DWARF 2)调试信息。 GDB可以用这个工作
  调试信息。在使用stabs格式大多数系统中,-g
  允许使用额外的调试信息,只有GDB可以使用;这个
  额外的信息使得调试工作更好地在GDB但可能
  使得其他调试器崩溃或拒绝读入程序。如果你想
  来控制对某些是否产生额外的信息,使用
  -gstabs +,-gstabs,-gxcoff +,-gxcoff或-gvms(见下文)。


  
  

...




  

-ggdb


  
  

生产用于通过使用GDB调试信息。这意味着要使用现有的最前pressive格式(矮人2,刺,或本机
  如果这两个时间都不支持的格式),包括GDB扩展,如果
  在所有可能的。




  

-gvmslevel


  
  

请求的调试信息,还可以使用级别指定多少信息。默认级别为2级0不产生
  调试信息都没有。因此,-g0否定-g。


  
  

...


  
  

3级包括额外的信息,例如所有的宏定义
  present在程序中。一些调试器支持宏扩展时
  您使用-g3。


When compiling C source code with either gcc or Clang, I always use the -g flag to generate debugging information for gdb.

gcc -g -o helloworld helloworld.c

I noticed that some people recommend -g3 instead. What is the difference between the -g and -g3 flags? Also is there a difference between -g and -ggdb?

解决方案

From the docs:

-g

Produce debugging information in the operating system's native format (stabs, COFF, XCOFF, or DWARF 2). 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 probably makes 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).

...


-ggdb

Produce debugging information for use by GDB. This means to use the most expressive format available (DWARF 2, stabs, or the native format if neither of those are supported), including GDB extensions if at all possible.


-gvmslevel

Request debugging information and also use level to specify how much information. The default level is 2. Level 0 produces no debug information at all. Thus, -g0 negates -g.

....

Level 3 includes extra information, such as all the macro definitions present in the program. Some debuggers support macro expansion when you use -g3.

这篇关于GCC -g VS -g3 GDB标志:有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆