Re: [RFC][patch] Allow to disassemble line.

Paul Pluzhnikov
2009-10-16T23:11:39Z

[-- Attachment #1: Type: text/plain, Size: 383 bytes --]

On Fri, Oct 16, 2009 at 4:07 PM, Paul Pluzhnikov <ppluzhnikov@google.com> wrote:

> I usually do 'x/10i $pc-15' (as instruction size is not fixed), and then
> "hunt" for the current PC in the resulting output. This patch makes it so
> much easier:

It would have helped if gmail didn't mangle the output so much :-(
I've attached actual observed output.

Thanks,
--
Paul Pluzhnikov

[-- Attachment #2: pp.txt --]
[-- Type: text/plain, Size: 4386 bytes --]

(top) x/10i $pc-15
0x54d212 <catch_errors+54>: mov -0x10(%rbp),%edi
0x54d215 <catch_errors+57>: mov $0x1,%esi
0x54d21a <catch_errors+62>: callq 0x452c38 <__sigsetjmp@plt>
0x54d21f <catch_errors+67>: jmp 0x54d237 <catch_errors+91>
* 0x54d221 <catch_errors+69>: mov -0x30(%rbp),%rdi
0x54d225 <catch_errors+73>: mov -0x28(%rbp),%rax
0x54d229 <catch_errors+77>: callq *%rax
0x54d22b <catch_errors+79>: mov %eax,-0x4(%rbp)
0x54d22e <catch_errors+82>: callq 0x54c9c0 <exceptions_state_mc_action_iter_1>
0x54d233 <catch_errors+87>: test %eax,%eax

(top) set disassemble-next-line on
(top) ni
0x000000000054d225 510 val = func (func_args);
0x000000000054d221 <catch_errors+69>: 48 8b 7d d0 mov -0x30(%rbp),%rdi
* 0x000000000054d225 <catch_errors+73>: 48 8b 45 d8 mov -0x28(%rbp),%rax
0x000000000054d229 <catch_errors+77>: ff d0 callq *%rax
0x000000000054d22b <catch_errors+79>: 89 45 fc mov %eax,-0x4(%rbp)
(top) ni
0x000000000054d229 510 val = func (func_args);
0x000000000054d221 <catch_errors+69>: 48 8b 7d d0 mov -0x30(%rbp),%rdi
0x000000000054d225 <catch_errors+73>: 48 8b 45 d8 mov -0x28(%rbp),%rax
* 0x000000000054d229 <catch_errors+77>: ff d0 callq *%rax
0x000000000054d22b <catch_errors+79>: 89 45 fc mov %eax,-0x4(%rbp)

(top) disas
Dump of assembler code for function catch_errors:
0x000000000054d1dc <catch_errors+0>: push %rbp
0x000000000054d1dd <catch_errors+1>: mov %rsp,%rbp
0x000000000054d1e0 <catch_errors+4>: sub $0x40,%rsp
0x000000000054d1e4 <catch_errors+8>: mov %rdi,-0x28(%rbp)
0x000000000054d1e8 <catch_errors+12>: mov %rsi,-0x30(%rbp)
0x000000000054d1ec <catch_errors+16>: mov %rdx,-0x38(%rbp)
0x000000000054d1f0 <catch_errors+20>: mov %ecx,-0x3c(%rbp)
0x000000000054d1f3 <catch_errors+23>: movl $0x0,-0x4(%rbp)
0x000000000054d1fa <catch_errors+30>: mov 0x56e1bf(%rip),%rdi # 0xabb3c0 <uiout>
0x000000000054d201 <catch_errors+37>: mov -0x3c(%rbp),%edx
0x000000000054d204 <catch_errors+40>: lea -0x20(%rbp),%rsi
0x000000000054d208 <catch_errors+44>: callq 0x54c678 <exceptions_state_mc_init>
0x000000000054d20d <catch_errors+49>: mov %rax,-0x10(%rbp)
0x000000000054d211 <catch_errors+53>: mov -0x10(%rbp),%rdi
0x000000000054d215 <catch_errors+57>: mov $0x1,%esi
0x000000000054d21a <catch_errors+62>: callq 0x452c38 <__sigsetjmp@plt>
0x000000000054d21f <catch_errors+67>: jmp 0x54d237 <catch_errors+91>
0x000000000054d221 <catch_errors+69>: mov -0x30(%rbp),%rdi
0x000000000054d225 <catch_errors+73>: mov -0x28(%rbp),%rax
* 0x000000000054d229 <catch_errors+77>: callq *%rax
0x000000000054d22b <catch_errors+79>: mov %eax,-0x4(%rbp)
0x000000000054d22e <catch_errors+82>: callq 0x54c9c0 <exceptions_state_mc_action_iter_1>
0x000000000054d233 <catch_errors+87>: test %eax,%eax
0x000000000054d235 <catch_errors+89>: jne 0x54d221 <catch_errors+69>
0x000000000054d237 <catch_errors+91>: callq 0x54c9b0 <exceptions_state_mc_action_iter>
0x000000000054d23c <catch_errors+96>: test %eax,%eax
0x000000000054d23e <catch_errors+98>: jne 0x54d22e <catch_errors+82>
0x000000000054d240 <catch_errors+100>: mov 0x593721(%rip),%rdi # 0xae0968 <gdb_stderr>
0x000000000054d247 <catch_errors+107>: mov -0x20(%rbp),%rdx
0x000000000054d24b <catch_errors+111>: mov -0x18(%rbp),%rcx
0x000000000054d24f <catch_errors+115>: mov -0x38(%rbp),%rsi
0x000000000054d253 <catch_errors+119>: callq 0x54cdea <print_any_exception>
0x000000000054d258 <catch_errors+124>: mov -0x20(%rbp),%eax
0x000000000054d25b <catch_errors+127>: test %eax,%eax
0x000000000054d25d <catch_errors+129>: je 0x54d268 <catch_errors+140>
0x000000000054d25f <catch_errors+131>: movl $0x0,-0x40(%rbp)
0x000000000054d266 <catch_errors+138>: jmp 0x54d26e <catch_errors+146>
0x000000000054d268 <catch_errors+140>: mov -0x4(%rbp),%eax
0x000000000054d26b <catch_errors+143>: mov %eax,-0x40(%rbp)
0x000000000054d26e <catch_errors+146>: mov -0x40(%rbp),%eax
0x000000000054d271 <catch_errors+149>: leaveq
0x000000000054d272 <catch_errors+150>: retq
End of assembler dump.