gpt4 book ai didi

c++ - 在 gdb 中调试 map>

转载 作者:太空宇宙 更新时间:2023-11-04 14:05:24 24 4
gpt4 key购买 nike

我在我的 Mac 上使用支持 c++ 11 功能的 g++ 4.8。

/opt/local/bin/g++-mp-4.8

我还使用 gdb 6.3.50。

GNU gdb 6.3.50-20050815 (Apple version gdb-1822) (Sun Aug  5 03:00:42 UTC 2012)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin".

我的代码有很多具有 unique_ptr 的 map 或 vector ,调试它们真的很痛苦,因为我看不到关于 map 或 vector 中元素的信息。

我尝试制作一个实用方法并在 gdb 中调用它们,但它似乎不起作用。它不会抛出错误消息,但也不会显示任何内容。

void testPrint( map<int, unique_ptr<GroupContextSummary>> & m, int i )
{
cout << m[i].get()->to_string() << endl;
}

有什么方法可以查看 map /vector 中的元素吗?

enter image description here

最佳答案

这篇文章有一些提示表明 gdb 7 可能会解决这个问题。

Gdb on MacOSX lion

brew install https://raw.github.com/Homebrew/homebrew-dupes/master/gdb.rb

然后我需要协同设计。

==> ./configure --prefix=/usr/local/Cellar/gdb/7.6 --with-python=/usr --with-system-readline
==> make
==> make install
==> Caveats
gdb requires special privileges to access Mach ports.
You will need to codesign the binary. For instructions, see:

http://sourceware.org/gdb/wiki/BuildingOnDarwin

或者您可以直接从 sudo 运行 gdb。

Gdb 7.0 可以在我的 Mac 上编译和构建,但它不能正确调试程序。我希望 Mac 上的下一版本 gdb 能够解决这些问题。

关于c++ - 在 gdb 中调试 map<int, unique_ptr<A>>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17204568/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com