![]() Here are a few aspects in particular to talk through: The auto-display instructions show you what is happening on the stack and how $rip and $rsp are changing. Observe how control is transferred from caller to callee and back. Walk through the kermit function, including the calls made to dinky/ binky. Now use stepi to single-step by assembly instruction. The way to read this is from top-to-bottom, left-to-right in other words, interpret it in the following "stack diagram" drawing where the top of the stack (the lowest stack address) is at the bottom: Address This displays the top 4 8-byte entries on the stack. The second command says "display the 4 iant words (quadwords) in he starting at $rsp". This displays the instruction we are currently on, and the two instructions coming up next. For instance, say you have the following loop in your code: 1 for (int i = 0 i 0x400587 : push %rbp You can set breakpoints to only trigger when certain conditions in your code are true. Clever use of the display command can provide similar benefits to the tui GUI-like gdb interface, minus the flakiness and garbled display. Type display with no arguments to list all of the currently-set expressions to display, and undisplay X to stop displaying expression X in the list shown by display. (gdb) display/3i $rip // next 3 assembly instructions to execute For example, try these display expressions: (gdb) display/2gx $rsp // 2 quadwords, in hex, read from stack top The handy gdb command display sets up an expression to be repeatedly evaluated and printed as you single-step. You can dictate how to interpret the value by adding a / to the print command or by using a C typecast, e.g. In gdb, remember that access to a register is via $name instead of the more familiar %name.Ī register is treated as an untyped 8-byte value and when you ask gdb to print it, it shows a decimal integer or hex address. p $rax to print value from a single register. The info reg command displays current values for all integer registers.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |