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]

c++/2434: C++, breakpoint set in ancestor's virtual method, for RVCT compiled elf-file


>Number:         2434
>Category:       c++
>Synopsis:       C++, breakpoint set in ancestor's virtual method, for RVCT compiled elf-file
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Mar 26 15:18:02 UTC 2008
>Closed-Date:
>Last-Modified:
>Originator:     anders.hessel@enea.com
>Release:        6.7.1
>Organization:
>Environment:
C++, RVCT 3.1 (569), dwarf2, Host=linux-pentium, target=arm-elf
>Description:
I set a breakpoint on a <class>::<method> (e.g. A::getValue) but the breakpoint is set at the virtual method <baseclass>::<method> (e.g. Base::getValue)
that <class>::<method> is overriding. This happens when I use a RVCT compiled elf file using dwarf2, but not with a gcc compiled (elf/dwarf2) file.
I am using gdb 6.7.1 linux/arm and RVCT 3.1. 
>How-To-Repeat:
> cat bug.cpp
#include <iostream>
using namespace std;

class Base {
public:
   Base() {}
   virtual ~Base() {}
   virtual int getValue(); // not virtual
};

class A : public Base {
public:
   A() : Base() {}
   ~A() {}
   int getValue();
};

int Base::getValue(){
   return 0;
}

int A::getValue(){
   return 100;
}

int main (int argc, char** argv) 
{
   A a;
   Base *object;
   object = &a; // object is now an A object

   int value = object->getValue();
   cout << "new value should be 100 is " << value << endl; 
}

//// END OF FILE

-------------------------------------------------------------------------
RVCT compiled elf-file run in gdb sim
The breakpoint is not set on line 23 as it should be,
and thus the program does not stop on the breakpoint.
Note that the run is correct only the breakpoint is at the wrong place.
-------------------------------------------------------------------------

> make -f build_rvct.mk clean
rm -f *.o *.elf
> make -f build_rvct.mk all
/ARM/RVCT/Programs/3.1/569/linux-pentium/armcpp -c -g -O0 -I/ARM/RVCT/Data/3.1/569/include/unix --dwarf2 bug.cpp -o bug.o
"bug.cpp", line 14: Warning:  #1300-D: ~A inherits implicit virtual
     ~A() {}
     ^
"bug.cpp", line 15: Warning:  #1300-D: getValue inherits implicit virtual
     int getValue();
         ^
bug.cpp: 2 warnings, 0 errors
/ARM/RVCT/Programs/3.1/569/linux-pentium/armlink --libpath /ARM/RVCT/Data/3.1/569/lib bug.o --info totals --elf -o bug.elf
<<<< info removed >>>>
Build completed
> /gdb_linux_arm_6.7.1/bin/arm-ose-gdb
GNU gdb 6.7.1
Copyright (C) 2007 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 "--host=i686-pc-linux-gnu --target=arm-ose".
(gdb) target sim
Connected to the simulator.
(gdb) load bug.elf
Loading section ER_RO, size 0xc0b8 vma 0x8000
Loading section ER_RW, size 0xa4 vma 0x140b8
Start address 0x8000
Transfer rate: 396000 bits in <1 sec.
(gdb) file bug.elf
Reading symbols from /homes/anders/bug.elf...done.
(gdb) break A::getValue
Breakpoint 1 at 0x8160: file bug.cpp, line 19.
(gdb) r
Starting program: /homes/anders/bug.elf 
new value should be 100 is 100

Program exited normally.
(gdb) quit

----------------------------------------------------------
This is how is should be. 
!!!It is only shown as an example!!!
Breakpoint is set on line 23, and the program correctly hit the breakpoint.
Here linux native is used, but it is the same on linux-arm in our environment using the same gdb as above. 
Disregard that another gdb is used in this example
----------------------------------------------------------

> make -f build_gcc.mk clean
rm -f *.o nobug
> make -f build_gcc.mk all
g++ -o nobug -g --static -lstdc++ bug.cpp
Build completed
> gdb nobug
GNU gdb Red Hat Linux (6.3.0.0-1.138.el3rh)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux-gnu"...Using host libthread_db library "/lib/tls/libthread_db.so.1".

(gdb) break A::getValue
Breakpoint 1 at 0x80481fd: file bug.cpp, line 23.
(gdb) r
Starting program: /homes/anders/nobug 

Breakpoint 1, A::getValue (this=0xbfffa260) at bug.cpp:23
23	   return 100;
(gdb) quit
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="bug.cpp"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="bug.cpp"

I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY2xhc3MgQmFzZSB7CnB1
YmxpYzoKICAgQmFzZSgpIHt9CiAgIHZpcnR1YWwgfkJhc2UoKSB7fQogICB2aXJ0dWFsIGludCBn
ZXRWYWx1ZSgpOyAvLyBub3QgdmlydHVhbAp9OwoKY2xhc3MgQSA6IHB1YmxpYyBCYXNlIHsKcHVi
bGljOgogICBBKCkgOiBCYXNlKCkge30KICAgfkEoKSB7fQogICBpbnQgZ2V0VmFsdWUoKTsKfTsK
CmludCBCYXNlOjpnZXRWYWx1ZSgpewogICByZXR1cm4gMDsKfQoKaW50IEE6OmdldFZhbHVlKCl7
CiAgIHJldHVybiAxMDA7Cn0KCmludCBtYWluIChpbnQgYXJnYywgY2hhcioqIGFyZ3YpIAp7CiAg
IEEgYTsKICAgQmFzZSAqb2JqZWN0OwogICBvYmplY3QgPSAmYTsgLy8gb2JqZWN0IGlzIG5vdyBh
biBBIG9iamVjdAoKICAgaW50IHZhbHVlID0gb2JqZWN0LT5nZXRWYWx1ZSgpOwogICBjb3V0IDw8
ICJuZXcgdmFsdWUgc2hvdWxkIGJlIDEwMCBpcyAiIDw8IHZhbHVlIDw8IGVuZGw7IAp9Cgo=


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