Skip to main content
Engineering LibreTexts

3.5: Debugging with gdb

  • Page ID
    76107
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    Often a simulator is used to teach assembly. This is often done because the simulators are pared down versions of the real assembly, only presenting the students with what is believed to be the necessary information to understand the concepts the instructor wants to present. The tools that come with these simulators are designed to be easy to use by the students and to present simplified visuals for the students.

    This textbook takes a different approach to this problem of how to present material to the students. It uses tools that the reader might encounter in a real world programming environment to create, run, and visualize the code. It requires students to use a real operating system, the Raspberry Pi OS, which is a version of Linux. The reader has to learn to use the bash shell, how the write make files to create programs, and that there are intermediate files between the source files and the executable files called object and library files. Later, readers will learn how to decompose and read the object and executable files using commands such as objdump and readelf.

    This section will teach the students the GNU debugger, gdb. The gdb debugger will be presented with a console oriented interface named tui (or gdbtui, gdb’s Text User Interface). This debugger will be used by the readers to debug program, to help understand the execution of their programs, as well as visualize what is happening with memory and registers during the execution of their program.


    This page titled 3.5: Debugging with gdb is shared under a CC BY 4.0 license and was authored, remixed, and/or curated by Charles W. Kann III via source content that was edited to the style and standards of the LibreTexts platform; a detailed edit history is available upon request.

    • Was this article helpful?