diff options
Diffstat (limited to 'lldb/source/Core')
-rw-r--r-- | lldb/source/Core/DataExtractor.cpp | 2 | ||||
-rw-r--r-- | lldb/source/Core/Debugger.cpp | 14 | ||||
-rw-r--r-- | lldb/source/Core/FormatClasses.cpp | 140 | ||||
-rw-r--r-- | lldb/source/Core/FormatManager.cpp | 75 |
4 files changed, 143 insertions, 88 deletions
diff --git a/lldb/source/Core/DataExtractor.cpp b/lldb/source/Core/DataExtractor.cpp index e364dfd6097..f8be9a421e0 100644 --- a/lldb/source/Core/DataExtractor.cpp +++ b/lldb/source/Core/DataExtractor.cpp @@ -754,7 +754,7 @@ DataExtractor::GetMaxU64Bitfield (uint32_t *offset_ptr, uint32_t size, uint32_t if (bitfield_bit_offset > 0) uval64 >>= bitfield_bit_offset; uint64_t bitfield_mask = ((1ul << bitfield_bit_size) - 1); - if(!bitfield_mask && bitfield_bit_offset == 0 && bitfield_bit_size == 64) + if (!bitfield_mask && bitfield_bit_offset == 0 && bitfield_bit_size == 64) return uval64; uval64 &= bitfield_mask; } diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp index 1c62a8cb46f..cce768f8684 100644 --- a/lldb/source/Core/Debugger.cpp +++ b/lldb/source/Core/Debugger.cpp @@ -1755,12 +1755,6 @@ Debugger::Formatting::ValueFormats::GetCount() return GetFormatManager().Value().GetCount(); } -lldb::FormatCategorySP -Debugger::Formatting::SummaryFormats(const char* category_name) -{ - return GetFormatManager().Category(category_name); -} - bool Debugger::Formatting::GetSummaryFormat(ValueObject& vobj, lldb::SummaryFormatSP& entry) @@ -1804,15 +1798,10 @@ void Debugger::Formatting::Categories::Enable(ConstString& category) { if (GetFormatManager().Category(category.GetCString())->IsEnabled() == false) - { - //GetFormatManager().Category(category.GetCString())->Enable(); GetFormatManager().EnableCategory(category.GetCString()); - } else { - //GetFormatManager().Category(category.GetCString())->Disable(); GetFormatManager().DisableCategory(category.GetCString()); - //GetFormatManager().Category(category.GetCString())->Enable(); GetFormatManager().EnableCategory(category.GetCString()); } } @@ -1821,10 +1810,7 @@ void Debugger::Formatting::Categories::Disable(ConstString& category) { if (GetFormatManager().Category(category.GetCString())->IsEnabled() == true) - { - //GetFormatManager().Category(category.GetCString())->Disable(); GetFormatManager().DisableCategory(category.GetCString()); - } } void diff --git a/lldb/source/Core/FormatClasses.cpp b/lldb/source/Core/FormatClasses.cpp new file mode 100644 index 00000000000..8ff237a603a --- /dev/null +++ b/lldb/source/Core/FormatClasses.cpp @@ -0,0 +1,140 @@ +//===-- FormatClasses.cpp ----------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// C Includes + +// C++ Includes +#include <ostream> + +// Other libraries and framework includes + +// Project includes +#include "lldb/lldb-public.h" +#include "lldb/lldb-enumerations.h" + +#include "lldb/Core/Debugger.h" +#include "lldb/Core/FormatClasses.h" +#include "lldb/Core/StreamString.h" +#include "lldb/Symbol/ClangASTType.h" +#include "lldb/Target/StackFrame.h" + +using namespace lldb; +using namespace lldb_private; + +std::string +ValueFormat::FormatObject(lldb::ValueObjectSP object) +{ + if (!object.get()) + return "NULL"; + + StreamString sstr; + + if (ClangASTType::DumpTypeValue (object->GetClangAST(), // The clang AST + object->GetClangType(), // The clang type to display + &sstr, + m_format, // Format to display this type with + object->GetDataExtractor(), // Data to extract from + 0, // Byte offset into "data" + object->GetByteSize(), // Byte size of item in "data" + object->GetBitfieldBitSize(), // Bitfield bit size + object->GetBitfieldBitOffset())) // Bitfield bit offset + return (sstr.GetString()); + else + { + return ("unsufficient data for value"); + } +} + +std::string +StringSummaryFormat::FormatObject(lldb::ValueObjectSP object) +{ + if (!object.get()) + return "NULL"; + + StreamString s; + ExecutionContext exe_ctx; + object->GetExecutionContextScope()->CalculateExecutionContext(exe_ctx); + SymbolContext sc; + if (exe_ctx.frame) + sc = exe_ctx.frame->GetSymbolContext(lldb::eSymbolContextEverything); + + if (m_show_members_oneliner) + { + const uint32_t num_children = object->GetNumChildren(); + if (num_children) + { + s.PutChar('('); + + for (uint32_t idx=0; idx<num_children; ++idx) + { + lldb::ValueObjectSP child_sp(object->GetChildAtIndex(idx, true)); + if (child_sp.get()) + { + if (idx) + s.PutCString(", "); + s.PutCString(child_sp.get()->GetName().AsCString()); + s.PutChar('='); + s.PutCString(child_sp.get()->GetPrintableRepresentation()); + } + } + + s.PutChar(')'); + + return s.GetString(); + } + else + return ""; + + } + else + { + if (Debugger::FormatPrompt(m_format.c_str(), &sc, &exe_ctx, &sc.line_entry.range.GetBaseAddress(), s, NULL, object.get())) + return s.GetString(); + else + return ""; + } +} + +std::string +StringSummaryFormat::GetDescription() +{ + StreamString sstr; + sstr.Printf ("`%s`%s%s%s%s%s%s", m_format.c_str(), + m_cascades ? "" : " (not cascading)", + m_dont_show_children ? "" : " (show children)", + m_dont_show_value ? " (hide value)" : "", + m_show_members_oneliner ? " (one-line printout)" : "", + m_skip_pointers ? " (skip pointers)" : "", + m_skip_references ? " (skip references)" : ""); + return sstr.GetString(); +} + +std::string +ScriptSummaryFormat::FormatObject(lldb::ValueObjectSP object) +{ + return std::string(ScriptInterpreterPython::CallPythonScriptFunction(m_function_name.c_str(), + object).c_str()); +} + +std::string +ScriptSummaryFormat::GetDescription() +{ + StreamString sstr; + sstr.Printf ("%s%s%s%s%s%s\n%s", m_cascades ? "" : " (not cascading)", + m_dont_show_children ? "" : " (show children)", + m_dont_show_value ? " (hide value)" : "", + m_show_members_oneliner ? " (one-line printout)" : "", + m_skip_pointers ? " (skip pointers)" : "", + m_skip_references ? " (skip references)" : "", + m_python_script.c_str()); + return sstr.GetString(); + +} + + diff --git a/lldb/source/Core/FormatManager.cpp b/lldb/source/Core/FormatManager.cpp index 2ce91aed8fd..e064534028f 100644 --- a/lldb/source/Core/FormatManager.cpp +++ b/lldb/source/Core/FormatManager.cpp @@ -184,7 +184,7 @@ FormatNavigator<lldb::RegularExpressionSP, SummaryFormat>::Delete(const char* ty if ( ::strcmp(type,regex->GetText()) == 0) { m_format_map.map().erase(pos); - if(m_format_map.listener) + if (m_format_map.listener) m_format_map.listener->Changed(); return true; } @@ -220,75 +220,4 @@ FormatManager::GetSingleItemFormat(lldb::Format vector_format) default: return lldb::eFormatInvalid; } -} - -std::string -StringSummaryFormat::FormatObject(lldb::ValueObjectSP object) -{ - if (!object.get()) - return "NULL"; - - StreamString s; - ExecutionContext exe_ctx; - object->GetExecutionContextScope()->CalculateExecutionContext(exe_ctx); - SymbolContext sc; - if (exe_ctx.frame) - sc = exe_ctx.frame->GetSymbolContext(lldb::eSymbolContextEverything); - - if (m_show_members_oneliner) - { - const uint32_t num_children = object->GetNumChildren(); - if (num_children) - { - s.PutChar('('); - - for (uint32_t idx=0; idx<num_children; ++idx) - { - lldb::ValueObjectSP child_sp(object->GetChildAtIndex(idx, true)); - if (child_sp.get()) - { - if (idx) - s.PutCString(", "); - s.PutCString(child_sp.get()->GetName().AsCString()); - s.PutChar('='); - s.PutCString(child_sp.get()->GetPrintableRepresentation()); - } - } - - s.PutChar(')'); - - return s.GetString(); - } - else - return ""; - - } - else - { - if (Debugger::FormatPrompt(m_format.c_str(), &sc, &exe_ctx, &sc.line_entry.range.GetBaseAddress(), s, NULL, object.get())) - return s.GetString(); - else - return ""; - } -} - -void -FormatCategory::ChooseAsPreferential(const char* name) -{ - Mutex::Locker(m_mutex); - lldb::SummaryFormatSP format; - - uint32_t revision = Debugger::Formatting::ValueFormats::GetCurrentRevision(); - - if ( Summary()->Get(name, format) ) - format->SetPriority(revision); - - format.reset(); - - if ( RegexSummary()->Get(name, format) ) - format->SetPriority(revision); - - if(m_change_listener) - m_change_listener->Changed(); - -} +}
\ No newline at end of file |