diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp --- a/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp @@ -233,8 +233,15 @@ ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) { const bool scalar_is_load_addr = true; AddressType addr_type; - lldb::addr_t addr_of_string = - valobj.GetAddressOf(scalar_is_load_addr, &addr_type); + lldb::addr_t addr_of_string = LLDB_INVALID_ADDRESS; + if (valobj.IsPointerOrReferenceType()) { + Status error; + ValueObjectSP pointee_sp = valobj.Dereference(error); + if (pointee_sp && error.Success()) + addr_of_string = pointee_sp->GetAddressOf(scalar_is_load_addr, &addr_type); + } else + addr_of_string = + valobj.GetAddressOf(scalar_is_load_addr, &addr_type); if (addr_of_string != LLDB_INVALID_ADDRESS) { switch (addr_type) { case eAddressTypeLoad: { diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py @@ -57,6 +57,11 @@ var_empty = self.frame().FindVariable('empty') var_q = self.frame().FindVariable('q') var_Q = self.frame().FindVariable('Q') + var_rq = self.frame().FindVariable('rq') + var_rQ = self.frame().FindVariable('rQ') + var_pq = self.frame().FindVariable('pq') + var_pQ = self.frame().FindVariable('pQ') + var_uchar = self.frame().FindVariable('uchar') self.assertEqual(var_wempty.GetSummary(), 'L""', "wempty summary wrong") @@ -75,6 +80,18 @@ var_Q.GetSummary(), '"quite a long std::strin with lots of info inside it"', "Q summary wrong") self.assertEqual(var_uchar.GetSummary(), '"aaaaa"', "u summary wrong") + self.assertEqual( + var_rq.GetSummary(), '"hello world"', + "rq summary wrong") + self.assertEqual( + var_rQ.GetSummary(), '"quite a long std::strin with lots of info inside it"', + "rQ summary wrong") + self.assertEqual( + var_pq.GetSummary(), '"hello world"', + "pq summary wrong") + self.assertEqual( + var_pQ.GetSummary(), '"quite a long std::strin with lots of info inside it"', + "pQ summary wrong") self.runCmd("next") diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/main.cpp --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/main.cpp +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/main.cpp @@ -10,6 +10,8 @@ std::string q("hello world"); std::string Q("quite a long std::strin with lots of info inside it"); std::basic_string uchar(5, 'a'); + auto &rq = q, &rQ = Q; + std::string *pq = &q, *pQ = &Q; S.assign(L"!!!!!"); // Set break point at this line. return 0; }