Hello,
yi*****@gmail.c om wrote:
I am trying to debug a C++ program in GDB on linux.
I want to dump out the content of the "this" object,
Here is what I get:
(gdb) print *this
$2 = {path = <incomplete type>}
My question is why I don't see the content of 'path'? It said
'<incomplete type>'.
In the code, path is:
ostringstream path;
When I try to do this: at GDB prompt 'print this->path.str()' , I get
this error:
(gdb) print this->path.str()
Couldn't find method ostringstream:: str
While others found this off-topic, I think there are at least three
problems here connected to debugging which can be faced on all usual
C++ implementations . The subject line was clearly off-topic.
Could it be that your standard library is missing debugging information?
Then showing information about its internals will surely fail with all
C++ implementations . The incomplete type is a clear indication that
debugging information is missing.
I'm not sure, whether non-open-source implementors of a standard C++
library have the freedom to make their internals visible enough to make
some debugging sensible at all, i.e. handing out information the full
source code could be derived from easily. I would not expect
source-level debugging to be possible with all C++ implementations .
Even g++ has not enabled this by default. The runtime libraries might
have to be recompiled to make this possible.
Calling methods from a debugger might not be possible when methods are
inlined due to optimization. Maybe you can force the compiler to emit a
non-inlined version of the functions by taking their addresses. The
small missing method which is used in the code is a clear indication of
inlining.
Bernd Strieder