summaryrefslogtreecommitdiffstats
path: root/lldb/source/Core
diff options
context:
space:
mode:
authorEnrico Granata <granata.enrico@gmail.com>2011-07-24 00:14:56 +0000
committerEnrico Granata <granata.enrico@gmail.com>2011-07-24 00:14:56 +0000
commita37a065c3392ab52abd6a896ac1e95b4878cafad (patch)
tree87687e7cf49c92f298ba9f8c9a65fc0cecb81b0f /lldb/source/Core
parentfb66d5cc9c236d0f6b07177e42509244d9b9d5d5 (diff)
downloadbcm5719-llvm-a37a065c3392ab52abd6a896ac1e95b4878cafad.tar.gz
bcm5719-llvm-a37a065c3392ab52abd6a896ac1e95b4878cafad.zip
Python synthetic children:
- you can now define a Python class as a synthetic children producer for a type the class must adhere to this "interface": def __init__(self, valobj, dict): def get_child_at_index(self, index): def get_child_index(self, name): then using type synth add -l className typeName (e.g. type synth add -l fooSynthProvider foo) (This is still WIP with lots to be added) A small test case is available also as reference llvm-svn: 135865
Diffstat (limited to 'lldb/source/Core')
-rw-r--r--lldb/source/Core/Debugger.cpp8
-rw-r--r--lldb/source/Core/FormatClasses.cpp24
-rw-r--r--lldb/source/Core/ValueObject.cpp5
-rw-r--r--lldb/source/Core/ValueObjectSyntheticFilter.cpp90
4 files changed, 84 insertions, 43 deletions
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index d7538f60d42..dff2eb00fe8 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -1746,6 +1746,12 @@ GetFormatManager() {
return g_format_manager;
}
+void
+Debugger::Formatting::ForceUpdate()
+{
+ GetFormatManager().Changed();
+}
+
bool
Debugger::Formatting::ValueFormats::Get(ValueObject& vobj, ValueFormat::SharedPointer &entry)
{
@@ -1796,7 +1802,7 @@ Debugger::Formatting::GetSummaryFormat(ValueObject& vobj,
}
bool
Debugger::Formatting::GetSyntheticFilter(ValueObject& vobj,
- lldb::SyntheticFilterSP& entry)
+ lldb::SyntheticChildrenSP& entry)
{
return GetFormatManager().Get(vobj, entry);
}
diff --git a/lldb/source/Core/FormatClasses.cpp b/lldb/source/Core/FormatClasses.cpp
index f301a7bbc3a..9a232ae7af4 100644
--- a/lldb/source/Core/FormatClasses.cpp
+++ b/lldb/source/Core/FormatClasses.cpp
@@ -21,8 +21,10 @@
#include "lldb/Core/Debugger.h"
#include "lldb/Core/FormatClasses.h"
#include "lldb/Core/StreamString.h"
+#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Symbol/ClangASTType.h"
#include "lldb/Target/StackFrame.h"
+#include "lldb/Target/Target.h"
using namespace lldb;
using namespace lldb_private;
@@ -156,3 +158,25 @@ SyntheticFilter::GetDescription()
sstr.Printf("}");
return sstr.GetString();
}
+
+SyntheticScriptProvider::FrontEnd::FrontEnd(std::string pclass,
+ lldb::ValueObjectSP be) :
+SyntheticChildrenFrontEnd(be),
+m_python_class(pclass)
+{
+ m_interpreter = be->GetUpdatePoint().GetTarget()->GetDebugger().GetCommandInterpreter().GetScriptInterpreter();
+ m_wrapper = (PyObject*)m_interpreter->CreateSyntheticScriptedProvider(m_python_class, m_backend);
+}
+
+std::string
+SyntheticScriptProvider::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)" : "",
+ m_python_class.c_str());
+
+ return sstr.GetString();
+} \ No newline at end of file
diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp
index 76deaf9d288..a98d0beae93 100644
--- a/lldb/source/Core/ValueObject.cpp
+++ b/lldb/source/Core/ValueObject.cpp
@@ -219,6 +219,8 @@ ValueObject::UpdateFormatsIfNeeded()
m_last_value_format.reset(/*(ValueFormat*)NULL*/);
if (m_last_synthetic_filter.get())
m_last_synthetic_filter.reset(/*(SyntheticFilter*)NULL*/);
+
+ m_synthetic_value = NULL;
Debugger::Formatting::ValueFormats::Get(*this, m_last_value_format);
Debugger::Formatting::GetSummaryFormat(*this, m_last_summary_format);
@@ -1493,7 +1495,8 @@ ValueObject::CalculateSyntheticValue (lldb::SyntheticValueType use_synthetic)
if (m_last_synthetic_filter.get() == NULL)
return;
- m_synthetic_value = new ValueObjectSyntheticFilter(*this, m_last_synthetic_filter);
+ if (m_synthetic_value == NULL)
+ m_synthetic_value = new ValueObjectSynthetic(*this, m_last_synthetic_filter);
}
diff --git a/lldb/source/Core/ValueObjectSyntheticFilter.cpp b/lldb/source/Core/ValueObjectSyntheticFilter.cpp
index 4756b1cea29..d7d00b64611 100644
--- a/lldb/source/Core/ValueObjectSyntheticFilter.cpp
+++ b/lldb/source/Core/ValueObjectSyntheticFilter.cpp
@@ -35,23 +35,25 @@
using namespace lldb_private;
-ValueObjectSyntheticFilter::ValueObjectSyntheticFilter (ValueObject &parent, lldb::SyntheticFilterSP filter) :
+ValueObjectSynthetic::ValueObjectSynthetic (ValueObject &parent, lldb::SyntheticChildrenSP filter) :
ValueObject(parent),
m_address (),
m_type_sp(),
-m_use_synthetic (lldb::eUseSyntheticFilter),
- m_synth_filter(filter)
+ m_use_synthetic (lldb::eUseSyntheticFilter),
+ m_synth_filter(filter->GetFrontEnd(parent.GetSP())),
+ m_children_byindex(),
+ m_name_toindex()
{
SetName (parent.GetName().AsCString());
}
-ValueObjectSyntheticFilter::~ValueObjectSyntheticFilter()
+ValueObjectSynthetic::~ValueObjectSynthetic()
{
m_owning_valobj_sp.reset();
}
lldb::clang_type_t
-ValueObjectSyntheticFilter::GetClangType ()
+ValueObjectSynthetic::GetClangType ()
{
if (m_type_sp)
return m_value.GetClangType();
@@ -60,7 +62,7 @@ ValueObjectSyntheticFilter::GetClangType ()
}
ConstString
-ValueObjectSyntheticFilter::GetTypeName()
+ValueObjectSynthetic::GetTypeName()
{
const bool success = UpdateValueIfNeeded();
if (success && m_type_sp)
@@ -70,22 +72,13 @@ ValueObjectSyntheticFilter::GetTypeName()
}
uint32_t
-ValueObjectSyntheticFilter::CalculateNumChildren()
+ValueObjectSynthetic::CalculateNumChildren()
{
- const bool success = UpdateValueIfNeeded();
- if (!success)
- return 0;
- if (m_synth_filter.get())
- return m_synth_filter->GetCount();
- return 0;
- if (success && m_type_sp)
- return ClangASTContext::GetNumChildren (GetClangAST (), GetClangType(), true);
- else
- return m_parent->GetNumChildren();
+ return m_synth_filter->CalculateNumChildren();
}
clang::ASTContext *
-ValueObjectSyntheticFilter::GetClangAST ()
+ValueObjectSynthetic::GetClangAST ()
{
const bool success = UpdateValueIfNeeded(false);
if (success && m_type_sp)
@@ -95,7 +88,7 @@ ValueObjectSyntheticFilter::GetClangAST ()
}
size_t
-ValueObjectSyntheticFilter::GetByteSize()
+ValueObjectSynthetic::GetByteSize()
{
const bool success = UpdateValueIfNeeded();
if (success && m_type_sp)
@@ -105,13 +98,13 @@ ValueObjectSyntheticFilter::GetByteSize()
}
lldb::ValueType
-ValueObjectSyntheticFilter::GetValueType() const
+ValueObjectSynthetic::GetValueType() const
{
return m_parent->GetValueType();
}
bool
-ValueObjectSyntheticFilter::UpdateValue ()
+ValueObjectSynthetic::UpdateValue ()
{
SetValueIsValid (false);
m_error.Clear();
@@ -124,46 +117,61 @@ ValueObjectSyntheticFilter::UpdateValue ()
return false;
}
+ m_children_byindex.clear();
+ m_name_toindex.clear();
+
SetValueIsValid(true);
return true;
}
lldb::ValueObjectSP
-ValueObjectSyntheticFilter::GetChildAtIndex (uint32_t idx, bool can_create)
+ValueObjectSynthetic::GetChildAtIndex (uint32_t idx, bool can_create)
{
- if (!m_synth_filter.get())
- return lldb::ValueObjectSP();
- if (idx >= m_synth_filter->GetCount())
- return lldb::ValueObjectSP();
- return m_parent->GetSyntheticExpressionPathChild(m_synth_filter->GetExpressionPathAtIndex(idx).c_str(), can_create);
+ ByIndexIterator iter = m_children_byindex.find(idx);
+
+ if (iter == m_children_byindex.end())
+ {
+ if (can_create)
+ {
+ lldb::ValueObjectSP synth_guy = m_synth_filter->GetChildAtIndex (idx, can_create);
+ m_children_byindex[idx]= synth_guy;
+ return synth_guy;
+ }
+ else
+ return lldb::ValueObjectSP();
+ }
+ else
+ return iter->second;
}
lldb::ValueObjectSP
-ValueObjectSyntheticFilter::GetChildMemberWithName (const ConstString &name, bool can_create)
+ValueObjectSynthetic::GetChildMemberWithName (const ConstString &name, bool can_create)
{
- if (!m_synth_filter.get())
- return lldb::ValueObjectSP();
- uint32_t idx = GetIndexOfChildWithName(name);
- if (idx >= m_synth_filter->GetCount())
+
+ uint32_t index = GetIndexOfChildWithName(name);
+
+ if (index == UINT32_MAX)
return lldb::ValueObjectSP();
- return m_parent->GetSyntheticExpressionPathChild(name.GetCString(), can_create);
+
+ return GetChildAtIndex(index, can_create);
}
uint32_t
-ValueObjectSyntheticFilter::GetIndexOfChildWithName (const ConstString &name)
+ValueObjectSynthetic::GetIndexOfChildWithName (const ConstString &name)
{
- const char* name_cstr = name.GetCString();
- for (int i = 0; i < m_synth_filter->GetCount(); i++)
+ NameToIndexIterator iter = m_name_toindex.find(name.GetCString());
+
+ if (iter == m_name_toindex.end())
{
- const char* expr_cstr = m_synth_filter->GetExpressionPathAtIndex(i).c_str();
- if (::strcmp(name_cstr, expr_cstr))
- return i;
+ uint32_t index = m_synth_filter->GetIndexOfChildWithName (name);
+ m_name_toindex[name.GetCString()] = index;
+ return index;
}
- return UINT32_MAX;
+ return iter->second;
}
bool
-ValueObjectSyntheticFilter::IsInScope ()
+ValueObjectSynthetic::IsInScope ()
{
return m_parent->IsInScope();
}
OpenPOWER on IntegriCloud