对 STL 调试提供适当支持的 Linux IDE

发布于 2024-08-03 06:41:59 字数 998 浏览 7 评论 0原文

我正在寻找一个支持 STL 调试的 Linux IDE。

问题是,使用 Eclipse CDT,如果我在 push_back 之后检查向量:

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

我会得到一些敌意的东西

{<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>}

,而

vector["blah"]

不是类似的东西。 是否有适用于 Linux 的替代 IDE/调试器可以提供更好的 STL 支持?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

蓝海似她心 2024-08-10 06:41:59

QtCreator 具有用于 Qt 容器、一些 STL 容器和一堆的调试器转储器Qt 类。它的响应速度也比 Eclipse 更快。

请参阅 Qt Creator 调试器转储器

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.

友欢 2024-08-10 06:41:59

只需编写 GDB 脚本即可打印 stl 容器。
打印矢量:

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

现在您甚至可以在 python 上编写脚本。检查文档。

我个人使用cgdb,这是一个非常方便的curses调试器。

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.

北音执念 2024-08-10 06:41:59

这与 IDE 本身无关,但这是您所使用的调试器的一个缺点。 IDE,尤其是 Linux 上的 IDE,只是调试器的前端。我想您正在使用 GDB,它不会比这更好。顺便说一句,在 Linux 上开发时,我使用仔细放置的打印语句而不是调试器,大多数时候我发现它比使用调试器更好!

This has got nothing to do with the IDE per se, but this is a drawback of the debugger you are using. IDEs, especially on Linux, are just front-ends for debuggers. I suppose you are using GDB, and it won't get any better than this. BTW, while developing on Linux, I use carefully placed print statements instead of a debugger and most of the time I find it better than using a debugger!

伤痕我心 2024-08-10 06:41:59

Eclipse 使用 gdb,您可以编写 gdb 脚本,以便它按照您想要的方式打印不同的类型。我对自己的类型使用自己的脚本,但有许多可用的 stl 脚本。

现在棘手的部分是让 Eclipse 顺利完成这项工作,但它可以是一个解决方案。

Eclipse use gdb and you can script gdb so it print different types the way you want. I use my own scripts for my own types but there is many available scripts for the stl.

Now the tricky part will be to make this work smoothly is Eclipse, but it can be a solution.

审判长 2024-08-10 06:41:59

如果您想远离 GDB 脚本,您不妨离开 Eclipse,转而使用 QtCreator 或者如果您不介意支付许可证费用 CLion 是 IMO 周围最好的 IDE。

If you want to stay away from GDB scripts you might as well leave Eclipse in favor of QtCreator or if you don't mind paying for a license CLion is the best IDE around IMO.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文