19#include "llvm/ADT/STLExtras.h"
78 "All formats must have a corresponding info entry.");
94 bool partial_match_ok,
Format &format) {
103 if (partial_match_ok) {
106 .starts_with_insensitive(format_name)) {
122 iter.second->GetFormatCache().Clear();
127 bool partial_match_ok,
129 bool success =
false;
130 if (format_cstr && format_cstr[0]) {
131 if (format_cstr[1] ==
'\0') {
163 iter.second->Enable();
172 iter.second->Disable();
183 valobj.
GetTargetSP()->GetDebugger().GetScriptInterpreter();
188 entries.push_back({bitfieldname, script_interpreter,
189 TypeImpl(compiler_type), current_flags});
193 entries.push_back({type_name, script_interpreter,
TypeImpl(compiler_type),
197 if (display_type_name != type_name)
198 entries.push_back({display_type_name, script_interpreter,
199 TypeImpl(compiler_type), current_flags});
202 for (
bool is_rvalue_ref =
true, j =
true;
203 j && compiler_type.
IsReferenceType(
nullptr, &is_rvalue_ref); j =
false) {
209 deffed_referenced_type =
214 valobj, deffed_referenced_type,
235 if (compiler_type.
IsArrayType(
nullptr, &array_size,
nullptr)) {
246 valobj, deffed_array_type,
255 language->GetPossibleFormattersMatches(valobj, use_dynamic)) {
256 entries.push_back(candidate);
275 if (!unqual_compiler_ast_type.
IsValid())
280 entries, current_flags);
288 static_value_sp->GetCompilerType(), use_dynamic,
289 entries, current_flags,
true);
294lldb::TypeFormatImplSP
297 return lldb::TypeFormatImplSP();
298 lldb::TypeFormatImplSP format_chosen_sp;
300 lldb::TypeCategoryImplSP category_sp;
302 for (
uint32_t category_id = 0; category_id < num_categories; category_id++) {
304 if (!category_sp->IsEnabled())
306 lldb::TypeFormatImplSP format_current_sp =
307 category_sp->GetFormatForType(type_sp);
308 if (format_current_sp &&
309 (format_chosen_sp.get() ==
nullptr ||
310 (prio_category > category_sp->GetEnabledPosition()))) {
311 prio_category = category_sp->GetEnabledPosition();
312 format_chosen_sp = format_current_sp;
315 return format_chosen_sp;
318lldb::TypeSummaryImplSP
321 return lldb::TypeSummaryImplSP();
322 lldb::TypeSummaryImplSP summary_chosen_sp;
324 lldb::TypeCategoryImplSP category_sp;
326 for (
uint32_t category_id = 0; category_id < num_categories; category_id++) {
328 if (!category_sp->IsEnabled())
330 lldb::TypeSummaryImplSP summary_current_sp =
331 category_sp->GetSummaryForType(type_sp);
332 if (summary_current_sp &&
333 (summary_chosen_sp.get() ==
nullptr ||
334 (prio_category > category_sp->GetEnabledPosition()))) {
335 prio_category = category_sp->GetEnabledPosition();
336 summary_chosen_sp = summary_current_sp;
339 return summary_chosen_sp;
342lldb::TypeFilterImplSP
345 return lldb::TypeFilterImplSP();
346 lldb::TypeFilterImplSP filter_chosen_sp;
348 lldb::TypeCategoryImplSP category_sp;
350 for (
uint32_t category_id = 0; category_id < num_categories; category_id++) {
352 if (!category_sp->IsEnabled())
354 lldb::TypeFilterImplSP filter_current_sp(
356 if (filter_current_sp &&
357 (filter_chosen_sp.get() ==
nullptr ||
358 (prio_category > category_sp->GetEnabledPosition()))) {
359 prio_category = category_sp->GetEnabledPosition();
360 filter_chosen_sp = filter_current_sp;
363 return filter_chosen_sp;
366lldb::ScriptedSyntheticChildrenSP
369 return lldb::ScriptedSyntheticChildrenSP();
370 lldb::ScriptedSyntheticChildrenSP synth_chosen_sp;
372 lldb::TypeCategoryImplSP category_sp;
374 for (
uint32_t category_id = 0; category_id < num_categories; category_id++) {
376 if (!category_sp->IsEnabled())
378 lldb::ScriptedSyntheticChildrenSP synth_current_sp(
381 if (synth_current_sp &&
382 (synth_chosen_sp.get() ==
nullptr ||
383 (prio_category > category_sp->GetEnabledPosition()))) {
384 prio_category = category_sp->GetEnabledPosition();
385 synth_chosen_sp = synth_current_sp;
388 return synth_chosen_sp;
395 if (
auto category_sp = entry.second->GetCategory()) {
396 if (!callback(category_sp))
402lldb::TypeCategoryImplSP
406 lldb::TypeCategoryImplSP category;
411 return lldb::TypeCategoryImplSP();
420 switch (vector_format) {
450 !valobj.
GetTargetSP()->GetDebugger().GetAutoOneLineSummaries())
475 size_t total_children_name_len = 0;
478 bool is_synth_val =
false;
485 CompilerType child_compiler_type(child_sp->GetCompilerType());
486 if (child_compiler_type.
IsValid()) {
500 if (child_sp->GetSyntheticChildren().get() !=
nullptr) {
501 ValueObjectSP synth_sp(child_sp->GetSyntheticValue());
506 if (!synth_sp->MightHaveChildren() &&
507 synth_sp->DoesProvideSyntheticValue())
513 total_children_name_len += child_sp->GetName().GetLength();
518 if (total_children_name_len > 50)
522 if (child_sp->GetSummaryFormat()) {
524 if (child_sp->GetSummaryFormat()->DoesPrintChildren(child_sp.get()))
529 if (child_sp->GetNumChildren()) {
535 if (!child_sp->GetSummaryFormat() && !is_synth_val)
549 if (valobj_sp && valobj_sp->GetCompilerType().IsValid()) {
550 if (!valobj_sp->GetCompilerType().IsMeaninglessWithoutDynamicResolution())
551 return valobj_sp->GetQualifiedTypeName();
556std::vector<lldb::LanguageType>
571 llvm_unreachable(
"Fully covered switch");
580 return iter->second.get();
584 return lang_category;
587template <
typename ImplSP>
592 if (lang_category->GetHardcoded(*
this, match_data, retval_sp))
599template <
typename ImplSP>
603 if (ImplSP retval_sp = GetCached<ImplSP>(match_data))
608 LLDB_LOGF(log,
"[%s] Search failed. Giving language a chance.", __FUNCTION__);
612 if (lang_category->Get(match_data, retval_sp))
614 LLDB_LOGF(log,
"[%s] Language search success. Returning.",
621 LLDB_LOGF(log,
"[%s] Search failed. Giving hardcoded a chance.",
623 return GetHardcoded<ImplSP>(match_data);
626template <
typename ImplSP>
631 LLDB_LOGF(log,
"\n\n[%s] Looking into cache for type %s", __FUNCTION__,
635 LLDB_LOGF(log,
"[%s] Cache search success. Returning.", __FUNCTION__);
636 LLDB_LOGV(log,
"Cache hits: {0} - Cache Misses: {1}",
642 LLDB_LOGF(log,
"[%s] Cache search failed. Going normal route",
647 if (match_data.
GetTypeForCache() && (!retval_sp || !retval_sp->NonCacheable())) {
648 LLDB_LOGF(log,
"[%s] Caching %p for type %s", __FUNCTION__,
649 static_cast<void *
>(retval_sp.get()),
653 LLDB_LOGV(log,
"Cache hits: {0} - Cache Misses: {1}",
658lldb::TypeFormatImplSP
664lldb::TypeSummaryImplSP
670lldb::SyntheticChildrenSP
677 : m_last_revision(0), m_format_cache(), m_language_categories_mutex(),
678 m_language_categories_map(), m_named_summaries_map(this),
679 m_categories_map(this), m_default_category_name(
ConstString(
"default")),
681 m_vectortypes_category_name(
ConstString(
"VectorTypes")) {
710 lldb::TypeSummaryImplSP string_format(
713 lldb::TypeSummaryImplSP string_array_format(
719 sys_category_sp->AddTypeSummary(R
"(^(unsigned )?char ?(\*|\[\])$)",
722 sys_category_sp->AddTypeSummary(R"(^((un)?signed )?char ?\[[0-9]+\]$)",
725 lldb::TypeSummaryImplSP ostype_summary(
728 .SetSkipPointers(
true)
729 .SetSkipReferences(
true)
730 .SetDontShowChildren(
true)
731 .SetDontShowValue(
false)
732 .SetShowMembersOneLiner(
false)
733 .SetHideItemNames(
false),
760 AddStringSummary(vectors_category_sp,
"${var.uint128}",
"builtin_type_vec128",
#define LLDB_LOGF(log,...)
#define LLDB_LOGV(log,...)
Generic representation of a type in a programming language.
CompilerType GetTypeForFormatters() const
CompilerType GetArrayType(uint64_t size) const
bool IsArrayType(CompilerType *element_type=nullptr, uint64_t *size=nullptr, bool *is_incomplete=nullptr) const
CompilerType GetRValueReferenceType() const
Return a new CompilerType that is a R value reference to this type if this type is valid and the type...
CompilerType GetPointerType() const
Return a new CompilerType that is a pointer to this type.
lldb::opaque_compiler_type_t GetOpaqueQualType() const
CompilerType GetLValueReferenceType() const
Return a new CompilerType that is a L value reference to this type if this type is valid and the type...
CompilerType GetNonReferenceType() const
If this type is a reference to a type (L value or R value reference), return a new type with the refe...
bool IsMeaninglessWithoutDynamicResolution() const
ConstString GetTypeName(bool BaseOnly=false) const
CompilerType GetTypedefedType() const
If the current object represents a typedef type, get the underlying type.
bool IsReferenceType(CompilerType *pointee_type=nullptr, bool *is_rvalue=nullptr) const
CompilerType GetArrayElementType(ExecutionContextScope *exe_scope) const
Creating related types.
CompilerType GetFullyUnqualifiedType() const
CompilerType GetPointeeType() const
If this type is a pointer type, return the type that the pointer points to, else return an invalid ty...
bool IsTypedefType() const
LazyBool ShouldPrintAsOneLiner(ValueObject *valobj) const
bool IsPointerType(CompilerType *pointee_type=nullptr) const
A uniqued constant string class.
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
ExecutionContextScope * GetBestExecutionContextScope() const
std::unique_ptr< LanguageCategory > UniquePointer
static Language * FindPlugin(lldb::LanguageType language)
llvm::StringRef GetString() const
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
std::shared_ptr< TypeCategoryImpl > SharedPointer
bool Get(KeyType name, ValueSP &entry)
void Add(KeyType name, const ValueSP &entry)
static const Position Last
std::function< bool(const ValueSP &)> ForEachCallback
void DisableAllCategories()
void EnableAllCategories()
void ForEach(ForEachCallback callback)
Flags & SetCascades(bool value=true)
Flags & SetSkipPointers(bool value=true)
Flags & SetHideItemNames(bool value=true)
Flags & SetDontShowChildren(bool value=true)
Flags & SetSkipReferences(bool value=true)
Flags & SetShowMembersOneLiner(bool value=true)
Flags & SetDontShowValue(bool value=true)
lldb::TypeSummaryImplSP GetSummaryFormat()
virtual uint32_t GetBitfieldBitSize()
virtual lldb::ValueObjectSP GetChildAtIndex(size_t idx, bool can_create)
size_t GetNumChildren(uint32_t max=UINT32_MAX)
CompilerType GetCompilerType()
lldb::ValueObjectSP GetQualifiedRepresentationIfAvailable(lldb::DynamicValueType dynValue, bool synthValue)
lldb::TargetSP GetTargetSP() const
virtual lldb::ValueObjectSP GetStaticValue()
virtual bool IsSynthetic()
const ExecutionContextRef & GetExecutionContextRef() const
virtual lldb::LanguageType GetObjectRuntimeLanguage()
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
template bool LanguageCategory::Get< lldb::TypeFormatImplSP >(FormattersMatchData &, lldb::TypeFormatImplSP &)
Explicit instantiations for the three types.
std::vector< FormattersMatchCandidate > FormattersMatchVector
template bool LanguageCategory::Get< lldb::SyntheticChildrenSP >(FormattersMatchData &, lldb::SyntheticChildrenSP &)
template bool LanguageCategory::Get< lldb::TypeSummaryImplSP >(FormattersMatchData &, lldb::TypeSummaryImplSP &)
Format
Display format definitions.
@ eFormatCString
NULL terminated C strings.
@ eFormatCharArray
Print characters with no single quotes, used for character arrays that can contain non printable char...
@ eFormatInstruction
Disassemble an opcode.
@ eFormatVoid
Do not print this.
@ eFormatHexFloat
ISO C99 hex float string.
@ eFormatOSType
OS character codes encoded into an integer 'PICT' 'text' etc...
@ eFormatAddressInfo
Describe what an address points to (func + offset.
@ eFormatCharPrintable
Only printable characters, '.' if not printable.
@ eFormatComplexInteger
Integer complex type.
LanguageType
Programming language type.
@ eLanguageTypeC_plus_plus_14
ISO C++:2014.
@ eLanguageTypeC11
ISO C:2011.
@ eLanguageTypeC99
ISO C:1999.
@ eLanguageTypeC_plus_plus_03
ISO C++:2003.
@ eLanguageTypeObjC_plus_plus
Objective-C++.
@ eLanguageTypeC_plus_plus_11
ISO C++:2011.
@ eLanguageTypeC89
ISO C:1989.
@ eLanguageTypeC
Non-standardized C, such as K&R.
@ eLanguageTypeObjC
Objective-C.
@ eLanguageTypeC_plus_plus
ISO C++:1998.