Fix the std::string formatter to report errors in the case where the
authorJim Ingham <jingham@apple.com>
Tue, 17 May 2022 15:21:09 +0000 (08:21 -0700)
committerJim Ingham <jingham@apple.com>
Tue, 17 May 2022 15:22:30 +0000 (08:22 -0700)
commit7afd257ff8a45a348767b4432abc6f4f105fc376
tree9a15683a94e3e4691d16bf20ec4b05f9c7fdb794
parentf032690a7c0b221b27bfb79ffec85147f23d520f
Fix the std::string formatter to report errors in the case where the
string points to unaccessible memory.

The formatter tries to get the data field of the std::string, and to
check whether that fails it just checks that the ValueObjectSP
returned is not empty. But we never return empty ValueObjectSP's to
indicate failure, since doing so would lose the Error object that
tells you why fetching the ValueObject failed.

This patch adds a check for ValueObject::GetError().Success().

I also added a test case for this failure, and reworked the test case
a bit (to use run_to_source_breakpoint). I also renamed a couple of
single letter locals which don't follow the lldb coding conventions.

Differential Revision: https://reviews.llvm.org/D108228
lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/main.cpp