I have a static library that I compiled with -g0 -O3 flags. Since this library provides a framework, I can use it in many different projects. I do not want to distribute all of the source code of this library (that's why I need -g0 flag). The users who have this library can create their own executables by including it. When one tries to debug his/her executable with gdb, he/she cannot see the contents of member variables which are inherited from the base classes defined in the library. What I mean is that:
// This class is defined in a static library and it is compiled with -g0 flag.
class Foo {
protected:
std::string name;
virtual void someAction() = 0;
//...
};
// This class is defined in a project that uses the static library and it is compiled with -g3 flag.
class Bar {
protected:
std::string surname;
void someAction(){
std::string fullName = this->name + " " + this->surname;
}
};
When the executable project is being debugged, the user cannot see the name attribute in gdb. If I compile the library with -g3 flag everything is OK, but it is not desired. When I use -g0 flag and tries to run p this.name in gdb when the debugger is at the someAction function, I am getting this error message:
No symbol "name" in current context.
Is there any advice or solution for this? I think it should be possible because the compiler can know the content of the Foo class even if the debugging flag is -g0. By the way, I need to access only contents of the members. Maybe, is there an option for gdb for this. I use gdb 9.2, g++ 10.1.0 under MSYS2 in Windows 10.