[contents]
[usage]
[execution]
[stack]
[breakpoints]
[watchpoints]
[advanced]
6. Advanced gdb Features
6.1 How do I examine memory? [top]  [toc]Use the x command to examine memory. The syntax for the x command is x/FMT ADDRESS. The FMT field is a count followed by a format letter and a size letter. There are many options here, use the help command 'help x' to see them all. The ADDRESS argument can either be a symbol name, such as a variable, or a memory address.
If we have Examine the variable as a string:
Examine the variable as a character:
Examine the variable as 4 characters:
Examine the first 32 bits of the variable:
Examine the first 24 bytes of the variable in hex:
6.2 How do I see what is in the processor registers? [top]  [toc]Use the info registers command. The output of this command depends on the hardware architecture. The following is part of the output on an intel machine:
6.3 How do I debug with a core file? [top]  [toc]When your program segfaults and leaves a core dump file, you can use gdb to look at the program state when it crashed. Use the core command to load a core file. The argument to the core command is the filename of the core dump file, which is usually "core", making the full command core core.
6.4 How do I step through my code at the instruction level? [top]  [toc]There are two commands, nexti and stepi, that work similar to next and step. See the usage of those commands for an idea of how to use these two. 6.5 How do I see the assembly code my program is running? [top]  [toc]Use the disassemble command. The argument to this command is a memory address. Here is an example of the disassembly for the main function of a simple program on an intel machine:
[contents] [usage] [execution] [stack] [breakpoints] [watchpoints] [advanced] Questions? Comments? Flames? email rms@unknownroad.com |