I am using Eclipse with GDB. For any smart pointer class, I have, for example, MyString, I keep getting
warning: RTTI character not found for class MyString
And indeed, I do not see the values ββstored in the smart pointer container:
MyString str = "test"; //can see "test" fine when examining variable value MyStringPtr strPtr = &str; //can not see "test" contained by the container strPtr when examining variable value.
I believe the reason is the warning that the pointer to the "test" became the void pointer, and not the MyString typed pointer. However, this works:
int L = strPtr->length(); //correctly is 4 char c = strPtr->charAt(1); //correctly is 'e'.
So GDB seems to work correctly, but not perfect, so I can't debug.
I should mention that there are no problems when developing in Visual Studio. The problem only occurs for Eclipse with Cygwin g ++.
Cygwin g ++ compilation options: -O0 -g3 -Wall -c -fmessage-length = 0
The following is a simplified sketch of the respective classes.
[code]
class MyObjectPtr { protected: MyObject* pObj; public: MyObjectPtr(MyObject* p= 0); MyObjectPtr(const MyObjectPtr& r); ~MyObjectPtr(); protected: void set(MyObject* p) { if(p!=0) p->incrementReference(); if(pObj!=0) pObj->decreasetReference(); pObj= p; } void set(const char* chArray) { pObj= new MyString(chArray); if(pObj!=0) pObj->incrementReference(); } void assertError(const char* error); public: const MyObjectPtr& operator=(const MyObjectPtr& r) { set(r); return *this; } const MyObjectPtr& operator=(MyObject* p) { set(p); return *this; } MyObject* operator->() { if(pObj==null) assertError("MyObject"); return pObj; } operator MyObject*() const { return pObj; }; MyObjectPtr(const char* pch) { set(pch); }; const MyObjectPtr& operator=(const char* pch); }; class MyStringPtr : public MyObjectPtr { public: MyStringPtr(MyObject* p= 0) : MyObjectPtr(p) {} MyStringPtr(const int n) : MyObjectPtr() {} const MyStringPtr& operator=(MyObject* p) { set(p); return *this; } MyString* operator->() { if(pObj==null) assertError("MyString"); return (MyString*)pObj; }; MyStringPtr(const char* pch) { if( pch != NULL ) { set( new MyString(pch) ); } else set( NULL ); }
[/code]
source share