aboutsummaryrefslogtreecommitdiffstats
path: root/source/DataFormatters
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2019-10-23 17:53:01 +0000
committerDimitry Andric <dim@FreeBSD.org>2019-10-23 17:53:01 +0000
commitead246455adf1a215ec2715dad6533073a6beb4e (patch)
treef3f97a47d77053bf96fe74cdbd6fae74380e8a92 /source/DataFormatters
parentfdb00c4408990a0a63ef7f496d809ce59f263bc5 (diff)
downloadsrc-vendor/lldb.tar.gz
src-vendor/lldb.zip
Vendor import of stripped lldb trunk r375505, the last commit before thevendor/lldb/lldb-trunk-r375505vendor/lldb
upstream Subversion repository was made read-only, and the LLVM project migrated to GitHub: https://llvm.org/svn/llvm-project/lldb/trunk@375505
Notes
Notes: svn path=/vendor/lldb/dist/; revision=353952 svn path=/vendor/lldb/lldb-r375505/; revision=353953; tag=vendor/lldb/lldb-trunk-r375505
Diffstat (limited to 'source/DataFormatters')
-rw-r--r--source/DataFormatters/FormatManager.cpp180
-rw-r--r--source/DataFormatters/FormattersHelpers.cpp42
-rw-r--r--source/DataFormatters/TypeCategoryMap.cpp56
-rw-r--r--source/DataFormatters/TypeFormat.cpp2
-rw-r--r--source/DataFormatters/ValueObjectPrinter.cpp30
-rw-r--r--source/DataFormatters/VectorType.cpp22
6 files changed, 161 insertions, 171 deletions
diff --git a/source/DataFormatters/FormatManager.cpp b/source/DataFormatters/FormatManager.cpp
index dd2808a7cf7c..1eac372d79ec 100644
--- a/source/DataFormatters/FormatManager.cpp
+++ b/source/DataFormatters/FormatManager.cpp
@@ -30,7 +30,7 @@ struct FormatInfo {
// current format
};
-static FormatInfo g_format_infos[] = {
+static constexpr FormatInfo g_format_infos[] = {
{eFormatDefault, '\0', "default"},
{eFormatBoolean, 'B', "boolean"},
{eFormatBinary, 'b', "binary"},
@@ -69,7 +69,13 @@ static FormatInfo g_format_infos[] = {
{eFormatAddressInfo, 'A', "address"},
{eFormatHexFloat, '\0', "hex float"},
{eFormatInstruction, 'i', "instruction"},
- {eFormatVoid, 'v', "void"}};
+ {eFormatVoid, 'v', "void"},
+ {eFormatUnicode8, 'u', "unicode8"},
+};
+
+static_assert((sizeof(g_format_infos) / sizeof(g_format_infos[0])) ==
+ kNumFormats,
+ "All formats must have a corresponding info entry.");
static uint32_t g_num_format_infos = llvm::array_lengthof(g_format_infos);
@@ -630,30 +636,29 @@ FormatManager::GetFormat(ValueObject &valobj,
TypeFormatImplSP retval;
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_DATAFORMATTERS));
if (match_data.GetTypeForCache()) {
- if (log)
- log->Printf(
- "\n\n[FormatManager::GetFormat] Looking into cache for type %s",
- match_data.GetTypeForCache().AsCString("<invalid>"));
+ LLDB_LOGF(log,
+ "\n\n[FormatManager::GetFormat] Looking into cache for type %s",
+ match_data.GetTypeForCache().AsCString("<invalid>"));
if (m_format_cache.GetFormat(match_data.GetTypeForCache(), retval)) {
if (log) {
- log->Printf(
- "[FormatManager::GetFormat] Cache search success. Returning.");
+ LLDB_LOGF(
+ log, "[FormatManager::GetFormat] Cache search success. Returning.");
LLDB_LOGV(log, "Cache hits: {0} - Cache Misses: {1}",
m_format_cache.GetCacheHits(),
m_format_cache.GetCacheMisses());
}
return retval;
}
- if (log)
- log->Printf(
- "[FormatManager::GetFormat] Cache search failed. Going normal route");
+ LLDB_LOGF(
+ log,
+ "[FormatManager::GetFormat] Cache search failed. Going normal route");
}
retval = m_categories_map.GetFormat(match_data);
if (!retval) {
- if (log)
- log->Printf("[FormatManager::GetFormat] Search failed. Giving language a "
- "chance.");
+ LLDB_LOGF(log,
+ "[FormatManager::GetFormat] Search failed. Giving language a "
+ "chance.");
for (lldb::LanguageType lang_type : match_data.GetCandidateLanguages()) {
if (LanguageCategory *lang_category = GetCategoryForLanguage(lang_type)) {
if (lang_category->Get(match_data, retval))
@@ -661,24 +666,22 @@ FormatManager::GetFormat(ValueObject &valobj,
}
}
if (retval) {
- if (log)
- log->Printf(
- "[FormatManager::GetFormat] Language search success. Returning.");
+ LLDB_LOGF(
+ log,
+ "[FormatManager::GetFormat] Language search success. Returning.");
return retval;
}
}
if (!retval) {
- if (log)
- log->Printf("[FormatManager::GetFormat] Search failed. Giving hardcoded "
- "a chance.");
+ LLDB_LOGF(log, "[FormatManager::GetFormat] Search failed. Giving hardcoded "
+ "a chance.");
retval = GetHardcodedFormat(match_data);
}
if (match_data.GetTypeForCache() && (!retval || !retval->NonCacheable())) {
- if (log)
- log->Printf("[FormatManager::GetFormat] Caching %p for type %s",
- static_cast<void *>(retval.get()),
- match_data.GetTypeForCache().AsCString("<invalid>"));
+ LLDB_LOGF(log, "[FormatManager::GetFormat] Caching %p for type %s",
+ static_cast<void *>(retval.get()),
+ match_data.GetTypeForCache().AsCString("<invalid>"));
m_format_cache.SetFormat(match_data.GetTypeForCache(), retval);
}
LLDB_LOGV(log, "Cache hits: {0} - Cache Misses: {1}",
@@ -708,30 +711,29 @@ FormatManager::GetSummaryFormat(ValueObject &valobj,
TypeSummaryImplSP retval;
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_DATAFORMATTERS));
if (match_data.GetTypeForCache()) {
- if (log)
- log->Printf("\n\n[FormatManager::GetSummaryFormat] Looking into cache "
- "for type %s",
- match_data.GetTypeForCache().AsCString("<invalid>"));
+ LLDB_LOGF(log,
+ "\n\n[FormatManager::GetSummaryFormat] Looking into cache "
+ "for type %s",
+ match_data.GetTypeForCache().AsCString("<invalid>"));
if (m_format_cache.GetSummary(match_data.GetTypeForCache(), retval)) {
if (log) {
- log->Printf("[FormatManager::GetSummaryFormat] Cache search success. "
- "Returning.");
+ LLDB_LOGF(log,
+ "[FormatManager::GetSummaryFormat] Cache search success. "
+ "Returning.");
LLDB_LOGV(log, "Cache hits: {0} - Cache Misses: {1}",
m_format_cache.GetCacheHits(),
m_format_cache.GetCacheMisses());
}
return retval;
}
- if (log)
- log->Printf("[FormatManager::GetSummaryFormat] Cache search failed. "
- "Going normal route");
+ LLDB_LOGF(log, "[FormatManager::GetSummaryFormat] Cache search failed. "
+ "Going normal route");
}
retval = m_categories_map.GetSummaryFormat(match_data);
if (!retval) {
- if (log)
- log->Printf("[FormatManager::GetSummaryFormat] Search failed. Giving "
- "language a chance.");
+ LLDB_LOGF(log, "[FormatManager::GetSummaryFormat] Search failed. Giving "
+ "language a chance.");
for (lldb::LanguageType lang_type : match_data.GetCandidateLanguages()) {
if (LanguageCategory *lang_category = GetCategoryForLanguage(lang_type)) {
if (lang_category->Get(match_data, retval))
@@ -739,24 +741,21 @@ FormatManager::GetSummaryFormat(ValueObject &valobj,
}
}
if (retval) {
- if (log)
- log->Printf("[FormatManager::GetSummaryFormat] Language search "
- "success. Returning.");
+ LLDB_LOGF(log, "[FormatManager::GetSummaryFormat] Language search "
+ "success. Returning.");
return retval;
}
}
if (!retval) {
- if (log)
- log->Printf("[FormatManager::GetSummaryFormat] Search failed. Giving "
- "hardcoded a chance.");
+ LLDB_LOGF(log, "[FormatManager::GetSummaryFormat] Search failed. Giving "
+ "hardcoded a chance.");
retval = GetHardcodedSummaryFormat(match_data);
}
if (match_data.GetTypeForCache() && (!retval || !retval->NonCacheable())) {
- if (log)
- log->Printf("[FormatManager::GetSummaryFormat] Caching %p for type %s",
- static_cast<void *>(retval.get()),
- match_data.GetTypeForCache().AsCString("<invalid>"));
+ LLDB_LOGF(log, "[FormatManager::GetSummaryFormat] Caching %p for type %s",
+ static_cast<void *>(retval.get()),
+ match_data.GetTypeForCache().AsCString("<invalid>"));
m_format_cache.SetSummary(match_data.GetTypeForCache(), retval);
}
LLDB_LOGV(log, "Cache hits: {0} - Cache Misses: {1}",
@@ -786,30 +785,29 @@ FormatManager::GetSyntheticChildren(ValueObject &valobj,
SyntheticChildrenSP retval;
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_DATAFORMATTERS));
if (match_data.GetTypeForCache()) {
- if (log)
- log->Printf("\n\n[FormatManager::GetSyntheticChildren] Looking into "
- "cache for type %s",
- match_data.GetTypeForCache().AsCString("<invalid>"));
+ LLDB_LOGF(log,
+ "\n\n[FormatManager::GetSyntheticChildren] Looking into "
+ "cache for type %s",
+ match_data.GetTypeForCache().AsCString("<invalid>"));
if (m_format_cache.GetSynthetic(match_data.GetTypeForCache(), retval)) {
if (log) {
- log->Printf("[FormatManager::GetSyntheticChildren] Cache search "
- "success. Returning.");
+ LLDB_LOGF(log, "[FormatManager::GetSyntheticChildren] Cache search "
+ "success. Returning.");
LLDB_LOGV(log, "Cache hits: {0} - Cache Misses: {1}",
m_format_cache.GetCacheHits(),
m_format_cache.GetCacheMisses());
}
return retval;
}
- if (log)
- log->Printf("[FormatManager::GetSyntheticChildren] Cache search failed. "
- "Going normal route");
+ LLDB_LOGF(log, "[FormatManager::GetSyntheticChildren] Cache search failed. "
+ "Going normal route");
}
retval = m_categories_map.GetSyntheticChildren(match_data);
if (!retval) {
- if (log)
- log->Printf("[FormatManager::GetSyntheticChildren] Search failed. Giving "
- "language a chance.");
+ LLDB_LOGF(log,
+ "[FormatManager::GetSyntheticChildren] Search failed. Giving "
+ "language a chance.");
for (lldb::LanguageType lang_type : match_data.GetCandidateLanguages()) {
if (LanguageCategory *lang_category = GetCategoryForLanguage(lang_type)) {
if (lang_category->Get(match_data, retval))
@@ -817,25 +815,23 @@ FormatManager::GetSyntheticChildren(ValueObject &valobj,
}
}
if (retval) {
- if (log)
- log->Printf("[FormatManager::GetSyntheticChildren] Language search "
- "success. Returning.");
+ LLDB_LOGF(log, "[FormatManager::GetSyntheticChildren] Language search "
+ "success. Returning.");
return retval;
}
}
if (!retval) {
- if (log)
- log->Printf("[FormatManager::GetSyntheticChildren] Search failed. Giving "
- "hardcoded a chance.");
+ LLDB_LOGF(log,
+ "[FormatManager::GetSyntheticChildren] Search failed. Giving "
+ "hardcoded a chance.");
retval = GetHardcodedSyntheticChildren(match_data);
}
if (match_data.GetTypeForCache() && (!retval || !retval->NonCacheable())) {
- if (log)
- log->Printf(
- "[FormatManager::GetSyntheticChildren] Caching %p for type %s",
- static_cast<void *>(retval.get()),
- match_data.GetTypeForCache().AsCString("<invalid>"));
+ LLDB_LOGF(log,
+ "[FormatManager::GetSyntheticChildren] Caching %p for type %s",
+ static_cast<void *>(retval.get()),
+ match_data.GetTypeForCache().AsCString("<invalid>"));
m_format_cache.SetSynthetic(match_data.GetTypeForCache(), retval);
}
LLDB_LOGV(log, "Cache hits: {0} - Cache Misses: {1}",
@@ -851,13 +847,13 @@ FormatManager::GetValidator(ValueObject &valobj,
TypeValidatorImplSP retval;
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_DATAFORMATTERS));
if (match_data.GetTypeForCache()) {
- if (log)
- log->Printf(
- "\n\n[FormatManager::GetValidator] Looking into cache for type %s",
- match_data.GetTypeForCache().AsCString("<invalid>"));
+ LLDB_LOGF(
+ log, "\n\n[FormatManager::GetValidator] Looking into cache for type %s",
+ match_data.GetTypeForCache().AsCString("<invalid>"));
if (m_format_cache.GetValidator(match_data.GetTypeForCache(), retval)) {
if (log) {
- log->Printf(
+ LLDB_LOGF(
+ log,
"[FormatManager::GetValidator] Cache search success. Returning.");
LLDB_LOGV(log, "Cache hits: {0} - Cache Misses: {1}",
m_format_cache.GetCacheHits(),
@@ -865,16 +861,14 @@ FormatManager::GetValidator(ValueObject &valobj,
}
return retval;
}
- if (log)
- log->Printf("[FormatManager::GetValidator] Cache search failed. Going "
- "normal route");
+ LLDB_LOGF(log, "[FormatManager::GetValidator] Cache search failed. Going "
+ "normal route");
}
retval = m_categories_map.GetValidator(match_data);
if (!retval) {
- if (log)
- log->Printf("[FormatManager::GetValidator] Search failed. Giving "
- "language a chance.");
+ LLDB_LOGF(log, "[FormatManager::GetValidator] Search failed. Giving "
+ "language a chance.");
for (lldb::LanguageType lang_type : match_data.GetCandidateLanguages()) {
if (LanguageCategory *lang_category = GetCategoryForLanguage(lang_type)) {
if (lang_category->Get(match_data, retval))
@@ -882,24 +876,21 @@ FormatManager::GetValidator(ValueObject &valobj,
}
}
if (retval) {
- if (log)
- log->Printf("[FormatManager::GetValidator] Language search success. "
- "Returning.");
+ LLDB_LOGF(log, "[FormatManager::GetValidator] Language search success. "
+ "Returning.");
return retval;
}
}
if (!retval) {
- if (log)
- log->Printf("[FormatManager::GetValidator] Search failed. Giving "
- "hardcoded a chance.");
+ LLDB_LOGF(log, "[FormatManager::GetValidator] Search failed. Giving "
+ "hardcoded a chance.");
retval = GetHardcodedValidator(match_data);
}
if (match_data.GetTypeForCache() && (!retval || !retval->NonCacheable())) {
- if (log)
- log->Printf("[FormatManager::GetValidator] Caching %p for type %s",
- static_cast<void *>(retval.get()),
- match_data.GetTypeForCache().AsCString("<invalid>"));
+ LLDB_LOGF(log, "[FormatManager::GetValidator] Caching %p for type %s",
+ static_cast<void *>(retval.get()),
+ match_data.GetTypeForCache().AsCString("<invalid>"));
m_format_cache.SetValidator(match_data.GetTypeForCache(), retval);
}
LLDB_LOGV(log, "Cache hits: {0} - Cache Misses: {1}",
@@ -961,10 +952,7 @@ void FormatManager::LoadSystemFormatters() {
lldb::TypeSummaryImplSP string_array_format(
new StringSummaryFormat(string_array_flags, "${var%s}"));
- lldb::RegularExpressionSP any_size_char_arr(
- new RegularExpression(llvm::StringRef("char \\[[0-9]+\\]")));
- lldb::RegularExpressionSP any_size_wchar_arr(
- new RegularExpression(llvm::StringRef("wchar_t \\[[0-9]+\\]")));
+ RegularExpression any_size_char_arr(llvm::StringRef("char \\[[0-9]+\\]"));
TypeCategoryImpl::SharedPointer sys_category_sp =
GetCategory(m_system_category_name);
@@ -973,8 +961,8 @@ void FormatManager::LoadSystemFormatters() {
string_format);
sys_category_sp->GetTypeSummariesContainer()->Add(
ConstString("unsigned char *"), string_format);
- sys_category_sp->GetRegexTypeSummariesContainer()->Add(any_size_char_arr,
- string_array_format);
+ sys_category_sp->GetRegexTypeSummariesContainer()->Add(
+ std::move(any_size_char_arr), string_array_format);
lldb::TypeSummaryImplSP ostype_summary(
new StringSummaryFormat(TypeSummaryImpl::Flags()
diff --git a/source/DataFormatters/FormattersHelpers.cpp b/source/DataFormatters/FormattersHelpers.cpp
index 8f007df03faa..b2a5a17595c8 100644
--- a/source/DataFormatters/FormattersHelpers.cpp
+++ b/source/DataFormatters/FormattersHelpers.cpp
@@ -29,10 +29,10 @@ void lldb_private::formatters::AddFormat(
if (regex)
category_sp->GetRegexTypeFormatsContainer()->Add(
- RegularExpressionSP(new RegularExpression(type_name.GetStringRef())),
- format_sp);
+ RegularExpression(type_name.GetStringRef()), format_sp);
else
- category_sp->GetTypeFormatsContainer()->Add(type_name, format_sp);
+ category_sp->GetTypeFormatsContainer()->Add(std::move(type_name),
+ format_sp);
}
void lldb_private::formatters::AddSummary(
@@ -40,10 +40,10 @@ void lldb_private::formatters::AddSummary(
ConstString type_name, bool regex) {
if (regex)
category_sp->GetRegexTypeSummariesContainer()->Add(
- RegularExpressionSP(new RegularExpression(type_name.GetStringRef())),
- summary_sp);
+ RegularExpression(type_name.GetStringRef()), summary_sp);
else
- category_sp->GetTypeSummariesContainer()->Add(type_name, summary_sp);
+ category_sp->GetTypeSummariesContainer()->Add(std::move(type_name),
+ summary_sp);
}
void lldb_private::formatters::AddStringSummary(
@@ -53,10 +53,10 @@ void lldb_private::formatters::AddStringSummary(
if (regex)
category_sp->GetRegexTypeSummariesContainer()->Add(
- RegularExpressionSP(new RegularExpression(type_name.GetStringRef())),
- summary_sp);
+ RegularExpression(type_name.GetStringRef()), summary_sp);
else
- category_sp->GetTypeSummariesContainer()->Add(type_name, summary_sp);
+ category_sp->GetTypeSummariesContainer()->Add(std::move(type_name),
+ summary_sp);
}
void lldb_private::formatters::AddOneLineSummary(
@@ -67,10 +67,10 @@ void lldb_private::formatters::AddOneLineSummary(
if (regex)
category_sp->GetRegexTypeSummariesContainer()->Add(
- RegularExpressionSP(new RegularExpression(type_name.GetStringRef())),
- summary_sp);
+ RegularExpression(type_name.GetStringRef()), summary_sp);
else
- category_sp->GetTypeSummariesContainer()->Add(type_name, summary_sp);
+ category_sp->GetTypeSummariesContainer()->Add(std::move(type_name),
+ summary_sp);
}
void lldb_private::formatters::AddCXXSummary(
@@ -81,10 +81,10 @@ void lldb_private::formatters::AddCXXSummary(
new CXXFunctionSummaryFormat(flags, funct, description));
if (regex)
category_sp->GetRegexTypeSummariesContainer()->Add(
- RegularExpressionSP(new RegularExpression(type_name.GetStringRef())),
- summary_sp);
+ RegularExpression(type_name.GetStringRef()), summary_sp);
else
- category_sp->GetTypeSummariesContainer()->Add(type_name, summary_sp);
+ category_sp->GetTypeSummariesContainer()->Add(std::move(type_name),
+ summary_sp);
}
void lldb_private::formatters::AddCXXSynthetic(
@@ -96,10 +96,10 @@ void lldb_private::formatters::AddCXXSynthetic(
new CXXSyntheticChildren(flags, description, generator));
if (regex)
category_sp->GetRegexTypeSyntheticsContainer()->Add(
- RegularExpressionSP(new RegularExpression(type_name.GetStringRef())),
- synth_sp);
+ RegularExpression(type_name.GetStringRef()), synth_sp);
else
- category_sp->GetTypeSyntheticsContainer()->Add(type_name, synth_sp);
+ category_sp->GetTypeSyntheticsContainer()->Add(std::move(type_name),
+ synth_sp);
}
void lldb_private::formatters::AddFilter(
@@ -111,10 +111,10 @@ void lldb_private::formatters::AddFilter(
filter_sp->AddExpressionPath(child);
if (regex)
category_sp->GetRegexTypeFiltersContainer()->Add(
- RegularExpressionSP(new RegularExpression(type_name.GetStringRef())),
- filter_sp);
+ RegularExpression(type_name.GetStringRef()), filter_sp);
else
- category_sp->GetTypeFiltersContainer()->Add(type_name, filter_sp);
+ category_sp->GetTypeFiltersContainer()->Add(std::move(type_name),
+ filter_sp);
}
size_t lldb_private::formatters::ExtractIndexFromString(const char *item_name) {
diff --git a/source/DataFormatters/TypeCategoryMap.cpp b/source/DataFormatters/TypeCategoryMap.cpp
index 69757c9844e1..b1075e9878d8 100644
--- a/source/DataFormatters/TypeCategoryMap.cpp
+++ b/source/DataFormatters/TypeCategoryMap.cpp
@@ -180,7 +180,8 @@ TypeCategoryMap::GetFormat(FormattersMatchData &match_data) {
if (log) {
for (auto match : match_data.GetMatchesVector()) {
- log->Printf(
+ LLDB_LOGF(
+ log,
"[CategoryMap::GetFormat] candidate match = %s %s %s %s reason = "
"%" PRIu32,
match.GetTypeName().GetCString(),
@@ -194,18 +195,16 @@ TypeCategoryMap::GetFormat(FormattersMatchData &match_data) {
for (begin = m_active_categories.begin(); begin != end; begin++) {
lldb::TypeCategoryImplSP category_sp = *begin;
lldb::TypeFormatImplSP current_format;
- if (log)
- log->Printf("[TypeCategoryMap::GetFormat] Trying to use category %s",
- category_sp->GetName());
+ LLDB_LOGF(log, "[TypeCategoryMap::GetFormat] Trying to use category %s",
+ category_sp->GetName());
if (!category_sp->Get(match_data.GetValueObject(),
match_data.GetMatchesVector(), current_format,
&reason_why))
continue;
return current_format;
}
- if (log)
- log->Printf(
- "[TypeCategoryMap::GetFormat] nothing found - returning empty SP");
+ LLDB_LOGF(log,
+ "[TypeCategoryMap::GetFormat] nothing found - returning empty SP");
return lldb::TypeFormatImplSP();
}
@@ -220,7 +219,8 @@ TypeCategoryMap::GetSummaryFormat(FormattersMatchData &match_data) {
if (log) {
for (auto match : match_data.GetMatchesVector()) {
- log->Printf(
+ LLDB_LOGF(
+ log,
"[CategoryMap::GetSummaryFormat] candidate match = %s %s %s %s "
"reason = %" PRIu32,
match.GetTypeName().GetCString(),
@@ -234,18 +234,17 @@ TypeCategoryMap::GetSummaryFormat(FormattersMatchData &match_data) {
for (begin = m_active_categories.begin(); begin != end; begin++) {
lldb::TypeCategoryImplSP category_sp = *begin;
lldb::TypeSummaryImplSP current_format;
- if (log)
- log->Printf("[CategoryMap::GetSummaryFormat] Trying to use category %s",
- category_sp->GetName());
+ LLDB_LOGF(log, "[CategoryMap::GetSummaryFormat] Trying to use category %s",
+ category_sp->GetName());
if (!category_sp->Get(match_data.GetValueObject(),
match_data.GetMatchesVector(), current_format,
&reason_why))
continue;
return current_format;
}
- if (log)
- log->Printf(
- "[CategoryMap::GetSummaryFormat] nothing found - returning empty SP");
+ LLDB_LOGF(
+ log,
+ "[CategoryMap::GetSummaryFormat] nothing found - returning empty SP");
return lldb::TypeSummaryImplSP();
}
@@ -261,7 +260,8 @@ TypeCategoryMap::GetSyntheticChildren(FormattersMatchData &match_data) {
if (log) {
for (auto match : match_data.GetMatchesVector()) {
- log->Printf(
+ LLDB_LOGF(
+ log,
"[CategoryMap::GetSyntheticChildren] candidate match = %s %s %s %s "
"reason = %" PRIu32,
match.GetTypeName().GetCString(),
@@ -275,19 +275,18 @@ TypeCategoryMap::GetSyntheticChildren(FormattersMatchData &match_data) {
for (begin = m_active_categories.begin(); begin != end; begin++) {
lldb::TypeCategoryImplSP category_sp = *begin;
lldb::SyntheticChildrenSP current_format;
- if (log)
- log->Printf(
- "[CategoryMap::GetSyntheticChildren] Trying to use category %s",
- category_sp->GetName());
+ LLDB_LOGF(log,
+ "[CategoryMap::GetSyntheticChildren] Trying to use category %s",
+ category_sp->GetName());
if (!category_sp->Get(match_data.GetValueObject(),
match_data.GetMatchesVector(), current_format,
&reason_why))
continue;
return current_format;
}
- if (log)
- log->Printf("[CategoryMap::GetSyntheticChildren] nothing found - returning "
- "empty SP");
+ LLDB_LOGF(log,
+ "[CategoryMap::GetSyntheticChildren] nothing found - returning "
+ "empty SP");
return lldb::SyntheticChildrenSP();
}
@@ -302,7 +301,8 @@ TypeCategoryMap::GetValidator(FormattersMatchData &match_data) {
if (log) {
for (auto match : match_data.GetMatchesVector()) {
- log->Printf(
+ LLDB_LOGF(
+ log,
"[CategoryMap::GetValidator] candidate match = %s %s %s %s reason = "
"%" PRIu32,
match.GetTypeName().GetCString(),
@@ -316,18 +316,16 @@ TypeCategoryMap::GetValidator(FormattersMatchData &match_data) {
for (begin = m_active_categories.begin(); begin != end; begin++) {
lldb::TypeCategoryImplSP category_sp = *begin;
lldb::TypeValidatorImplSP current_format;
- if (log)
- log->Printf("[CategoryMap::GetValidator] Trying to use category %s",
- category_sp->GetName());
+ LLDB_LOGF(log, "[CategoryMap::GetValidator] Trying to use category %s",
+ category_sp->GetName());
if (!category_sp->Get(match_data.GetValueObject(),
match_data.GetMatchesVector(), current_format,
&reason_why))
continue;
return current_format;
}
- if (log)
- log->Printf(
- "[CategoryMap::GetValidator] nothing found - returning empty SP");
+ LLDB_LOGF(log,
+ "[CategoryMap::GetValidator] nothing found - returning empty SP");
return lldb::TypeValidatorImplSP();
}
diff --git a/source/DataFormatters/TypeFormat.cpp b/source/DataFormatters/TypeFormat.cpp
index b526e9a744bc..b272c2e8dc3b 100644
--- a/source/DataFormatters/TypeFormat.cpp
+++ b/source/DataFormatters/TypeFormat.cpp
@@ -164,7 +164,7 @@ bool TypeFormatImpl_EnumType::FormatObject(ValueObject *valobj,
llvm::DenseSet<lldb_private::SymbolFile *> searched_symbol_files;
images.FindTypes(nullptr, m_enum_type, false, UINT32_MAX,
searched_symbol_files, types);
- if (types.GetSize() == 0)
+ if (types.Empty())
return false;
for (lldb::TypeSP type_sp : types.Types()) {
if (!type_sp)
diff --git a/source/DataFormatters/ValueObjectPrinter.cpp b/source/DataFormatters/ValueObjectPrinter.cpp
index 409cffed9b0f..fa43c677a194 100644
--- a/source/DataFormatters/ValueObjectPrinter.cpp
+++ b/source/DataFormatters/ValueObjectPrinter.cpp
@@ -456,7 +456,7 @@ bool ValueObjectPrinter::PrintObjectDescriptionIfNeeded(bool value_printed,
if (object_desc[object_end] == '\n')
m_stream->Printf("%s", object_desc);
else
- m_stream->Printf("%s\n", object_desc);
+ m_stream->Printf("%s\n", object_desc);
return true;
} else if (!value_printed && !summary_printed)
return true;
@@ -751,34 +751,30 @@ bool ValueObjectPrinter::PrintChildrenOneLiner(bool hide_names) {
void ValueObjectPrinter::PrintChildrenIfNeeded(bool value_printed,
bool summary_printed) {
- // this flag controls whether we tried to display a description for this
- // object and failed if that happens, we want to display the children, if any
+ // This flag controls whether we tried to display a description for this
+ // object and failed if that happens, we want to display the children if any.
bool is_failed_description =
!PrintObjectDescriptionIfNeeded(value_printed, summary_printed);
- auto curr_ptr_depth = m_ptr_depth;
- bool print_children =
+ DumpValueObjectOptions::PointerDepth curr_ptr_depth = m_ptr_depth;
+ const bool print_children =
ShouldPrintChildren(is_failed_description, curr_ptr_depth);
- bool print_oneline =
+ const bool print_oneline =
(curr_ptr_depth.CanAllowExpansion() || m_options.m_show_types ||
!m_options.m_allow_oneliner_mode || m_options.m_flat_output ||
(m_options.m_pointer_as_array) || m_options.m_show_location)
? false
: DataVisualization::ShouldPrintAsOneLiner(*m_valobj);
- bool is_instance_ptr = IsInstancePointer();
- uint64_t instance_ptr_value = LLDB_INVALID_ADDRESS;
-
- if (print_children && is_instance_ptr) {
- instance_ptr_value = m_valobj->GetValueAsUnsigned(0);
+ if (print_children && IsInstancePointer()) {
+ uint64_t instance_ptr_value = m_valobj->GetValueAsUnsigned(0);
if (m_printed_instance_pointers->count(instance_ptr_value)) {
- // we already printed this instance-is-pointer thing, so don't expand it
+ // We already printed this instance-is-pointer thing, so don't expand it.
m_stream->PutCString(" {...}\n");
-
- // we're done here - get out fast
return;
- } else
- m_printed_instance_pointers->emplace(
- instance_ptr_value); // remember this guy for future reference
+ } else {
+ // Remember this guy for future reference.
+ m_printed_instance_pointers->emplace(instance_ptr_value);
+ }
}
if (print_children) {
diff --git a/source/DataFormatters/VectorType.cpp b/source/DataFormatters/VectorType.cpp
index 18880f72ef2e..26fc03a4cdc2 100644
--- a/source/DataFormatters/VectorType.cpp
+++ b/source/DataFormatters/VectorType.cpp
@@ -15,6 +15,7 @@
#include "lldb/Target/Target.h"
#include "lldb/Utility/LLDBAssert.h"
+#include "lldb/Utility/Log.h"
using namespace lldb;
using namespace lldb_private;
@@ -219,13 +220,20 @@ public:
CompilerType parent_type(m_backend.GetCompilerType());
CompilerType element_type;
parent_type.IsVectorType(&element_type, nullptr);
- TargetSP target_sp(m_backend.GetTargetSP());
- m_child_type = ::GetCompilerTypeForFormat(
- m_parent_format, element_type,
- target_sp
- ? target_sp->GetScratchTypeSystemForLanguage(nullptr,
- lldb::eLanguageTypeC)
- : nullptr);
+ TypeSystem *type_system = nullptr;
+ if (auto target_sp = m_backend.GetTargetSP()) {
+ auto type_system_or_err =
+ target_sp->GetScratchTypeSystemForLanguage(lldb::eLanguageTypeC);
+ if (auto err = type_system_or_err.takeError()) {
+ LLDB_LOG_ERROR(
+ lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_DATAFORMATTERS),
+ std::move(err), "Unable to update from scratch TypeSystem");
+ } else {
+ type_system = &type_system_or_err.get();
+ }
+ }
+ m_child_type =
+ ::GetCompilerTypeForFormat(m_parent_format, element_type, type_system);
m_num_children = ::CalculateNumChildren(parent_type, m_child_type);
m_item_format = GetItemFormatForFormat(m_parent_format, m_child_type);
return false;