问题
I try to debug c++ code with Xcode 4.5, compiled with llvm 4.1. The code is very simple, just inserting several items to a map.
When I step over STL functions, the execution stops inside STL code, instead of performing the step as usual.
When I compile using LLVM-GCC 4.2 the debug is just fine, but this compiler doesn't have C++11 support.
Did anyone encounter this problem before, and knows if it can be fixed?
回答1:
I can certainly experience the same issue since LLDB was introduced into Xcode. It seems it doesn't properly handle stepping over inlined functions (see: Debugger steps deeper when trying to step out of C++11 std lib).
I've just submitted a bug report to Apple (ID 12588579), but I'm guessing it will take a couple of iterations before LLDB is completely ready to use in C++11 production code (it's getting there, remember the version shipped with Xcode was not usable at all until 4.4).
回答2:
The lldb in Xcode 4.5.x doesn't have support for stepping over inlined functions. The C++11 standard library has aggressive function inlining even when built at -O0 so this problem is especially obvious. Inlined stepping support has since been added to lldb, v. http://llvm.org/viewvc/llvm-project?view=rev&revision=163044 and is available for use in the sources at http://lldb.llvm.org/ but you won't be able to replace the lldb inside Xcode with these sources (the APIs have changed since 4.5 was released).
Note that stepping over inlined functions -- making them appear to be "real" functions as you work in the debugger -- is a complicated feature and any inaccuracies in the debug information generated by clang can cause bad stepping behavior. There are (and still will be) corner cases that don't work properly either because of insufficient debug information or because of bugs in lldb - this is tricky to get 100% right.
You can try to reduce the hassle of C++11 std lib programming a little by putting
settings set target.process.thread.step-avoid-regexp ^[^ ]+ std::|^std::
in your ~/.lldbinit
file. I don't think this will help with inlined functions but if a call to a stdlib method is out of line it will at least step over it.
来源:https://stackoverflow.com/questions/13099916/stepping-through-the-code-is-stopping-on-stl-code-when-debugging-c-with-xcode