Seeing std::string values while debugging [message #197268] |
Sun, 15 July 2007 13:25  |
Eclipse User |
|
|
|
Originally posted by: usenet.aristeia.com
I've just started playing with the CDT Europa debugger (atop mingw g++ on
WinXP), and it seems that std::string variables are not displayed as strings.
Googling around yielded this posting from Leo von Klenze from last October:
> has anybody an idea by getting a wellformat output for stl strings in
> the variable view? It always prints something like that:
>
> {static npos = 4294967295, _M_dataplus = {<allocator<char>> =
> {<new_allocator<char>> = {<No data fields>}, <No data fields>}, _M_p =
> 0x6c2704 "Hello World"}}
>
> I think this is because std::string is a class not a simple type but
> this is very nasty if you have a lot of these strings to debug. I know
> you can use the cast to type feature but eclipse forget it after each
> session.
>
> Perhaps anybody has a good idea for improving string debugging. Or isn't
> it interesting for most people? Perhaps an option will be fine for
> special handling of strings?
I didn't see any followups to this posting, but I'm hoping the problem of
viewing the values of std::strings has since been resolved. If not, can
somebody please elaborate on Leo's comment about "cast to type feature" so I can
see the value of my std::strings as strings?
Thanks,
Scott
|
|
|
|
Re: Seeing std::string values while debugging [message #197485 is a reply to message #197446] |
Mon, 16 July 2007 14:43  |
Eclipse User |
|
|
|
Originally posted by: usenet.aristeia.com
Joost Kraaijeveld wrote:
> 1. Click on the triangle of the string variable to expand it, do the
> same for _M_dataplus (is this the same for all GCC versions?) and choose
> _M_p. The contents/value of the string buffer (?) is displayed in the
> window
I'm beginning to think that something is wacky with my installation of CDT as
regards debugging. Consider this program:
#include <string>
#include <iostream>
int main()
{
std::string s("Hello");
std::cout << s.c_str();
}
When I set a breakpoint on the std::cout line and run to that breakpoint, there
are no variables displayed in the Variables tab. If I then select a different
tab (e.g., Breakpoints) and then select the Variables tab again, the variable s
is shown twice. The substructure of both is the same, so this looks like a
duplicate entry, but _M_p is out of bounds, and looking at *_M_p (by clicking on
it in the Variables window) yields this message:
Target request failed: Cannot access memory at address 0x5dd4d6.
Something is clearly wrong.
The only thing unusual about my configuration is that I'm running g++ 4.1.1 and
gdb 6.3, the former build per
http://aristeia.com/Misc/gcc4ForWindows_frames.html and the latter downloaded
per that same page.
Am I doing something fundamentally wrong, is there some incompatibility between
CDT/Europa and the versions of g++/gdb I'm using, or is something else at work here?
Thanks,
Scott
|
|
|
Powered by
FUDForum. Page generated in 0.03372 seconds