您应该能够检查unordered_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
Run Code Online (Sandbox Code Playgroud)
lldb为简洁起见未显示输出
(lldb) proc launch
Run Code Online (Sandbox Code Playgroud)
n输入 5 次 Untilreturn 0;语句
(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
Run Code Online (Sandbox Code Playgroud)
然后使用以下命令检查对象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
Run Code Online (Sandbox Code Playgroud)
您使用的版本lldb会有所不同,因为它一直在改进:
$ lldb -version
LLDB-179.5
Run Code Online (Sandbox Code Playgroud)
(即Xcode 5 DP 6命令行包自带的)
| 归档时间: |
|
| 查看次数: |
1918 次 |
| 最近记录: |