Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linux IDE with proper support for STL debugging

I am looking for a Linux IDE with support for STL debugging.

the problem is that with Eclipse CDT, if I inspect the vector after the push_back:

int main() {
 vector<string> v;
 v.push_back("blah");
 return 0;
}

I get something hostile like

{<std::_Vector_base<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >> = {_M_impl = {<std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >> = {<__gnu_cxx::new_allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >> = {<No data fields>}, <No data fields>}, _M_start = 0x1fee040, _M_finish = 0x1fee048, _M_end_of_storage = 0x1fee048}}, <No data fields>}

instead of something like

vector["blah"]

or something similar. is there an alternative IDE/Debugger for linux that provides better STL support?

like image 409
Omry Yadan Avatar asked Sep 03 '09 08:09

Omry Yadan


2 Answers

QtCreator has debugger dumpers for the Qt containers, some of the STL containers and a bunch of the Qt classes. It's also more responsive than Eclipse.

See Qt Creator debugger dumpers.

like image 161
rpg Avatar answered Nov 13 '22 15:11

rpg


Just a matter of scripting GDB so you can print stl containers. To print a vector:

define pvec
    set $vec = ($arg0)
    set $vec_size = $vec->_M_impl->_M_finish - $vec->_M_impl->_M_start
    if ($vec_size != 0)
        set $i = 0
        while ($i < $vec_size)

          printf "Vector Element %d:  ", $i

          p *($vec->_M_impl->_M_start+$i)

          set $i++

        end
    end
end

Now you can even script it on python. Check the documentation.

I personally use cgdb which is a very convenient curses debugger.

like image 1
piotr Avatar answered Nov 13 '22 15:11

piotr