My goal is: I want to step into the some line of code of STL istream. So I used custom built "LIBC++13" with "Debug" build type(the command I used are shown at the bottom), so that (I think) I can get a fully debuggable version of STL, and be able to step into everything I want. But I got a problem.
Here are my breakpoints settings for istream, BREAKPOINT A(Line 1447) and want to step into Line 310:
// -*- C++ -*-
//===--------------------------- istream ----------------------------------===//
// ..................(other).....................
basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is,
basic_string<_CharT, _Traits, _Allocator>& __str)
{
ios_base::iostate __state = ios_base::goodbit;
typename basic_istream<_CharT, _Traits>::sentry __sen(__is); // BREAKPOINT A (Line 1447)
if (__sen) // Line 1448
{
// ...
}
// ..................(other).....................
template <class _CharT, class _Traits>
basic_istream<_CharT, _Traits>::sentry::sentry(basic_istream<_CharT, _Traits>& __is,
bool __noskipws)
: __ok_(false)
{
if (__is.good()) // Want To Step Into Here (Line 310)
{
// ...
}
and the program:
#include <fstream>
#include <string>
using namespace std;
int main()
{
ifstream ifs{"testdata.txt"};
string tmp{};
ifs >> tmp;
}
My problem is: With GDB, when I stopped at "BREAKPOINT A", I can step into "Line 310". But with LLDB, when I stopped at "BREAKPOINT A", I cannot step into "Line 310", and trying to step into would cause execution stopping at "Line 1448", which just skipping the "Line 310". Why was that? And Moreover, either with LLDB or GBD, I just cannot explicitly set breakpoint at "Line 310". Have no idea what happened in my situation.
So my question is: Why some lines of code in STL will be skipped/ignored by LLDB? (in my case, that is Line 310)
LIBC++13 is built by command: (using the examples in Building Libcxx Guides, /usr/local/myllvm is my install location))
cmake -G Ninja -S llvm -B build \
-DLLVM_ENABLE_PROJECTS="libcxx;libcxxabi" \
-DCMAKE_BUILD_TYPE="Debug" \
-DCMAKE_INSTALL_PREFIX="/usr/local/myllvm" \
-DCMAKE_CXX_COMPILER="clang++"
Program is compiled with recommended options:
clang++ -nostdinc++ -nostdlib++ \
-isystem /usr/local/myllvm/include/c++/v1 \
-L /usr/local/myllvm/lib \
-Wl,-rpath,/usr/local/myllvm/lib \
-lc++ -g -O0 test1.cpp