在Xcode 4.4中使用libc ++调试问题 [英] Debug issues with libc++ in Xcode 4.4

查看:180
本文介绍了在Xcode 4.4中使用libc ++调试问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我做了一个简单的测试应用程序:

  int main(int argc,const char * argv [])
{
//在此插入代码
std :: cout<< 你好,世界!\\\
;

std :: list< int>名单
list.push_back(1);
list.push_back(2);
- > list.push_back(3); //在
之前的行(std :: list< int> :: const_iterator i = list.begin(); i!= list.end(); i ++)
{
std :: cout<< * i< std :: endl;
}
return 0;
}

调试时,当我在标有箭头的行上,当我一步一步,它开始从c ++文件中的代码进入:'list'。
我必须像15遍一样,直到最后到达for语句里面的代码。



这个问题只发生在Xcode 4.4中。在Xcode 4.3中,调试工作完美。



这里有一些不同的场景有不同的结果:


  1. 使用LLVM GCC 4.2作为编译器→它工作正常。

  2. 使用Apple LLVM编译器4.0并为C ++标准库设置libstdc ++(GNU C ++标准库)→它工作

  3. Apple LLVM编译器4.0,并为C ++标准库设置libc ++(支持C ++ 11的LLVM C ++标准库)→出现问题。

在我正在开展的项目中,我们使用的是Apple LLVM编译器4.0和libc ++(使用C ++ 11支持的LLVM C ++标准库),所以我需要解决这个问题有没有人知道可能会发生什么事情,如果有修复?



h2_lin>解决方案

这是一个与libc ++交互的lldb / llvm问题,自从我们启用它以来,我已经看到了,虽然我认为只有libc ++ / lldb开发者能够告诉w帽子就是这样。



虽然这不是一个解决方案,但似乎是使用llvm 3.1(当前版本与Xcode 4.5)的命令行的问题。如果我这样做:

  clang ++ -g -O0 -stdlib = libc ++ -std = c ++ 11 test.cpp -o test 
lldb test
断点集--file test.cpp --line 8

...然后尝试使用'n'直到主要的结尾,它跳转到列表的来源:

  * thread#1:tid = 0x1c03,0x00000001000010a2 test`main [inlined] std :: __ 1 :: __ list_imp< int,std :: __ 1 :: allocator< int> > :: begin()at list:543,stop reason = step over 
frame#0:0x00000001000010a2 test`main [inlined] std :: __ 1 :: __ list_imp< int,std :: __ 1 :: allocator< int> > :: begin()at list:543
540 {
541 #if _LIBCPP_DEBUG_LEVEL> = 2
542 return iterator(__ end _.__ next_,this);
- > 543 #else
544 return iterator(__ end _.__ next_);
545 #endif
546}

我同意,这真的减慢了发展/调试时间,应报告给 lldb开发者


I am having a problem when I try to debug on a list iteration on c++.

I made a simple test app:

int main(int argc, const char * argv[])
{
// insert code here...
std::cout << "Hello, World!\n";

std::list<int> list;
list.push_back(1);
list.push_back(2);
--> list.push_back(3);    //Line before step over
    for (std::list<int>::const_iterator i = list.begin(); i != list.end(); i++)
    {
      std::cout << *i << std::endl;
    }
    return 0;
}

While debugging, when I am on the line marked with an arrow, when I step over, it starts stepping in on code from a c++ file: 'list'. I have to step over like 15 times until it finally gets to the code inside the for statement.

This issue only happens in Xcode 4.4. In Xcode 4.3 the debug works perfectly.

Here there are some different scenarios with different results:

  1. Use LLVM GCC 4.2 as the compiler → It works ok.
  2. Use Apple LLVM compiler 4.0 and set libstdc++ (GNU C++ standard library) for the C++ Standard library → It works ok.
  3. Apple LLVM compiler 4.0 and set libc++ (LLVM C++ standard library with C++11 support) for the C++ Standard library → The issue happens.

In the project I am working on, we are using Apple LLVM compiler 4.0 and libc++ (LLVM C++ standard library with C++11 support) so I need to solve this issue for scenario 3).

Does anybody knows what could be happening and if there is a fix for it?

解决方案

It's a problem with lldb / llvm interacting with libc++, I've seen it ever since we enabled it, although I think only the libc++ / lldb devs will be able to tell what that is.

While this isn't a solution, it seems to be an issue from the command line with with llvm 3.1 (current release with Xcode 4.5). If I do:

clang++ -g -O0 -stdlib=libc++ -std=c++11 test.cpp -o test
lldb test
breakpoint set --file test.cpp --line 8

... and then try to use 'n' to step through until the end of main, it jumps into list's source at:

* thread #1: tid = 0x1c03, 0x00000001000010a2 test`main [inlined] std::__1::__list_imp<int, std::__1::allocator<int> >::begin() at list:543, stop reason = step over
    frame #0: 0x00000001000010a2 test`main [inlined] std::__1::__list_imp<int, std::__1::allocator<int> >::begin() at list:543
   540      {
   541  #if _LIBCPP_DEBUG_LEVEL >= 2
   542          return iterator(__end_.__next_, this);
-> 543  #else
   544          return iterator(__end_.__next_);
   545  #endif
   546      }

I agree, this really slows down development / debugging time, and it should be reported to the lldb devs

这篇关于在Xcode 4.4中使用libc ++调试问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