This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: What about add a interface to output the assembly codes follow inferior execution
Hi Doug and Daniel,
Thanks for your reply.
I think I didn't talk clear of my idea.
When exec-disassemble is on,
If the $pc doesn't have the line message, gdb will output the assembly
code for $pc.
If the $pc has the line message, gdb will output the assembly codes of
this line.
For example:
(gdb) set exec-disassemble on
(gdb) n
26 printf ("a = %d b = %d c = %d\n", a, b, c);
80483fe: 8b 15 84 96 04 08 mov 0x8049684,%edx
8048404: 8b 45 f4 mov -0xc(%ebp),%eax
8048407: 89 44 24 0c mov %eax,0xc(%esp)
804840b: 8b 45 f8 mov -0x8(%ebp),%eax
804840e: 89 44 24 08 mov %eax,0x8(%esp)
8048412: 89 54 24 04 mov %edx,0x4(%esp)
8048416: c7 04 24 58 85 04 08 movl $0x8048558,(%esp)
804841d: e8 b6 fe ff ff call 80482d8 <printf@plt>
This assembly codes is for line 26 printf ("a = %d b = %d c = %d\n", a, b, c);
(gdb) n
21 int c = 1;
80483c8: c7 45 f4 01 00 00 00 movl $0x1,-0xc(%ebp)
This assembly codes is for line 21 int c = 1;
It will make user clear what instructions will be execute in next line.
The "disp/8i $pc" just can output 8 instructions, even if the next
line just have 1 instruction.
For example:
(gdb) n
21 int c = 1;
1: x/8i $pc
0x80483c8 <main+24>: movl $0x1,-0xc(%ebp)
0x80483cf <main+31>: mov 0x8049684,%edx
0x80483d5 <main+37>: mov -0xc(%ebp),%eax
0x80483d8 <main+40>: mov %eax,0xc(%esp)
0x80483dc <main+44>: mov -0x8(%ebp),%eax
0x80483df <main+47>: mov %eax,0x8(%esp)
0x80483e3 <main+51>: mov %edx,0x4(%esp)
0x80483e7 <main+55>: movl $0x8048558,(%esp)
Just 1 line for line 21.
Thanks,
Hui
On Wed, Mar 4, 2009 at 01:04, Daniel Jacobowitz <drow@false.org> wrote:
> On Tue, Mar 03, 2009 at 08:41:53AM -0800, Doug Evans wrote:
>> Are you looking for behaviour different than what "disp/8i $pc" would give you?
>
> I often run with display/i $pc. ?But I think the 'auto' setting is a
> nice idea; it's when I don't have source code that this is most useful.
>
> --
> Daniel Jacobowitz
> CodeSourcery
>