2013-04-09 57 views
3

This thread是clang的libC++的調試模式的早期討論,通過在編譯器命令中定義_LIBCPP_DEBUG2來啓用它。剛剛完成與錯誤分配的std::vector<>的戰鬥,我有興趣能夠打開此調試版本。是否有可能在Mountain Lion的當前Xcode 4.6.1工具鏈中啓用_LIBCPP_DEBUG2?

當我試圖簡單地增加_LIBCPP_DEBUG=1預處理宏構建設置,我在鏈接階段(如下圖所示)出現錯誤。我懷疑這些是由討論主題中描述的調試數據庫的新生成引用引起的。

在早期的討論中,有人說圖書館的標準版本提供了必要的支持,但現在看來並非如此。它仍然支持嗎?如果是這樣,我如何鏈接到必要的位?

Ld /Users/kaelin/Library/Developer/Xcode/DerivedData/OMWorkspace-bzkzcamyqoztgyalubrmemkzmjvk/Build/Products/Debug/vMAT.dylib normal x86_64 
    cd /Users/Shared/Source/vMAT 
    setenv MACOSX_DEPLOYMENT_TARGET 10.8 
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch x86_64 -dynamiclib -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -L/Users/kaelin/Library/Developer/Xcode/DerivedData/OMWorkspace-bzkzcamyqoztgyalubrmemkzmjvk/Build/Products/Debug -F/Users/kaelin/Library/Developer/Xcode/DerivedData/OMWorkspace-bzkzcamyqoztgyalubrmemkzmjvk/Build/Products/Debug -F/Users/Shared/Source/vMAT/../../../kaelin/Library/Developer/Xcode/DerivedData/OMWorkspace-bzkzcamyqoztgyalubrmemkzmjvk/Build/Products/Debug -filelist /Users/kaelin/Library/Developer/Xcode/DerivedData/OMWorkspace-bzkzcamyqoztgyalubrmemkzmjvk/Build/Intermediates/vMAT.build/Debug/vMAT.build/Objects-normal/x86_64/vMAT.LinkFileList -install_name "@rpath/vMAT.dylib" -mmacosx-version-min=10.8 -fobjc-arc -fobjc-link-runtime -stdlib=libc++ -framework BlocksKit -framework Accelerate -framework Cocoa -single_module -compatibility_version 1 -current_version 1 -o /Users/kaelin/Library/Developer/Xcode/DerivedData/OMWorkspace-bzkzcamyqoztgyalubrmemkzmjvk/Build/Products/Debug/vMAT.dylib 

