Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xcode/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ LLDB:如何检查无序地图_C++_Xcode_C++11_Lldb - Fatal编程技术网

C++ LLDB:如何检查无序地图

C++ LLDB:如何检查无序地图,c++,xcode,c++11,lldb,C++,Xcode,C++11,Lldb,大多数其他STL容器打印得很好,但是unordered\u map是一团乱 我使用操作符您应该能够检查无序映射对象本身,而无需对其调用方法 例如,以这个简单的程序为例: #include <iostream> #include <string> #include <unordered_map> using namespace std; int main() { unordered_map<int, string> map; ma

大多数其他STL容器打印得很好,但是
unordered\u map
是一团乱


我使用
操作符您应该能够检查
无序映射
对象本身,而无需对其调用方法

例如,以这个简单的程序为例:

#include <iostream>
#include <string>
#include <unordered_map>

using namespace std;

int main() {
    unordered_map<int, string> map;
    map[0] = "mary";
    map[1] = "had";
    map[2] = "a";
    map[3] = "little";
    map[4] = "lamb";

    return 0;
}

$ clang++ -std=c++11 -stdlib=libc++ -g unmap.cpp -o unmap
$ lldb unmap
Current executable set to 'unmap' (x86_64).
(lldb) break set --name main
n
输入5次,直到
返回0语句

然后使用
p
检查对象:

(lldb) p map[0]
(std::__1::unordered_map<int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::hash<int>, std::__1::equal_to<int>, std::__1::allocator<std::__1::pair<const int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > >::mapped_type) $2 = "mary"
(lldb) p map[1]
(std::__1::unordered_map<int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::hash<int>, std::__1::equal_to<int>, std::__1::allocator<std::__1::pair<const int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > >::mapped_type) $3 = "had"
(lldb) quit

(即Xcode 5 DP 6命令行软件包附带的一个)

如果您愿意使用开源lldb并自己动手构建它,那么有一个无序映射的合成提供者,您可以使用:

作者:enrico日期:Wed Sep 4 12:48:52 2013新版本:189964

URL:Log:This 是libc++无序(多)映射和集的示例合成提供程序 感谢Jared Grubb撰写并分享


如何从cmdline从lldb连接到ARM进程?我可以将两个实例附加到同一个正在运行的程序吗?(有些东西告诉我没有…)在不升级Xcode的情况下升级Xcode中的lldb版本怎么样?(因为vim插件,我想保留Xcode 4)我确实有lldb项目本身通过Xcode成功编译。@StevenLu不,我不知道你怎么做,但是你可以使用调试器控制台从Xcode内部与lldb交互。我会尝试使用LLDB的版本,您必须查看是否可以执行类似于
p map[0]
的操作。我有LLDB
179.6
。它失败:
p this->memberUnorderedMap[0]错误:在非静态成员函数外部无效使用“this”
p memberUnorderedMap[0]错误:使用未声明的标识符“memberUnorderedMap”
(我可以使用
p this->memberUnorderedMap
获得整个映射本身的超级丑陋转储)@StevenLu为什么要使用
这个->
?这是让它在Objective实例中打印任何内容的唯一方法不清楚如何将其与Xcode集成,这样我每次都可以连接和调试ARM应用程序,而无需一些复杂的设置过程是的,在所有这些方法中,电话调试可能是一个棘手的问题。您可以尝试的是从ToT源代码中提取Python脚本,并将其“命令脚本导入”到您的Xcode会话中,而不保证它能正常工作。这可能有效,也可能无效,这取决于您正在使用的Xcode/LLDB版本,以及自那时以来SB API的发展程度(就可用调用/修复错误而言)。通常,编写这些脚本时没有考虑与较旧的LLDB兼容,也没有进行这样的测试。这可能有用。如果是这样,那就是你的幸运日:)是的。不过,我的模板打印机非常有效,足够粒度的日志记录在这一点上几乎可以完成任何可以想象的工作。我可能更适合在基于网络的日志系统上工作,而不是尝试调整调试器。
(lldb)
Process 18063 stopped
* thread #1: tid = 0x1c03, 0x0000000100000aea unmap`main + 1082 at unmap.cpp:15, stop reason = step over
    frame #0: 0x0000000100000aea unmap`main + 1082 at unmap.cpp:15
   12       map[3] = "little";
   13       map[4] = "lamb";
   14
-> 15       return 0;
   16   }
   17
(lldb) p map[0]
(std::__1::unordered_map<int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::hash<int>, std::__1::equal_to<int>, std::__1::allocator<std::__1::pair<const int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > >::mapped_type) $2 = "mary"
(lldb) p map[1]
(std::__1::unordered_map<int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::hash<int>, std::__1::equal_to<int>, std::__1::allocator<std::__1::pair<const int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > >::mapped_type) $3 = "had"
(lldb) quit
$ lldb -version
LLDB-179.5