On Thu, Oct 8, 2009 at 9:52 AM, Paul Pluzhnikov wrote: > On Thu, Oct 8, 2009 at 9:23 AM, Daniel Jacobowitz wrote: > >> I'd mildly prefer changing the behavior of GDB - but only if we can >> get an additional enhancement that I don't think we have yet: "*" at >> the PC... > > That sounds good. I'll try to implement that. Here my attempt to implement that. I am guessing that it is flawed, as it possibly breaks something in MI (which I don't understand yet). It also breaks quite a few test cases -- I'll adjust expected patterns if it is decided to go ahead with this. I should say that from CLI perspective I like this very much. On x86, often you need to examine 10 or so instructions before the crash point. 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: (top) x/10i $pc-15 0x54d212 : mov -0x10(%rbp),%edi 0x54d215 : mov $0x1,%esi 0x54d21a : callq 0x452c38 <__sigsetjmp@plt> 0x54d21f : jmp 0x54d237 * 0x54d221 : mov -0x30(%rbp),%rdi 0x54d225 : mov -0x28(%rbp),%rax 0x54d229 : callq *%rax 0x54d22b : mov %eax,-0x4(%rbp) 0x54d22e : callq 0x54c9c0 0x54d233 : test %eax,%eax I also like how 'disassemble-next-line on' works: (top) set disassemble-next-line on (top) ni 0x000000000054d225 510 val = func (func_args); 0x000000000054d221 : 48 8b 7d d0 mov -0x30(%rbp),%rdi * 0x000000000054d225 : 48 8b 45 d8 mov -0x28(%rbp),%rax 0x000000000054d229 : ff d0 callq *%rax 0x000000000054d22b : 89 45 fc mov %eax,-0x4(%rbp) (top) ni 0x000000000054d229 510 val = func (func_args); 0x000000000054d221 : 48 8b 7d d0 mov -0x30(%rbp),%rdi 0x000000000054d225 : 48 8b 45 d8 mov -0x28(%rbp),%rax * 0x000000000054d229 : ff d0 callq *%rax 0x000000000054d22b : 89 45 fc mov %eax,-0x4(%rbp) As well as how 'disas' works: (top) disas Dump of assembler code for function catch_errors: 0x000000000054d1dc : push %rbp 0x000000000054d1dd : mov %rsp,%rbp 0x000000000054d1e0 : sub $0x40,%rsp 0x000000000054d1e4 : mov %rdi,-0x28(%rbp) 0x000000000054d1e8 : mov %rsi,-0x30(%rbp) 0x000000000054d1ec : mov %rdx,-0x38(%rbp) 0x000000000054d1f0 : mov %ecx,-0x3c(%rbp) 0x000000000054d1f3 : movl $0x0,-0x4(%rbp) 0x000000000054d1fa : mov 0x56e1bf(%rip),%rdi # 0xabb3c0 0x000000000054d201 : mov -0x3c(%rbp),%edx 0x000000000054d204 : lea -0x20(%rbp),%rsi 0x000000000054d208 : callq 0x54c678 0x000000000054d20d : mov %rax,-0x10(%rbp) 0x000000000054d211 : mov -0x10(%rbp),%rdi 0x000000000054d215 : mov $0x1,%esi 0x000000000054d21a : callq 0x452c38 <__sigsetjmp@plt> 0x000000000054d21f : jmp 0x54d237 0x000000000054d221 : mov -0x30(%rbp),%rdi 0x000000000054d225 : mov -0x28(%rbp),%rax * 0x000000000054d229 : callq *%rax 0x000000000054d22b : mov %eax,-0x4(%rbp) 0x000000000054d22e : callq 0x54c9c0 0x000000000054d233 : test %eax,%eax 0x000000000054d235 : jne 0x54d221 0x000000000054d237 : callq 0x54c9b0 0x000000000054d23c : test %eax,%eax 0x000000000054d23e : jne 0x54d22e 0x000000000054d240 : mov 0x593721(%rip),%rdi # 0xae0968 0x000000000054d247 : mov -0x20(%rbp),%rdx 0x000000000054d24b : mov -0x18(%rbp),%rcx 0x000000000054d24f : mov -0x38(%rbp),%rsi 0x000000000054d253 : callq 0x54cdea 0x000000000054d258 : mov -0x20(%rbp),%eax 0x000000000054d25b : test %eax,%eax 0x000000000054d25d : je 0x54d268 0x000000000054d25f : movl $0x0,-0x40(%rbp) 0x000000000054d266 : jmp 0x54d26e 0x000000000054d268 : mov -0x4(%rbp),%eax 0x000000000054d26b : mov %eax,-0x40(%rbp) 0x000000000054d26e : mov -0x40(%rbp),%eax 0x000000000054d271 : leaveq 0x000000000054d272 : retq End of assembler dump. Thanks, -- Paul Pluzhnikov 2009-10-16 Paul Pluzhnikov * defs.h (pc_prefix): New prototype. * disasm.c (dump_insns): Identify instruction address as such. * ui-out.c (ui_out_field_core_addr): Highlight current instruction. * printcmd.c (do_examine): Likewise. (pc_prefix, print_pc_prefix): New function. * stack.c (print_frame_info): Disassemble entire current line.