GDB debug assembly
This article involves the following topics:
- How to disassemble source code to machine code?
- How to dump machine instruction along with source line?
- How to layout src and asm side by side in a single gdb window?
This article involves the following topics:
在调试程序时,中断程序的运行是必须的。GDB 可以方便地暂停/继续程序的运行。
通过设置断点,可以决定程序在哪行,在什么条件下,或者在收到什么信号时暂停,以便查验程序运行的流程和状态。
程序暂停后,我们可以通过相关命令控制程序继续运行到下一个预设的中断点,在这种“暂停-继续”往复中调试验证程序设计的正确性。
Invocation (Debugging with GDB)
This article discusses how to start GDB, and how to get out of it.
gdb
to start GDB.file
to change and load debugging FILE.info
/list
to show info/src about the program.run
command to start your program under GDB.start
command to start debugging and to stop at main.quit
, exit
or ctrl+d to exit GDB console.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.
This initial piece introduces how to use the gdb help system.
Inspect and dump mainstream compilers(gcc/clang/msvc) predefined macros, c/c++ language standard and search paths.
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:
Overview of concepts of Toolchain, Cross Compiler and Cross Compiler Toolchain.