GDB Disassembly Output—No Optimization
Explore how to use GDB to disassemble and debug a simple arithmetic program compiled without optimization. Learn to set breakpoints, disable address randomization, and analyze assembly output to better understand program execution and memory changes within the GDB environment.
We'll cover the following...
Arithmetic program
Let’s rewrite our arithmetic program in way that works in both C and C++. Corresponding assembly language instructions are written in the comments:
Disassembly in no-optimization mode
It’s easier to track the progress of our program during debugging if we can recompile without optimization. The steps to initialize the GDB environment are below:
Note: You can practice all the commands in the coding playground provided at the end of the lesson.
Let’s compile and link the program in no optimization mode (default):
gcc ...