Looking at the Generated Code. Simple Debugging

You can print memory as instructions or as data.

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

GDB Mode

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

 

(idb) x /10i $pc

0x08052e8f <main+27>:                 pushl    %edi

0x08052e90 <main+28>:                 leal     -160(%ebp), %eax

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

0x08052e99 <main+37>:                 call     0x0804c4c8 <_ZN4ListI4NodeEC1Ev>

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

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

0x08052eab <main+55>:                 pushl    %edi

0x08052eac <main+56>:                 movl     $0xc, (%esp)

0x08052eb3 <main+63>:                 call     0x0804c308 <_init+744>

0x08052eb8 <main+68>:                 addl     $0x4, %esp

(idb) x /10xh $pc

0x8052e8f <main+27>: 0x8d57 0x6085 0xffff 0x89ff 0x2404 0x2ae8 0xff96 0x83ff

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

(idb) x /6xw $pc

0x8052e8f <main+27>: 0x60858d57 0x89ffffff 0x2ae82404 0x83ffff96

0x8052e9f <main+43>: 0x85c704c4 0xffffff64

(idb) x /2xg $pc

0x8052e8f <main+27>: 0x89ffffff60858d57 0x83ffff962ae824044

 

To examine individual registers, use the print command with the register name prepended with the dollar sign ($). Commands showing all (or a subset of) the registers are specific for the mode; see examples below.