Undefined symbols for architecture x86_64: 
    "std::__1::__libcpp_db::__comparable(void const*, void const*) const", referenced from: 
     NSString* (anonymous namespace)::dump<double>(NSString*, double*, int vector[4]) in vMAT_Array+UnaryOps.o 
     NSString* (anonymous namespace)::dump<float>(NSString*, float*, int vector[4]) in vMAT_Array+UnaryOps.o 
     signed char (anonymous namespace)::isEqualEpsilon<double>(double*, int vector[4], double*, int vector[4], double) in vMAT_Array+BinaryOps.o 
     signed char (anonymous namespace)::isEqualEpsilon<float>(float*, int vector[4], float*, int vector[4], double) in vMAT_Array+BinaryOps.o 
    "std::__1::__libcpp_db::__dereferenceable(void const*) const", referenced from: 
     NSString* (anonymous namespace)::dump<double>(NSString*, double*, int vector[4]) in vMAT_Array+UnaryOps.o 
     NSString* (anonymous namespace)::dump<float>(NSString*, float*, int vector[4]) in vMAT_Array+UnaryOps.o 
     signed char (anonymous namespace)::isEqualEpsilon<double>(double*, int vector[4], double*, int vector[4], double) in vMAT_Array+BinaryOps.o 
     signed char (anonymous namespace)::isEqualEpsilon<float>(float*, int vector[4], float*, int vector[4], double) in vMAT_Array+BinaryOps.o 
    "std::__1::__libcpp_db::__insert_c(void*)", referenced from: 
     std::__1::vector<float, std::__1::allocator<float> >::vector<float*>(float*, float*, std::__1::enable_if<__is_forward_iterator<float*>::value, void>::type*) in vMAT_Array+UnaryOps.o 
     std::__1::vector<double, std::__1::allocator<double> >::vector<double*>(double*, double*, std::__1::enable_if<__is_forward_iterator<double*>::value, void>::type*) in vMAT_Array+UnaryOps.o 
     std::__1::vector<float, std::__1::allocator<float> >::vector<float*>(float*, float*, std::__1::enable_if<__is_forward_iterator<float*>::value, void>::type*) in vMAT_Array+BinaryOps.o 
     std::__1::vector<double, std::__1::allocator<double> >::vector<double*>(double*, double*, std::__1::enable_if<__is_forward_iterator<double*>::value, void>::type*) in vMAT_Array+BinaryOps.o 
     std::__1::vector<int, std::__1::allocator<int> >::vector(unsigned long, int const&) in vMAT_inconsistent.o 
     std::__1::vector<int, std::__1::allocator<int> >::vector(std::__1::vector<int, std::__1::allocator<int> > const&) in vMAT_inconsistent.o 
     (anonymous namespace)::clusterOptions(NSArray*) in vMAT_cluster.o 
     ... 
    "std::__1::__libcpp_db::__insert_ic(void*, void const*)", referenced from: 
     NSString* (anonymous namespace)::dump<double>(NSString*, double*, int vector[4]) in vMAT_Array+UnaryOps.o 
     NSString* (anonymous namespace)::dump<float>(NSString*, float*, int vector[4]) in vMAT_Array+UnaryOps.o 
     signed char (anonymous namespace)::isEqualEpsilon<double>(double*, int vector[4], double*, int vector[4], double) in vMAT_Array+BinaryOps.o 
     signed char (anonymous namespace)::isEqualEpsilon<float>(float*, int vector[4], float*, int vector[4], double) in vMAT_Array+BinaryOps.o 
    "std::__1::__libcpp_db::__erase_c(void*)", referenced from: 
     NSString* (anonymous namespace)::dump<double>(NSString*, double*, int vector[4]) in vMAT_Array+UnaryOps.o 
     NSString* (anonymous namespace)::dump<float>(NSString*, float*, int vector[4]) in vMAT_Array+UnaryOps.o 
     signed char (anonymous namespace)::isEqualEpsilon<double>(double*, int vector[4], double*, int vector[4], double) in vMAT_Array+BinaryOps.o 
     signed char (anonymous namespace)::isEqualEpsilon<float>(float*, int vector[4], float*, int vector[4], double) in vMAT_Array+BinaryOps.o 
     (anonymous namespace)::traceTree(vMAT::Matrix<double>, double*, int, unsigned int) in vMAT_inconsistent.o 
     ___Block_byref_object_dispose_ in vMAT_inconsistent.o 
     (anonymous namespace)::Options::~Options() in vMAT_cluster.o 
     ... 
    "std::__1::__libcpp_db::__erase_i(void*)", referenced from: 
     NSString* (anonymous namespace)::dump<double>(NSString*, double*, int vector[4]) in vMAT_Array+UnaryOps.o 
     NSString* (anonymous namespace)::dump<float>(NSString*, float*, int vector[4]) in vMAT_Array+UnaryOps.o 
     signed char (anonymous namespace)::isEqualEpsilon<double>(double*, int vector[4], double*, int vector[4], double) in vMAT_Array+BinaryOps.o 
     signed char (anonymous namespace)::isEqualEpsilon<float>(float*, int vector[4], float*, int vector[4], double) in vMAT_Array+BinaryOps.o 
    "std::__1::__get_const_db()", referenced from: 
     NSString* (anonymous namespace)::dump<double>(NSString*, double*, int vector[4]) in vMAT_Array+UnaryOps.o 
     NSString* (anonymous namespace)::dump<float>(NSString*, float*, int vector[4]) in vMAT_Array+UnaryOps.o 
     signed char (anonymous namespace)::isEqualEpsilon<double>(double*, int vector[4], double*, int vector[4], double) in vMAT_Array+BinaryOps.o 
     signed char (anonymous namespace)::isEqualEpsilon<float>(float*, int vector[4], float*, int vector[4], double) in vMAT_Array+BinaryOps.o 
    "std::__1::__c_node::~__c_node()", referenced from: 
     std::__1::_C_node<std::__1::vector<float, std::__1::allocator<float> > >::~_C_node() in vMAT_Array+UnaryOps.o 
     std::__1::_C_node<std::__1::vector<double, std::__1::allocator<double> > >::~_C_node() in vMAT_Array+UnaryOps.o 
     std::__1::_C_node<std::__1::vector<float, std::__1::allocator<float> > >::~_C_node() in vMAT_Array+BinaryOps.o 
     std::__1::_C_node<std::__1::vector<double, std::__1::allocator<double> > >::~_C_node() in vMAT_Array+BinaryOps.o 
     std::__1::_C_node<std::__1::vector<int, std::__1::allocator<int> > >::~_C_node() in vMAT_inconsistent.o 
     std::__1::_C_node<std::__1::vector<int, std::__1::allocator<int> > >::~_C_node() in vMAT_cluster.o 
     std::__1::_C_node<std::__1::vector<double, std::__1::allocator<double> > >::~_C_node() in vMAT_cluster.o 
     ... 
    "std::__1::__get_db()", referenced from: 
     NSString* (anonymous namespace)::dump<double>(NSString*, double*, int vector[4]) in vMAT_Array+UnaryOps.o 
     NSString* (anonymous namespace)::dump<float>(NSString*, float*, int vector[4]) in vMAT_Array+UnaryOps.o 
     std::__1::vector<float, std::__1::allocator<float> >::vector<float*>(float*, float*, std::__1::enable_if<__is_forward_iterator<float*>::value, void>::type*) in vMAT_Array+UnaryOps.o 
     std::__1::vector<double, std::__1::allocator<double> >::vector<double*>(double*, double*, std::__1::enable_if<__is_forward_iterator<double*>::value, void>::type*) in vMAT_Array+UnaryOps.o 
     signed char (anonymous namespace)::isEqualEpsilon<double>(double*, int vector[4], double*, int vector[4], double) in vMAT_Array+BinaryOps.o 
     signed char (anonymous namespace)::isEqualEpsilon<float>(float*, int vector[4], float*, int vector[4], double) in vMAT_Array+BinaryOps.o 
     std::__1::vector<float, std::__1::allocator<float> >::vector<float*>(float*, float*, std::__1::enable_if<__is_forward_iterator<float*>::value, void>::type*) in vMAT_Array+BinaryOps.o 
     ... 
    "typeinfo for std::__1::__c_node", referenced from: 
     typeinfo for std::__1::_C_node<std::__1::vector<float, std::__1::allocator<float> > > in vMAT_Array+UnaryOps.o 
     typeinfo for std::__1::_C_node<std::__1::vector<double, std::__1::allocator<double> > > in vMAT_Array+UnaryOps.o 
     typeinfo for std::__1::_C_node<std::__1::vector<float, std::__1::allocator<float> > > in vMAT_Array+BinaryOps.o 
     typeinfo for std::__1::_C_node<std::__1::vector<double, std::__1::allocator<double> > > in vMAT_Array+BinaryOps.o 
     typeinfo for std::__1::_C_node<std::__1::vector<int, std::__1::allocator<int> > > in vMAT_inconsistent.o 
     typeinfo for std::__1::_C_node<std::__1::vector<int, std::__1::allocator<int> > > in vMAT_cluster.o 
     typeinfo for std::__1::_C_node<std::__1::vector<double, std::__1::allocator<double> > > in vMAT_cluster.o 
     ... 
    "vtable for std::__1::__c_node", referenced from: 
     std::__1::_C_node<std::__1::vector<float, std::__1::allocator<float> > >::_C_node(void*, std::__1::__c_node*) in vMAT_Array+UnaryOps.o 
     std::__1::_C_node<std::__1::vector<double, std::__1::allocator<double> > >::_C_node(void*, std::__1::__c_node*) in vMAT_Array+UnaryOps.o 
     std::__1::_C_node<std::__1::vector<float, std::__1::allocator<float> > >::_C_node(void*, std::__1::__c_node*) in vMAT_Array+BinaryOps.o 
     std::__1::_C_node<std::__1::vector<double, std::__1::allocator<double> > >::_C_node(void*, std::__1::__c_node*) in vMAT_Array+BinaryOps.o 
     std::__1::_C_node<std::__1::vector<int, std::__1::allocator<int> > >::_C_node(void*, std::__1::__c_node*) in vMAT_inconsistent.o 
     std::__1::_C_node<std::__1::vector<int, std::__1::allocator<int> > >::_C_node(void*, std::__1::__c_node*) in vMAT_cluster.o 
     std::__1::_C_node<std::__1::vector<double, std::__1::allocator<double> > >::_C_node(void*, std::__1::__c_node*) in vMAT_cluster.o 
     ... 
    NOTE: a missing vtable usually means the first non-inline virtual member function has no definition. 
