lldb on xcode vs lldb on standalone [英] lldb on xcode vs lldb on standalone
本文介绍了lldb on xcode vs lldb on standalone的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个C ++ 11代码,在向量中使用 unique_ptr
。
I have this C++11 code that uses unique_ptr
in vector.
#include <vector>
#include <iostream>
#include <memory>
using namespace std;
class A
{
int x;
public:
A() {}
~A() {}
A(A& a) {}
A(int x) {this->x = x;}
int get() {return x;}
};
int main()
{
vector<unique_ptr<A>> v;
auto a = new A(10);
unique_ptr<A> pa(a);
v.push_back(move(pa)); // move(pa);
auto a2 = new A(20);
unique_ptr<A> pb(a2);
v.push_back(move(pb)); // move(pa);
for (auto& i: v)
{
cout << i->get();
}
}
我可以使用Xcode调试和检查向量中的值>。
但是,当我在clld和debug中编译相同的代码时,有两个错误。
I could use Xcode to debug and check value in vector>. However, when I compile the same code with clang and debug in lldb, there are two errors.
第一个是lldb跟踪STL源代码。
The first one is lldb traces into STL source code.
* thread #1: tid = 0x1f03, 0x0000000100001744 a.out`__gnu_cxx::__normal_iterator<std::unique_ptr<A, std::default_delete<A> >*, std::vector<std::unique_ptr<A, std::default_delete<A> >, std::allocator<std::unique_ptr<A, std::default_delete<A> > > > >::operator*() const at stl_iterator.h:740, stop reason = step over
frame #0: 0x0000000100001744 a.out`__gnu_cxx::__normal_iterator<std::unique_ptr<A, std::default_delete<A> >*, std::vector<std::unique_ptr<A, std::default_delete<A> >, std::allocator<std::unique_ptr<A, std::default_delete<A> > > > >::operator*() const at stl_iterator.h:740
737
738 // Forward iterator requirements
739 reference
-> 740 operator*() const
741 { return *_M_current; }
742
743 pointer
(lldb) n
Process 41243 stopped
b $ b
第二个错误是当我尝试查看向量内容时出现分段错误。
The second error is I have segmentation error when I tried to see the vector contents.
(lldb) p v
Segmentation fault: 11
我使用此命令进行编译。
I used this command for compilation.
clang++ -std=c++11 -stdlib=libc++ -g testit.cpp -o a
可能有什么问题?
推荐答案
我重新安装了Xcode的最新版本的Lion:Xcode 4.6,
I reinstalled the Xcode with the newest version for Lion: Xcode 4.6, and the problem is gone.
这篇关于lldb on xcode vs lldb on standalone的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文