diff options
Diffstat (limited to 'lldb/source')
-rw-r--r-- | lldb/source/API/SBDebugger.cpp | 146 | ||||
-rw-r--r-- | lldb/source/API/SBTypeCategory.cpp | 556 | ||||
-rw-r--r-- | lldb/source/API/SBTypeFilter.cpp | 197 | ||||
-rw-r--r-- | lldb/source/API/SBTypeFormat.cpp | 153 | ||||
-rw-r--r-- | lldb/source/API/SBTypeNameSpecifier.cpp | 127 | ||||
-rw-r--r-- | lldb/source/API/SBTypeSummary.cpp | 298 | ||||
-rw-r--r-- | lldb/source/API/SBTypeSynthetic.cpp | 203 | ||||
-rw-r--r-- | lldb/source/Commands/CommandObjectFrame.cpp | 2 | ||||
-rw-r--r-- | lldb/source/Commands/CommandObjectType.cpp | 150 | ||||
-rw-r--r-- | lldb/source/Core/DataVisualization.cpp | 87 | ||||
-rw-r--r-- | lldb/source/Core/Debugger.cpp | 21 | ||||
-rw-r--r-- | lldb/source/Core/FormatClasses.cpp | 85 | ||||
-rw-r--r-- | lldb/source/Core/FormatManager.cpp | 199 | ||||
-rw-r--r-- | lldb/source/Core/ValueObject.cpp | 6 | ||||
-rw-r--r-- | lldb/source/Interpreter/ScriptInterpreterPython.cpp | 34 |
15 files changed, 2026 insertions, 238 deletions
diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp index 9c2eea065ce..f98ca35f813 100644 --- a/lldb/source/API/SBDebugger.cpp +++ b/lldb/source/API/SBDebugger.cpp @@ -25,6 +25,15 @@ #include "lldb/API/SBStringList.h" #include "lldb/API/SBTarget.h" #include "lldb/API/SBThread.h" +#include "lldb/API/SBTypeCategory.h" +#include "lldb/API/SBTypeFormat.h" +#include "lldb/API/SBTypeFilter.h" +#include "lldb/API/SBTypeNameSpecifier.h" +#include "lldb/API/SBTypeSummary.h" +#include "lldb/API/SBTypeSynthetic.h" + + +#include "lldb/Core/DataVisualization.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/State.h" #include "lldb/Interpreter/Args.h" @@ -1054,3 +1063,140 @@ SBDebugger::SetCloseInputOnEOF (bool b) if (m_opaque_sp) m_opaque_sp->SetCloseInputOnEOF (b); } + +SBTypeCategory +SBDebugger::GetCategory (const char* category_name) +{ + if (!category_name || *category_name == 0) + return SBTypeCategory(); + + TypeCategoryImplSP category_sp; + + if (DataVisualization::Categories::GetCategory(ConstString(category_name), category_sp, false)) + return SBTypeCategory(category_sp); + else + return SBTypeCategory(); +} + +SBTypeCategory +SBDebugger::CreateCategory (const char* category_name) +{ + if (!category_name || *category_name == 0) + return SBTypeCategory(); + + TypeCategoryImplSP category_sp; + + if (DataVisualization::Categories::GetCategory(ConstString(category_name), category_sp, true)) + return SBTypeCategory(category_sp); + else + return SBTypeCategory(); +} + +bool +SBDebugger::DeleteCategory (const char* category_name) +{ + if (!category_name || *category_name == 0) + return false; + + return DataVisualization::Categories::Delete(ConstString(category_name)); +} + +uint32_t +SBDebugger::GetNumCategories() +{ + return DataVisualization::Categories::GetCount(); +} + +SBTypeCategory +SBDebugger::GetCategoryAtIndex (uint32_t index) +{ + return SBTypeCategory(DataVisualization::Categories::GetCategoryAtIndex(index)); +} + +SBTypeCategory +SBDebugger::GetDefaultCategory() +{ + return GetCategory("default"); +} + +SBTypeFormat +SBDebugger::GetFormatForType (SBTypeNameSpecifier type_name) +{ + SBTypeCategory default_category_sb = GetDefaultCategory(); + if (default_category_sb.GetEnabled()) + return default_category_sb.GetFormatForType(type_name); + return SBTypeFormat(); +} + +SBTypeSummary +SBDebugger::GetSummaryForType (SBTypeNameSpecifier type_name) +{ + SBTypeSummary summary_chosen; + uint32_t num_categories = GetNumCategories(); + SBTypeCategory category_sb; + uint32_t prio_category = UINT32_MAX; + for (uint32_t category_id = 0; + category_id < num_categories; + category_id++) + { + category_sb = GetCategoryAtIndex(category_id); + if (category_sb.GetEnabled() == false) + continue; + SBTypeSummary summary_current = category_sb.GetSummaryForType(type_name); + if (summary_current.IsValid() && (summary_chosen.IsValid() == false || (prio_category > category_sb.m_opaque_sp->GetEnabledPosition()))) + { + prio_category = category_sb.m_opaque_sp->GetEnabledPosition(); + summary_chosen = summary_current; + } + } + return summary_chosen; +} + +SBTypeFilter +SBDebugger::GetFilterForType (SBTypeNameSpecifier type_name) +{ + SBTypeFilter filter_chosen; + uint32_t num_categories = GetNumCategories(); + SBTypeCategory category_sb; + uint32_t prio_category = UINT32_MAX; + for (uint32_t category_id = 0; + category_id < num_categories; + category_id++) + { + category_sb = GetCategoryAtIndex(category_id); + if (category_sb.GetEnabled() == false) + continue; + SBTypeFilter filter_current = category_sb.GetFilterForType(type_name); + if (filter_current.IsValid() && (filter_chosen.IsValid() == false || (prio_category > category_sb.m_opaque_sp->GetEnabledPosition()))) + { + prio_category = category_sb.m_opaque_sp->GetEnabledPosition(); + filter_chosen = filter_current; + } + } + return filter_chosen; +} + +SBTypeSynthetic +SBDebugger::GetSyntheticForType (SBTypeNameSpecifier type_name) +{ + SBTypeSynthetic synth_chosen; + uint32_t num_categories = GetNumCategories(); + SBTypeCategory category_sb; + uint32_t prio_category = UINT32_MAX; + for (uint32_t category_id = 0; + category_id < num_categories; + category_id++) + { + category_sb = GetCategoryAtIndex(category_id); + if (category_sb.GetEnabled() == false) + continue; + SBTypeSynthetic synth_current = category_sb.GetSyntheticForType(type_name); + if (synth_current.IsValid() && (synth_chosen.IsValid() == false || (prio_category > category_sb.m_opaque_sp->GetEnabledPosition()))) + { + prio_category = category_sb.m_opaque_sp->GetEnabledPosition(); + synth_chosen = synth_current; + } + } + return synth_chosen; +} + diff --git a/lldb/source/API/SBTypeCategory.cpp b/lldb/source/API/SBTypeCategory.cpp new file mode 100644 index 00000000000..b76f8444587 --- /dev/null +++ b/lldb/source/API/SBTypeCategory.cpp @@ -0,0 +1,556 @@ +//===-- SBTypeCategory.cpp ----------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "lldb/API/SBTypeCategory.h" + +#include "lldb/API/SBTypeFilter.h" +#include "lldb/API/SBTypeFormat.h" +#include "lldb/API/SBTypeSummary.h" +#include "lldb/API/SBTypeSynthetic.h" +#include "lldb/API/SBTypeNameSpecifier.h" +#include "lldb/API/SBStream.h" + +#include "lldb/Core/DataVisualization.h" +#include "lldb/Core/Debugger.h" +#include "lldb/Interpreter/CommandInterpreter.h" +#include "lldb/Interpreter/ScriptInterpreter.h" + +using namespace lldb; +using namespace lldb_private; + +typedef std::pair<lldb::TypeCategoryImplSP,user_id_t> ImplType; + +SBTypeCategory::SBTypeCategory() : +m_opaque_sp() +{ +} + +SBTypeCategory::SBTypeCategory (const char* name) : +m_opaque_sp() +{ + DataVisualization::Categories::GetCategory(ConstString(name), m_opaque_sp); +} + +SBTypeCategory::SBTypeCategory (const lldb::SBTypeCategory &rhs) : +m_opaque_sp(rhs.m_opaque_sp) +{ +} + +SBTypeCategory::~SBTypeCategory () +{ +} + +bool +SBTypeCategory::IsValid() const +{ + return (m_opaque_sp.get() != NULL); +} + +bool +SBTypeCategory::GetEnabled () +{ + if (!IsValid()) + return false; + return m_opaque_sp->IsEnabled(); +} + +void +SBTypeCategory::SetEnabled (bool enabled) +{ + if (!IsValid()) + return; + if (enabled) + DataVisualization::Categories::Enable(m_opaque_sp); + else + DataVisualization::Categories::Disable(m_opaque_sp); +} + +const char* +SBTypeCategory::GetName() +{ + if (!IsValid()) + return false; + return m_opaque_sp->GetName(); +} + +uint32_t +SBTypeCategory::GetNumFormats () +{ + if (!IsDefaultCategory()) + return 0; + + return DataVisualization::ValueFormats::GetCount(); +} + +uint32_t +SBTypeCategory::GetNumSummaries () +{ + if (!IsValid()) + return 0; + return m_opaque_sp->GetSummaryNavigator()->GetCount() + m_opaque_sp->GetRegexSummaryNavigator()->GetCount(); +} + +uint32_t +SBTypeCategory::GetNumFilters () +{ + if (!IsValid()) + return 0; + return m_opaque_sp->GetFilterNavigator()->GetCount() + m_opaque_sp->GetRegexFilterNavigator()->GetCount(); +} + +uint32_t +SBTypeCategory::GetNumSynthetics () +{ + if (!IsValid()) + return 0; + return m_opaque_sp->GetSyntheticNavigator()->GetCount() + m_opaque_sp->GetRegexSyntheticNavigator()->GetCount(); +} + +lldb::SBTypeNameSpecifier +SBTypeCategory::GetTypeNameSpecifierForFilterAtIndex (uint32_t index) +{ + if (!IsValid()) + return SBTypeNameSpecifier(); + return SBTypeNameSpecifier(m_opaque_sp->GetTypeNameSpecifierForFilterAtIndex(index)); +} + +lldb::SBTypeNameSpecifier +SBTypeCategory::GetTypeNameSpecifierForFormatAtIndex (uint32_t index) +{ + if (!IsDefaultCategory()) + return SBTypeNameSpecifier(); + return SBTypeNameSpecifier(DataVisualization::ValueFormats::GetTypeNameSpecifierForFormatAtIndex(index)); +} + +lldb::SBTypeNameSpecifier +SBTypeCategory::GetTypeNameSpecifierForSummaryAtIndex (uint32_t index) +{ + if (!IsValid()) + return SBTypeNameSpecifier(); + return SBTypeNameSpecifier(m_opaque_sp->GetTypeNameSpecifierForSummaryAtIndex(index)); +} + +lldb::SBTypeNameSpecifier +SBTypeCategory::GetTypeNameSpecifierForSyntheticAtIndex (uint32_t index) +{ + if (!IsValid()) + return SBTypeNameSpecifier(); + return SBTypeNameSpecifier(m_opaque_sp->GetTypeNameSpecifierForSyntheticAtIndex(index)); +} + +SBTypeFilter +SBTypeCategory::GetFilterForType (SBTypeNameSpecifier spec) +{ + if (!IsValid()) + return SBTypeFilter(); + + if (!spec.IsValid()) + return SBTypeFilter(); + + lldb::SyntheticChildrenSP children_sp; + + if (spec.IsRegex()) + m_opaque_sp->GetRegexFilterNavigator()->GetExact(ConstString(spec.GetName()), children_sp); + else + m_opaque_sp->GetFilterNavigator()->GetExact(ConstString(spec.GetName()), children_sp); + + if (!children_sp) + return lldb::SBTypeFilter(); + + TypeFilterImplSP filter_sp = std::tr1::static_pointer_cast<TypeFilterImpl>(children_sp); + + return lldb::SBTypeFilter(filter_sp); + +} +SBTypeFormat +SBTypeCategory::GetFormatForType (SBTypeNameSpecifier spec) +{ + if (!IsDefaultCategory()) + return SBTypeFormat(); + + if (!spec.IsValid()) + return SBTypeFormat(); + + if (spec.IsRegex()) + return SBTypeFormat(); + + return SBTypeFormat(DataVisualization::ValueFormats::GetFormat(ConstString(spec.GetName()))); +} + +SBTypeSummary +SBTypeCategory::GetSummaryForType (SBTypeNameSpecifier spec) +{ + if (!IsValid()) + return SBTypeSummary(); + + if (!spec.IsValid()) + return SBTypeSummary(); + + lldb::TypeSummaryImplSP summary_sp; + + if (spec.IsRegex()) + m_opaque_sp->GetRegexSummaryNavigator()->GetExact(ConstString(spec.GetName()), summary_sp); + else + m_opaque_sp->GetSummaryNavigator()->GetExact(ConstString(spec.GetName()), summary_sp); + + if (!summary_sp) + return lldb::SBTypeSummary(); + + return lldb::SBTypeSummary(summary_sp); +} + +SBTypeSynthetic +SBTypeCategory::GetSyntheticForType (SBTypeNameSpecifier spec) +{ + if (!IsValid()) + return SBTypeSynthetic(); + + if (!spec.IsValid()) + return SBTypeSynthetic(); + + lldb::SyntheticChildrenSP children_sp; + + if (spec.IsRegex()) + m_opaque_sp->GetRegexSyntheticNavigator()->GetExact(ConstString(spec.GetName()), children_sp); + else + m_opaque_sp->GetSyntheticNavigator()->GetExact(ConstString(spec.GetName()), children_sp); + + if (!children_sp) + return lldb::SBTypeSynthetic(); + + TypeSyntheticImplSP synth_sp = std::tr1::static_pointer_cast<TypeSyntheticImpl>(children_sp); + + return lldb::SBTypeSynthetic(synth_sp); +} + +SBTypeFilter +SBTypeCategory::GetFilterAtIndex (uint32_t index) +{ + if (!IsValid()) + return SBTypeFilter(); + lldb::SyntheticChildrenSP children_sp = m_opaque_sp->GetSyntheticAtIndex((index)); + + if (!children_sp.get()) + return lldb::SBTypeFilter(); + + TypeFilterImplSP filter_sp = std::tr1::static_pointer_cast<TypeFilterImpl>(children_sp); + + return lldb::SBTypeFilter(filter_sp); +} + +SBTypeFormat +SBTypeCategory::GetFormatAtIndex (uint32_t index) +{ + if (!IsDefaultCategory()) + return SBTypeFormat(); + return SBTypeFormat(DataVisualization::ValueFormats::GetFormatAtIndex((index))); +} + +SBTypeSummary +SBTypeCategory::GetSummaryAtIndex (uint32_t index) +{ + if (!IsValid()) + return SBTypeSummary(); + return SBTypeSummary(m_opaque_sp->GetSummaryAtIndex((index))); +} + +SBTypeSynthetic +SBTypeCategory::GetSyntheticAtIndex (uint32_t index) +{ + if (!IsValid()) + return SBTypeSynthetic(); + lldb::SyntheticChildrenSP children_sp = m_opaque_sp->GetSyntheticAtIndex((index)); + + if (!children_sp.get()) + return lldb::SBTypeSynthetic(); + + TypeSyntheticImplSP synth_sp = std::tr1::static_pointer_cast<TypeSyntheticImpl>(children_sp); + + return lldb::SBTypeSynthetic(synth_sp); +} + +bool +SBTypeCategory::AddTypeFormat (SBTypeNameSpecifier type_name, + SBTypeFormat format) +{ + if (!IsDefaultCategory()) + return false; + + if (!type_name.IsValid()) + return false; + + if (!format.IsValid()) + return false; + + if (type_name.IsRegex()) + return false; + + DataVisualization::ValueFormats::Add(ConstString(type_name.GetName()), format.GetSP()); + + return true; +} + +bool +SBTypeCategory::DeleteTypeFormat (SBTypeNameSpecifier type_name) +{ + if (!IsDefaultCategory()) + return false; + + if (!type_name.IsValid()) + return false; + + if (type_name.IsRegex()) + return false; + + return DataVisualization::ValueFormats::Delete(ConstString(type_name.GetName())); +} + +bool +SBTypeCategory::AddTypeSummary (SBTypeNameSpecifier type_name, + SBTypeSummary summary) +{ + if (!IsValid()) + return false; + + if (!type_name.IsValid()) + return false; + + if (!summary.IsValid()) + return false; + + // FIXME: we need to iterate over all the Debugger objects and have each of them contain a copy of the function + // since we currently have formatters live in a global space, while Python code lives in a specific Debugger-related environment + // this should eventually be fixed by deciding a final location in the LLDB object space for formatters + if (summary.IsFunctionCode()) + { + void *name_token = (void*)ConstString(type_name.GetName()).GetCString(); + const char* script = summary.GetData(); + StringList input; input.SplitIntoLines(script, strlen(script)); + uint32_t num_debuggers = lldb_private::Debugger::GetNumDebuggers(); + bool need_set = true; + for (uint32_t j = 0; + j < num_debuggers; + j++) + { + DebuggerSP debugger_sp = lldb_private::Debugger::GetDebuggerAtIndex(j); + if (debugger_sp) + { + ScriptInterpreter* interpreter_ptr = debugger_sp->GetCommandInterpreter().GetScriptInterpreter(); + if (interpreter_ptr) + { + StringList output; + if (interpreter_ptr->GenerateTypeScriptFunction(input, output, name_token) && output.GetSize() > 0) + { + if (need_set) + { + need_set = false; + summary.SetFunctionName(output.GetStringAtIndex(0)); + } + } + } + } + } + } + + if (type_name.IsRegex()) + m_opaque_sp->GetRegexSummaryNavigator()->Add(lldb::RegularExpressionSP(new RegularExpression(type_name.GetName())), summary.GetSP()); + else + m_opaque_sp->GetSummaryNavigator()->Add(ConstString(type_name.GetName()), summary.GetSP()); + + return true; +} + +bool +SBTypeCategory::DeleteTypeSummary (SBTypeNameSpecifier type_name) +{ + if (!IsValid()) + return false; + + if (!type_name.IsValid()) + return false; + + if (type_name.IsRegex()) + return m_opaque_sp->GetRegexSummaryNavigator()->Delete(ConstString(type_name.GetName())); + else + return m_opaque_sp->GetSummaryNavigator()->Delete(ConstString(type_name.GetName())); +} + +bool +SBTypeCategory::AddTypeFilter (SBTypeNameSpecifier type_name, + SBTypeFilter filter) +{ + if (!IsValid()) + return false; + + if (!type_name.IsValid()) + return false; + + if (!filter.IsValid()) + return false; + + if (type_name.IsRegex()) + m_opaque_sp->GetRegexFilterNavigator()->Add(lldb::RegularExpressionSP(new RegularExpression(type_name.GetName())), filter.GetSP()); + else + m_opaque_sp->GetFilterNavigator()->Add(ConstString(type_name.GetName()), filter.GetSP()); + + return true; +} + +bool +SBTypeCategory::DeleteTypeFilter (SBTypeNameSpecifier type_name) +{ + if (!IsValid()) + return false; + + if (!type_name.IsValid()) + return false; + + if (type_name.IsRegex()) + return m_opaque_sp->GetRegexFilterNavigator()->Delete(ConstString(type_name.GetName())); + else + return m_opaque_sp->GetFilterNavigator()->Delete(ConstString(type_name.GetName())); +} + +bool +SBTypeCategory::AddTypeSynthetic (SBTypeNameSpecifier type_name, + SBTypeSynthetic synth) +{ + if (!IsValid()) + return false; + + if (!type_name.IsValid()) + return false; + + if (!synth.IsValid()) + return false; + + // FIXME: we need to iterate over all the Debugger objects and have each of them contain a copy of the function + // since we currently have formatters live in a global space, while Python code lives in a specific Debugger-related environment + // this should eventually be fixed by deciding a final location in the LLDB object space for formatters + if (synth.IsClassCode()) + { + void *name_token = (void*)ConstString(type_name.GetName()).GetCString(); + const char* script = synth.GetData(); + StringList input; input.SplitIntoLines(script, strlen(script)); + uint32_t num_debuggers = lldb_private::Debugger::GetNumDebuggers(); + bool need_set = true; + for (uint32_t j = 0; + j < num_debuggers; + j++) + { + DebuggerSP debugger_sp = lldb_private::Debugger::GetDebuggerAtIndex(j); + if (debugger_sp) + { + ScriptInterpreter* interpreter_ptr = debugger_sp->GetCommandInterpreter().GetScriptInterpreter(); + if (interpreter_ptr) + { + StringList output; + if (interpreter_ptr->GenerateTypeSynthClass(input, output, name_token) && output.GetSize() > 0) + { + if (need_set) + { + need_set = false; + synth.SetClassName(output.GetStringAtIndex(0)); + } + } + } + } + } + } + + if (type_name.IsRegex()) + m_opaque_sp->GetRegexSyntheticNavigator()->Add(lldb::RegularExpressionSP(new RegularExpression(type_name.GetName())), synth.GetSP()); + else + m_opaque_sp->GetSyntheticNavigator()->Add(ConstString(type_name.GetName()), synth.GetSP()); + + return true; +} + +bool +SBTypeCategory::DeleteTypeSynthetic (SBTypeNameSpecifier type_name) +{ + if (!IsValid()) + return false; + + if (!type_name.IsValid()) + return false; + + if (type_name.IsRegex()) + return m_opaque_sp->GetRegexSyntheticNavigator()->Delete(ConstString(type_name.GetName())); + else + return m_opaque_sp->GetSyntheticNavigator()->Delete(ConstString(type_name.GetName())); +} + +bool +SBTypeCategory::GetDescription (lldb::SBStream &description, + lldb::DescriptionLevel description_level) +{ + if (!IsValid()) + return false; + description.Printf("Category name: %s\n",GetName()); + return true; +} + +lldb::SBTypeCategory & +SBTypeCategory::operator = (const lldb::SBTypeCategory &rhs) +{ + if (this != &rhs) + { + m_opaque_sp = rhs.m_opaque_sp; + } + return *this; +} + +bool +SBTypeCategory::operator == (lldb::SBTypeCategory &rhs) +{ + if (IsValid() == false) + return !rhs.IsValid(); + + return m_opaque_sp.get() == rhs.m_opaque_sp.get(); + +} + +bool +SBTypeCategory::operator != (lldb::SBTypeCategory &rhs) +{ + if (IsValid() == false) + return rhs.IsValid(); + + return m_opaque_sp.get() != rhs.m_opaque_sp.get(); +} + +lldb::TypeCategoryImplSP +SBTypeCategory::GetSP () +{ + if (!IsValid()) + return lldb::TypeCategoryImplSP(); + return m_opaque_sp; +} + +void +SBTypeCategory::SetSP (const lldb::TypeCategoryImplSP &typecategory_impl_sp) +{ + m_opaque_sp = typecategory_impl_sp; +} + +SBTypeCategory::SBTypeCategory (const lldb::TypeCategoryImplSP &typecategory_impl_sp) : +m_opaque_sp(typecategory_impl_sp) +{ +} + +bool +SBTypeCategory::IsDefaultCategory() +{ + if (!IsValid()) + return false; + + return (strcmp(m_opaque_sp->GetName(),"default") == 0); +} + diff --git a/lldb/source/API/SBTypeFilter.cpp b/lldb/source/API/SBTypeFilter.cpp new file mode 100644 index 00000000000..50ecc25a6d4 --- /dev/null +++ b/lldb/source/API/SBTypeFilter.cpp @@ -0,0 +1,197 @@ +//===-- SBTypeFilter.cpp ------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "lldb/API/SBTypeFilter.h" + +#include "lldb/API/SBStream.h" + +#include "lldb/Core/DataVisualization.h" + +using namespace lldb; +using namespace lldb_private; + +SBTypeFilter::SBTypeFilter() : +m_opaque_sp() +{ +} + +SBTypeFilter::SBTypeFilter (uint32_t options) +: m_opaque_sp(TypeFilterImplSP(new TypeFilterImpl(options))) +{ +} + +SBTypeFilter::SBTypeFilter (const lldb::SBTypeFilter &rhs) : +m_opaque_sp(rhs.m_opaque_sp) +{ +} + +SBTypeFilter::~SBTypeFilter () +{ +} + +bool +SBTypeFilter::IsValid() const +{ + return m_opaque_sp.get() != NULL; +} + +uint32_t +SBTypeFilter::GetOptions() +{ + if (IsValid()) + return m_opaque_sp->GetOptions(); + return 0; +} + +void +SBTypeFilter::SetOptions (uint32_t value) +{ + if (CopyOnWrite_Impl()) + m_opaque_sp->SetOptions(value); +} + +bool +SBTypeFilter::GetDescription (lldb::SBStream &description, + lldb::DescriptionLevel description_level) +{ + if (!IsValid()) + return false; + else { + description.Printf("%s\n", + m_opaque_sp->GetDescription().c_str()); + return true; + } +} + +void +SBTypeFilter::Clear() +{ + if (CopyOnWrite_Impl()) + m_opaque_sp->Clear(); +} + +uint32_t +SBTypeFilter::GetNumberOfExpressionPaths() +{ + if (IsValid()) + return m_opaque_sp->GetCount(); + return 0; +} + +const char* +SBTypeFilter::GetExpressionPathAtIndex (uint32_t i) +{ + if (IsValid()) + { + const char* item = m_opaque_sp->GetExpressionPathAtIndex(i); + if (item && *item == '.') + item++; + return item; + } + return NULL; +} + +bool +SBTypeFilter::ReplaceExpressionPathAtIndex (uint32_t i, const char* item) +{ + if (CopyOnWrite_Impl()) + return m_opaque_sp->SetExpressionPathAtIndex(i, item); + else + return false; +} + +void +SBTypeFilter::AppendExpressionPath (const char* item) +{ + if (CopyOnWrite_Impl()) + m_opaque_sp->AddExpressionPath(item); +} + +lldb::SBTypeFilter & +SBTypeFilter::operator = (const lldb::SBTypeFilter &rhs) +{ + if (this != &rhs) + { + m_opaque_sp = rhs.m_opaque_sp; + } + return *this; +} + +bool +SBTypeFilter::operator == (lldb::SBTypeFilter &rhs) +{ + if (IsValid() == false) + return !rhs.IsValid(); + + return m_opaque_sp == rhs.m_opaque_sp; +} + +bool +SBTypeFilter::IsEqualTo (lldb::SBTypeFilter &rhs) +{ + if (IsValid() == false) + return !rhs.IsValid(); + + if (GetNumberOfExpressionPaths() != rhs.GetNumberOfExpressionPaths()) + return false; + + for (uint32_t j = 0; + j < GetNumberOfExpressionPaths(); + j++) + if ( strcmp(GetExpressionPathAtIndex(j),rhs.GetExpressionPathAtIndex(j)) != 0) + return false; + + return GetOptions() == rhs.GetOptions(); +} + +bool +SBTypeFilter::operator != (lldb::SBTypeFilter &rhs) +{ + if (IsValid() == false) + return !rhs.IsValid(); + + return m_opaque_sp != rhs.m_opaque_sp; +} + +lldb::TypeFilterImplSP +SBTypeFilter::GetSP () +{ + return m_opaque_sp; +} + +void +SBTypeFilter::SetSP (const lldb::TypeFilterImplSP &typefilter_impl_sp) +{ + m_opaque_sp = typefilter_impl_sp; +} + +SBTypeFilter::SBTypeFilter (const lldb::TypeFilterImplSP &typefilter_impl_sp) : +m_opaque_sp(typefilter_impl_sp) +{ +} + +bool +SBTypeFilter::CopyOnWrite_Impl() +{ + if (!IsValid()) + return false; + if (m_opaque_sp.unique()) + return true; + + TypeFilterImplSP new_sp(new TypeFilterImpl(GetOptions())); + + for (uint32_t j = 0; + j < GetNumberOfExpressionPaths(); + j++) + new_sp->AddExpressionPath(GetExpressionPathAtIndex(j)); + + SetSP(new_sp); + + return true; +} diff --git a/lldb/source/API/SBTypeFormat.cpp b/lldb/source/API/SBTypeFormat.cpp new file mode 100644 index 00000000000..20df87bbdaf --- /dev/null +++ b/lldb/source/API/SBTypeFormat.cpp @@ -0,0 +1,153 @@ +//===-- SBTypeFormat.cpp ------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "lldb/API/SBTypeFormat.h" + +#include "lldb/API/SBStream.h" + +#include "lldb/Core/DataVisualization.h" + +using namespace lldb; +using namespace lldb_private; + +SBTypeFormat::SBTypeFormat() : +m_opaque_sp() +{ +} + +SBTypeFormat::SBTypeFormat (lldb::Format format, + uint32_t options) +: m_opaque_sp(TypeFormatImplSP(new TypeFormatImpl(format,options))) +{ +} + +SBTypeFormat::SBTypeFormat (const lldb::SBTypeFormat &rhs) : +m_opaque_sp(rhs.m_opaque_sp) +{ +} + +SBTypeFormat::~SBTypeFormat () +{ +} + +bool +SBTypeFormat::IsValid() const +{ + return m_opaque_sp.get() != NULL; +} + +lldb::Format +SBTypeFormat::GetFormat () +{ + if (IsValid()) + return m_opaque_sp->GetFormat(); + return lldb::eFormatInvalid; +} + +uint32_t +SBTypeFormat::GetOptions() +{ + if (IsValid()) + return m_opaque_sp->GetOptions(); + return 0; +} + +void +SBTypeFormat::SetFormat (lldb::Format fmt) +{ + if (CopyOnWrite_Impl()) + m_opaque_sp->SetFormat(fmt); +} + +void +SBTypeFormat::SetOptions (uint32_t value) +{ + if (CopyOnWrite_Impl()) + m_opaque_sp->SetOptions(value); +} + +bool +SBTypeFormat::GetDescription (lldb::SBStream &description, + lldb::DescriptionLevel description_level) +{ + if (!IsValid()) + return false; + else { + description.Printf("%s\n", + m_opaque_sp->GetDescription().c_str()); + return true; + } +} + +lldb::SBTypeFormat & +SBTypeFormat::operator = (const lldb::SBTypeFormat &rhs) +{ + if (this != &rhs) + { + m_opaque_sp = rhs.m_opaque_sp; + } + return *this; +} + +bool +SBTypeFormat::operator == (lldb::SBTypeFormat &rhs) +{ + if (IsValid() == false) + return !rhs.IsValid(); + return m_opaque_sp == rhs.m_opaque_sp; +} + +bool +SBTypeFormat::IsEqualTo (lldb::SBTypeFormat &rhs) +{ + if (IsValid() == false) + return !rhs.IsValid(); + + if (GetFormat() == rhs.GetFormat()) + return GetOptions() == rhs.GetOptions(); + else + return false; +} + +bool +SBTypeFormat::operator != (lldb::SBTypeFormat &rhs) +{ + if (IsValid() == false) + return !rhs.IsValid(); + return m_opaque_sp != rhs.m_opaque_sp; +} + +lldb::TypeFormatImplSP +SBTypeFormat::GetSP () +{ + return m_opaque_sp; +} + +void +SBTypeFormat::SetSP (const lldb::TypeFormatImplSP &typeformat_impl_sp) +{ + m_opaque_sp = typeformat_impl_sp; +} + +SBTypeFormat::SBTypeFormat (const lldb::TypeFormatImplSP &typeformat_impl_sp) : + m_opaque_sp(typeformat_impl_sp) +{ +} + +bool +SBTypeFormat::CopyOnWrite_Impl() +{ + if (!IsValid()) + return false; + if (m_opaque_sp.unique()) + return true; + + SetSP(TypeFormatImplSP(new TypeFormatImpl(GetFormat(),GetOptions()))); + return true; +} diff --git a/lldb/source/API/SBTypeNameSpecifier.cpp b/lldb/source/API/SBTypeNameSpecifier.cpp new file mode 100644 index 00000000000..ef43e805f4f --- /dev/null +++ b/lldb/source/API/SBTypeNameSpecifier.cpp @@ -0,0 +1,127 @@ +//===-- SBTypeNameSpecifier.cpp ------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "lldb/API/SBTypeNameSpecifier.h" + +#include "lldb/API/SBStream.h" + +#include "lldb/Core/DataVisualization.h" + +using namespace lldb; +using namespace lldb_private; + +SBTypeNameSpecifier::SBTypeNameSpecifier() : +m_opaque_sp() +{ +} + +SBTypeNameSpecifier::SBTypeNameSpecifier (const char* name, + bool is_regex) : +m_opaque_sp(new TypeNameSpecifierImpl(name, is_regex)) +{ + if (name == NULL || (*name) == 0) + m_opaque_sp.reset(); +} + +SBTypeNameSpecifier::SBTypeNameSpecifier (const lldb::SBTypeNameSpecifier &rhs) : +m_opaque_sp(rhs.m_opaque_sp) +{} + +SBTypeNameSpecifier::~SBTypeNameSpecifier () +{ +} + +bool +SBTypeNameSpecifier::IsValid() const +{ + return m_opaque_sp.get() != NULL; +} + +const char* +SBTypeNameSpecifier::GetName () +{ + if (!IsValid()) + return NULL; + + return m_opaque_sp->GetName(); +} + +bool +SBTypeNameSpecifier::IsRegex () +{ + if (!IsValid()) + return false; + + return m_opaque_sp->IsRegex(); +} + +bool +SBTypeNameSpecifier::GetDescription (lldb::SBStream &description, + lldb::DescriptionLevel description_level) +{ + if (!IsValid()) + return false; + description.Printf("SBTypeNameSpecifier(%s,%s)", GetName(), IsRegex() ? "regex" : "plain"); + return true; +} + +lldb::SBTypeNameSpecifier & +SBTypeNameSpecifier::operator = (const lldb::SBTypeNameSpecifier &rhs) +{ + if (this != &rhs) + { + m_opaque_sp = rhs.m_opaque_sp; + } + return *this; +} + +bool +SBTypeNameSpecifier::operator == (lldb::SBTypeNameSpecifier &rhs) +{ + if (IsValid() == false) + return !rhs.IsValid(); + return m_opaque_sp == rhs.m_opaque_sp; +} + +bool +SBTypeNameSpecifier::IsEqualTo (lldb::SBTypeNameSpecifier &rhs) +{ + if (IsValid() == false) + return !rhs.IsValid(); + + if (IsRegex() != rhs.IsRegex()) + return false; + + return (strcmp(GetName(), rhs.GetName()) == 0); +} + +bool +SBTypeNameSpecifier::operator != (lldb::SBTypeNameSpecifier &rhs) +{ + if (IsValid() == false) + return !rhs.IsValid(); + return m_opaque_sp != rhs.m_opaque_sp; +} + +lldb::TypeNameSpecifierImplSP +SBTypeNameSpecifier::GetSP () +{ + return m_opaque_sp; +} + +void +SBTypeNameSpecifier::SetSP (const lldb::TypeNameSpecifierImplSP &type_namespec_sp) +{ + m_opaque_sp = type_namespec_sp; +} + +SBTypeNameSpecifier::SBTypeNameSpecifier (const lldb::TypeNameSpecifierImplSP &type_namespec_sp) : +m_opaque_sp(type_namespec_sp) +{ +} diff --git a/lldb/source/API/SBTypeSummary.cpp b/lldb/source/API/SBTypeSummary.cpp new file mode 100644 index 00000000000..5edff66e660 --- /dev/null +++ b/lldb/source/API/SBTypeSummary.cpp @@ -0,0 +1,298 @@ +//===-- SBTypeSummary.cpp -----------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "lldb/API/SBTypeSummary.h" + +#include "lldb/API/SBStream.h" + +#include "lldb/Core/DataVisualization.h" + +using namespace lldb; +using namespace lldb_private; + +SBTypeSummary::SBTypeSummary() : +m_opaque_sp() +{ +} + +SBTypeSummary +SBTypeSummary::CreateWithSummaryString (const char* data, uint32_t options) +{ + if (!data || data[0] == 0) + return SBTypeSummary(); + + return SBTypeSummary(TypeSummaryImplSP(new StringSummaryFormat(options, data))); +} + +SBTypeSummary +SBTypeSummary::CreateWithFunctionName (const char* data, uint32_t options) +{ + if (!data || data[0] == 0) + return SBTypeSummary(); + + return SBTypeSummary(TypeSummaryImplSP(new ScriptSummaryFormat(options, data))); +} + +SBTypeSummary +SBTypeSummary::CreateWithScriptCode (const char* data, uint32_t options) +{ + if (!data || data[0] == 0) + return SBTypeSummary(); + + return SBTypeSummary(TypeSummaryImplSP(new ScriptSummaryFormat(options, "", data))); +} + +SBTypeSummary::SBTypeSummary (const lldb::SBTypeSummary &rhs) : +m_opaque_sp(rhs.m_opaque_sp) +{ +} + +SBTypeSummary::~SBTypeSummary () +{ +} + +bool +SBTypeSummary::IsValid() const +{ + return m_opaque_sp.get() != NULL; +} + +bool +SBTypeSummary::IsFunctionCode() +{ + if (!IsValid()) + return false; + if (m_opaque_sp->IsScripted()) + { + ScriptSummaryFormat* script_summary_ptr = (ScriptSummaryFormat*)m_opaque_sp.get(); + const char* ftext = script_summary_ptr->GetPythonScript(); + return (ftext && *ftext != 0); + } + return false; +} + +bool +SBTypeSummary::IsFunctionName() +{ + if (!IsValid()) + return false; + if (m_opaque_sp->IsScripted()) + { + ScriptSummaryFormat* script_summary_ptr = (ScriptSummaryFormat*)m_opaque_sp.get(); + const char* ftext = script_summary_ptr->GetPythonScript(); + return (!ftext || *ftext == 0); + } + return false; +} + +bool +SBTypeSummary::IsSummaryString() +{ + if (!IsValid()) + return false; + + return !m_opaque_sp->IsScripted(); +} + +const char* +SBTypeSummary::GetData () +{ + if (!IsValid()) + return NULL; + if (m_opaque_sp->IsScripted()) + { + ScriptSummaryFormat* script_summary_ptr = (ScriptSummaryFormat*)m_opaque_sp.get(); + const char* fname = script_summary_ptr->GetFunctionName(); + const char* ftext = script_summary_ptr->GetPythonScript(); + if (ftext && *ftext) + return ftext; + return fname; + } + else + { + StringSummaryFormat* string_summary_ptr = (StringSummaryFormat*)m_opaque_sp.get(); + return string_summary_ptr->GetSummaryString(); + } +} + +uint32_t +SBTypeSummary::GetOptions () +{ + if (!IsValid()) + return lldb::eTypeOptionNone; + return m_opaque_sp->GetOptions(); +} + +void +SBTypeSummary::SetOptions (uint32_t value) +{ + if (!CopyOnWrite_Impl()) + return; + m_opaque_sp->SetOptions(value); +} + +void +SBTypeSummary::SetSummaryString (const char* data) +{ + if (!IsValid()) + return; + if (m_opaque_sp->IsScripted()) + ChangeSummaryType(false); + ((StringSummaryFormat*)m_opaque_sp.get())->SetSummaryString(data); +} + +void +SBTypeSummary::SetFunctionName (const char* data) +{ + if (!IsValid()) + return; + if (!m_opaque_sp->IsScripted()) + ChangeSummaryType(true); + ((ScriptSummaryFormat*)m_opaque_sp.get())->SetFunctionName(data); +} + +void +SBTypeSummary::SetFunctionCode (const char* data) +{ + if (!IsValid()) + return; + if (!m_opaque_sp->IsScripted()) + ChangeSummaryType(true); + ((ScriptSummaryFormat*)m_opaque_sp.get())->SetPythonScript(data); +} + +bool +SBTypeSummary::GetDescription (lldb::SBStream &description, + lldb::DescriptionLevel description_level) +{ + if (!CopyOnWrite_Impl()) + return false; + else { + description.Printf("%s\n", + m_opaque_sp->GetDescription().c_str()); + return true; + } +} + +lldb::SBTypeSummary & +SBTypeSummary::operator = (const lldb::SBTypeSummary &rhs) +{ + if (this != &rhs) + { + m_opaque_sp = rhs.m_opaque_sp; + } + return *this; +} + +bool +SBTypeSummary::operator == (lldb::SBTypeSummary &rhs) +{ + if (IsValid() == false) + return !rhs.IsValid(); + return m_opaque_sp == rhs.m_opaque_sp; +} + +bool +SBTypeSummary::IsEqualTo (lldb::SBTypeSummary &rhs) +{ + if (IsValid() == false) + return !rhs.IsValid(); + + if (m_opaque_sp->IsScripted() != rhs.m_opaque_sp->IsScripted()) + return false; + + if (IsFunctionCode() != rhs.IsFunctionCode()) + return false; + + if (IsSummaryString() != rhs.IsSummaryString()) + return false; + + if (IsFunctionName() != rhs.IsFunctionName()) + return false; + + if ( strcmp(GetData(), rhs.GetData()) ) + return false; + + return GetOptions() == rhs.GetOptions(); + +} + +bool +SBTypeSummary::operator != (lldb::SBTypeSummary &rhs) +{ + if (IsValid() == false) + return !rhs.IsValid(); + return m_opaque_sp != rhs.m_opaque_sp; +} + +lldb::TypeSummaryImplSP +SBTypeSummary::GetSP () +{ + return m_opaque_sp; +} + +void +SBTypeSummary::SetSP (const lldb::TypeSummaryImplSP &typesummary_impl_sp) +{ + m_opaque_sp = typesummary_impl_sp; +} + +SBTypeSummary::SBTypeSummary (const lldb::TypeSummaryImplSP &typesummary_impl_sp) : +m_opaque_sp(typesummary_impl_sp) +{ +} + +bool +SBTypeSummary::CopyOnWrite_Impl() +{ + if (!IsValid()) + return false; + if (m_opaque_sp.unique()) + return true; + + TypeSummaryImplSP new_sp; + + if (m_opaque_sp->IsScripted()) + { + ScriptSummaryFormat* current_summary_ptr = (ScriptSummaryFormat*)m_opaque_sp.get(); + new_sp = TypeSummaryImplSP(new ScriptSummaryFormat(GetOptions(), + current_summary_ptr->GetFunctionName(), + current_summary_ptr->GetPythonScript())); + } + else { + StringSummaryFormat* current_summary_ptr = (StringSummaryFormat*)m_opaque_sp.get(); + new_sp = TypeSummaryImplSP(new StringSummaryFormat(GetOptions(), + current_summary_ptr->GetSummaryString())); + } + + SetSP(new_sp); + + return true; +} + +bool +SBTypeSummary::ChangeSummaryType (bool want_script) +{ + if (!IsValid()) + return false; + + if (want_script == m_opaque_sp->IsScripted()) + return CopyOnWrite_Impl(); + + TypeSummaryImplSP new_sp; + + if (want_script) + new_sp = TypeSummaryImplSP(new ScriptSummaryFormat(GetOptions(), "", "")); + else + new_sp = TypeSummaryImplSP(new StringSummaryFormat(GetOptions(), "")); + + SetSP(new_sp); + + return true; +} diff --git a/lldb/source/API/SBTypeSynthetic.cpp b/lldb/source/API/SBTypeSynthetic.cpp new file mode 100644 index 00000000000..66e2d8b68b3 --- /dev/null +++ b/lldb/source/API/SBTypeSynthetic.cpp @@ -0,0 +1,203 @@ +//===-- SBTypeSynthetic.cpp -----------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "lldb/API/SBTypeSynthetic.h" + +#include "lldb/API/SBStream.h" + +#include "lldb/Core/DataVisualization.h" + +using namespace lldb; +using namespace lldb_private; + +SBTypeSynthetic::SBTypeSynthetic() : +m_opaque_sp() +{ +} + +SBTypeSynthetic +SBTypeSynthetic::CreateWithClassName (const char* data, uint32_t options) +{ + if (!data || data[0] == 0) + return SBTypeSynthetic(); + return SBTypeSynthetic(TypeSyntheticImplSP(new TypeSyntheticImpl(options, data, ""))); +} + +SBTypeSynthetic +SBTypeSynthetic::CreateWithScriptCode (const char* data, uint32_t options) +{ + if (!data || data[0] == 0) + return SBTypeSynthetic(); + return SBTypeSynthetic(TypeSyntheticImplSP(new TypeSyntheticImpl(options, "", data))); +} + +SBTypeSynthetic::SBTypeSynthetic (const lldb::SBTypeSynthetic &rhs) : +m_opaque_sp(rhs.m_opaque_sp) +{ +} + +SBTypeSynthetic::~SBTypeSynthetic () +{ +} + +bool +SBTypeSynthetic::IsValid() const +{ + return m_opaque_sp.get() != NULL; +} + +bool +SBTypeSynthetic::IsClassCode() +{ + if (!IsValid()) + return false; + const char* code = m_opaque_sp->GetPythonCode(); + return (code && *code); +} + +bool +SBTypeSynthetic::IsClassName() +{ + if (!IsValid()) + return false; + return !IsClassCode(); +} + +const char* +SBTypeSynthetic::GetData () +{ + if (!IsValid()) + return NULL; + if (IsClassCode()) + return m_opaque_sp->GetPythonCode(); + else + return m_opaque_sp->GetPythonClassName(); +} + +void +SBTypeSynthetic::SetClassName (const char* data) +{ + if (IsValid() && data && *data) + m_opaque_sp->SetPythonClassName(data); +} + +void +SBTypeSynthetic::SetClassCode (const char* data) +{ + if (IsValid() && data && *data) + m_opaque_sp->SetPythonCode(data); +} + +uint32_t +SBTypeSynthetic::GetOptions () +{ + if (!IsValid()) + return lldb::eTypeOptionNone; + return m_opaque_sp->GetOptions(); +} + +void +SBTypeSynthetic::SetOptions (uint32_t value) +{ + if (!CopyOnWrite_Impl()) + return; + m_opaque_sp->SetOptions(value); +} + +bool +SBTypeSynthetic::GetDescription (lldb::SBStream &description, + lldb::DescriptionLevel description_level) +{ + if (!CopyOnWrite_Impl()) + return false; + else { + description.Printf("%s\n", + m_opaque_sp->GetDescription().c_str()); + return true; + } +} + +lldb::SBTypeSynthetic & +SBTypeSynthetic::operator = (const lldb::SBTypeSynthetic &rhs) +{ + if (this != &rhs) + { + m_opaque_sp = rhs.m_opaque_sp; + } + return *this; +} + +bool +SBTypeSynthetic::operator == (lldb::SBTypeSynthetic &rhs) +{ + if (IsValid() == false) + return !rhs.IsValid(); + return m_opaque_sp == rhs.m_opaque_sp; +} + +bool +SBTypeSynthetic::IsEqualTo (lldb::SBTypeSynthetic &rhs) +{ + if (IsValid() == false) + return !rhs.IsValid(); + + if (m_opaque_sp->IsScripted() != rhs.m_opaque_sp->IsScripted()) + return false; + + if (IsClassCode() != rhs.IsClassCode()) + return false; + + if ( strcmp(GetData(), rhs.GetData()) ) + return false; + + return GetOptions() == rhs.GetOptions(); + +} + +bool +SBTypeSynthetic::operator != (lldb::SBTypeSynthetic &rhs) +{ + if (IsValid() == false) + return !rhs.IsValid(); + return m_opaque_sp != rhs.m_opaque_sp; +} + +lldb::TypeSyntheticImplSP +SBTypeSynthetic::GetSP () +{ + return m_opaque_sp; +} + +void +SBTypeSynthetic::SetSP (const lldb::TypeSyntheticImplSP &TypeSynthetic_impl_sp) +{ + m_opaque_sp = TypeSynthetic_impl_sp; +} + +SBTypeSynthetic::SBTypeSynthetic (const lldb::TypeSyntheticImplSP &TypeSynthetic_impl_sp) : +m_opaque_sp(TypeSynthetic_impl_sp) +{ +} + +bool +SBTypeSynthetic::CopyOnWrite_Impl() +{ + if (!IsValid()) + return false; + if (m_opaque_sp.unique()) + return true; + + TypeSyntheticImplSP new_sp(new TypeSyntheticImpl(m_opaque_sp->GetOptions(), + m_opaque_sp->GetPythonClassName(), + m_opaque_sp->GetPythonCode())); + + SetSP(new_sp); + + return true; +} diff --git a/lldb/source/Commands/CommandObjectFrame.cpp b/lldb/source/Commands/CommandObjectFrame.cpp index 78a0d140d1e..c8a9bcc217f 100644 --- a/lldb/source/Commands/CommandObjectFrame.cpp +++ b/lldb/source/Commands/CommandObjectFrame.cpp @@ -399,7 +399,7 @@ public: const char *name_cstr = NULL; size_t idx; - SummaryFormatSP summary_format_sp; + TypeSummaryImplSP summary_format_sp; if (!m_option_variable.summary.empty()) DataVisualization::NamedSummaryFormats::GetSummaryFormat(ConstString(m_option_variable.summary.c_str()), summary_format_sp); diff --git a/lldb/source/Commands/CommandObjectType.cpp b/lldb/source/Commands/CommandObjectType.cpp index 5739bbe5e2b..90fdafca17f 100644 --- a/lldb/source/Commands/CommandObjectType.cpp +++ b/lldb/source/Commands/CommandObjectType.cpp @@ -37,7 +37,7 @@ class ScriptAddOptions public: - SummaryFormat::Flags m_flags; + TypeSummaryImpl::Flags m_flags; StringList m_target_types; StringList m_user_source; @@ -48,7 +48,7 @@ public: std::string m_category; - ScriptAddOptions(const SummaryFormat::Flags& flags, + ScriptAddOptions(const TypeSummaryImpl::Flags& flags, bool regx, const ConstString& name, std::string catg) : @@ -133,7 +133,7 @@ private: // Instance variables to hold the values for command options. - SummaryFormat::Flags m_flags; + TypeSummaryImpl::Flags m_flags; bool m_regex; std::string m_format_string; ConstString m_name; @@ -181,7 +181,7 @@ public: static bool AddSummary(const ConstString& type_name, - lldb::SummaryFormatSP entry, + lldb::TypeSummaryImplSP entry, SummaryFormatType type, std::string category, Error* error = NULL); @@ -496,12 +496,12 @@ public: return false; } - ValueFormatSP entry; + TypeFormatImplSP entry; - entry.reset(new ValueFormat(format, - m_command_options.m_cascade, - m_command_options.m_skip_pointers, - m_command_options.m_skip_references)); + entry.reset(new TypeFormatImpl(format, + TypeFormatImpl::Flags().SetCascades(m_command_options.m_cascade). + SetSkipPointers(m_command_options.m_skip_pointers). + SetSkipReferences(m_command_options.m_skip_references))); // now I have a valid format, let's add it to every type @@ -641,7 +641,7 @@ public: // CommandObjectTypeFormatList //------------------------------------------------------------------------- -bool CommandObjectTypeFormatList_LoopCallback(void* pt2self, ConstString type, const lldb::ValueFormatSP& entry); +bool CommandObjectTypeFormatList_LoopCallback(void* pt2self, ConstString type, const lldb::TypeFormatImplSP& entry); class CommandObjectTypeFormatList; @@ -702,22 +702,19 @@ private: bool LoopCallback (ConstString type, - const lldb::ValueFormatSP& entry, + const lldb::TypeFormatImplSP& entry, RegularExpression* regex, CommandReturnObject *result) { if (regex == NULL || regex->Execute(type.AsCString())) { - result->GetOutputStream().Printf ("%s: %s%s%s%s\n", type.AsCString(), - FormatManager::GetFormatAsCString (entry->m_format), - entry->m_cascades ? "" : " (not cascading)", - entry->m_skip_pointers ? " (skip pointers)" : "", - entry->m_skip_references ? " (skip references)" : ""); + result->GetOutputStream().Printf ("%s: %s\n", type.AsCString(), + entry->GetDescription().c_str()); } return true; } - friend bool CommandObjectTypeFormatList_LoopCallback(void* pt2self, ConstString type, const lldb::ValueFormatSP& entry); + friend bool CommandObjectTypeFormatList_LoopCallback(void* pt2self, ConstString type, const lldb::TypeFormatImplSP& entry); }; @@ -725,7 +722,7 @@ bool CommandObjectTypeFormatList_LoopCallback ( void* pt2self, ConstString type, - const lldb::ValueFormatSP& entry) + const lldb::TypeFormatImplSP& entry) { CommandObjectTypeFormatList_LoopCallbackParam* param = (CommandObjectTypeFormatList_LoopCallbackParam*)pt2self; return param->self->LoopCallback(type, entry, param->regex, param->result); @@ -850,10 +847,10 @@ public: } // now I have a valid function name, let's add this as script for every type in the list - SummaryFormatSP script_format; + TypeSummaryImplSP script_format; script_format.reset(new ScriptSummaryFormat(options->m_flags, - std::string(funct_name), - options->m_user_source.CopyList(" "))); + funct_name, + options->m_user_source.CopyList(" ").c_str())); Error error; @@ -1035,7 +1032,7 @@ CommandObjectTypeSummaryAdd::Execute_ScriptSummary (Args& command, CommandReturn return false; } - SummaryFormatSP script_format; + TypeSummaryImplSP script_format; if (!m_options.m_python_function.empty()) // we have a Python function ready to use { @@ -1054,9 +1051,11 @@ CommandObjectTypeSummaryAdd::Execute_ScriptSummary (Args& command, CommandReturn return false; } + std::string code = (" " + m_options.m_python_function + "(valobj,dict)"); + script_format.reset(new ScriptSummaryFormat(m_options.m_flags, - std::string(funct_name), - " " + m_options.m_python_function + "(valobj,dict)")); + funct_name, + code.c_str())); } else if (!m_options.m_python_script.empty()) // we have a quick 1-line script, just use it { @@ -1091,9 +1090,11 @@ CommandObjectTypeSummaryAdd::Execute_ScriptSummary (Args& command, CommandReturn return false; } + std::string code = " " + m_options.m_python_script; + script_format.reset(new ScriptSummaryFormat(m_options.m_flags, - std::string(funct_name), - " " + m_options.m_python_script)); + funct_name, + code.c_str())); } else // use an InputReader to grab Python code from the user { @@ -1189,7 +1190,7 @@ CommandObjectTypeSummaryAdd::Execute_StringSummary (Args& command, CommandReturn Error error; - lldb::SummaryFormatSP entry(new StringSummaryFormat(m_options.m_flags, + lldb::TypeSummaryImplSP entry(new StringSummaryFormat(m_options.m_flags, format_cstr)); if (error.Fail()) @@ -1343,12 +1344,12 @@ CommandObjectTypeSummaryAdd::Execute (Args& command, CommandReturnObject &result bool CommandObjectTypeSummaryAdd::AddSummary(const ConstString& type_name, - SummaryFormatSP entry, + TypeSummaryImplSP entry, SummaryFormatType type, std::string category_name, Error* error) { - lldb::FormatCategorySP category; + lldb::TypeCategoryImplSP category; DataVisualization::Categories::GetCategory(ConstString(category_name.c_str()), category); if (type == eRegexSummary) @@ -1475,11 +1476,11 @@ private: static bool PerCategoryCallback(void* param, - const lldb::FormatCategorySP& cate) + const lldb::TypeCategoryImplSP& category_sp) { - ConstString *name = (ConstString*)param; - cate->Delete(*name, eFormatCategoryItemSummary | eFormatCategoryItemRegexSummary); - return true; + ConstString *name = (ConstString*)param; + category_sp->Delete(*name, eFormatCategoryItemSummary | eFormatCategoryItemRegexSummary); + return true; } public: @@ -1534,7 +1535,7 @@ public: return result.Succeeded(); } - lldb::FormatCategorySP category; + lldb::TypeCategoryImplSP category; DataVisualization::Categories::GetCategory(ConstString(m_options.m_category.c_str()), category); bool delete_category = category->Delete(typeCS, @@ -1631,7 +1632,7 @@ private: static bool PerCategoryCallback(void* param, - const lldb::FormatCategorySP& cate) + const lldb::TypeCategoryImplSP& cate) { cate->GetSummaryNavigator()->Clear(); cate->GetRegexSummaryNavigator()->Clear(); @@ -1661,7 +1662,7 @@ public: else { - lldb::FormatCategorySP category; + lldb::TypeCategoryImplSP category; if (command.GetArgumentCount() > 0) { const char* cat_name = command.GetArgumentAtIndex(0); @@ -1840,14 +1841,14 @@ private: static bool PerCategoryCallback(void* param_vp, - const lldb::FormatCategorySP& cate) + const lldb::TypeCategoryImplSP& cate) { CommandObjectTypeSummaryList_LoopCallbackParam* param = (CommandObjectTypeSummaryList_LoopCallbackParam*)param_vp; CommandReturnObject* result = param->result; - const char* cate_name = cate->GetName().c_str(); + const char* cate_name = cate->GetName(); // if the category is disabled or empty and there is no regex, just skip it if ((cate->IsEnabled() == false || cate->GetCount(eFormatCategoryItemSummary | eFormatCategoryItemRegexSummary) == 0) && param->cate_regex == NULL) @@ -1874,7 +1875,7 @@ private: bool LoopCallback (const char* type, - const lldb::SummaryFormatSP& entry, + const lldb::TypeSummaryImplSP& entry, RegularExpression* regex, CommandReturnObject *result) { @@ -1883,15 +1884,15 @@ private: return true; } - friend bool CommandObjectTypeSummaryList_LoopCallback(void* pt2self, ConstString type, const lldb::SummaryFormatSP& entry); - friend bool CommandObjectTypeRXSummaryList_LoopCallback(void* pt2self, lldb::RegularExpressionSP regex, const lldb::SummaryFormatSP& entry); + friend bool CommandObjectTypeSummaryList_LoopCallback(void* pt2self, ConstString type, const lldb::TypeSummaryImplSP& entry); + friend bool CommandObjectTypeRXSummaryList_LoopCallback(void* pt2self, lldb::RegularExpressionSP regex, const lldb::TypeSummaryImplSP& entry); }; bool CommandObjectTypeSummaryList_LoopCallback ( void* pt2self, ConstString type, - const lldb::SummaryFormatSP& entry) + const lldb::TypeSummaryImplSP& entry) { CommandObjectTypeSummaryList_LoopCallbackParam* param = (CommandObjectTypeSummaryList_LoopCallbackParam*)pt2self; return param->self->LoopCallback(type.AsCString(), entry, param->regex, param->result); @@ -1901,7 +1902,7 @@ bool CommandObjectTypeRXSummaryList_LoopCallback ( void* pt2self, lldb::RegularExpressionSP regex, - const lldb::SummaryFormatSP& entry) + const lldb::TypeSummaryImplSP& entry) { CommandObjectTypeSummaryList_LoopCallbackParam* param = (CommandObjectTypeSummaryList_LoopCallbackParam*)pt2self; return param->self->LoopCallback(regex->GetText(), entry, param->regex, param->result); @@ -1967,7 +1968,7 @@ public: return false; } DataVisualization::Categories::Enable(typeCS); - lldb::FormatCategorySP cate; + lldb::TypeCategoryImplSP cate; if (DataVisualization::Categories::GetCategory(typeCS, cate) && cate.get()) { if (cate->GetCount() == 0) @@ -2141,14 +2142,14 @@ private: static bool PerCategoryCallback(void* param_vp, - const lldb::FormatCategorySP& cate) + const lldb::TypeCategoryImplSP& cate) { CommandObjectTypeCategoryList_CallbackParam* param = (CommandObjectTypeCategoryList_CallbackParam*)param_vp; CommandReturnObject* result = param->result; RegularExpression* regex = param->regex; - const char* cate_name = cate->GetName().c_str(); + const char* cate_name = cate->GetName(); if (regex == NULL || regex->Execute(cate_name)) result->GetOutputStream().Printf("Category %s is%s enabled\n", @@ -2346,10 +2347,10 @@ private: static bool PerCategoryCallback(void* param_vp, - const lldb::FormatCategorySP& cate) + const lldb::TypeCategoryImplSP& cate) { - const char* cate_name = cate->GetName().c_str(); + const char* cate_name = cate->GetName(); CommandObjectTypeFilterList_LoopCallbackParam* param = (CommandObjectTypeFilterList_LoopCallbackParam*)param_vp; @@ -2558,14 +2559,14 @@ private: static bool PerCategoryCallback(void* param_vp, - const lldb::FormatCategorySP& cate) + const lldb::TypeCategoryImplSP& cate) { CommandObjectTypeSynthList_LoopCallbackParam* param = (CommandObjectTypeSynthList_LoopCallbackParam*)param_vp; CommandReturnObject* result = param->result; - const char* cate_name = cate->GetName().c_str(); + const char* cate_name = cate->GetName(); // if the category is disabled or empty and there is no regex, just skip it if ((cate->IsEnabled() == false || cate->GetCount(eFormatCategoryItemSynth | eFormatCategoryItemRegexSynth) == 0) && param->cate_regex == NULL) @@ -2707,7 +2708,7 @@ private: static bool PerCategoryCallback(void* param, - const lldb::FormatCategorySP& cate) + const lldb::TypeCategoryImplSP& cate) { ConstString *name = (ConstString*)param; return cate->Delete(*name, eFormatCategoryItemFilter | eFormatCategoryItemRegexFilter); @@ -2765,7 +2766,7 @@ public: return result.Succeeded(); } - lldb::FormatCategorySP category; + lldb::TypeCategoryImplSP category; DataVisualization::Categories::GetCategory(ConstString(m_options.m_category.c_str()), category); bool delete_category = category->GetFilterNavigator()->Delete(typeCS); @@ -2871,7 +2872,7 @@ private: static bool PerCategoryCallback(void* param, - const lldb::FormatCategorySP& cate) + const lldb::TypeCategoryImplSP& cate) { ConstString* name = (ConstString*)param; return cate->Delete(*name, eFormatCategoryItemSynth | eFormatCategoryItemRegexSynth); @@ -2929,7 +2930,7 @@ public: return result.Succeeded(); } - lldb::FormatCategorySP category; + lldb::TypeCategoryImplSP category; DataVisualization::Categories::GetCategory(ConstString(m_options.m_category.c_str()), category); bool delete_category = category->GetSyntheticNavigator()->Delete(typeCS); @@ -3031,7 +3032,7 @@ private: static bool PerCategoryCallback(void* param, - const lldb::FormatCategorySP& cate) + const lldb::TypeCategoryImplSP& cate) { cate->Clear(eFormatCategoryItemFilter | eFormatCategoryItemRegexFilter); return true; @@ -3060,7 +3061,7 @@ public: else { - lldb::FormatCategorySP category; + lldb::TypeCategoryImplSP category; if (command.GetArgumentCount() > 0) { const char* cat_name = command.GetArgumentAtIndex(0); @@ -3158,7 +3159,7 @@ private: static bool PerCategoryCallback(void* param, - const lldb::FormatCategorySP& cate) + const lldb::TypeCategoryImplSP& cate) { cate->Clear(eFormatCategoryItemSynth | eFormatCategoryItemRegexSynth); return true; @@ -3187,7 +3188,7 @@ public: else { - lldb::FormatCategorySP category; + lldb::TypeCategoryImplSP category; if (command.GetArgumentCount() > 0) { const char* cat_name = command.GetArgumentAtIndex(0); @@ -3338,13 +3339,13 @@ public: // everything should be fine now, let's add the synth provider class SyntheticChildrenSP synth_provider; - synth_provider.reset(new SyntheticScriptProvider(options->m_cascade, - options->m_skip_pointers, - options->m_skip_references, - std::string(class_name))); + synth_provider.reset(new TypeSyntheticImpl(SyntheticChildren::Flags().SetCascades(options->m_cascade). + SetSkipPointers(options->m_skip_pointers). + SetSkipReferences(options->m_skip_references), + class_name)); - lldb::FormatCategorySP category; + lldb::TypeCategoryImplSP category; DataVisualization::Categories::GetCategory(ConstString(options->m_category.c_str()), category); Error error; @@ -3457,16 +3458,17 @@ CommandObjectTypeSynthAdd::Execute_PythonClass (Args& command, CommandReturnObje SyntheticChildrenSP entry; - SyntheticScriptProvider* impl = new SyntheticScriptProvider(m_options.m_cascade, - m_options.m_skip_pointers, - m_options.m_skip_references, - m_options.m_class_name); + TypeSyntheticImpl* impl = new TypeSyntheticImpl(SyntheticChildren::Flags(). + SetCascades(m_options.m_cascade). + SetSkipPointers(m_options.m_skip_pointers). + SetSkipReferences(m_options.m_skip_references), + m_options.m_class_name.c_str()); entry.reset(impl); // now I have a valid provider, let's add it to every type - lldb::FormatCategorySP category; + lldb::TypeCategoryImplSP category; DataVisualization::Categories::GetCategory(ConstString(m_options.m_category.c_str()), category); Error error; @@ -3525,7 +3527,7 @@ CommandObjectTypeSynthAdd::AddSynth(const ConstString& type_name, std::string category_name, Error* error) { - lldb::FormatCategorySP category; + lldb::TypeCategoryImplSP category; DataVisualization::Categories::GetCategory(ConstString(category_name.c_str()), category); if (category->AnyMatches(type_name, @@ -3704,7 +3706,7 @@ private: std::string category_name, Error* error) { - lldb::FormatCategorySP category; + lldb::TypeCategoryImplSP category; DataVisualization::Categories::GetCategory(ConstString(category_name.c_str()), category); if (category->AnyMatches(type_name, @@ -3811,9 +3813,9 @@ public: SyntheticChildrenSP entry; - SyntheticFilter* impl = new SyntheticFilter(m_options.m_cascade, - m_options.m_skip_pointers, - m_options.m_skip_references); + TypeFilterImpl* impl = new TypeFilterImpl(SyntheticChildren::Flags().SetCascades(m_options.m_cascade). + SetSkipPointers(m_options.m_skip_pointers). + SetSkipReferences(m_options.m_skip_references)); entry.reset(impl); @@ -3826,7 +3828,7 @@ public: // now I have a valid provider, let's add it to every type - lldb::FormatCategorySP category; + lldb::TypeCategoryImplSP category; DataVisualization::Categories::GetCategory(ConstString(m_options.m_category.c_str()), category); Error error; diff --git a/lldb/source/Core/DataVisualization.cpp b/lldb/source/Core/DataVisualization.cpp index ce587dc944f..c5f0088c7dc 100644 --- a/lldb/source/Core/DataVisualization.cpp +++ b/lldb/source/Core/DataVisualization.cpp @@ -38,16 +38,24 @@ DataVisualization::GetCurrentRevision () return GetFormatManager().GetCurrentRevision(); } -lldb::ValueFormatSP +lldb::TypeFormatImplSP DataVisualization::ValueFormats::GetFormat (ValueObject& valobj, lldb::DynamicValueType use_dynamic) { - lldb::ValueFormatSP entry; + lldb::TypeFormatImplSP entry; GetFormatManager().GetValueNavigator().Get(valobj, entry, use_dynamic); return entry; } +lldb::TypeFormatImplSP +DataVisualization::ValueFormats::GetFormat (const ConstString &type) +{ + lldb::TypeFormatImplSP entry; + GetFormatManager().GetValueNavigator().Get(type, entry); + return entry; +} + void -DataVisualization::ValueFormats::Add (const ConstString &type, const lldb::ValueFormatSP &entry) +DataVisualization::ValueFormats::Add (const ConstString &type, const lldb::TypeFormatImplSP &entry) { GetFormatManager().GetValueNavigator().Add(FormatManager::GetValidTypeName(type),entry); } @@ -65,7 +73,7 @@ DataVisualization::ValueFormats::Clear () } void -DataVisualization::ValueFormats::LoopThrough (ValueFormat::ValueCallback callback, void* callback_baton) +DataVisualization::ValueFormats::LoopThrough (TypeFormatImpl::ValueCallback callback, void* callback_baton) { GetFormatManager().GetValueNavigator().LoopThrough(callback, callback_baton); } @@ -76,7 +84,19 @@ DataVisualization::ValueFormats::GetCount () return GetFormatManager().GetValueNavigator().GetCount(); } -lldb::SummaryFormatSP +lldb::TypeNameSpecifierImplSP +DataVisualization::ValueFormats::GetTypeNameSpecifierForFormatAtIndex (uint32_t index) +{ + return GetFormatManager().GetValueNavigator().GetTypeNameSpecifierAtIndex(index); +} + +lldb::TypeFormatImplSP +DataVisualization::ValueFormats::GetFormatAtIndex (uint32_t index) +{ + return GetFormatManager().GetValueNavigator().GetAtIndex(index); +} + +lldb::TypeSummaryImplSP DataVisualization::GetSummaryFormat (ValueObject& valobj, lldb::DynamicValueType use_dynamic) { @@ -92,10 +112,10 @@ DataVisualization::GetSyntheticChildren (ValueObject& valobj, bool DataVisualization::AnyMatches (ConstString type_name, - FormatCategory::FormatCategoryItems items, + TypeCategoryImpl::FormatCategoryItems items, bool only_enabled, const char** matching_category, - FormatCategory::FormatCategoryItems* matching_type) + TypeCategoryImpl::FormatCategoryItems* matching_type) { return GetFormatManager().AnyMatches(type_name, items, @@ -105,10 +125,11 @@ DataVisualization::AnyMatches (ConstString type_name, } bool -DataVisualization::Categories::GetCategory (const ConstString &category, lldb::FormatCategorySP &entry) +DataVisualization::Categories::GetCategory (const ConstString &category, lldb::TypeCategoryImplSP &entry, + bool allow_create) { - entry = GetFormatManager().GetCategory(category); - return true; + entry = GetFormatManager().GetCategory(category, allow_create); + return (entry.get() != NULL); } void @@ -131,31 +152,47 @@ DataVisualization::Categories::Clear () } void -DataVisualization::Categories::Clear (ConstString &category) +DataVisualization::Categories::Clear (const ConstString &category) { GetFormatManager().GetCategory(category)->Clear(eFormatCategoryItemSummary | eFormatCategoryItemRegexSummary); } void -DataVisualization::Categories::Enable (ConstString& category) +DataVisualization::Categories::Enable (const ConstString& category, + CategoryMap::Position pos) { - if (GetFormatManager().GetCategory(category)->IsEnabled() == false) - GetFormatManager().EnableCategory(category); - else - { + if (GetFormatManager().GetCategory(category)->IsEnabled()) GetFormatManager().DisableCategory(category); - GetFormatManager().EnableCategory(category); - } + GetFormatManager().EnableCategory(category, pos); } void -DataVisualization::Categories::Disable (ConstString& category) +DataVisualization::Categories::Disable (const ConstString& category) { if (GetFormatManager().GetCategory(category)->IsEnabled() == true) GetFormatManager().DisableCategory(category); } void +DataVisualization::Categories::Enable (const lldb::TypeCategoryImplSP& category, + CategoryMap::Position pos) +{ + if (category.get()) + { + if (category->IsEnabled()) + GetFormatManager().DisableCategory(category); + GetFormatManager().EnableCategory(category, pos); + } +} + +void +DataVisualization::Categories::Disable (const lldb::TypeCategoryImplSP& category) +{ + if (category.get() && category->IsEnabled() == true) + GetFormatManager().DisableCategory(category); +} + +void DataVisualization::Categories::LoopThrough (FormatManager::CategoryCallback callback, void* callback_baton) { GetFormatManager().LoopThroughCategories(callback, callback_baton); @@ -167,14 +204,20 @@ DataVisualization::Categories::GetCount () return GetFormatManager().GetCategoriesCount(); } +lldb::TypeCategoryImplSP +DataVisualization::Categories::GetCategoryAtIndex (uint32_t index) +{ + return GetFormatManager().GetCategoryAtIndex(index); +} + bool -DataVisualization::NamedSummaryFormats::GetSummaryFormat (const ConstString &type, lldb::SummaryFormatSP &entry) +DataVisualization::NamedSummaryFormats::GetSummaryFormat (const ConstString &type, lldb::TypeSummaryImplSP &entry) { return GetFormatManager().GetNamedSummaryNavigator().Get(type,entry); } void -DataVisualization::NamedSummaryFormats::Add (const ConstString &type, const lldb::SummaryFormatSP &entry) +DataVisualization::NamedSummaryFormats::Add (const ConstString &type, const lldb::TypeSummaryImplSP &entry) { GetFormatManager().GetNamedSummaryNavigator().Add(FormatManager::GetValidTypeName(type),entry); } @@ -192,7 +235,7 @@ DataVisualization::NamedSummaryFormats::Clear () } void -DataVisualization::NamedSummaryFormats::LoopThrough (SummaryFormat::SummaryCallback callback, void* callback_baton) +DataVisualization::NamedSummaryFormats::LoopThrough (TypeSummaryImpl::SummaryCallback callback, void* callback_baton) { GetFormatManager().GetNamedSummaryNavigator().LoopThrough(callback, callback_baton); } diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp index 060e579eadc..ad6b86f044b 100644 --- a/lldb/source/Core/Debugger.cpp +++ b/lldb/source/Core/Debugger.cpp @@ -729,6 +729,27 @@ Debugger::GetAsyncErrorStream () CommandInterpreter::eBroadcastBitAsynchronousErrorData)); } +uint32_t +Debugger::GetNumDebuggers() +{ + Mutex::Locker locker (GetDebuggerListMutex ()); + return GetDebuggerList().size(); +} + +lldb::DebuggerSP +Debugger::GetDebuggerAtIndex (uint32_t index) +{ + DebuggerSP debugger_sp; + + Mutex::Locker locker (GetDebuggerListMutex ()); + DebuggerList &debugger_list = GetDebuggerList(); + + if (index < debugger_list.size()) + debugger_sp = debugger_list[index]; + + return debugger_sp; +} + DebuggerSP Debugger::FindDebuggerWithID (lldb::user_id_t id) { diff --git a/lldb/source/Core/FormatClasses.cpp b/lldb/source/Core/FormatClasses.cpp index 07fcb4140c5..ded4938568b 100644 --- a/lldb/source/Core/FormatClasses.cpp +++ b/lldb/source/Core/FormatClasses.cpp @@ -44,30 +44,40 @@ struct PyObject; 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), +TypeFormatImpl::TypeFormatImpl (lldb::Format f, + const Flags& flags) : + m_flags(flags), m_format (f) { } -SummaryFormat::SummaryFormat(const SummaryFormat::Flags& flags) : - m_flags(flags) +std::string +TypeFormatImpl::GetDescription() { + StreamString sstr; + sstr.Printf ("%s%s%s%s\n", + FormatManager::GetFormatAsCString (GetFormat()), + Cascades() ? "" : " (not cascading)", + SkipsPointers() ? " (skip pointers)" : "", + SkipsReferences() ? " (skip references)" : ""); + return sstr.GetString(); } -StringSummaryFormat::StringSummaryFormat(const SummaryFormat::Flags& flags, - std::string f) : - SummaryFormat(flags), - m_format(f) +TypeSummaryImpl::TypeSummaryImpl(const TypeSummaryImpl::Flags& flags) : + m_flags(flags) { } +StringSummaryFormat::StringSummaryFormat(const TypeSummaryImpl::Flags& flags, + const char *format_cstr) : + TypeSummaryImpl(flags), + m_format() +{ + if (format_cstr) + m_format.assign(format_cstr); +} + std::string StringSummaryFormat::FormatObject(lldb::ValueObjectSP object) { @@ -141,16 +151,20 @@ StringSummaryFormat::GetDescription() #ifndef LLDB_DISABLE_PYTHON -ScriptSummaryFormat::ScriptSummaryFormat(const SummaryFormat::Flags& flags, - std::string fname, - std::string pscri) : - SummaryFormat(flags), - m_function_name(fname), - m_python_script(pscri) + +ScriptSummaryFormat::ScriptSummaryFormat(const TypeSummaryImpl::Flags& flags, + const char * function_name, + const char * python_script) : + TypeSummaryImpl(flags), + m_function_name(), + m_python_script() { + if (function_name) + m_function_name.assign(function_name); + if (python_script) + m_python_script.assign(python_script); } - std::string ScriptSummaryFormat::FormatObject(lldb::ValueObjectSP object) { @@ -177,18 +191,18 @@ ScriptSummaryFormat::GetDescription() #endif // #ifndef LLDB_DISABLE_PYTHON std::string -SyntheticFilter::GetDescription() +TypeFilterImpl::GetDescription() { StreamString sstr; sstr.Printf("%s%s%s {\n", - m_cascades ? "" : " (not cascading)", - m_skip_pointers ? " (skip pointers)" : "", - m_skip_references ? " (skip references)" : ""); + Cascades() ? "" : " (not cascading)", + SkipsPointers() ? " (skip pointers)" : "", + SkipsReferences() ? " (skip references)" : ""); for (int i = 0; i < GetCount(); i++) { sstr.Printf(" %s\n", - GetExpressionPathAtIndex(i).c_str()); + GetExpressionPathAtIndex(i)); } sstr.Printf("}"); @@ -200,9 +214,10 @@ SyntheticArrayView::GetDescription() { StreamString sstr; sstr.Printf("%s%s%s {\n", - m_cascades ? "" : " (not cascading)", - m_skip_pointers ? " (skip pointers)" : "", - m_skip_references ? " (skip references)" : ""); + Cascades() ? "" : " (not cascading)", + SkipsPointers() ? " (skip pointers)" : "", + SkipsReferences() ? " (skip references)" : ""); + SyntheticArrayRange* ptr = &m_head; while (ptr && ptr != m_tail) { @@ -222,7 +237,7 @@ SyntheticArrayView::GetDescription() #ifndef LLDB_DISABLE_PYTHON -SyntheticScriptProvider::FrontEnd::FrontEnd(std::string pclass, +TypeSyntheticImpl::FrontEnd::FrontEnd(std::string pclass, lldb::ValueObjectSP be) : SyntheticChildrenFrontEnd(be), m_python_class(pclass) @@ -242,13 +257,13 @@ SyntheticScriptProvider::FrontEnd::FrontEnd(std::string pclass, m_wrapper = m_interpreter->CreateSyntheticScriptedProvider(m_python_class, m_backend); } -SyntheticScriptProvider::FrontEnd::~FrontEnd() +TypeSyntheticImpl::FrontEnd::~FrontEnd() { Py_XDECREF((PyObject*)m_wrapper); } lldb::ValueObjectSP -SyntheticScriptProvider::FrontEnd::GetChildAtIndex (uint32_t idx, bool can_create) +TypeSyntheticImpl::FrontEnd::GetChildAtIndex (uint32_t idx, bool can_create) { if (m_wrapper == NULL || m_interpreter == NULL) return lldb::ValueObjectSP(); @@ -257,13 +272,13 @@ SyntheticScriptProvider::FrontEnd::GetChildAtIndex (uint32_t idx, bool can_creat } std::string -SyntheticScriptProvider::GetDescription() +TypeSyntheticImpl::GetDescription() { StreamString sstr; sstr.Printf("%s%s%s Python class %s", - m_cascades ? "" : " (not cascading)", - m_skip_pointers ? " (skip pointers)" : "", - m_skip_references ? " (skip references)" : "", + Cascades() ? "" : " (not cascading)", + SkipsPointers() ? " (skip pointers)" : "", + SkipsReferences() ? " (skip references)" : "", m_python_class.c_str()); return sstr.GetString(); diff --git a/lldb/source/Core/FormatManager.cpp b/lldb/source/Core/FormatManager.cpp index fb24f17d3ee..278bc69df95 100644 --- a/lldb/source/Core/FormatManager.cpp +++ b/lldb/source/Core/FormatManager.cpp @@ -157,8 +157,8 @@ FormatManager::GetFormatAsCString (Format format) return NULL; } -FormatCategory::FormatCategory(IFormatChangeListener* clist, - std::string name) : +TypeCategoryImpl::TypeCategoryImpl(IFormatChangeListener* clist, + ConstString name) : m_summary_nav(new SummaryNavigator("summary",clist)), m_regex_summary_nav(new RegexSummaryNavigator("regex-summary",clist)), m_filter_nav(new FilterNavigator("filter",clist)), @@ -174,8 +174,8 @@ FormatCategory::FormatCategory(IFormatChangeListener* clist, {} bool -FormatCategory::Get (ValueObject& valobj, - lldb::SummaryFormatSP& entry, +TypeCategoryImpl::Get (ValueObject& valobj, + lldb::TypeSummaryImplSP& entry, lldb::DynamicValueType use_dynamic, uint32_t* reason) { @@ -190,14 +190,14 @@ FormatCategory::Get (ValueObject& valobj, } bool -FormatCategory::Get(ValueObject& valobj, +TypeCategoryImpl::Get(ValueObject& valobj, lldb::SyntheticChildrenSP& entry_sp, lldb::DynamicValueType use_dynamic, uint32_t* reason) { if (!IsEnabled()) return false; - SyntheticFilter::SharedPointer filter_sp; + TypeFilterImpl::SharedPointer filter_sp; uint32_t reason_filter = 0; bool regex_filter = false; // first find both Filter and Synth, and then check which is most recent @@ -209,7 +209,7 @@ FormatCategory::Get(ValueObject& valobj, bool regex_synth = false; uint32_t reason_synth = 0; bool pick_synth = false; - SyntheticScriptProvider::SharedPointer synth; + TypeSyntheticImpl::SharedPointer synth; if (!GetSyntheticNavigator()->Get(valobj, synth, use_dynamic, &reason_synth)) regex_synth = GetRegexSyntheticNavigator()->Get (valobj, synth, use_dynamic, &reason_synth); if (!filter_sp.get() && !synth.get()) @@ -222,7 +222,7 @@ FormatCategory::Get(ValueObject& valobj, else /*if (filter_sp.get() && synth.get())*/ { - if (filter_sp->m_my_revision > synth->m_my_revision) + if (filter_sp->GetRevision() > synth->GetRevision()) pick_synth = false; else pick_synth = true; @@ -255,7 +255,7 @@ FormatCategory::Get(ValueObject& valobj, } void -FormatCategory::Clear (FormatCategoryItems items) +TypeCategoryImpl::Clear (FormatCategoryItems items) { if ( (items & eFormatCategoryItemSummary) == eFormatCategoryItemSummary ) m_summary_nav->Clear(); @@ -274,7 +274,7 @@ FormatCategory::Clear (FormatCategoryItems items) } bool -FormatCategory::Delete (ConstString name, +TypeCategoryImpl::Delete (ConstString name, FormatCategoryItems items) { bool success = false; @@ -296,7 +296,7 @@ FormatCategory::Delete (ConstString name, } uint32_t -FormatCategory::GetCount (FormatCategoryItems items) +TypeCategoryImpl::GetCount (FormatCategoryItems items) { uint32_t count = 0; if ( (items & eFormatCategoryItemSummary) == eFormatCategoryItemSummary ) @@ -317,7 +317,7 @@ FormatCategory::GetCount (FormatCategoryItems items) } bool -FormatCategory::AnyMatches(ConstString type_name, +TypeCategoryImpl::AnyMatches(ConstString type_name, FormatCategoryItems items, bool only_enabled, const char** matching_category, @@ -326,10 +326,10 @@ FormatCategory::AnyMatches(ConstString type_name, if (!IsEnabled() && only_enabled) return false; - lldb::SummaryFormatSP summary; - SyntheticFilter::SharedPointer filter; + lldb::TypeSummaryImplSP summary; + TypeFilterImpl::SharedPointer filter; #ifndef LLDB_DISABLE_PYTHON - SyntheticScriptProvider::SharedPointer synth; + TypeSyntheticImpl::SharedPointer synth; #endif if ( (items & eFormatCategoryItemSummary) == eFormatCategoryItemSummary ) @@ -337,7 +337,7 @@ FormatCategory::AnyMatches(ConstString type_name, if (m_summary_nav->Get(type_name, summary)) { if (matching_category) - *matching_category = m_name.c_str(); + *matching_category = m_name.GetCString(); if (matching_type) *matching_type = eFormatCategoryItemSummary; return true; @@ -348,7 +348,7 @@ FormatCategory::AnyMatches(ConstString type_name, if (m_regex_summary_nav->Get(type_name, summary)) { if (matching_category) - *matching_category = m_name.c_str(); + *matching_category = m_name.GetCString(); if (matching_type) *matching_type = eFormatCategoryItemRegexSummary; return true; @@ -359,7 +359,7 @@ FormatCategory::AnyMatches(ConstString type_name, if (m_filter_nav->Get(type_name, filter)) { if (matching_category) - *matching_category = m_name.c_str(); + *matching_category = m_name.GetCString(); if (matching_type) *matching_type = eFormatCategoryItemFilter; return true; @@ -370,7 +370,7 @@ FormatCategory::AnyMatches(ConstString type_name, if (m_regex_filter_nav->Get(type_name, filter)) { if (matching_category) - *matching_category = m_name.c_str(); + *matching_category = m_name.GetCString(); if (matching_type) *matching_type = eFormatCategoryItemRegexFilter; return true; @@ -382,7 +382,7 @@ FormatCategory::AnyMatches(ConstString type_name, if (m_synth_nav->Get(type_name, synth)) { if (matching_category) - *matching_category = m_name.c_str(); + *matching_category = m_name.GetCString(); if (matching_type) *matching_type = eFormatCategoryItemSynth; return true; @@ -393,7 +393,7 @@ FormatCategory::AnyMatches(ConstString type_name, if (m_regex_synth_nav->Get(type_name, synth)) { if (matching_category) - *matching_category = m_name.c_str(); + *matching_category = m_name.GetCString(); if (matching_type) *matching_type = eFormatCategoryItemRegexSynth; return true; @@ -405,10 +405,10 @@ FormatCategory::AnyMatches(ConstString type_name, bool CategoryMap::AnyMatches (ConstString type_name, - FormatCategory::FormatCategoryItems items, - bool only_enabled, - const char** matching_category, - FormatCategory::FormatCategoryItems* matching_type) + TypeCategoryImpl::FormatCategoryItems items, + bool only_enabled, + const char** matching_category, + TypeCategoryImpl::FormatCategoryItems* matching_type) { Mutex::Locker(m_map_mutex); @@ -425,7 +425,7 @@ CategoryMap::AnyMatches (ConstString type_name, return false; } -lldb::SummaryFormatSP +lldb::TypeSummaryImplSP CategoryMap::GetSummaryFormat (ValueObject& valobj, lldb::DynamicValueType use_dynamic) { @@ -436,13 +436,13 @@ CategoryMap::GetSummaryFormat (ValueObject& valobj, for (begin = m_active_categories.begin(); begin != end; begin++) { - lldb::FormatCategorySP category = *begin; - lldb::SummaryFormatSP current_format; + lldb::TypeCategoryImplSP category = *begin; + lldb::TypeSummaryImplSP current_format; if (!category->Get(valobj, current_format, use_dynamic, &reason_why)) continue; return current_format; } - return lldb::SummaryFormatSP(); + return lldb::TypeSummaryImplSP(); } lldb::SyntheticChildrenSP @@ -457,7 +457,7 @@ CategoryMap::GetSyntheticChildren (ValueObject& valobj, for (begin = m_active_categories.begin(); begin != end; begin++) { - lldb::FormatCategorySP category = *begin; + lldb::TypeCategoryImplSP category = *begin; lldb::SyntheticChildrenSP current_format; if (!category->Get(valobj, current_format, use_dynamic, &reason_why)) continue; @@ -478,8 +478,8 @@ CategoryMap::LoopThrough(CallbackType callback, void* param) ActiveCategoriesIterator begin, end = m_active_categories.end(); for (begin = m_active_categories.begin(); begin != end; begin++) { - lldb::FormatCategorySP category = *begin; - ConstString type = ConstString(category->GetName().c_str()); + lldb::TypeCategoryImplSP category = *begin; + ConstString type = ConstString(category->GetName()); if (!callback(param, category)) break; } @@ -500,20 +500,39 @@ CategoryMap::LoopThrough(CallbackType callback, void* param) } } -lldb::FormatCategorySP +TypeCategoryImplSP +CategoryMap::GetAtIndex (uint32_t index) +{ + Mutex::Locker(m_map_mutex); + + if (index < m_map.size()) + { + MapIterator pos, end = m_map.end(); + for (pos = m_map.begin(); pos != end; pos++) + { + if (index == 0) + return pos->second; + index--; + } + } + + return TypeCategoryImplSP(); +} + +lldb::TypeCategoryImplSP FormatManager::GetCategory (const ConstString& category_name, bool can_create) { if (!category_name) return GetCategory(m_default_category_name); - lldb::FormatCategorySP category; + lldb::TypeCategoryImplSP category; if (m_categories_map.Get(category_name, category)) return category; if (!can_create) - return lldb::FormatCategorySP(); + return lldb::TypeCategoryImplSP(); - m_categories_map.Add(category_name,lldb::FormatCategorySP(new FormatCategory(this, category_name.AsCString()))); + m_categories_map.Add(category_name,lldb::TypeCategoryImplSP(new TypeCategoryImpl(this, category_name))); return GetCategory(category_name); } @@ -566,35 +585,33 @@ FormatManager::FormatManager() : // add some default stuff // most formats, summaries, ... actually belong to the users' lldbinit file rather than here - lldb::SummaryFormatSP string_format(new StringSummaryFormat(SummaryFormat::Flags().SetCascades(false) - .SetSkipPointers(true) - .SetSkipReferences(false) - .SetDontShowChildren(true) - .SetDontShowValue(false) - .SetShowMembersOneLiner(false) - .SetHideItemNames(false), - "${var%s}")); + lldb::TypeSummaryImplSP string_format(new StringSummaryFormat(TypeSummaryImpl::Flags().SetCascades(false) + .SetSkipPointers(true) + .SetSkipReferences(false) + .SetDontShowChildren(true) + .SetDontShowValue(false) + .SetShowMembersOneLiner(false) + .SetHideItemNames(false), + "${var%s}")); - lldb::SummaryFormatSP string_array_format(new StringSummaryFormat(SummaryFormat::Flags().SetCascades(false) - .SetSkipPointers(true) - .SetSkipReferences(false) - .SetDontShowChildren(false) - .SetDontShowValue(true) - .SetShowMembersOneLiner(false) - .SetHideItemNames(false), - "${var%s}")); + lldb::TypeSummaryImplSP string_array_format(new StringSummaryFormat(TypeSummaryImpl::Flags().SetCascades(false) + .SetSkipPointers(true) + .SetSkipReferences(false) + .SetDontShowChildren(false) + .SetDontShowValue(true) + .SetShowMembersOneLiner(false) + .SetHideItemNames(false), + "${var%s}")); lldb::RegularExpressionSP any_size_char_arr(new RegularExpression("char \\[[0-9]+\\]")); - FormatCategory::SharedPointer sys_category_sp = GetCategory(m_system_category_name); + TypeCategoryImpl::SharedPointer sys_category_sp = GetCategory(m_system_category_name); sys_category_sp->GetSummaryNavigator()->Add(ConstString("char *"), string_format); sys_category_sp->GetSummaryNavigator()->Add(ConstString("const char *"), string_format); sys_category_sp->GetRegexSummaryNavigator()->Add(any_size_char_arr, string_array_format); - GetCategory(m_default_category_name); // this call is there to force LLDB into creating an empty "default" category - // WARNING: temporary code!! // The platform should be responsible for initializing its own formatters // (e.g. to handle versioning, different runtime libraries, ...) @@ -602,16 +619,16 @@ FormatManager::FormatManager() : // the GNU libstdc++ are defined regardless, and enabled by default // This is going to be moved to some platform-dependent location // (in the meanwhile, these formatters should work for Mac OS X & Linux) - lldb::SummaryFormatSP std_string_summary_sp(new StringSummaryFormat(SummaryFormat::Flags().SetCascades(true) - .SetSkipPointers(false) - .SetSkipReferences(false) - .SetDontShowChildren(true) - .SetDontShowValue(true) - .SetShowMembersOneLiner(false) - .SetHideItemNames(false), - "${var._M_dataplus._M_p}")); + lldb::TypeSummaryImplSP std_string_summary_sp(new StringSummaryFormat(TypeSummaryImpl::Flags().SetCascades(true) + .SetSkipPointers(false) + .SetSkipReferences(false) + .SetDontShowChildren(true) + .SetDontShowValue(true) + .SetShowMembersOneLiner(false) + .SetHideItemNames(false), + "${var._M_dataplus._M_p}")); - FormatCategory::SharedPointer gnu_category_sp = GetCategory(m_gnu_cpp_category_name); + TypeCategoryImpl::SharedPointer gnu_category_sp = GetCategory(m_gnu_cpp_category_name); gnu_category_sp->GetSummaryNavigator()->Add(ConstString("std::string"), std_string_summary_sp); @@ -624,40 +641,34 @@ FormatManager::FormatManager() : #ifndef LLDB_DISABLE_PYTHON + + SyntheticChildren::Flags stl_synth_flags; + stl_synth_flags.SetCascades(true).SetSkipPointers(false).SetSkipReferences(false); + gnu_category_sp->GetRegexSyntheticNavigator()->Add(RegularExpressionSP(new RegularExpression("^(std::)?vector<.+>$")), - SyntheticChildrenSP(new SyntheticScriptProvider(true, - false, - false, - "gnu_libstdcpp.StdVectorSynthProvider"))); + SyntheticChildrenSP(new TypeSyntheticImpl(stl_synth_flags, + "gnu_libstdcpp.StdVectorSynthProvider"))); gnu_category_sp->GetRegexSyntheticNavigator()->Add(RegularExpressionSP(new RegularExpression("^(std::)?map<.+> >$")), - SyntheticChildrenSP(new SyntheticScriptProvider(true, - false, - false, - "gnu_libstdcpp.StdMapSynthProvider"))); + SyntheticChildrenSP(new TypeSyntheticImpl(stl_synth_flags, + "gnu_libstdcpp.StdMapSynthProvider"))); gnu_category_sp->GetRegexSyntheticNavigator()->Add(RegularExpressionSP(new RegularExpression("^(std::)?list<.+>$")), - SyntheticChildrenSP(new SyntheticScriptProvider(true, - false, - false, - "gnu_libstdcpp.StdListSynthProvider"))); - - lldb::SummaryFormatSP ObjC_BOOL_summary(new ScriptSummaryFormat(SummaryFormat::Flags().SetCascades(false) - .SetSkipPointers(false) - .SetSkipReferences(false) - .SetDontShowChildren(true) - .SetDontShowValue(true) - .SetShowMembersOneLiner(false) - .SetHideItemNames(false), - "objc.BOOL_SummaryProvider", - "")); - FormatCategory::SharedPointer objc_category_sp = GetCategory(m_objc_category_name); + SyntheticChildrenSP(new TypeSyntheticImpl(stl_synth_flags, + "gnu_libstdcpp.StdListSynthProvider"))); + + lldb::TypeSummaryImplSP ObjC_BOOL_summary(new ScriptSummaryFormat(TypeSummaryImpl::Flags().SetCascades(false) + .SetSkipPointers(false) + .SetSkipReferences(false) + .SetDontShowChildren(true) + .SetDontShowValue(true) + .SetShowMembersOneLiner(false) + .SetHideItemNames(false), + "objc.BOOL_SummaryProvider", + "")); + TypeCategoryImpl::SharedPointer objc_category_sp = GetCategory(m_objc_category_name); objc_category_sp->GetSummaryNavigator()->Add(ConstString("BOOL"), ObjC_BOOL_summary); #endif - - // DO NOT change the order of these calls, unless you WANT a change in the priority of these categories - EnableCategory(m_system_category_name); - EnableCategory(m_objc_category_name); - EnableCategory(m_gnu_cpp_category_name); - EnableCategory(m_default_category_name); - + EnableCategory(m_objc_category_name,CategoryMap::Last); + EnableCategory(m_gnu_cpp_category_name,CategoryMap::Last); + EnableCategory(m_system_category_name,CategoryMap::Last); } diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp index 8767b82c87d..9182979fd40 100644 --- a/lldb/source/Core/ValueObject.cpp +++ b/lldb/source/Core/ValueObject.cpp @@ -575,7 +575,7 @@ ValueObject::GetSummaryAsCString () { if (m_summary_str.empty()) { - SummaryFormat *summary_format = GetSummaryFormat().get(); + TypeSummaryImpl *summary_format = GetSummaryFormat().get(); if (summary_format) { @@ -1771,7 +1771,7 @@ ValueObject::GetSyntheticArrayRangeChild (uint32_t from, uint32_t to, bool can_c // We haven't made a synthetic array member for INDEX yet, so // lets make one and cache it for any future reference. - SyntheticArrayView *view = new SyntheticArrayView(); + SyntheticArrayView *view = new SyntheticArrayView(SyntheticChildren::Flags()); view->AddRange(from,to); SyntheticChildrenSP view_sp(view); synthetic_child = new ValueObjectSynthetic(*this, view_sp); @@ -3075,7 +3075,7 @@ ValueObject::DumpValueObject std::string value_str; const char *val_cstr = NULL; const char *sum_cstr = NULL; - SummaryFormat* entry = valobj->GetSummaryFormat().get(); + TypeSummaryImpl* entry = valobj->GetSummaryFormat().get(); if (omit_summary_depth > 0) entry = NULL; diff --git a/lldb/source/Interpreter/ScriptInterpreterPython.cpp b/lldb/source/Interpreter/ScriptInterpreterPython.cpp index d2d355cac41..71b7162102a 100644 --- a/lldb/source/Interpreter/ScriptInterpreterPython.cpp +++ b/lldb/source/Interpreter/ScriptInterpreterPython.cpp @@ -1140,7 +1140,7 @@ ScriptInterpreterPython::GenerateFunction(std::string& signature, StringList &in // this implementation is identical to GenerateBreakpointCommandCallbackData (apart from the name // given to generated functions, of course) bool -ScriptInterpreterPython::GenerateTypeScriptFunction (StringList &user_input, StringList &output) +ScriptInterpreterPython::GenerateTypeScriptFunction (StringList &user_input, StringList &output, void* name_token) { static int num_created_functions = 0; user_input.RemoveBlankLines (); @@ -1154,7 +1154,10 @@ ScriptInterpreterPython::GenerateTypeScriptFunction (StringList &user_input, Str // Take what the user wrote, wrap it all up inside one big auto-generated Python function, passing in the // ValueObject as parameter to the function. - sstr.Printf ("lldb_autogen_python_type_print_func_%d", num_created_functions); + if (!name_token) + sstr.Printf ("lldb_autogen_python_type_print_func_%d", num_created_functions); + else + sstr.Printf ("lldb_gen_python_type_print_func_%p", name_token); ++num_created_functions; std::string auto_generated_function_name = sstr.GetData(); @@ -1267,7 +1270,7 @@ ScriptInterpreterPython::GenerateScriptAliasFunction (StringList &user_input, St bool -ScriptInterpreterPython::GenerateTypeSynthClass (StringList &user_input, StringList &output) +ScriptInterpreterPython::GenerateTypeSynthClass (StringList &user_input, StringList &output, void* name_token) { static int num_created_classes = 0; user_input.RemoveBlankLines (); @@ -1280,7 +1283,10 @@ ScriptInterpreterPython::GenerateTypeSynthClass (StringList &user_input, StringL // Wrap all user input into a Python class - sstr.Printf ("lldb_autogen_python_type_synth_class_%d", num_created_classes); + if (!name_token) + sstr.Printf ("lldb_autogen_python_type_synth_class_%d", num_created_classes); + else + sstr.Printf ("lldb_gen_python_type_synth_class_%p", name_token); ++num_created_classes; std::string auto_generated_class_name = sstr.GetData(); @@ -1349,13 +1355,23 @@ ScriptInterpreterPython::CreateSyntheticScriptedProvider (std::string class_name } bool -ScriptInterpreterPython::GenerateTypeScriptFunction (const char* oneliner, StringList &output) +ScriptInterpreterPython::GenerateTypeScriptFunction (const char* oneliner, StringList &output, void* name_token) { - StringList input(oneliner); - return GenerateTypeScriptFunction(input, output); + StringList input; + input.SplitIntoLines(oneliner, strlen(oneliner)); + return GenerateTypeScriptFunction(input, output, name_token); } bool +ScriptInterpreterPython::GenerateTypeSynthClass (const char* oneliner, StringList &output, void* name_token) +{ + StringList input; + input.SplitIntoLines(oneliner, strlen(oneliner)); + return GenerateTypeSynthClass(input, output, name_token); +} + + +bool ScriptInterpreterPython::GenerateBreakpointCommandCallbackData (StringList &user_input, StringList &callback_data) { static int num_created_functions = 0; @@ -1775,12 +1791,12 @@ ScriptInterpreterPython::LoadScriptingModule (const char* pathname, return false; } - // call __lldb_module_init(debugger,dict) + // call __lldb_init_module(debugger,dict) if (!g_swig_call_module_init (basename, m_dictionary_name.c_str(), debugger_sp)) { - error.SetErrorString("calling __lldb_module_init failed"); + error.SetErrorString("calling __lldb_init_module failed"); return false; } return true; |