I’m having a problem with gdb (standard version 6.8.50.20081120-cvs) while trying to debug a C++ program compiled with the standard C++ compiler (gcc version 4.3.2 [gcc-4_3-branch revision 141291]).
When debugging a function where arguments are provided by value, the local object within the function is not rightly referenced in the debugger.
As an example, here is a simple piece of code to illustrate the problem :
#include <iostream>
using namespace std;
class Obj {
private:
int i;
public:
Obj();
Obj(const Obj&);
void show();
};
Obj::Obj(const Obj& other) {
i = other.i;
}
Obj::Obj() {
i = 1;
}
void Obj::show() {
cout << "hello
";
}
void f(Obj S) {
S.show();
cout << &S << endl;
}
int main() {
Obj A;
f(A);
return 0;
}
If you try to debug this program the S object in function f cannot be debugged with gdb. There seems to be some mismatch with the object address if you compare it within the function, in the copy constructor (which is just there to prove this fact) and the this pointer in the show member function call.
If I go back to version 4.1 of the compiler, things are all right…
So it seems to be a debug info mismatch between the gdb and gcc.
Does anybody have a solution ?
Manny