This is the mail archive of the gdb@sources.redhat.com 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]

gdb namespaces/wrapper bug?


Hi,

I encountered a strange problem while debugging and I'm not sure wether
the problem is coming from gcc-3.x or gdb?

Consider the following code, consisting of 3 files
=========================================================================
=========================================================================
[klaas@c014 /tmp]$ cat wrapper_object.h
#include <vector>

namespace BASE
{
  class Foo
  {
  public:
    Foo(){};
    virtual ~Foo(){};
    virtual void Method();
  };

}
=========================================================================
[klaas@c014 /tmp]$ cat wrapper_object.cpp
#include "wrapper_object.h"

namespace BASE
{
  void
  Foo::Method(){};
}
==========================================================================
[klaas@c014 /tmp]$ cat wrapper.cpp
#include "wrapper_object.h"

namespace WRAPPED
{
  class Foo : public BASE::Foo
  {
  public:
    Foo() : BASE::Foo(){};
    virtual ~Foo(){};
  };
}

using namespace WRAPPED;

int main()
{
  Foo mywrapped;
  return 0;
}
==========================================================================
==========================================================================

This compiles and runs just fine (compile wrapper_object.cpp, compile
wrapper.cpp linking with wrapper_object.o), but when debugging the code
with gdb (I only tried with both 5.3-debian and 6.0-debian (the latest
from testing and unstable)) and trying to display the mywrapped variable,
gdb enters in a infinite loop:

(gdb) display mywrapped
1: mywrapped = {<Foo> = {<Foo> = ....

and finally segfaults.

Used compilers (all debian packages):

[klaas@c014 /tmp]$ g++ --version
g++ (GCC) 3.3.3 20040110 (prerelease) (Debian)

I also tried with 3.3.2, but that gives the same result.

The problem does not exist when:
- The code is compiled with g++ 2.95.4
- All code is inlined in 1 file (yes, that's why there are 3 files above :)
- I omit the member function method and put the constructor implementation
  in the cpp file.
- When Foo in namespace WRAPPED is renamed into Boo

Is this a gdb problem? or is is related to gcc 3.x?  Or am I missing
something important here?

thanks,

klaas


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