Skip to content

toolchain#

compiling for debugging with GDB

Compilation (Debugging with GDB)

In order to debug a program effectively, you need to generate debugging information when you compile it. This debugging information is stored in the object file; it describes the data type of each variable or function and the correspondence between source line numbers and addresses in the executable code.

To request debugging information, specify the -g option when you run the compiler.

GDB manual & help

The best known command-line debugger is the official GNU Debugger(aka GDB).

Vanilla GDB is an amazing tool in process debugging, just like a swiss army knife.

This initial piece introduces how to use the gdb help system.

  1. GDB onlinedocs, concept index.
  2. Help within GDB, search command class and detailed command name.
  3. Take the breakpoints search as an example to exemplify help usage.

Mainstream Compiler - gcc/clang/msvc

Try and tease out mainstream compilers(GNU/GCC, Clang/LLVM, Microsoft Visual Studio) architecture/framework, toolchain, binutils and language(C/C++) standards.

The following concepts/topics will be involved:

  1. gcc/g++, glibc/libstdc++, gdb
  2. clang/clang++, llvm-gcc/llvm-g++, libc/libc++, lldb
  3. msvc/cl, windbg

Compiler Toolchain

Overview of concepts of Toolchain, Cross Compiler and Cross Compiler Toolchain.

In computing, a compiler is a computer program that translates computer code written in one programming language (the source language) into another language (the target language). The name "compiler" is primarily used for programs that translate source code from a high-level programming language to a low-level programming language (e.g. assembly language, object code, or machine code) to create an executable program.

There are many different types of compilers which produce output in different useful forms. A cross-compiler produces code for a different CPU or operating system than the one on which the cross-compiler itself runs. A bootstrap compiler is often a temporary compiler, used for compiling a more permanent or better optimised compiler for a language.