Debugging problems with libC ++ in Xcode 4.4

I got a problem when I try to debug list iteration in C ++.

I made a simple test application:

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; } 

During debugging, when I am in the line marked with an arrow, when I step over, it starts to enter the code from the C ++: "list" file. I have to step over 15 times until it finally gets into the code inside the for statement.

This issue only occurs in Xcode 4.4. In Xcode 4.3, debugging works fine.

There are several different scenarios with different results:

  • Use LLVM GCC 4.2 as a compiler -> It works fine.
  • Use the Apple LLVM 4.0 compiler and install the libstdC ++ library (GNU C ++ standard library) for the C ++ standard library → It works fine.
  • Apple LLVM 4.0 compiler and lib ++ set (LLVM ++ standard library with ++ 11 support) for ++ standard library → The problem occurs.

In the project I'm working on, we use Apple LLVM compiler 4.0 and lib ++ (the standard LLVM C ++ library with C ++ 11 support), so I need to solve this problem for scenario 3).

Does anyone know what could happen, and if there is a fix for it?

+6
source share
1 answer

The problem with lldb / llvm interacting with lib ++, I have seen this since we turned it on, although I think that only lib ++ / lldb developers will be able to say what it is.

Although this is not a solution, it seems to be a command line issue with llvm 3.1 (current version since Xcode 4.5). If I do this:

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

... and then try using "n" to go to the end of main, it jumps to the source of the list 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 should be reported to lldb devs

+2
source

Source: https://habr.com/ru/post/925476/


All Articles