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

Re: C++ and "no data fields" when printing objects


On date Thursday 2009-04-02 14:52:20 -0400, Daniel Jacobowitz wrote:
> On Thu, Apr 02, 2009 at 03:28:11PM +0200, Stefano Sabatini wrote:
> > 1) which are the conditions under which the abovementioned problem
> > occurrs (e.g. with shared/static lib, with some arch, only with some
> > compiler+flags/binary format)?
> 
> I have no idea; it doesn't happen to me.  In your searching did you
> find any bugs in bugzilla describing this problem?  If not, do you
> have any test where you can demonstrate it?

OK I found #9222.

And here is how I can reproduce it, I'll try to work out a more
minimal issue case.

---------------8<------------------------------------------------
#include <iostream>

#include <ptlib.h>
#include <ptlib/safecoll.h>
#include <ptlib/pprocess.h>

class Test : public PProcess {
    PCLASSINFO(Test, PProcess)
    public:

    void Main(void);
};

class SafeThing : public PSafeObject {
public:
    SafeThing(int bar, int foo) : m_Bar(bar), m_Foo(foo) { }

    virtual void PrintOn(ostream &strm) const {
        strm << "foo(" << m_Foo << ") "
             << "bar(" << m_Bar << ") ";
    }

private:
    int m_Bar;
    int m_Foo;
};

PCREATE_PROCESS(Test)

void Test::Main(void)
{
    PSafePtr<SafeThing> ptr;
    
    cout << "ptr: " << ptr << endl;
    if (!!ptr)
        cout << *ptr << endl;

    return;
}
------------------------------8<-------------------------------

Informations on the system:

stefano@geppetto ~/s/ptlib> uname -a
Linux geppetto 2.6.26-1-686 #1 SMP Sat Oct 18 16:22:25 UTC 2008 i686 GNU/Linux
stefano@geppetto ~/s/ptlib> g++ --version
g++ (Debian 4.3.2-1) 4.3.2

Compilation command performed:
g++ -DPTRACING=1 -D_REENTRANT -D_GNU_SOURCE=1 -fno-exceptions
-I/home/stefano/include -I/usr/include/SDL -g -O0 -ggdb
-L/home/stefano/lib -lpt -lpthread -lsasl2 -lldap -llber -lldap_r
-lssl -lcrypto -lexpat -lSDL -lresolv -ldl psafeptr.cxx -o psafeptr

And here it is my gdb output:

(gdb) show version
GNU gdb 6.8-debian
Copyright (C) 2008 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 "i486-linux-gnu".
(gdb) file psafeptr
(gdb) b Test::Main
Breakpoint 9 at 0x8049886: file psafeptr.cxx, line 35.
(gdb) r
[Thread debugging using libthread_db enabled]
[New Thread 0xb74236c0 (LWP 2490)]
[Switching to Thread 0xb74236c0 (LWP 2490)]

Breakpoint 7, main (argc=1, argv=0xbfc45474, envp=0xbfc4547c) at psafeptr.cxx:31
warning: Source file is more recent than executable.
(gdb) n

Breakpoint 8, Test::Main (this=0x9f4f000) at psafeptr.cxx:35
(gdb) p ptr
$15 = {
  <> = {<No data fields>}, <No data fields>}
(gdb) 

I'm using the latest SVN libpt (but I don't think it depends on the
version used, since it shows up also with a very ancient version of
it), and yes I compiled the lib with -ggdb -00 (compiled with make
debugshared).

Regards.


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