Re: How to display instructions around the current instuction?
Peng Yu via Gdb <[email protected]>
| Newsgroups | gmane.comp.gdb.devel |
|---|---|
| Message-ID | <CABrM6wkPGb4FTUosXqjRN65t+x-N327Hc+29Rt=3Eho=n+QiVw@mail.gmail.com> |
Hi Stefan, > display/10i $rip-10 > > I don't think x86-64 instructions have fixed width, so that won't > always print the same number of instructions before the current one, > but it's probably a good approximation. Have you tried it? If $rip-5 is not right at the start of an instruction, it does not even disassmble correctly. Please test your recommendation before sending it out. It is not appropriate to waste other people's time. (gdb) 1: x/10i $rip-5 <error: No registers.> (gdb) Temporary breakpoint 1 at 0x401134 Starting program: /mnt/macosx/pengy/mrrdir/test/gnu/gdb/cmd/display/main.exe Temporary breakpoint 1, 0x0000000000401134 in main () 1: x/10i $rip-5 0x40112f <frame_dummy+15>: add BYTE PTR [rbp+0x48],dl 0x401132 <main+2>: mov ebp,esp => 0x401134 <main+4>: sub rsp,0x10 0x401138 <main+8>: movabs rdi,0x402004 0x401142 <main+18>: mov al,0x0 0x401144 <main+20>: call 0x401030 <printf@plt> 0x401149 <main+25>: xor ecx,ecx 0x40114b <main+27>: mov DWORD PTR [rbp-0x4],eax 0x40114e <main+30>: mov eax,ecx 0x401150 <main+32>: add rsp,0x10 (gdb) 0x0000000000401138 in main () 1: x/10i $rip-5 0x401133 <main+3>: in eax,0x48 0x401135 <main+5>: sub esp,0x10 => 0x401138 <main+8>: movabs rdi,0x402004 0x401142 <main+18>: mov al,0x0 0x401144 <main+20>: call 0x401030 <printf@plt> 0x401149 <main+25>: xor ecx,ecx 0x40114b <main+27>: mov DWORD PTR [rbp-0x4],eax 0x40114e <main+30>: mov eax,ecx 0x401150 <main+32>: add rsp,0x10 0x401154 <main+36>: pop rbp (gdb) 0x0000000000401142 in main () 1: x/10i $rip-5 0x40113d <main+13>: add BYTE PTR [rax],al 0x40113f <main+15>: add BYTE PTR [rax],al 0x401141 <main+17>: add BYTE PTR [rax-0x1181800],dh 0x401147 <main+23>: (bad) 0x401148 <main+24>: push QWORD PTR [rcx] 0x40114a <main+26>: leave 0x40114b <main+27>: mov DWORD PTR [rbp-0x4],eax 0x40114e <main+30>: mov eax,ecx 0x401150 <main+32>: add rsp,0x10 0x401154 <main+36>: pop rbp -- Regards, Peng