diff options
author | emaste <emaste@FreeBSD.org> | 2014-07-23 19:35:02 +0000 |
---|---|---|
committer | emaste <emaste@FreeBSD.org> | 2014-07-23 19:35:02 +0000 |
commit | aa794b38fedea0f2e99519975acab0b289714b41 (patch) | |
tree | d542e0aa192601387eab969343acfada413521e6 /contrib/llvm/tools/lldb/source/DataFormatters/LibCxx.cpp | |
parent | 35d9abcb8d9ec0494bd89b56ca40aa22b6206e54 (diff) | |
download | FreeBSD-src-aa794b38fedea0f2e99519975acab0b289714b41.zip FreeBSD-src-aa794b38fedea0f2e99519975acab0b289714b41.tar.gz |
MFC r262528: Update LLDB snapshot to upstream r202189
Highlights include (upstream revs in parens):
- Improvements to the remote GDB protocol client
(r196610, r197579, r197857, r200072, and others)
- Bug fixes for big-endian targets
(r196808)
- Initial support for libdispatch (GCD) queues in the debuggee
(r197190)
- Add "step-avoid-libraries" setting
(r199943)
- IO subsystem improvements (including initial work on a curses gui)
(r200263)
- Support hardware watchpoints on FreeBSD
(r201706)
- Improved unwinding through hand-written assembly functions
(r201839)
- Handle DW_TAG_unspecified_parameters for variadic functions
(r202061)
- Fix Ctrl+C interrupting a running inferior process
(r202086, r202154)
- Various bug fixes for memory leaks, LLDB segfaults, the C++ demangler,
ELF core files, DWARF debug info, and others.
Sponsored by: DARPA, AFRL
Diffstat (limited to 'contrib/llvm/tools/lldb/source/DataFormatters/LibCxx.cpp')
-rw-r--r-- | contrib/llvm/tools/lldb/source/DataFormatters/LibCxx.cpp | 74 |
1 files changed, 63 insertions, 11 deletions
diff --git a/contrib/llvm/tools/lldb/source/DataFormatters/LibCxx.cpp b/contrib/llvm/tools/lldb/source/DataFormatters/LibCxx.cpp index 21e1046..6380d97 100644 --- a/contrib/llvm/tools/lldb/source/DataFormatters/LibCxx.cpp +++ b/contrib/llvm/tools/lldb/source/DataFormatters/LibCxx.cpp @@ -26,19 +26,64 @@ using namespace lldb; using namespace lldb_private; using namespace lldb_private::formatters; +bool +lldb_private::formatters::LibcxxSmartPointerSummaryProvider (ValueObject& valobj, Stream& stream) +{ + ValueObjectSP valobj_sp(valobj.GetNonSyntheticValue()); + if (!valobj_sp) + return false; + ValueObjectSP ptr_sp(valobj_sp->GetChildMemberWithName(ConstString("__ptr_"), true)); + ValueObjectSP count_sp(valobj_sp->GetChildAtNamePath( {ConstString("__cntrl_"),ConstString("__shared_owners_")} )); + ValueObjectSP weakcount_sp(valobj_sp->GetChildAtNamePath( {ConstString("__cntrl_"),ConstString("__shared_weak_owners_")} )); + + if (!ptr_sp) + return false; + + if (ptr_sp->GetValueAsUnsigned(0) == 0) + { + stream.Printf("nullptr"); + return true; + } + else + { + bool print_pointee = false; + Error error; + ValueObjectSP pointee_sp = ptr_sp->Dereference(error); + if (pointee_sp && error.Success()) + { + if (pointee_sp->DumpPrintableRepresentation(stream, + ValueObject::eValueObjectRepresentationStyleSummary, + lldb::eFormatInvalid, + ValueObject::ePrintableRepresentationSpecialCasesDisable, + false)) + print_pointee = true; + } + if (!print_pointee) + stream.Printf("ptr = 0x%" PRIx64, ptr_sp->GetValueAsUnsigned(0)); + } + + if (count_sp) + stream.Printf(" strong=%" PRIu64, 1+count_sp->GetValueAsUnsigned(0)); + + if (weakcount_sp) + stream.Printf(" weak=%" PRIu64, 1+weakcount_sp->GetValueAsUnsigned(0)); + + return true; +} + 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 +95,16 @@ lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEnd::CalculateNumChildre 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 +139,15 @@ lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEnd::GetChildAtIndex (si 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 +164,7 @@ lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEnd::GetChildAtIndex (si bool lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEnd::Update() { + m_children.clear(); ValueObjectSP valobj_sp = m_backend.GetSP(); if (!valobj_sp) return false; |