This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug gdb/11833] New: disassemble/m should be PC-driven, not source line driven


If you have -O2 code the source line <-> PC do not map linearly, they "jump".
objdump -dS displays the disassembly annotated by source lines.
GDB disass/m displays the source lines annotated by disassembly.
I find the objdump way better, in fact the only meaningful one.

GDB dump below displays PCs:
0x0, 0x1, 0xc, 0x7, 0xf, 0x11, 0x12.

-----------------------------------------------------------------------------
int
f (void)
{
  extern int j;
  int i = j + 1;

  extern void g (void);
  g();
  return i;
}
-----------------------------------------------------------------------------
gcc -O2 -g (gcc-4.4.4-10.fc13.x86_64)
-----------------------------------------------------------------------------
objdump -dS
0000000000000000 <f>:
int
f (void)
{
   0:	53                   	push   %rbx
  extern int j;
  int i = j + 1;
   1:	8b 1d 00 00 00 00    	mov    0x0(%rip),%ebx        # 7 <f+0x7>

  extern void g (void);
  g();
   7:	e8 00 00 00 00       	callq  c <f+0xc>
int
f (void)
{
  extern int j;
  int i = j + 1;
   c:	83 c3 01             	add    $0x1,%ebx

  extern void g (void);
  g();
  return i;
}
   f:	89 d8                	mov    %ebx,%eax
  11:	5b                   	pop    %rbx
  12:	c3                   	retq   
-----------------------------------------------------------------------------
(gdb) disass/m f
Dump of assembler code for function f:
3	{
   0x0000000000000000 <+0>:	push   %rbx

4	  extern int j;
5	  int i = j + 1;
   0x0000000000000001 <+1>:	mov    0x0(%rip),%ebx        # 0x7 <f+7>
   0x000000000000000c <+12>:	add    $0x1,%ebx

6	
7	  extern void g (void);
8	  g();
   0x0000000000000007 <+7>:	callq  0xc <f+12>

9	  return i;
10	}
   0x000000000000000f <+15>:	mov    %ebx,%eax
   0x0000000000000011 <+17>:	pop    %rbx
   0x0000000000000012 <+18>:	retq   

End of assembler dump.

-- 
           Summary: disassemble/m should be PC-driven, not source line
                    driven
           Product: gdb
           Version: unknown
            Status: UNCONFIRMED
          Severity: minor
          Priority: P2
         Component: gdb
        AssignedTo: unassigned at sourceware dot org
        ReportedBy: jan dot kratochvil at redhat dot com
                CC: gdb-prs at sourceware dot org
GCC target triplet: x86_64-unknown-linux-gnu


http://sourceware.org/bugzilla/show_bug.cgi?id=11833

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]