Examining the Generated Code

You can print memory as instructions or as data.

GDB Mode

Use the x command to dump memory in various formats. The disassemble command also provides disassembling capability.

(idb) x /10i $pc

0x08051603 <main+27>:                 pushl    %edi

0x08051604 <main+28>:                 leal     -136(%ebp), %eax

0x0805160a <main+34>:                 movl     %eax, (%esp)

0x0805160d <main+37>:                 call     0x0804ad50 <_ZN4ListI4NodeEC1Ev>

0x08051612 <main+42>:                 addl     $0x4, %esp

0x08051615 <main+45>:                 movl     $0x0, -132(%ebp)

0x0805161f <main+55>:                 jmp      0x08051645 <main+93>

0x08051621 <main+57>:                 pushl    %edi

0x08051622 <main+58>:                 leal     -136(%ebp), %eax

0x08051628 <main+64>:                 movl     %eax, (%esp)

(idb) x /10xh $pc

0x8051603 <main+27>: 0x8d57 0x7885 0xffff 0x89ff 0x2404 0x3ee8 0xff97 0x83ff

0x8051613 <main+43>: 0x04c4 0x85c7

(idb) x /6xw $pc

0x8051603 <main+27>: 0x78858d57 0x89ffffff 0x3ee82404 0x83ffff97

0x8051613 <main+43>: 0x85c704c4 0xffffff7c

(idb) x /2xg $pc

0x8051603 <main+27>: 0x89ffffff78858d57 0x83ffff973ee82404

DBX Mode

In the following example, the wi alias lists machine instructions before and after the current instruction. Note that the asterisk (*) marks the current instruction.

(idb) alias wi

wi ($curpc - 20)/10 i

(idb) wi

CompoundNode::CompoundNode(float, int): x_list.cxx

 [line 105, 0x120002348] cpys $f17,$f17,$f0

 [line 105, 0x12000234c] bis r31, r18, r8

 [line 101, 0x120002350] bis r31, r19, r16

 [line 101, 0x120002354] bis r31, r8, r17

 [line 101, 0x120002358] bsr r26, IntNode::IntNode(int)

*[line 101, 0x12000235c] ldq r18, -32712(gp)

 [line 101, 0x120002360] lda r18, 48(r18)

 [line 101, 0x120002364] stq r18, 8(r19)

 [line 101, 0x120002368] sts $f0, 24(r19)

 [line 106, 0x12000236c] bis r31, r19, r0

(idb) $pc/10x

0x12000235c: 0x8038 0xa65d 0x0030 0x2252 0x0008 0xb653 0x0018 0x9813

0x12000236c: 0x0400 0x47f3

(idb) $pc/6xx

0x12000235c: 0xa65d8038 0x22520030 0xb6530008 0x98130018

0x12000236c: 0x47f30400 0x47f5041a

(idb) $pc/2X

0x12000235c: 0x22520030a65d8038 0x98130018b6530008

See also

Memory Display and Search Commands