Skip to main content



      Home
Home » Language IDEs » C / C++ IDE (CDT) » Exploring std::map and std::list in debugger(can't see any data inside)
Exploring std::map and std::list in debugger [message #544836] Mon, 05 July 2010 12:42 Go to next message
Eclipse UserFriend
Using Eclipse CDT Helios with GNU gdb 6.8.
I would like to see something like this (MSVC2008):
http://omploader.org/vNHVlNQ/MSVC2008-Debugger-Map-List.png
http://omploader.org/vNHVlNg/MSVC2008-Debugger-Map-List-Iterator.png

And now in Eclipse I can see only this:
http://omploader.org/vNHVlOA/Eclipse-CDT-Debugger-Map-List.png
http://omploader.org/vNHVlOQ/Eclipse-CDT-Debugger-Map-List-Iterator.png
No any data displayed. It is not possible to debug programs. How can this be resolved?
Re: Exploring std::map and std::list in debugger [message #544844 is a reply to message #544836] Mon, 05 July 2010 12:57 Go to previous messageGo to next message
Eclipse UserFriend
On Mon, 05 Jul 2010 12:42:22 -0400, Nobody <cdtfan@gmail.com> wrote:

>Using Eclipse CDT Helios with GNU gdb 6.8.
>I would like to see something like this (MSVC2008):
>
>
>
>And now in Eclipse I can see only this:
>
>
>No any data displayed. It is not possible to debug programs. How can this be resolved?

See earlier - no binaries.
Re: Exploring std::map and std::list in debugger [message #544855 is a reply to message #544844] Mon, 05 July 2010 13:44 Go to previous messageGo to next message
Eclipse UserFriend
No any binaries, there were only screenshots inside messages on the forum.

For a very simple program like this one:
#include <map>
#include <list>
#include <string>
using namespace std;

int main()
{
    typedef map<string, list<string> > map_t;
    map_t m;
    m["one"].push_back("a");
    m["one"].push_back("b");
    m["one"].push_back("c");
    m["two"].push_back("1");
    m["two"].push_back("2");
    m["two"].push_back("3");
    map_t::const_iterator i = m.begin();
    i++;
    return 0; // <= break point on this line
}

I've set break point on the line with return statement.

In MSVC2008 debugger I see something like:
[-] m[2]("one",[3]("a","b","c")),("two",[3]("1","2","3")))
 [+] [0] ("one",[3]("a","b","c"))
 [+] [1] ("two",[3]("1","2","3"))

and
[+] i ("two",[3]("1","2","3"))


And Eclipse shows me like this:
[-] m     | map_t                            | {...}
 [+] _M_t | std::_Rb_tree<std::basic_strin.. | {...}

and
[-] i        | std::_Rb_tree_const_iterator<s.. | {...}
 [+] _M_node | std::_Rb_tree<std::basic_strin.. | 0x3e2550

no actual data inside std::map or std::list is displayed.
Re: Exploring std::map and std::list in debugger [message #544897 is a reply to message #544836] Mon, 05 July 2010 18:41 Go to previous messageGo to next message
Eclipse UserFriend
CDT 7.0 support of GDB's pretty-printing feature. Requires GDB 7.0 or newer as well as python, and GDB's python pretty-printers. Some information available here
Re: Exploring std::map and std::list in debugger [message #544913 is a reply to message #544897] Tue, 06 July 2010 00:33 Go to previous messageGo to next message
Eclipse UserFriend
Andrey Kourskov wrote on Mon, 05 July 2010 18:41
CDT 7.0 support of GDB's pretty-printing feature. Requires GDB 7.0 or newer as well as python, and GDB's python pretty-printers. Some information available here


Already using latest CDT version. Downloaded gdb-7.1-2-mingw32-bin.tar.gz from sourceforge, unpacked to MinGW directory. Now "gdb --version" tells me "GNU gdb (GDB) 7.1". But no any changes in Eclipse debugger, data in STL containers is not displayed.
Re: Exploring std::map and std::list in debugger [message #545005 is a reply to message #544913] Tue, 06 July 2010 06:44 Go to previous messageGo to next message
Eclipse UserFriend
Nobody wrote on Tue, 06 July 2010 00:33
Andrey Kourskov wrote on Mon, 05 July 2010 18:41
CDT 7.0 support of GDB's pretty-printing feature. Requires GDB 7.0 or newer as well as python, and GDB's python pretty-printers. Some information available here


Already using latest CDT version. Downloaded gdb-7.1-2-mingw32-bin.tar.gz from sourceforge, unpacked to MinGW directory. Now "gdb --version" tells me "GNU gdb (GDB) 7.1". But no any changes in Eclipse debugger, data in STL containers is not displayed.

You have to load some python code into via gdbinit. You can find more info here http://sourceware.org/gdb/wiki/STLSupport
Re: Exploring std::map and std::list in debugger [message #545035 is a reply to message #545005] Tue, 06 July 2010 09:34 Go to previous messageGo to next message
Eclipse UserFriend
Axel Mueller wrote on Tue, 06 July 2010 06:44
You have to load some python code into via gdbinit. You can find more info here http://sourceware.org/gdb/wiki/STLSupport


So I have done this: "svn co svn://gcc.gnu.org/svn/gcc/trunk/libstdc++-v3/python". Also created .gdbinit in home directory with content from the link above, changed the path to checked out python directory.

Also I pointed to ~/.gdbinit in Eclipse debug configuration. And now I have the following error:
.gdbinit:6: Error in sourced command file:
Python scripting is not supported in this copy of GDB.

What is wrong with GDB? I have downloaded it from http://sourceforge.net/projects/mingw/files/MinGW/BaseSystem /GDB/GDB-7.1/gdb-7.1-2-mingw32-bin.tar.gz/download. Is this the official place for downloading latest available GDB?

P.S. why such a simple thing like debugging c++ code with STL containers (works in MSVC for a long time) is so non-trivial for Eclipse?
Re: Exploring std::map and std::list in debugger [message #545090 is a reply to message #545035] Tue, 06 July 2010 11:23 Go to previous messageGo to next message
Eclipse UserFriend
Try to instal this MinGW GDB build
Re: Exploring std::map and std::list in debugger [message #545103 is a reply to message #545090] Tue, 06 July 2010 12:03 Go to previous messageGo to next message
Eclipse UserFriend
Andrey Kourskov wrote on Tue, 06 July 2010 11:23
Try to instal this MinGW GDB build

Thanks for the link. How did you get it by the way?

Now I have this in gdb console:
(gdb) break 18
Breakpoint 1 at 0x401a40: file ..\src\test.cpp, line 18.
(gdb) run
Starting program: ...\Projects\Eclipse\CDT\test\Debug/test.exe
[New Thread 3784.0xb20]

Breakpoint 1, main () at ..\src\test.cpp:18
18          return 0;
(gdb) print m
$1 = std::map with 2 elements = {
  ["one"] = std::list = {
    [0] = "a",
    [1] = "b",
    [2] = "c"
  },
  ["two"] = std::list = {
    [0] = "1",
    [1] = "2",
    [2] = "3"
  }
}

So it seems that now GDB can show values inside STL container now.

But almost nothing has changed inside Eclipse when I point to new GDB and .gdbinit file. I mean that it still shows me something like this:
[-] m     | map_t                            | {...}
 [+] _M_t | std::_Rb_tree<std::basic_strin.. | {...}

The only progress is in Details below:
Name : m
	Details:std::map with 2 elements = {\n  ["one"] = std::list = {\n    [0] = "a",\n ...   [2] = "3"\n  }\n}
	Default:{...}
	Decimal:{...}
              ...

So it is still not usable. Just look at the screenshot with MSVC above: only the required data is displayed in a very compact way. How can something similar be achived in Eclipse?
Re: Exploring std::map and std::list in debugger [message #545288 is a reply to message #545103] Wed, 07 July 2010 07:29 Go to previous messageGo to next message
Eclipse UserFriend
Unfortunately, pretty printing of children is not (yet) implemented (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=302121).
As a workaround you can use the gdb console inside Eclipse. I know that's not very comfortable but that's the only way at the moment.
Re: Exploring std::map and std::list in debugger [message #545323 is a reply to message #545288] Wed, 07 July 2010 08:59 Go to previous messageGo to next message
Eclipse UserFriend
Axel Mueller wrote on Wed, 07 July 2010 07:29
Unfortunately, pretty printing of children is not (yet) implemented (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=302121).
As a workaround you can use the gdb console inside Eclipse. I know that's not very comfortable but that's the only way at the moment.

It is a pity that Eclipse still doesn't have usable debugger for c++ development. Any chances for that bug to be fixed in next release?

By the way QtCreator has better integration with debugger. It can display values inside containers:
http://omploader.org/vNHYwbQ/QtCreatorDebugMapList.png
Though it failed to display iterator value correctly.
Re: Exploring std::map and std::list in debugger [message #545516 is a reply to message #545323] Thu, 08 July 2010 03:20 Go to previous message
Eclipse UserFriend
Quote:
Any chances for that bug to be fixed in next release?

Feel free to add your comment to the above mentioned bug report. I would also like to see this fixed.
Previous Topic:Cannot get eclipse to build program...? (Win XP)
Next Topic:Problem with building Hello World in Eclipse IDE for C/C++ Developers
Goto Forum:
  


Current Time: Tue Oct 28 18:02:56 EDT 2025

Powered by FUDForum. Page generated in 0.07447 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top