ld: symbol(s) not found for architecture x86_64 
clang: error: linker command failed with exit code 1 (use -v to see invocation) 

回答

2

this conversation

感謝克里斯。我已經檢查過這個實驗的實現。

-D_LIBCPP_DEBUG2

讓你的「標準」調試模式,其中包括 迭代器失效檢查。

-D_LIBCPP_DEBUG2 = 0

讓你 「調試精簡版」。這隻會檢查那些真正便宜的東西,比如你提到的東西。

我敞開了大門爲:

-D_LIBCPP_DEBUG2 = 2

這將使更加昂貴的檢查(例如檢查不變紅/黑樹 )。但這一點目前尚未完成。

我現在仍然只專注於矢量。

霍華德

當我試圖此標誌在Xcode 5.0.x版本(目前最新版本的Xcode),_LIBCPP_DEBUG2=1沒有工作,因爲它需要鏈接到它是專門寫的libcpp的調試支持運行時代碼調試libcpp本身。但_LIBCPP_DEBUG2=0工作時沒有鏈接到調試支持運行時,並且目前爲我提供了非常有用的斷言,例如在空向量上調用std::vector<T>::back()

1

只是爲了更新這個:下面似乎工作,趕上至少要趕在10.9的主要錯誤:大於0水平

-D_LIBCPP_DEBUG=0 

任何事情似乎不支持開箱即用的鐺++在10.9中

相關問題