[Lldb-commits] [lldb] r197858 - There is no need to use the expression parser to generate true and false - writing in a buffer is good enough
Enrico Granata
egranata at apple.com
Sat Dec 21 00:09:52 PST 2013
Author: enrico
Date: Sat Dec 21 02:09:49 2013
New Revision: 197858
URL: http://llvm.org/viewvc/llvm-project?rev=197858&view=rev
Log:
There is no need to use the expression parser to generate true and false - writing in a buffer is good enough
Modified:
lldb/trunk/include/lldb/DataFormatters/CXXFormatterFunctions.h
lldb/trunk/source/DataFormatters/LibCxx.cpp
Modified: lldb/trunk/include/lldb/DataFormatters/CXXFormatterFunctions.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/CXXFormatterFunctions.h?rev=197858&r1=197857&r2=197858&view=diff
==============================================================================
--- lldb/trunk/include/lldb/DataFormatters/CXXFormatterFunctions.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/CXXFormatterFunctions.h Sat Dec 21 02:09:49 2013
@@ -594,10 +594,11 @@ namespace lldb_private {
virtual
~LibcxxVectorBoolSyntheticFrontEnd ();
private:
+ ClangASTType m_bool_type;
ExecutionContextRef m_exe_ctx_ref;
uint64_t m_count;
lldb::addr_t m_base_data_address;
- EvaluateExpressionOptions m_options;
+ std::map<size_t,lldb::ValueObjectSP> m_children;
};
SyntheticChildrenFrontEnd* LibcxxVectorBoolSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
Modified: lldb/trunk/source/DataFormatters/LibCxx.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/LibCxx.cpp?rev=197858&r1=197857&r2=197858&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/LibCxx.cpp (original)
+++ lldb/trunk/source/DataFormatters/LibCxx.cpp Sat Dec 21 02:09:49 2013
@@ -28,17 +28,17 @@ using namespace lldb_private::formatters
lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEnd::LibcxxVectorBoolSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) :
SyntheticChildrenFrontEnd(*valobj_sp.get()),
+m_bool_type(),
m_exe_ctx_ref(),
m_count(0),
m_base_data_address(0),
-m_options()
+m_children()
{
if (valobj_sp)
+ {
Update();
- m_options.SetCoerceToId(false);
- m_options.SetUnwindOnError(true);
- m_options.SetKeepInMemory(true);
- m_options.SetUseDynamic(lldb::eDynamicCanRunTarget);
+ m_bool_type = valobj_sp->GetClangType().GetBasicTypeFromAST(lldb::eBasicTypeBool);
+ }
}
size_t
@@ -50,10 +50,16 @@ lldb_private::formatters::LibcxxVectorBo
lldb::ValueObjectSP
lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEnd::GetChildAtIndex (size_t idx)
{
+ auto iter = m_children.find(idx),
+ end = m_children.end();
+ if (iter != end)
+ return iter->second;
if (idx >= m_count)
return ValueObjectSP();
if (m_base_data_address == 0 || m_count == 0)
return ValueObjectSP();
+ if (!m_bool_type)
+ return ValueObjectSP();
size_t byte_idx = (idx >> 3); // divide by 8 to get byte index
size_t bit_index = (idx & 7); // efficient idx % 8 for bit index
lldb::addr_t byte_location = m_base_data_address + byte_idx;
@@ -88,15 +94,15 @@ lldb_private::formatters::LibcxxVectorBo
return ValueObjectSP();
}
bool bit_set = ((byte & mask) != 0);
- Target& target(process_sp->GetTarget());
ValueObjectSP retval_sp;
- if (bit_set)
- target.EvaluateExpression("(bool)true", NULL, retval_sp);
- else
- target.EvaluateExpression("(bool)false", NULL, retval_sp);
+ DataBufferSP buffer_sp(new DataBufferHeap(m_bool_type.GetByteSize(),0));
+ if (bit_set && buffer_sp && buffer_sp->GetBytes())
+ *(buffer_sp->GetBytes()) = 1; // regardless of endianness, anything non-zero is true
StreamString name; name.Printf("[%zu]",idx);
+ DataExtractor data(buffer_sp, process_sp->GetByteOrder(), process_sp->GetAddressByteSize());
+ retval_sp = ValueObject::CreateValueObjectFromData(name.GetData(), data, m_exe_ctx_ref, m_bool_type);
if (retval_sp)
- retval_sp->SetName(ConstString(name.GetData()));
+ m_children[idx] = retval_sp;
return retval_sp;
}
@@ -113,6 +119,7 @@ lldb_private::formatters::LibcxxVectorBo
bool
lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEnd::Update()
{
+ m_children.clear();
ValueObjectSP valobj_sp = m_backend.GetSP();
if (!valobj_sp)
return false;
More information about the lldb-commits
mailing list