GDB Disassembly Output – No Optimization
Explore how to use GDB to debug C/C++ programs compiled without optimization. Learn to set breakpoints, disable address randomization, inspect assembly instructions, and track changes in memory and registers to better understand program execution and disassembly output.
Arithmetic example in the C/C++ program
Let’s rewrite our arithmetic program in C/C++. Corresponding assembly language instructions are edited in the comments:
The flowchart below shows the working of the source code:
Disassembly in the no-optimization mode
It is easier to track the progress of our program during debugging if we can recompile without optimization.
Note: You can practice all the commands in the coding playground provided at the end of the lesson.
Compilation
If we compile and link the program in the no-optimization mode (default), as shown below, we get the ...