diff options
Diffstat (limited to 'lldb/source/Core')
-rw-r--r-- | lldb/source/Core/DataVisualization.cpp | 2 | ||||
-rw-r--r-- | lldb/source/Core/Debugger.cpp | 64 | ||||
-rw-r--r-- | lldb/source/Core/FormatClasses.cpp | 125 | ||||
-rw-r--r-- | lldb/source/Core/FormatManager.cpp | 100 |
4 files changed, 257 insertions, 34 deletions
diff --git a/lldb/source/Core/DataVisualization.cpp b/lldb/source/Core/DataVisualization.cpp index 10a9c2a4bde..6974132617a 100644 --- a/lldb/source/Core/DataVisualization.cpp +++ b/lldb/source/Core/DataVisualization.cpp @@ -132,7 +132,7 @@ DataVisualization::Categories::Clear () void DataVisualization::Categories::Clear (ConstString &category) { - GetFormatManager().Category(category)->ClearSummaries(); + GetFormatManager().Category(category)->Clear(eFormatCategoryItemSummary | eFormatCategoryItemRegexSummary); } void diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp index 07cbe7b92a7..ecca589cab6 100644 --- a/lldb/source/Core/Debugger.cpp +++ b/lldb/source/Core/Debugger.cpp @@ -694,20 +694,13 @@ TestPromptFormats (StackFrame *frame) } } -#define IFERROR_PRINT_IT if (error.Fail()) \ -{ \ - if (log) \ - log->Printf("ERROR: %s\n", error.AsCString("unknown")); \ - break; \ -} - static bool -ScanFormatDescriptor(const char* var_name_begin, - const char* var_name_end, - const char** var_name_final, - const char** percent_position, - lldb::Format* custom_format, - ValueObject::ValueObjectRepresentationStyle* val_obj_display) +ScanFormatDescriptor (const char* var_name_begin, + const char* var_name_end, + const char** var_name_final, + const char** percent_position, + lldb::Format* custom_format, + ValueObject::ValueObjectRepresentationStyle* val_obj_display) { LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES)); *percent_position = ::strchr(var_name_begin,'%'); @@ -766,15 +759,15 @@ ScanFormatDescriptor(const char* var_name_begin, } static bool -ScanBracketedRange(const char* var_name_begin, - const char* var_name_end, - const char* var_name_final, - const char** open_bracket_position, - const char** separator_position, - const char** close_bracket_position, - const char** var_name_final_if_array_range, - int64_t* index_lower, - int64_t* index_higher) +ScanBracketedRange (const char* var_name_begin, + const char* var_name_end, + const char* var_name_final, + const char** open_bracket_position, + const char** separator_position, + const char** close_bracket_position, + const char** var_name_final_if_array_range, + int64_t* index_lower, + int64_t* index_higher) { LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES)); *open_bracket_position = ::strchr(var_name_begin,'['); @@ -829,12 +822,12 @@ ScanBracketedRange(const char* var_name_begin, static ValueObjectSP -ExpandExpressionPath(ValueObject* valobj, - StackFrame* frame, - bool* do_deref_pointer, - const char* var_name_begin, - const char* var_name_final, - Error& error) +ExpandExpressionPath (ValueObject* valobj, + StackFrame* frame, + bool* do_deref_pointer, + const char* var_name_begin, + const char* var_name_final, + Error& error) { LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES)); StreamString sstring; @@ -870,10 +863,10 @@ ExpandExpressionPath(ValueObject* valobj, } static ValueObjectSP -ExpandIndexedExpression(ValueObject* valobj, - uint32_t index, - StackFrame* frame, - bool deref_pointer) +ExpandIndexedExpression (ValueObject* valobj, + uint32_t index, + StackFrame* frame, + bool deref_pointer) { LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES)); const char* ptr_deref_format = "[%d]"; @@ -1153,7 +1146,12 @@ Debugger::FormatPrompt // to get to the target ValueObject Error error; target = target->Dereference(error).get(); - IFERROR_PRINT_IT + if (error.Fail()) + { + if (log) + log->Printf("ERROR: %s\n", error.AsCString("unknown")); \ + break; + } do_deref_pointer = false; } diff --git a/lldb/source/Core/FormatClasses.cpp b/lldb/source/Core/FormatClasses.cpp index cd09d0c4fc0..a23225d3825 100644 --- a/lldb/source/Core/FormatClasses.cpp +++ b/lldb/source/Core/FormatClasses.cpp @@ -30,6 +30,17 @@ using namespace lldb; using namespace lldb_private; +ValueFormat::ValueFormat (lldb::Format f, + bool casc, + bool skipptr, + bool skipref) : + m_cascades(casc), + m_skip_pointers(skipptr), + m_skip_references(skipref), + m_format (f) +{ +} + std::string ValueFormat::FormatObject(lldb::ValueObjectSP object) { @@ -54,6 +65,39 @@ ValueFormat::FormatObject(lldb::ValueObjectSP object) } } +SummaryFormat::SummaryFormat(bool casc, + bool skipptr, + bool skipref, + bool nochildren, + bool novalue, + bool oneliner) : + m_cascades(casc), + m_skip_pointers(skipptr), + m_skip_references(skipref), + m_dont_show_children(nochildren), + m_dont_show_value(novalue), + m_show_members_oneliner(oneliner) +{ +} + +StringSummaryFormat::StringSummaryFormat(bool casc, + bool skipptr, + bool skipref, + bool nochildren, + bool novalue, + bool oneliner, + std::string f) : + SummaryFormat(casc, + skipptr, + skipref, + nochildren, + novalue, + oneliner), + m_format(f) +{ +} + + std::string StringSummaryFormat::FormatObject(lldb::ValueObjectSP object) { @@ -119,6 +163,26 @@ StringSummaryFormat::GetDescription() return sstr.GetString(); } +ScriptSummaryFormat::ScriptSummaryFormat(bool casc, + bool skipptr, + bool skipref, + bool nochildren, + bool novalue, + bool oneliner, + std::string fname, + std::string pscri) : + SummaryFormat(casc, + skipptr, + skipref, + nochildren, + novalue, + oneliner), + m_function_name(fname), + m_python_script(pscri) +{ +} + + std::string ScriptSummaryFormat::FormatObject(lldb::ValueObjectSP object) { @@ -245,6 +309,27 @@ SyntheticScriptProvider::FrontEnd::FrontEnd(std::string pclass, m_wrapper = (PyObject*)m_interpreter->CreateSyntheticScriptedProvider(m_python_class, m_backend); } +lldb::ValueObjectSP +SyntheticScriptProvider::FrontEnd::GetChildAtIndex (uint32_t idx, bool can_create) +{ + if (m_wrapper == NULL || m_interpreter == NULL) + return lldb::ValueObjectSP(); + + PyObject* py_return = (PyObject*)m_interpreter->GetChildAtIndex(m_wrapper, idx); + if (py_return == NULL || py_return == Py_None) + { + Py_XDECREF(py_return); + return lldb::ValueObjectSP(); + } + + lldb::SBValue *sb_ptr = m_interpreter->CastPyObjectToSBValue(py_return); + + if (py_return == NULL || sb_ptr == NULL) + return lldb::ValueObjectSP(); + + return sb_ptr->m_opaque_sp; +} + std::string SyntheticScriptProvider::GetDescription() { @@ -257,3 +342,43 @@ SyntheticScriptProvider::GetDescription() return sstr.GetString(); } + +const int +SyntheticArrayView::GetRealIndexForIndex(int i) +{ + if (i >= GetCount()) + return -1; + + SyntheticArrayRange* ptr = &m_head; + + int residual = i; + + while(ptr && ptr != m_tail) + { + if (residual >= ptr->GetSelfCount()) + { + residual -= ptr->GetSelfCount(); + ptr = ptr->GetNext(); + } + + return ptr->GetLow() + residual; + } + + return -1; +} + +uint32_t +SyntheticArrayView::FrontEnd::GetIndexOfChildWithName (const ConstString &name_cs) +{ + const char* name_cstr = name_cs.GetCString(); + if (*name_cstr != '[') + return UINT32_MAX; + std::string name(name_cstr+1); + if (name[name.size()-1] != ']') + return UINT32_MAX; + name = name.erase(name.size()-1,1); + int index = Args::StringToSInt32 (name.c_str(), -1); + if (index < 0) + return UINT32_MAX; + return index; +}
\ No newline at end of file diff --git a/lldb/source/Core/FormatManager.cpp b/lldb/source/Core/FormatManager.cpp index 9e7fe8602b8..89f92166475 100644 --- a/lldb/source/Core/FormatManager.cpp +++ b/lldb/source/Core/FormatManager.cpp @@ -169,6 +169,22 @@ FormatCategory::FormatCategory(IFormatChangeListener* clist, {} bool +FormatCategory::Get (ValueObject& valobj, + lldb::SummaryFormatSP& entry, + lldb::DynamicValueType use_dynamic, + uint32_t* reason) +{ + if (!IsEnabled()) + return false; + if (GetSummaryNavigator()->Get(valobj, entry, use_dynamic, reason)) + return true; + bool regex = GetRegexSummaryNavigator()->Get(valobj, entry, use_dynamic, reason); + if (regex && reason) + *reason |= lldb::eFormatterChoiceCriterionRegularExpressionSummary; + return regex; +} + +bool FormatCategory::Get(ValueObject& valobj, lldb::SyntheticChildrenSP& entry, lldb::DynamicValueType use_dynamic, @@ -364,6 +380,73 @@ FormatCategory::AnyMatches(ConstString type_name, return false; } +bool +CategoryMap::AnyMatches (ConstString type_name, + FormatCategory::FormatCategoryItems items, + bool only_enabled, + const char** matching_category, + FormatCategory::FormatCategoryItems* matching_type) +{ + Mutex::Locker(m_map_mutex); + + MapIterator pos, end = m_map.end(); + for (pos = m_map.begin(); pos != end; pos++) + { + if (pos->second->AnyMatches(type_name, + items, + only_enabled, + matching_category, + matching_type)) + return true; + } + return false; +} + +bool +CategoryMap::Get (ValueObject& valobj, + lldb::SummaryFormatSP& entry, + lldb::DynamicValueType use_dynamic) +{ + Mutex::Locker(m_map_mutex); + + uint32_t reason_why; + ActiveCategoriesIterator begin, end = m_active_categories.end(); + + for (begin = m_active_categories.begin(); begin != end; begin++) + { + lldb::FormatCategorySP category = *begin; + lldb::SummaryFormatSP current_format; + if (!category->Get(valobj, current_format, use_dynamic, &reason_why)) + continue; + entry = current_format; + return true; + } + return false; +} + +bool +CategoryMap::Get (ValueObject& valobj, + lldb::SyntheticChildrenSP& entry, + lldb::DynamicValueType use_dynamic) +{ + Mutex::Locker(m_map_mutex); + + uint32_t reason_why; + + ActiveCategoriesIterator begin, end = m_active_categories.end(); + + for (begin = m_active_categories.begin(); begin != end; begin++) + { + lldb::FormatCategorySP category = *begin; + lldb::SyntheticChildrenSP current_format; + if (!category->Get(valobj, current_format, use_dynamic, &reason_why)) + continue; + entry = current_format; + return true; + } + return false; +} + void CategoryMap::LoopThrough(CallbackType callback, void* param) { @@ -398,6 +481,23 @@ CategoryMap::LoopThrough(CallbackType callback, void* param) } } +lldb::FormatCategorySP +FormatManager::Category (const ConstString& category_name, + bool can_create) +{ + if (!category_name) + return Category(m_default_category_name); + lldb::FormatCategorySP category; + if (m_categories_map.Get(category_name, category)) + return category; + + if (!can_create) + return lldb::FormatCategorySP(); + + m_categories_map.Add(category_name,lldb::FormatCategorySP(new FormatCategory(this, category_name.AsCString()))); + return Category(category_name); +} + lldb::Format FormatManager::GetSingleItemFormat(lldb::Format vector_format) { |