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 breakpoints/13247] New: Wrong breakpoint address for ARM binarybuilt with -O2


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

             Bug #: 13247
           Summary: Wrong breakpoint address for ARM binary built with -O2
           Product: gdb
           Version: 7.3
            Status: NEW
          Severity: normal
          Priority: P2
         Component: breakpoints
        AssignedTo: unassigned@sourceware.org
        ReportedBy: christian.prochaska@genode-labs.com
    Classification: Unclassified


Created attachment 5958
  --> http://sourceware.org/bugzilla/attachment.cgi?id=5958
source, gcc temporary files and binaries of the test program

Platform
--------

Debian Squeeze armel (QEMU image from
http://people.debian.org/~aurel32/qemu/armel/)

GCC 4.6.1 built from source
---------------------------

Using built-in specs.
COLLECT_GCC=/opt/gcc/bin/gcc
COLLECT_LTO_WRAPPER=/opt/gcc-4.6.1/libexec/gcc/armv5tejl-unknown-linux-gnueabi/4.6.1/lto-wrapper
Target: armv5tejl-unknown-linux-gnueabi
Configured with: ../gcc-4.6.1/configure --prefix=/opt/gcc-4.6.1
Thread model: posix
gcc version 4.6.1 (GCC)


GDB 7.3.1 built from source
---------------------------

GNU gdb (GDB) 7.3.1
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "armv5tejl-unknown-linux-gnueabi".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.


Test program
------------

---- func1.h ----

struct arg_struct { int arg1, arg2, arg3, arg4, arg5; };

extern void func1(struct arg_struct func1_args);

---- func1.c ----

#include "func1.h"                                  

void func1(struct arg_struct func1_args)            
{
}

---- main.c ----

#include "func1.h"

int main(int argc, char *argv[])
{
        struct arg_struct test_args = {1, 2, 3, 4, 5};

        func1(test_args);

        return 0;
}

----------------

Correct breakpoint address of func1 when building with -O0:

$ /opt/gcc/bin/gcc -O0 -g -save-temps main.c func1.c
$ gdb ./a.out -ex "b func1" -ex "run" -ex "disassemble func1" -ex "info args"

Reading symbols from /home/user/test/a.out...done.
Breakpoint 1 at 0x83b8: file func1.c, line 5.
Starting program: /home/user/test/a.out

Breakpoint 1, func1 (func1_args=...) at func1.c:5
5       }
Dump of assembler code for function func1:
   0x000083a4 <+0>:     sub     sp, sp, #16
   0x000083a8 <+4>:     push    {r11}           ; (str r11, [sp, #-4]!)
   0x000083ac <+8>:     add     r11, sp, #0
   0x000083b0 <+12>:    add     r12, r11, #4
   0x000083b4 <+16>:    stm     r12, {r0, r1, r2, r3}
=> 0x000083b8 <+20>:    add     sp, r11, #0
   0x000083bc <+24>:    pop     {r11}
   0x000083c0 <+28>:    add     sp, sp, #16
   0x000083c4 <+32>:    bx      lr
End of assembler dump.
func1_args = {arg1 = 1, arg2 = 2, arg3 = 3, arg4 = 4, arg5 = 5}

---------------

Wrong breakpoint address when building with -O2:

$ /opt/gcc/bin/gcc -O2 -g -save-temps main.c func1.c
$ gdb ./a.out -ex "b func1" -ex "run" -ex "disassemble func1" -ex "info args"

Reading symbols from /home/user/test/a.out...done.
Breakpoint 1 at 0x8390: file func1.c, line 4.
Starting program: /home/user/test/a.out

Breakpoint 1, func1 (func1_args=...) at func1.c:4
4       {
Dump of assembler code for function func1:
   0x0000838c <+0>:     sub     sp, sp, #16
=> 0x00008390 <+4>:     sub     r12, sp, #4
   0x00008394 <+8>:     stmib   r12, {r0, r1, r2, r3}
   0x00008398 <+12>:    add     sp, sp, #16
   0x0000839c <+16>:    bx      lr
End of assembler dump.
func1_args = {arg1 = 1073895576, arg2 = 1073912552, arg3 = 0, arg4 = 33368,
  arg5 = 5}

---------------

The breakpoint address should be 0x8398 instead of 0x8390 for arg1-arg4 to be
shown correctly.

The attached archive contains the source, gcc temporary files and the binaries
of the test program. I can provide more files/information if needed.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


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