background preloader

GNU

Facebook Twitter

Invoking GCC. When you invoke GCC, it normally does preprocessing, compilation, assembly and linking.

Invoking GCC

The “overall options” allow you to stop this process at an intermediate stage. For example, the -c option says not to run the linker. Then the output consists of object files output by the assembler. Other options are passed on to one stage of processing. Some options control the preprocessor and others the compiler itself. Most of the command-line options that you can use with GCC are useful for C programs; when an option is only useful with another language (usually C++), the explanation says so explicitly. See Compiling C++ Programs, for a summary of special options for compiling C++ programs. The gcc program accepts options and file names as operands. You can mix options and other arguments. Many options have long names starting with ‘-f’ or with ‘-W’—for example, -fmove-loop-invariants, -Wformat and so on. See Option Index, for an index to GCC's options. Debugging Options. GCC has various special options that are used for debugging either your program or GCC: -g Produce debugging information in the operating system's native format (stabs, COFF, XCOFF, or DWARF 2).

Debugging Options

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).

GCC allows you to use -g with -O. Nevertheless it proves possible to debug optimized output. Debugging with GDB: GDB Files. GDB needs to know the file name of the program to be debugged, both in order to read its symbol table and in order to start your program.

Debugging with GDB: GDB Files

To debug a core dump of a previous run, you must also tell GDB the name of the core dump file. 15.1 Commands to Specify Files You may want to specify executable and core dump file names. View topic - separate debugging symbols. On the "How do I use a debugger with my OS" page, in the "Use gdb with Qemu" section, there is: Quote: But thats not all, you can compile your source code under gcc with debuging symbols using "-g".

View topic - separate debugging symbols

This will add all the debuging symbols in the kernel image itself (Thus making it bigger ). Using LD, the GNU linker - Table of Contents. Source Path - Debugging with GDB. 9.5 Specifying Source Directories Executable programs sometimes do not record the directories of the source files from which they were compiled, just the names.

Source Path - Debugging with GDB

Even when they do, the directories could be moved between the compilation and your debugging session. gdb has a list of directories to search for source files; this is called the source path . GDB/MI 层命令介绍 - coutcin的专栏 - CSDN博客. //作者:coutcin, 对于gdb的命令很多人可能都已经很熟悉了,本文介绍的mi层命令可能很少有人用到,它也是gdb的一部分,主要目的是为一些目标系统如IDE等提供调试功能,如eclipse下c/c++的cdt插件的底层就是调用的mi层命令,cdt的包里面有两个类RxThread,TxThread就是一个发送mi命令,一个接收返回数据的,大家有兴趣可以研究下。

GDB/MI 层命令介绍 - coutcin的专栏 - CSDN博客

Mi的命令依然是以文本行方式提供的,并兼容我们常用的gdb CLI命令,下面我们看一下它的进入和退出: ⇒进入命令 gdb --interpreter mi ****.exe ⇒推出命令 quit 效果如下: D:/exercise/c/test>gdb --interpreter mi~"GNU gdb 6.3.50_2004-12-28-cvs (cygwin-special)/n"~"Copyright 2004 Free Software Foundation, Inc. D:/exercise/c/test> mi的命令总共分为以下几个部分: 1.断点(Breakpoint) Debugging with GDB. This file documents the GNU debugger GDB.

Debugging with GDB

This is the Tenth Edition, of Debugging with GDB: the GNU Source-Level Debugger for GDB (GDB) Version 7.8.0.20140906-cvs. Copyright © 1988-2014 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with the Invariant Sections being “Free Software” and “Free Software Needs Free Documentation”, with the Front-Cover Texts being “A GNU Manual,” and with the Back-Cover Texts as in (a) below.

(a) The FSF’s Back-Cover Text is: “You are free to copy and modify this GNU Manual. Buying copies from GNU Press supports the FSF in developing GNU and promoting software freedom.”