summaryrefslogtreecommitdiff
path: root/lldb/source/Plugins/Language/CPlusPlus
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Plugins/Language/CPlusPlus')
-rw-r--r--lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp22
-rw-r--r--lldb/source/Plugins/Language/CPlusPlus/BlockPointer.h6
-rw-r--r--lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp25
-rw-r--r--lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h6
-rw-r--r--lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp33
-rw-r--r--lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.h7
-rw-r--r--lldb/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp4
-rw-r--r--lldb/source/Plugins/Language/CPlusPlus/CxxStringTypes.h6
-rw-r--r--lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp261
-rw-r--r--lldb/source/Plugins/Language/CPlusPlus/LibCxx.h34
-rw-r--r--lldb/source/Plugins/Language/CPlusPlus/LibCxxAtomic.cpp22
-rw-r--r--lldb/source/Plugins/Language/CPlusPlus/LibCxxAtomic.h6
-rw-r--r--lldb/source/Plugins/Language/CPlusPlus/LibCxxBitset.cpp4
-rw-r--r--lldb/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp2
-rw-r--r--lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp17
-rw-r--r--lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp8
-rw-r--r--lldb/source/Plugins/Language/CPlusPlus/LibCxxOptional.cpp13
-rw-r--r--lldb/source/Plugins/Language/CPlusPlus/LibCxxQueue.cpp2
-rw-r--r--lldb/source/Plugins/Language/CPlusPlus/LibCxxTuple.cpp2
-rw-r--r--lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp4
-rw-r--r--lldb/source/Plugins/Language/CPlusPlus/LibCxxVariant.cpp28
-rw-r--r--lldb/source/Plugins/Language/CPlusPlus/LibCxxVariant.h6
-rw-r--r--lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp2
-rw-r--r--lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp6
-rw-r--r--lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.h6
-rw-r--r--lldb/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp2
-rw-r--r--lldb/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp2
-rw-r--r--lldb/source/Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.cpp2
-rw-r--r--lldb/source/Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.h4
29 files changed, 368 insertions, 174 deletions
diff --git a/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp b/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
index 5cfd978774fd0..42f6bd9ffb7b4 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
@@ -1,4 +1,4 @@
-//===-- BlockPointer.cpp ----------------------------------------*- C++ -*-===//
+//===-- BlockPointer.cpp --------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -8,14 +8,14 @@
#include "BlockPointer.h"
+#include "Plugins/ExpressionParser/Clang/ClangASTImporter.h"
+#include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
-#include "lldb/Symbol/ClangASTContext.h"
-#include "lldb/Symbol/ClangASTImporter.h"
#include "lldb/Symbol/CompilerType.h"
#include "lldb/Symbol/TypeSystem.h"
#include "lldb/Target/Target.h"
-
#include "lldb/Utility/LLDBAssert.h"
#include "lldb/Utility/Log.h"
@@ -45,18 +45,24 @@ public:
if (auto err = type_system_or_err.takeError()) {
LLDB_LOG_ERROR(
lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_DATAFORMATTERS),
- std::move(err), "Failed to get scratch ClangASTContext");
+ std::move(err), "Failed to get scratch TypeSystemClang");
return;
}
- ClangASTContext *clang_ast_context =
- llvm::dyn_cast<ClangASTContext>(&type_system_or_err.get());
+ TypeSystemClang *clang_ast_context =
+ llvm::dyn_cast<TypeSystemClang>(&type_system_or_err.get());
if (!clang_ast_context) {
return;
}
- ClangASTImporterSP clang_ast_importer = target_sp->GetClangASTImporter();
+ std::shared_ptr<ClangASTImporter> clang_ast_importer;
+ auto *state = target_sp->GetPersistentExpressionStateForLanguage(
+ lldb::eLanguageTypeC_plus_plus);
+ if (state) {
+ auto *persistent_vars = llvm::cast<ClangPersistentVariables>(state);
+ clang_ast_importer = persistent_vars->GetClangASTImporter();
+ }
if (!clang_ast_importer) {
return;
diff --git a/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.h b/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.h
index 624c17a6a6af8..23f3f7b34b4f4 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.h
+++ b/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_BlockPointer_h_
-#define liblldb_BlockPointer_h_
+#ifndef LLDB_SOURCE_PLUGINS_LANGUAGE_CPLUSPLUS_BLOCKPOINTER_H
+#define LLDB_SOURCE_PLUGINS_LANGUAGE_CPLUSPLUS_BLOCKPOINTER_H
#include "lldb/lldb-forward.h"
@@ -22,4 +22,4 @@ BlockPointerSyntheticFrontEndCreator(CXXSyntheticChildren *,
} // namespace formatters
} // namespace lldb_private
-#endif // liblldb_BlockPointer_h_
+#endif // LLDB_SOURCE_PLUGINS_LANGUAGE_CPLUSPLUS_BLOCKPOINTER_H
diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
index 4385a60f58623..08e43ae6b3e81 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -1,4 +1,4 @@
-//===-- CPlusPlusLanguage.cpp -----------------------------------*- C++ -*-===//
+//===-- CPlusPlusLanguage.cpp ---------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -43,6 +43,8 @@ using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::formatters;
+LLDB_PLUGIN_DEFINE(CPlusPlusLanguage)
+
void CPlusPlusLanguage::Initialize() {
PluginManager::RegisterPlugin(GetPluginNameStatic(), "C++ Language",
CreateInstance);
@@ -68,7 +70,9 @@ uint32_t CPlusPlusLanguage::GetPluginVersion() { return 1; }
// Static Functions
Language *CPlusPlusLanguage::CreateInstance(lldb::LanguageType language) {
- if (Language::LanguageIsCPlusPlus(language))
+ // Use plugin for C++ but not for Objective-C++ (which has its own plugin).
+ if (Language::LanguageIsCPlusPlus(language) &&
+ language != eLanguageTypeObjC_plus_plus)
return new CPlusPlusLanguage();
return nullptr;
}
@@ -125,7 +129,7 @@ static bool IsTrivialBasename(const llvm::StringRef &basename) {
return false; // Empty string or "~"
if (!std::isalpha(basename[idx]) && basename[idx] != '_')
- return false; // First charater (after removing the possible '~'') isn't in
+ return false; // First character (after removing the possible '~'') isn't in
// [A-Za-z_]
// Read all characters matching [A-Za-z_0-9]
@@ -230,7 +234,7 @@ std::string CPlusPlusLanguage::MethodName::GetScopeQualifiedName() {
if (!m_parsed)
Parse();
if (m_context.empty())
- return m_basename;
+ return std::string(m_basename);
std::string res;
res += m_context;
@@ -609,6 +613,15 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
"shared_ptr synthetic children",
ConstString("^(std::__[[:alnum:]]+::)shared_ptr<.+>(( )?&)?$"),
stl_synth_flags, true);
+
+ ConstString libcxx_std_unique_ptr_regex(
+ "^std::__[[:alnum:]]+::unique_ptr<.+>(( )?&)?$");
+ AddCXXSynthetic(
+ cpp_category_sp,
+ lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEndCreator,
+ "unique_ptr synthetic children", libcxx_std_unique_ptr_regex,
+ stl_synth_flags, true);
+
AddCXXSynthetic(
cpp_category_sp,
lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEndCreator,
@@ -713,6 +726,10 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
"libc++ std::weak_ptr summary provider",
ConstString("^std::__[[:alnum:]]+::weak_ptr<.+>(( )?&)?$"),
stl_summary_flags, true);
+ AddCXXSummary(cpp_category_sp,
+ lldb_private::formatters::LibcxxUniquePointerSummaryProvider,
+ "libc++ std::unique_ptr summary provider",
+ libcxx_std_unique_ptr_regex, stl_summary_flags, true);
AddCXXSynthetic(
cpp_category_sp,
diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
index 4ed45bc904ce0..89dea08a2c530 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_CPlusPlusLanguage_h_
-#define liblldb_CPlusPlusLanguage_h_
+#ifndef LLDB_SOURCE_PLUGINS_LANGUAGE_CPLUSPLUS_CPLUSPLUSLANGUAGE_H
+#define LLDB_SOURCE_PLUGINS_LANGUAGE_CPLUSPLUS_CPLUSPLUSLANGUAGE_H
#include <set>
#include <vector>
@@ -133,4 +133,4 @@ public:
} // namespace lldb_private
-#endif // liblldb_CPlusPlusLanguage_h_
+#endif // LLDB_SOURCE_PLUGINS_LANGUAGE_CPLUSPLUS_CPLUSPLUSLANGUAGE_H
diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp
index 932db17b964a5..eca36fff18f83 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp
@@ -1,4 +1,4 @@
-//===-- CPlusPlusNameParser.cpp ---------------------------------*- C++ -*-===//
+//===-- CPlusPlusNameParser.cpp -------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -329,6 +329,37 @@ bool CPlusPlusNameParser::ConsumeOperator() {
}
const auto &token = Peek();
+
+ // When clang generates debug info it adds template parameters to names.
+ // Since clang doesn't add a space between the name and the template parameter
+ // in some cases we are not generating valid C++ names e.g.:
+ //
+ // operator<<A::B>
+ //
+ // In some of these cases we will not parse them correctly. This fixes the
+ // issue by detecting this case and inserting tok::less in place of
+ // tok::lessless and returning successfully that we consumed the operator.
+ if (token.getKind() == tok::lessless) {
+ // Make sure we have more tokens before attempting to look ahead one more.
+ if (m_next_token_index + 1 < m_tokens.size()) {
+ // Look ahead two tokens.
+ clang::Token n_token = m_tokens[m_next_token_index + 1];
+ // If we find ( or < then this is indeed operator<< no need for fix.
+ if (n_token.getKind() != tok::l_paren && n_token.getKind() != tok::less) {
+ clang::Token tmp_tok;
+ tmp_tok.startToken();
+ tmp_tok.setLength(1);
+ tmp_tok.setLocation(token.getLocation().getLocWithOffset(1));
+ tmp_tok.setKind(tok::less);
+
+ m_tokens[m_next_token_index] = tmp_tok;
+
+ start_position.Remove();
+ return true;
+ }
+ }
+ }
+
switch (token.getKind()) {
case tok::kw_new:
case tok::kw_delete:
diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.h b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.h
index 414c3a0091577..6fe6b12725b00 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.h
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.h
@@ -6,9 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_CPlusPlusNameParser_h_
-#define liblldb_CPlusPlusNameParser_h_
-
+#ifndef LLDB_SOURCE_PLUGINS_LANGUAGE_CPLUSPLUS_CPLUSPLUSNAMEPARSER_H
+#define LLDB_SOURCE_PLUGINS_LANGUAGE_CPLUSPLUS_CPLUSPLUSNAMEPARSER_H
#include "clang/Lex/Lexer.h"
#include "llvm/ADT/Optional.h"
@@ -174,4 +173,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_CPlusPlusNameParser_h_
+#endif // LLDB_SOURCE_PLUGINS_LANGUAGE_CPLUSPLUS_CPLUSPLUSNAMEPARSER_H
diff --git a/lldb/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp b/lldb/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp
index 3ea7589d8e4a8..41bbd2b01a1e7 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp
@@ -1,4 +1,4 @@
-//===-- CxxStringTypes.cpp --------------------------------------*- C++ -*-===//
+//===-- CxxStringTypes.cpp ------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -10,13 +10,13 @@
#include "llvm/Support/ConvertUTF.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
#include "lldb/DataFormatters/StringPrinter.h"
#include "lldb/DataFormatters/TypeSummary.h"
#include "lldb/Host/Time.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Target/ProcessStructReader.h"
#include "lldb/Target/SectionLoadList.h"
#include "lldb/Target/Target.h"
diff --git a/lldb/source/Plugins/Language/CPlusPlus/CxxStringTypes.h b/lldb/source/Plugins/Language/CPlusPlus/CxxStringTypes.h
index 35498b3b568f7..2713ded45929c 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CxxStringTypes.h
+++ b/lldb/source/Plugins/Language/CPlusPlus/CxxStringTypes.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_CxxStringTypes_h_
-#define liblldb_CxxStringTypes_h_
+#ifndef LLDB_SOURCE_PLUGINS_LANGUAGE_CPLUSPLUS_CXXSTRINGTYPES_H
+#define LLDB_SOURCE_PLUGINS_LANGUAGE_CPLUSPLUS_CXXSTRINGTYPES_H
#include "lldb/Core/ValueObject.h"
#include "lldb/DataFormatters/TypeSummary.h"
@@ -46,4 +46,4 @@ bool WCharSummaryProvider(ValueObject &valobj, Stream &stream,
} // namespace formatters
} // namespace lldb_private
-#endif // liblldb_CxxStringTypes_h_
+#endif // LLDB_SOURCE_PLUGINS_LANGUAGE_CPLUSPLUS_CXXSTRINGTYPES_H
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
index ecadaef7a87ed..84dd09a47d8ac 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
@@ -1,4 +1,4 @@
-//===-- LibCxx.cpp ----------------------------------------------*- C++ -*-===//
+//===-- LibCxx.cpp --------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -8,7 +8,6 @@
#include "LibCxx.h"
-#include "llvm/ADT/ScopeExit.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/FormatEntity.h"
#include "lldb/Core/ValueObject.h"
@@ -17,7 +16,6 @@
#include "lldb/DataFormatters/StringPrinter.h"
#include "lldb/DataFormatters/TypeSummary.h"
#include "lldb/DataFormatters/VectorIterator.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Target/ProcessStructReader.h"
#include "lldb/Target/SectionLoadList.h"
#include "lldb/Target/Target.h"
@@ -27,6 +25,7 @@
#include "lldb/Utility/Stream.h"
#include "Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
using namespace lldb;
using namespace lldb_private;
@@ -145,6 +144,43 @@ bool lldb_private::formatters::LibcxxSmartPointerSummaryProvider(
return true;
}
+bool lldb_private::formatters::LibcxxUniquePointerSummaryProvider(
+ ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
+ ValueObjectSP valobj_sp(valobj.GetNonSyntheticValue());
+ if (!valobj_sp)
+ return false;
+
+ ValueObjectSP ptr_sp(
+ valobj_sp->GetChildMemberWithName(ConstString("__ptr_"), true));
+ if (!ptr_sp)
+ return false;
+
+ ptr_sp = GetValueOfLibCXXCompressedPair(*ptr_sp);
+ if (!ptr_sp)
+ return false;
+
+ if (ptr_sp->GetValueAsUnsigned(0) == 0) {
+ stream.Printf("nullptr");
+ return true;
+ } else {
+ bool print_pointee = false;
+ Status error;
+ ValueObjectSP pointee_sp = ptr_sp->Dereference(error);
+ if (pointee_sp && error.Success()) {
+ if (pointee_sp->DumpPrintableRepresentation(
+ stream, ValueObject::eValueObjectRepresentationStyleSummary,
+ lldb::eFormatInvalid,
+ ValueObject::PrintableRepresentationSpecialCases::eDisable,
+ false))
+ print_pointee = true;
+ }
+ if (!print_pointee)
+ stream.Printf("ptr = 0x%" PRIx64, ptr_sp->GetValueAsUnsigned(0));
+ }
+
+ return true;
+}
+
/*
(lldb) fr var ibeg --raw --ptr-depth 1
(std::__1::__map_iterator<std::__1::__tree_iterator<std::__1::pair<int,
@@ -241,8 +277,8 @@ bool lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::Update() {
auto addr(m_pair_ptr->GetValueAsUnsigned(LLDB_INVALID_ADDRESS));
m_pair_ptr = nullptr;
if (addr && addr != LLDB_INVALID_ADDRESS) {
- ClangASTContext *ast_ctx =
- llvm::dyn_cast_or_null<ClangASTContext>(pair_type.GetTypeSystem());
+ TypeSystemClang *ast_ctx =
+ llvm::dyn_cast_or_null<TypeSystemClang>(pair_type.GetTypeSystem());
if (!ast_ctx)
return false;
CompilerType tree_node_type = ast_ctx->CreateStructForIdentifier(
@@ -450,6 +486,67 @@ lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEndCreator(
: nullptr);
}
+lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEnd::
+ LibcxxUniquePtrSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp)
+ : SyntheticChildrenFrontEnd(*valobj_sp), m_compressed_pair_sp() {
+ if (valobj_sp)
+ Update();
+}
+
+lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEnd::
+ ~LibcxxUniquePtrSyntheticFrontEnd() = default;
+
+SyntheticChildrenFrontEnd *
+lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEndCreator(
+ CXXSyntheticChildren *, lldb::ValueObjectSP valobj_sp) {
+ return (valobj_sp ? new LibcxxUniquePtrSyntheticFrontEnd(valobj_sp)
+ : nullptr);
+}
+
+size_t lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEnd::
+ CalculateNumChildren() {
+ return (m_compressed_pair_sp ? 1 : 0);
+}
+
+lldb::ValueObjectSP
+lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEnd::GetChildAtIndex(
+ size_t idx) {
+ if (!m_compressed_pair_sp)
+ return lldb::ValueObjectSP();
+
+ if (idx != 0)
+ return lldb::ValueObjectSP();
+
+ return m_compressed_pair_sp;
+}
+
+bool lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEnd::Update() {
+ ValueObjectSP valobj_sp = m_backend.GetSP();
+ if (!valobj_sp)
+ return false;
+
+ ValueObjectSP ptr_sp(
+ valobj_sp->GetChildMemberWithName(ConstString("__ptr_"), true));
+ if (!ptr_sp)
+ return false;
+
+ m_compressed_pair_sp = GetValueOfLibCXXCompressedPair(*ptr_sp);
+
+ return false;
+}
+
+bool lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEnd::
+ MightHaveChildren() {
+ return true;
+}
+
+size_t lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEnd::
+ GetIndexOfChildWithName(ConstString name) {
+ if (name == "__value_")
+ return 0;
+ return UINT32_MAX;
+}
+
bool lldb_private::formatters::LibcxxContainerSummaryProvider(
ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
if (valobj.IsPointerType()) {
@@ -469,22 +566,20 @@ enum LibcxxStringLayoutMode {
eLibcxxStringLayoutModeInvalid = 0xffff
};
-// this function abstracts away the layout and mode details of a libc++ string
-// and returns the address of the data and the size ready for callers to
-// consume
-static bool ExtractLibcxxStringInfo(ValueObject &valobj,
- ValueObjectSP &location_sp,
- uint64_t &size) {
+/// Determine the size in bytes of \p valobj (a libc++ std::string object) and
+/// extract its data payload. Return the size + payload pair.
+static llvm::Optional<std::pair<uint64_t, ValueObjectSP>>
+ExtractLibcxxStringInfo(ValueObject &valobj) {
ValueObjectSP D(valobj.GetChildAtIndexPath({0, 0, 0, 0}));
if (!D)
- return false;
+ return {};
ValueObjectSP layout_decider(
D->GetChildAtIndexPath(llvm::ArrayRef<size_t>({0, 0})));
// this child should exist
if (!layout_decider)
- return false;
+ return {};
ConstString g_data_name("__data_");
ConstString g_size_name("__size_");
@@ -498,13 +593,13 @@ static bool ExtractLibcxxStringInfo(ValueObject &valobj,
if (layout == eLibcxxStringLayoutModeDSC) {
ValueObjectSP size_mode(D->GetChildAtIndexPath({1, 1, 0}));
if (!size_mode)
- return false;
+ return {};
if (size_mode->GetName() != g_size_name) {
// we are hitting the padding structure, move along
size_mode = D->GetChildAtIndexPath({1, 1, 1});
if (!size_mode)
- return false;
+ return {};
}
size_mode_value = (size_mode->GetValueAsUnsigned(0));
@@ -512,7 +607,7 @@ static bool ExtractLibcxxStringInfo(ValueObject &valobj,
} else {
ValueObjectSP size_mode(D->GetChildAtIndexPath({1, 0, 0}));
if (!size_mode)
- return false;
+ return {};
size_mode_value = (size_mode->GetValueAsUnsigned(0));
short_mode = ((size_mode_value & 1) == 0);
@@ -521,36 +616,58 @@ static bool ExtractLibcxxStringInfo(ValueObject &valobj,
if (short_mode) {
ValueObjectSP s(D->GetChildAtIndex(1, true));
if (!s)
- return false;
- location_sp = s->GetChildAtIndex(
+ return {};
+ ValueObjectSP location_sp = s->GetChildAtIndex(
(layout == eLibcxxStringLayoutModeDSC) ? 0 : 1, true);
- size = (layout == eLibcxxStringLayoutModeDSC)
- ? size_mode_value
- : ((size_mode_value >> 1) % 256);
- return (location_sp.get() != nullptr);
- } else {
- ValueObjectSP l(D->GetChildAtIndex(0, true));
- if (!l)
- return false;
- // we can use the layout_decider object as the data pointer
- location_sp = (layout == eLibcxxStringLayoutModeDSC)
- ? layout_decider
- : l->GetChildAtIndex(2, true);
- ValueObjectSP size_vo(l->GetChildAtIndex(1, true));
- if (!size_vo || !location_sp)
- return false;
- size = size_vo->GetValueAsUnsigned(0);
- return true;
+ const uint64_t size = (layout == eLibcxxStringLayoutModeDSC)
+ ? size_mode_value
+ : ((size_mode_value >> 1) % 256);
+
+ // When the small-string optimization takes place, the data must fit in the
+ // inline string buffer (23 bytes on x86_64/Darwin). If it doesn't, it's
+ // likely that the string isn't initialized and we're reading garbage.
+ ExecutionContext exe_ctx(location_sp->GetExecutionContextRef());
+ const llvm::Optional<uint64_t> max_bytes =
+ location_sp->GetCompilerType().GetByteSize(
+ exe_ctx.GetBestExecutionContextScope());
+ if (!max_bytes || size > *max_bytes || !location_sp)
+ return {};
+
+ return std::make_pair(size, location_sp);
}
+
+ ValueObjectSP l(D->GetChildAtIndex(0, true));
+ if (!l)
+ return {};
+ // we can use the layout_decider object as the data pointer
+ ValueObjectSP location_sp = (layout == eLibcxxStringLayoutModeDSC)
+ ? layout_decider
+ : l->GetChildAtIndex(2, true);
+ ValueObjectSP size_vo(l->GetChildAtIndex(1, true));
+ const unsigned capacity_index =
+ (layout == eLibcxxStringLayoutModeDSC) ? 2 : 0;
+ ValueObjectSP capacity_vo(l->GetChildAtIndex(capacity_index, true));
+ if (!size_vo || !location_sp || !capacity_vo)
+ return {};
+ const uint64_t size = size_vo->GetValueAsUnsigned(LLDB_INVALID_OFFSET);
+ const uint64_t capacity =
+ capacity_vo->GetValueAsUnsigned(LLDB_INVALID_OFFSET);
+ if (size == LLDB_INVALID_OFFSET || capacity == LLDB_INVALID_OFFSET ||
+ capacity < size)
+ return {};
+ return std::make_pair(size, location_sp);
}
bool lldb_private::formatters::LibcxxWStringSummaryProvider(
ValueObject &valobj, Stream &stream,
const TypeSummaryOptions &summary_options) {
- uint64_t size = 0;
- ValueObjectSP location_sp;
- if (!ExtractLibcxxStringInfo(valobj, location_sp, size))
+ auto string_info = ExtractLibcxxStringInfo(valobj);
+ if (!string_info)
return false;
+ uint64_t size;
+ ValueObjectSP location_sp;
+ std::tie(size, location_sp) = *string_info;
+
if (size == 0) {
stream.Printf("L\"\"");
return true;
@@ -558,10 +675,8 @@ bool lldb_private::formatters::LibcxxWStringSummaryProvider(
if (!location_sp)
return false;
- DataExtractor extractor;
StringPrinter::ReadBufferAndDumpToStreamOptions options(valobj);
-
if (summary_options.GetCapping() == TypeSummaryCapping::eTypeSummaryCapped) {
const auto max_size = valobj.GetTargetSP()->GetMaximumSizeOfStringSummary();
if (size > max_size) {
@@ -569,11 +684,15 @@ bool lldb_private::formatters::LibcxxWStringSummaryProvider(
options.SetIsTruncated(true);
}
}
- location_sp->GetPointeeData(extractor, 0, size);
+
+ DataExtractor extractor;
+ const size_t bytes_read = location_sp->GetPointeeData(extractor, 0, size);
+ if (bytes_read < size)
+ return false;
// std::wstring::size() is measured in 'characters', not bytes
- ClangASTContext *ast_context =
- ClangASTContext::GetScratch(*valobj.GetTargetSP());
+ TypeSystemClang *ast_context =
+ TypeSystemClang::GetScratch(*valobj.GetTargetSP());
if (!ast_context)
return false;
@@ -591,40 +710,35 @@ bool lldb_private::formatters::LibcxxWStringSummaryProvider(
switch (*wchar_t_size) {
case 1:
- StringPrinter::ReadBufferAndDumpToStream<
+ return StringPrinter::ReadBufferAndDumpToStream<
lldb_private::formatters::StringPrinter::StringElementType::UTF8>(
options);
break;
case 2:
- lldb_private::formatters::StringPrinter::ReadBufferAndDumpToStream<
+ return StringPrinter::ReadBufferAndDumpToStream<
lldb_private::formatters::StringPrinter::StringElementType::UTF16>(
options);
break;
case 4:
- lldb_private::formatters::StringPrinter::ReadBufferAndDumpToStream<
+ return StringPrinter::ReadBufferAndDumpToStream<
lldb_private::formatters::StringPrinter::StringElementType::UTF32>(
options);
- break;
-
- default:
- stream.Printf("size for wchar_t is not valid");
- return true;
}
-
- return true;
+ return false;
}
template <StringPrinter::StringElementType element_type>
bool LibcxxStringSummaryProvider(ValueObject &valobj, Stream &stream,
const TypeSummaryOptions &summary_options,
- std::string prefix_token = "") {
- uint64_t size = 0;
- ValueObjectSP location_sp;
-
- if (!ExtractLibcxxStringInfo(valobj, location_sp, size))
+ std::string prefix_token) {
+ auto string_info = ExtractLibcxxStringInfo(valobj);
+ if (!string_info)
return false;
+ uint64_t size;
+ ValueObjectSP location_sp;
+ std::tie(size, location_sp) = *string_info;
if (size == 0) {
stream.Printf("\"\"");
@@ -636,7 +750,6 @@ bool LibcxxStringSummaryProvider(ValueObject &valobj, Stream &stream,
StringPrinter::ReadBufferAndDumpToStreamOptions options(valobj);
- DataExtractor extractor;
if (summary_options.GetCapping() == TypeSummaryCapping::eTypeSummaryCapped) {
const auto max_size = valobj.GetTargetSP()->GetMaximumSizeOfStringSummary();
if (size > max_size) {
@@ -644,41 +757,55 @@ bool LibcxxStringSummaryProvider(ValueObject &valobj, Stream &stream,
options.SetIsTruncated(true);
}
}
- location_sp->GetPointeeData(extractor, 0, size);
+
+ DataExtractor extractor;
+ const size_t bytes_read = location_sp->GetPointeeData(extractor, 0, size);
+ if (bytes_read < size)
+ return false;
options.SetData(extractor);
options.SetStream(&stream);
-
if (prefix_token.empty())
options.SetPrefixToken(nullptr);
else
options.SetPrefixToken(prefix_token);
-
options.SetQuote('"');
options.SetSourceSize(size);
options.SetBinaryZeroIsTerminator(false);
- StringPrinter::ReadBufferAndDumpToStream<element_type>(options);
+ return StringPrinter::ReadBufferAndDumpToStream<element_type>(options);
+}
+template <StringPrinter::StringElementType element_type>
+static bool formatStringImpl(ValueObject &valobj, Stream &stream,
+ const TypeSummaryOptions &summary_options,
+ std::string prefix_token) {
+ StreamString scratch_stream;
+ const bool success = LibcxxStringSummaryProvider<element_type>(
+ valobj, scratch_stream, summary_options, prefix_token);
+ if (success)
+ stream << scratch_stream.GetData();
+ else
+ stream << "Summary Unavailable";
return true;
}
bool lldb_private::formatters::LibcxxStringSummaryProviderASCII(
ValueObject &valobj, Stream &stream,
const TypeSummaryOptions &summary_options) {
- return LibcxxStringSummaryProvider<StringPrinter::StringElementType::ASCII>(
- valobj, stream, summary_options);
+ return formatStringImpl<StringPrinter::StringElementType::ASCII>(
+ valobj, stream, summary_options, "");
}
bool lldb_private::formatters::LibcxxStringSummaryProviderUTF16(
ValueObject &valobj, Stream &stream,
const TypeSummaryOptions &summary_options) {
- return LibcxxStringSummaryProvider<StringPrinter::StringElementType::UTF16>(
+ return formatStringImpl<StringPrinter::StringElementType::UTF16>(
valobj, stream, summary_options, "u");
}
bool lldb_private::formatters::LibcxxStringSummaryProviderUTF32(
ValueObject &valobj, Stream &stream,
const TypeSummaryOptions &summary_options) {
- return LibcxxStringSummaryProvider<StringPrinter::StringElementType::UTF32>(
+ return formatStringImpl<StringPrinter::StringElementType::UTF32>(
valobj, stream, summary_options, "U");
}
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.h b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.h
index 214f5512e4a50..ea5a7c1781783 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.h
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_LibCxx_h_
-#define liblldb_LibCxx_h_
+#ifndef LLDB_SOURCE_PLUGINS_LANGUAGE_CPLUSPLUS_LIBCXX_H
+#define LLDB_SOURCE_PLUGINS_LANGUAGE_CPLUSPLUS_LIBCXX_H
#include "lldb/Core/ValueObject.h"
#include "lldb/DataFormatters/TypeSummary.h"
@@ -43,6 +43,10 @@ bool LibcxxSmartPointerSummaryProvider(
const TypeSummaryOptions
&options); // libc++ std::shared_ptr<> and std::weak_ptr<>
+// libc++ std::unique_ptr<>
+bool LibcxxUniquePointerSummaryProvider(ValueObject &valobj, Stream &stream,
+ const TypeSummaryOptions &options);
+
bool LibcxxFunctionSummaryProvider(
ValueObject &valobj, Stream &stream,
const TypeSummaryOptions &options); // libc++ std::function<>
@@ -107,6 +111,26 @@ private:
lldb::ByteOrder m_byte_order;
};
+class LibcxxUniquePtrSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
+public:
+ LibcxxUniquePtrSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp);
+
+ size_t CalculateNumChildren() override;
+
+ lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
+
+ bool Update() override;
+
+ bool MightHaveChildren() override;
+
+ size_t GetIndexOfChildWithName(ConstString name) override;
+
+ ~LibcxxUniquePtrSyntheticFrontEnd() override;
+
+private:
+ lldb::ValueObjectSP m_compressed_pair_sp;
+};
+
SyntheticChildrenFrontEnd *
LibcxxBitsetSyntheticFrontEndCreator(CXXSyntheticChildren *,
lldb::ValueObjectSP);
@@ -116,6 +140,10 @@ LibcxxSharedPtrSyntheticFrontEndCreator(CXXSyntheticChildren *,
lldb::ValueObjectSP);
SyntheticChildrenFrontEnd *
+LibcxxUniquePtrSyntheticFrontEndCreator(CXXSyntheticChildren *,
+ lldb::ValueObjectSP);
+
+SyntheticChildrenFrontEnd *
LibcxxStdVectorSyntheticFrontEndCreator(CXXSyntheticChildren *,
lldb::ValueObjectSP);
@@ -156,4 +184,4 @@ LibcxxVariantFrontEndCreator(CXXSyntheticChildren *,
} // namespace formatters
} // namespace lldb_private
-#endif // liblldb_LibCxx_h_
+#endif // LLDB_SOURCE_PLUGINS_LANGUAGE_CPLUSPLUS_LIBCXX_H
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxAtomic.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxAtomic.cpp
index b4e7a1703e46a..45d4322e93d7d 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxAtomic.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxAtomic.cpp
@@ -1,5 +1,4 @@
-//===-- LibCxxAtomic.cpp ------------------------------------------*- C++
-//-*-===//
+//===-- LibCxxAtomic.cpp --------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -8,6 +7,7 @@
//===----------------------------------------------------------------------===//
#include "LibCxxAtomic.h"
+#include "lldb/DataFormatters/FormattersHelpers.h"
using namespace lldb;
using namespace lldb_private;
@@ -101,8 +101,6 @@ public:
size_t GetIndexOfChildWithName(ConstString name) override;
- lldb::ValueObjectSP GetSyntheticValue() override;
-
private:
ValueObject *m_real_child;
};
@@ -128,26 +126,20 @@ bool lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd::
size_t lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd::
CalculateNumChildren() {
- return m_real_child ? m_real_child->GetNumChildren() : 0;
+ return m_real_child ? 1 : 0;
}
lldb::ValueObjectSP
lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd::GetChildAtIndex(
size_t idx) {
- return m_real_child ? m_real_child->GetChildAtIndex(idx, true) : nullptr;
+ if (idx == 0)
+ return m_real_child->GetSP()->Clone(ConstString("Value"));
+ return nullptr;
}
size_t lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd::
GetIndexOfChildWithName(ConstString name) {
- return m_real_child ? m_real_child->GetIndexOfChildWithName(name)
- : UINT32_MAX;
-}
-
-lldb::ValueObjectSP lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd::
- GetSyntheticValue() {
- if (m_real_child && m_real_child->CanProvideValue())
- return m_real_child->GetSP();
- return nullptr;
+ return formatters::ExtractIndexFromString(name.GetCString());
}
SyntheticChildrenFrontEnd *
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxAtomic.h b/lldb/source/Plugins/Language/CPlusPlus/LibCxxAtomic.h
index 8be833dd82f6e..6fcceb645c7be 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxAtomic.h
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxAtomic.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_LibCxxAtomic_h_
-#define liblldb_LibCxxAtomic_h_
+#ifndef LLDB_SOURCE_PLUGINS_LANGUAGE_CPLUSPLUS_LIBCXXATOMIC_H
+#define LLDB_SOURCE_PLUGINS_LANGUAGE_CPLUSPLUS_LIBCXXATOMIC_H
#include "lldb/Core/ValueObject.h"
#include "lldb/DataFormatters/TypeSummary.h"
@@ -30,4 +30,4 @@ LibcxxAtomicSyntheticFrontEndCreator(CXXSyntheticChildren *,
} // namespace formatters
} // namespace lldb_private
-#endif // liblldb_LibCxxAtomic_h_
+#endif // LLDB_SOURCE_PLUGINS_LANGUAGE_CPLUSPLUS_LIBCXXATOMIC_H
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxBitset.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxBitset.cpp
index 78c453cd1b3c7..6de4637a6a4ac 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxBitset.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxBitset.cpp
@@ -1,4 +1,4 @@
-//===-- LibCxxBitset.cpp ----------------------------------------*- C++ -*-===//
+//===-- LibCxxBitset.cpp --------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//
#include "LibCxx.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Target/Target.h"
using namespace lldb;
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp
index 79c7434f617f8..65e88d114fcc2 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp
@@ -1,4 +1,4 @@
-//===-- LibCxxInitializerList.cpp -------------------------------*- C++ -*-===//
+//===-- LibCxxInitializerList.cpp -----------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp
index f5281f2ce532b..0d5ae16a0b295 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp
@@ -1,4 +1,4 @@
-//===-- LibCxxList.cpp ------------------------------------------*- C++ -*-===//
+//===-- LibCxxList.cpp ----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -8,10 +8,10 @@
#include "LibCxx.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/DataBufferHeap.h"
#include "lldb/Utility/Endian.h"
@@ -290,15 +290,6 @@ ValueObjectSP ForwardListFrontEnd::GetChildAtIndex(size_t idx) {
m_element_type);
}
-static ValueObjectSP GetValueOfCompressedPair(ValueObject &pair) {
- ValueObjectSP value = pair.GetChildMemberWithName(ConstString("__value_"), true);
- if (! value) {
- // pre-r300140 member name
- value = pair.GetChildMemberWithName(ConstString("__first_"), true);
- }
- return value;
-}
-
bool ForwardListFrontEnd::Update() {
AbstractListFrontEnd::Update();
@@ -311,7 +302,7 @@ bool ForwardListFrontEnd::Update() {
m_backend.GetChildMemberWithName(ConstString("__before_begin_"), true));
if (!impl_sp)
return false;
- impl_sp = GetValueOfCompressedPair(*impl_sp);
+ impl_sp = GetValueOfLibCXXCompressedPair(*impl_sp);
if (!impl_sp)
return false;
m_head = impl_sp->GetChildMemberWithName(ConstString("__next_"), true).get();
@@ -332,7 +323,7 @@ size_t ListFrontEnd::CalculateNumChildren() {
ValueObjectSP size_alloc(
m_backend.GetChildMemberWithName(ConstString("__size_alloc_"), true));
if (size_alloc) {
- ValueObjectSP value = GetValueOfCompressedPair(*size_alloc);
+ ValueObjectSP value = GetValueOfLibCXXCompressedPair(*size_alloc);
if (value) {
m_count = value->GetValueAsUnsigned(UINT32_MAX);
}
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp
index f6d8d4d9a7eb9..64a199e24e4a5 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp
@@ -1,4 +1,4 @@
-//===-- LibCxxMap.cpp -------------------------------------------*- C++ -*-===//
+//===-- LibCxxMap.cpp -----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -8,10 +8,10 @@
#include "LibCxx.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/DataBufferHeap.h"
#include "lldb/Utility/Endian.h"
@@ -298,8 +298,8 @@ void lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetValueOffset(
UINT32_MAX) {
m_skip_size = bit_offset / 8u;
} else {
- ClangASTContext *ast_ctx =
- llvm::dyn_cast_or_null<ClangASTContext>(node_type.GetTypeSystem());
+ TypeSystemClang *ast_ctx =
+ llvm::dyn_cast_or_null<TypeSystemClang>(node_type.GetTypeSystem());
if (!ast_ctx)
return;
CompilerType tree_node_type = ast_ctx->CreateStructForIdentifier(
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxOptional.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxOptional.cpp
index b1ad171d0b0c6..c0c8196328512 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxOptional.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxOptional.cpp
@@ -1,4 +1,4 @@
-//===-- LibCxxOptional.cpp --------------------------------------*- C++ -*-===//
+//===-- LibCxxOptional.cpp ------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -26,11 +26,12 @@ public:
bool MightHaveChildren() override { return true; }
bool Update() override;
- size_t CalculateNumChildren() override { return m_size; }
+ size_t CalculateNumChildren() override { return m_has_value ? 1U : 0U; }
ValueObjectSP GetChildAtIndex(size_t idx) override;
private:
- size_t m_size = 0;
+ /// True iff the option contains a value.
+ bool m_has_value = false;
};
} // namespace
@@ -44,13 +45,13 @@ bool OptionalFrontEnd::Update() {
// __engaged_ is a bool flag and is true if the optional contains a value.
// Converting it to unsigned gives us a size of 1 if it contains a value
// and 0 if not.
- m_size = engaged_sp->GetValueAsUnsigned(0);
+ m_has_value = engaged_sp->GetValueAsUnsigned(0) == 1;
return false;
}
ValueObjectSP OptionalFrontEnd::GetChildAtIndex(size_t idx) {
- if (idx >= m_size)
+ if (!m_has_value)
return ValueObjectSP();
// __val_ contains the underlying value of an optional if it has one.
@@ -71,7 +72,7 @@ ValueObjectSP OptionalFrontEnd::GetChildAtIndex(size_t idx) {
if (!holder_type)
return ValueObjectSP();
- return val_sp->Clone(ConstString(llvm::formatv("Value").str()));
+ return val_sp->Clone(ConstString("Value"));
}
SyntheticChildrenFrontEnd *
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxQueue.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxQueue.cpp
index 2f06d684f953c..616ffdca107d3 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxQueue.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxQueue.cpp
@@ -1,4 +1,4 @@
-//===-- LibCxxQueue.cpp -----------------------------------------*- C++ -*-===//
+//===-- LibCxxQueue.cpp ---------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxTuple.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxTuple.cpp
index 45294e25f0f5d..a113fe98c6b63 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxTuple.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxTuple.cpp
@@ -1,4 +1,4 @@
-//===-- LibCxxTuple.cpp -----------------------------------------*- C++ -*-===//
+//===-- LibCxxTuple.cpp ---------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
index b2c38c915c815..3a441973fc731 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
@@ -1,4 +1,4 @@
-//===-- LibCxxUnorderedMap.cpp ----------------------------------*- C++ -*-===//
+//===-- LibCxxUnorderedMap.cpp --------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -8,10 +8,10 @@
#include "LibCxx.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/DataBufferHeap.h"
#include "lldb/Utility/Endian.h"
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxVariant.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxVariant.cpp
index 62945bd3ce80b..951bf2896fb08 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxVariant.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxVariant.cpp
@@ -1,4 +1,4 @@
-//===-- LibCxxVariant.cpp --------------------------------------*- C++ -*-===//
+//===-- LibCxxVariant.cpp -------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -60,10 +60,10 @@ using namespace lldb_private;
namespace {
// libc++ std::variant index could have one of three states
-// 1) VALID, we can obtain it and its not variant_npos
-// 2) INVALID, we can't obtain it or it is not a type we expect
-// 3) NPOS, its value is variant_npos which means the variant has no value
-enum class LibcxxVariantIndexValidity { VALID, INVALID, NPOS };
+// 1) Valid, we can obtain it and its not variant_npos
+// 2) Invalid, we can't obtain it or it is not a type we expect
+// 3) NPos, its value is variant_npos which means the variant has no value
+enum class LibcxxVariantIndexValidity { Valid, Invalid, NPos };
LibcxxVariantIndexValidity
LibcxxVariantGetIndexValidity(ValueObjectSP &impl_sp) {
@@ -71,14 +71,14 @@ LibcxxVariantGetIndexValidity(ValueObjectSP &impl_sp) {
impl_sp->GetChildMemberWithName(ConstString("__index"), true));
if (!index_sp)
- return LibcxxVariantIndexValidity::INVALID;
+ return LibcxxVariantIndexValidity::Invalid;
int64_t index_value = index_sp->GetValueAsSigned(0);
if (index_value == -1)
- return LibcxxVariantIndexValidity::NPOS;
+ return LibcxxVariantIndexValidity::NPos;
- return LibcxxVariantIndexValidity::VALID;
+ return LibcxxVariantIndexValidity::Valid;
}
llvm::Optional<uint64_t> LibcxxVariantIndexValue(ValueObjectSP &impl_sp) {
@@ -129,10 +129,10 @@ bool LibcxxVariantSummaryProvider(ValueObject &valobj, Stream &stream,
LibcxxVariantIndexValidity validity = LibcxxVariantGetIndexValidity(impl_sp);
- if (validity == LibcxxVariantIndexValidity::INVALID)
+ if (validity == LibcxxVariantIndexValidity::Invalid)
return false;
- if (validity == LibcxxVariantIndexValidity::NPOS) {
+ if (validity == LibcxxVariantIndexValidity::NPos) {
stream.Printf(" No Value");
return true;
}
@@ -159,7 +159,7 @@ bool LibcxxVariantSummaryProvider(ValueObject &valobj, Stream &stream,
if (!template_type)
return false;
- stream.Printf(" Active Type = %s ", template_type.GetTypeName().GetCString());
+ stream << " Active Type = " << template_type.GetDisplayTypeName() << " ";
return true;
}
@@ -196,10 +196,10 @@ bool VariantFrontEnd::Update() {
LibcxxVariantIndexValidity validity = LibcxxVariantGetIndexValidity(impl_sp);
- if (validity == LibcxxVariantIndexValidity::INVALID)
+ if (validity == LibcxxVariantIndexValidity::Invalid)
return false;
- if (validity == LibcxxVariantIndexValidity::NPOS)
+ if (validity == LibcxxVariantIndexValidity::NPos)
return true;
m_size = 1;
@@ -242,7 +242,7 @@ ValueObjectSP VariantFrontEnd::GetChildAtIndex(size_t idx) {
if (!head_value)
return ValueObjectSP();
- return head_value->Clone(ConstString(ConstString("Value").AsCString()));
+ return head_value->Clone(ConstString("Value"));
}
SyntheticChildrenFrontEnd *
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxVariant.h b/lldb/source/Plugins/Language/CPlusPlus/LibCxxVariant.h
index 65db5aeaa99de..b4c27ccb9d771 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxVariant.h
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxVariant.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_LibCxxVariant_h_
-#define liblldb_LibCxxVariant_h_
+#ifndef LLDB_SOURCE_PLUGINS_LANGUAGE_CPLUSPLUS_LIBCXXVARIANT_H
+#define LLDB_SOURCE_PLUGINS_LANGUAGE_CPLUSPLUS_LIBCXXVARIANT_H
#include "lldb/Core/ValueObject.h"
#include "lldb/DataFormatters/TypeSummary.h"
@@ -27,4 +27,4 @@ SyntheticChildrenFrontEnd *LibcxxVariantFrontEndCreator(CXXSyntheticChildren *,
} // namespace formatters
} // namespace lldb_private
-#endif // liblldb_LibCxxVariant_h_
+#endif // LLDB_SOURCE_PLUGINS_LANGUAGE_CPLUSPLUS_LIBCXXVARIANT_H
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp
index bcd7442bc6693..43f76b0df8101 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp
@@ -1,4 +1,4 @@
-//===-- LibCxxVector.cpp ----------------------------------------*- C++ -*-===//
+//===-- LibCxxVector.cpp --------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp
index 0e0f6663c924b..b4af67ecee0dd 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp
@@ -1,4 +1,4 @@
-//===-- LibStdcpp.cpp -------------------------------------------*- C++ -*-===//
+//===-- LibStdcpp.cpp -----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -8,11 +8,11 @@
#include "LibStdcpp.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/DataFormatters/StringPrinter.h"
#include "lldb/DataFormatters/VectorIterator.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/DataBufferHeap.h"
#include "lldb/Utility/Endian.h"
@@ -259,6 +259,7 @@ bool lldb_private::formatters::LibStdcppStringSummaryProvider(
if (error.Fail())
return false;
options.SetSourceSize(size_of_data);
+ options.SetHasSourceSize(true);
if (!StringPrinter::ReadStringAndDumpToStream<
StringPrinter::StringElementType::UTF8>(options)) {
@@ -319,6 +320,7 @@ bool lldb_private::formatters::LibStdcppWStringSummaryProvider(
if (error.Fail())
return false;
options.SetSourceSize(size_of_data);
+ options.SetHasSourceSize(true);
options.SetPrefixToken("L");
switch (wchar_size) {
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.h b/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.h
index e7f88d667c141..9e41aa0ffc011 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.h
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_LibStdCpp_h_
-#define liblldb_LibStdCpp_h_
+#ifndef LLDB_SOURCE_PLUGINS_LANGUAGE_CPLUSPLUS_LIBSTDCPP_H
+#define LLDB_SOURCE_PLUGINS_LANGUAGE_CPLUSPLUS_LIBSTDCPP_H
#include "lldb/Core/ValueObject.h"
#include "lldb/DataFormatters/TypeSummary.h"
@@ -56,4 +56,4 @@ LibStdcppUniquePtrSyntheticFrontEndCreator(CXXSyntheticChildren *,
} // namespace formatters
} // namespace lldb_private
-#endif // liblldb_LibStdCpp_h_
+#endif // LLDB_SOURCE_PLUGINS_LANGUAGE_CPLUSPLUS_LIBSTDCPP_H
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp
index 0ac7b8f8e02b0..7ba59ff9d1adb 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp
@@ -1,4 +1,4 @@
-//===-- LibStdcppTuple.cpp --------------------------------------*- C++ -*-===//
+//===-- LibStdcppTuple.cpp ------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp
index cceb511cdc465..0b34b4e2fc899 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp
@@ -1,4 +1,4 @@
-//===-- LibStdcppUniquePointer.cpp ------------------------------*- C++ -*-===//
+//===-- LibStdcppUniquePointer.cpp ----------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.cpp b/lldb/source/Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.cpp
index 248c51acea420..b24bcc1344e23 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.cpp
@@ -1,4 +1,4 @@
-//===-- MSVCUndecoratedNameParser.cpp ---------------------------*- C++ -*-===//
+//===-- MSVCUndecoratedNameParser.cpp -------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.h b/lldb/source/Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.h
index 6e20877cae1b5..e5b60a0a1d5be 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.h
+++ b/lldb/source/Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_MSVCUndecoratedNameParser_h_
-#define liblldb_MSVCUndecoratedNameParser_h_
+#ifndef LLDB_SOURCE_PLUGINS_LANGUAGE_CPLUSPLUS_MSVCUNDECORATEDNAMEPARSER_H
+#define LLDB_SOURCE_PLUGINS_LANGUAGE_CPLUSPLUS_MSVCUNDECORATEDNAMEPARSER_H
#include <vector>