[Lldb-commits] [lldb] r173728 - <rdar://problem/12978143>
Enrico Granata
egranata at apple.com
Mon Jan 28 15:47:25 PST 2013
Author: enrico
Date: Mon Jan 28 17:47:25 2013
New Revision: 173728
URL: http://llvm.org/viewvc/llvm-project?rev=173728&view=rev
Log:
<rdar://problem/12978143>
Data formatters now cache themselves.
This commit provides a new formatter cache mechanism. Upon resolving a formatter (summary or synthetic), LLDB remembers the resolution for later faster retrieval.
Also moved the data formatters subsystem from the core to its own group and folder for easier management, and done some code reorganization.
The ObjC runtime v1 now returns a class name if asked for the dynamic type of an object. This is required for formatters caching to work with the v1 runtime.
Lastly, this commit disposes of the old hack where ValueObjects had to remember whether they were queried for formatters with their static or dynamic type.
Now the ValueObjectDynamicValue class works well enough that we can use its dynamic value setting for the same purpose.
Added:
lldb/trunk/include/lldb/DataFormatters/
lldb/trunk/include/lldb/DataFormatters/CXXFormatterFunctions.h
- copied, changed from r173281, lldb/trunk/include/lldb/Core/CXXFormatterFunctions.h
lldb/trunk/include/lldb/DataFormatters/DataVisualization.h
- copied, changed from r173281, lldb/trunk/include/lldb/Core/DataVisualization.h
lldb/trunk/include/lldb/DataFormatters/FormatCache.h
lldb/trunk/include/lldb/DataFormatters/FormatClasses.h
- copied, changed from r173281, lldb/trunk/include/lldb/Core/FormatClasses.h
lldb/trunk/include/lldb/DataFormatters/FormatManager.h
- copied, changed from r173281, lldb/trunk/include/lldb/Core/FormatManager.h
lldb/trunk/include/lldb/DataFormatters/FormatNavigator.h
- copied, changed from r173281, lldb/trunk/include/lldb/Core/FormatNavigator.h
lldb/trunk/include/lldb/DataFormatters/TypeCategory.h
lldb/trunk/include/lldb/DataFormatters/TypeCategoryMap.h
lldb/trunk/include/lldb/DataFormatters/TypeFormat.h
lldb/trunk/include/lldb/DataFormatters/TypeSummary.h
lldb/trunk/include/lldb/DataFormatters/TypeSynthetic.h
lldb/trunk/source/DataFormatters/
lldb/trunk/source/DataFormatters/CXXFormatterFunctions.cpp
- copied, changed from r173281, lldb/trunk/source/Core/CXXFormatterFunctions.cpp
lldb/trunk/source/DataFormatters/DataVisualization.cpp
- copied, changed from r173281, lldb/trunk/source/Core/DataVisualization.cpp
lldb/trunk/source/DataFormatters/FormatCache.cpp
lldb/trunk/source/DataFormatters/FormatClasses.cpp
- copied, changed from r173281, lldb/trunk/source/Core/FormatClasses.cpp
lldb/trunk/source/DataFormatters/FormatManager.cpp
- copied, changed from r173281, lldb/trunk/source/Core/FormatManager.cpp
lldb/trunk/source/DataFormatters/TypeCategory.cpp
lldb/trunk/source/DataFormatters/TypeCategoryMap.cpp
lldb/trunk/source/DataFormatters/TypeFormat.cpp
lldb/trunk/source/DataFormatters/TypeSummary.cpp
lldb/trunk/source/DataFormatters/TypeSynthetic.cpp
Removed:
lldb/trunk/include/lldb/Core/CXXFormatterFunctions.h
lldb/trunk/include/lldb/Core/DataVisualization.h
lldb/trunk/include/lldb/Core/FormatClasses.h
lldb/trunk/include/lldb/Core/FormatManager.h
lldb/trunk/include/lldb/Core/FormatNavigator.h
lldb/trunk/source/Core/CXXFormatterFunctions.cpp
lldb/trunk/source/Core/DataVisualization.cpp
lldb/trunk/source/Core/FormatClasses.cpp
lldb/trunk/source/Core/FormatManager.cpp
Modified:
lldb/trunk/include/lldb/API/SBTypeSynthetic.h
lldb/trunk/include/lldb/Core/Debugger.h
lldb/trunk/include/lldb/Core/ValueObject.h
lldb/trunk/include/lldb/Core/ValueObjectDynamicValue.h
lldb/trunk/include/lldb/Core/ValueObjectSyntheticFilter.h
lldb/trunk/include/lldb/lldb-forward.h
lldb/trunk/lldb.xcodeproj/project.pbxproj
lldb/trunk/source/API/SBDebugger.cpp
lldb/trunk/source/API/SBTypeCategory.cpp
lldb/trunk/source/API/SBTypeFilter.cpp
lldb/trunk/source/API/SBTypeFormat.cpp
lldb/trunk/source/API/SBTypeNameSpecifier.cpp
lldb/trunk/source/API/SBTypeSummary.cpp
lldb/trunk/source/API/SBTypeSynthetic.cpp
lldb/trunk/source/API/SBValue.cpp
lldb/trunk/source/Commands/CommandObjectFrame.cpp
lldb/trunk/source/Commands/CommandObjectType.cpp
lldb/trunk/source/Core/Debugger.cpp
lldb/trunk/source/Core/Timer.cpp
lldb/trunk/source/Core/ValueObject.cpp
lldb/trunk/source/Core/ValueObjectDynamicValue.cpp
lldb/trunk/source/Core/ValueObjectSyntheticFilter.cpp
lldb/trunk/source/Interpreter/Args.cpp
lldb/trunk/source/Interpreter/CommandObjectScript.cpp
lldb/trunk/source/Interpreter/OptionGroupVariable.cpp
lldb/trunk/source/Interpreter/OptionValueArch.cpp
lldb/trunk/source/Interpreter/OptionValueDictionary.cpp
lldb/trunk/source/Interpreter/OptionValueFileSpec.cpp
lldb/trunk/source/Interpreter/OptionValueFormat.cpp
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
lldb/trunk/test/functionalities/data-formatter/rdar-12437442/TestRdar12437442.py
Modified: lldb/trunk/include/lldb/API/SBTypeSynthetic.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBTypeSynthetic.h?rev=173728&r1=173727&r2=173728&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBTypeSynthetic.h (original)
+++ lldb/trunk/include/lldb/API/SBTypeSynthetic.h Mon Jan 28 17:47:25 2013
@@ -79,15 +79,15 @@ namespace lldb {
friend class SBTypeCategory;
friend class SBValue;
- lldb::TypeSyntheticImplSP
+ lldb::ScriptedSyntheticChildrenSP
GetSP ();
void
- SetSP (const lldb::TypeSyntheticImplSP &typefilter_impl_sp);
+ SetSP (const lldb::ScriptedSyntheticChildrenSP &typefilter_impl_sp);
- lldb::TypeSyntheticImplSP m_opaque_sp;
+ lldb::ScriptedSyntheticChildrenSP m_opaque_sp;
- SBTypeSynthetic (const lldb::TypeSyntheticImplSP &);
+ SBTypeSynthetic (const lldb::ScriptedSyntheticChildrenSP &);
bool
CopyOnWrite_Impl();
Removed: lldb/trunk/include/lldb/Core/CXXFormatterFunctions.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/CXXFormatterFunctions.h?rev=173727&view=auto
==============================================================================
--- lldb/trunk/include/lldb/Core/CXXFormatterFunctions.h (original)
+++ lldb/trunk/include/lldb/Core/CXXFormatterFunctions.h (removed)
@@ -1,355 +0,0 @@
-//===-- CXXFormatterFunctions.h------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef liblldb_CXXFormatterFunctions_h_
-#define liblldb_CXXFormatterFunctions_h_
-
-#include <stdint.h>
-#include "lldb/lldb-forward.h"
-
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/FormatClasses.h"
-
-#include "clang/AST/ASTContext.h"
-
-namespace lldb_private {
- namespace formatters
- {
-
- bool
- ExtractValueFromObjCExpression (ValueObject &valobj,
- const char* target_type,
- const char* selector,
- uint64_t &value);
-
- lldb::ValueObjectSP
- CallSelectorOnObject (ValueObject &valobj,
- const char* return_type,
- const char* selector,
- uint64_t index);
-
- lldb::ValueObjectSP
- CallSelectorOnObject (ValueObject &valobj,
- const char* return_type,
- const char* selector,
- const char* key);
-
- bool
- Char16StringSummaryProvider (ValueObject& valobj, Stream& stream); // char16_t* and unichar*
-
- bool
- Char32StringSummaryProvider (ValueObject& valobj, Stream& stream); // char32_t*
-
- bool
- WCharStringSummaryProvider (ValueObject& valobj, Stream& stream); // wchar_t*
-
- bool
- Char16SummaryProvider (ValueObject& valobj, Stream& stream); // char16_t and unichar
-
- bool
- Char32SummaryProvider (ValueObject& valobj, Stream& stream); // char32_t
-
- bool
- WCharSummaryProvider (ValueObject& valobj, Stream& stream); // wchar_t
-
- bool
- LibcxxStringSummaryProvider (ValueObject& valobj, Stream& stream); // libc++ std::string
-
- bool
- LibcxxWStringSummaryProvider (ValueObject& valobj, Stream& stream); // libc++ std::wstring
-
- template<bool name_entries>
- bool
- NSDictionarySummaryProvider (ValueObject& valobj, Stream& stream);
-
- bool
- NSArraySummaryProvider (ValueObject& valobj, Stream& stream);
-
- template<bool needs_at>
- bool
- NSDataSummaryProvider (ValueObject& valobj, Stream& stream);
-
- bool
- NSNumberSummaryProvider (ValueObject& valobj, Stream& stream);
-
- bool
- NSStringSummaryProvider (ValueObject& valobj, Stream& stream);
-
- bool
- ObjCBOOLSummaryProvider (ValueObject& valobj, Stream& stream);
-
- template <bool is_sel_ptr>
- bool
- ObjCSELSummaryProvider (ValueObject& valobj, Stream& stream);
-
- bool
- RuntimeSpecificDescriptionSummaryProvider (ValueObject& valobj, Stream& stream);
-
- extern template bool
- NSDictionarySummaryProvider<true> (ValueObject&, Stream&) ;
-
- extern template bool
- NSDictionarySummaryProvider<false> (ValueObject&, Stream&) ;
-
- extern template bool
- NSDataSummaryProvider<true> (ValueObject&, Stream&) ;
-
- extern template bool
- NSDataSummaryProvider<false> (ValueObject&, Stream&) ;
-
- extern template bool
- ObjCSELSummaryProvider<true> (ValueObject&, Stream&);
-
- extern template bool
- ObjCSELSummaryProvider<false> (ValueObject&, Stream&);
-
- class NSArrayMSyntheticFrontEnd : public SyntheticChildrenFrontEnd
- {
- private:
- struct DataDescriptor_32
- {
- uint32_t _used;
- uint32_t _priv1 : 2 ;
- uint32_t _size : 30;
- uint32_t _priv2 : 2;
- uint32_t offset : 30;
- uint32_t _priv3;
- uint32_t _data;
- };
- struct DataDescriptor_64
- {
- uint64_t _used;
- uint64_t _priv1 : 2 ;
- uint64_t _size : 62;
- uint64_t _priv2 : 2;
- uint64_t offset : 62;
- uint32_t _priv3;
- uint64_t _data;
- };
- public:
- NSArrayMSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
-
- virtual size_t
- CalculateNumChildren ();
-
- virtual lldb::ValueObjectSP
- GetChildAtIndex (size_t idx);
-
- virtual bool
- Update();
-
- virtual bool
- MightHaveChildren ();
-
- virtual uint32_t
- GetIndexOfChildWithName (const ConstString &name);
-
- virtual
- ~NSArrayMSyntheticFrontEnd ();
- private:
- ExecutionContextRef m_exe_ctx_ref;
- uint8_t m_ptr_size;
- DataDescriptor_32 *m_data_32;
- DataDescriptor_64 *m_data_64;
- ClangASTType m_id_type;
- std::vector<lldb::ValueObjectSP> m_children;
- };
-
- class NSArrayISyntheticFrontEnd : public SyntheticChildrenFrontEnd
- {
- public:
- NSArrayISyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
-
- virtual size_t
- CalculateNumChildren ();
-
- virtual lldb::ValueObjectSP
- GetChildAtIndex (size_t idx);
-
- virtual bool
- Update();
-
- virtual bool
- MightHaveChildren ();
-
- virtual uint32_t
- GetIndexOfChildWithName (const ConstString &name);
-
- virtual
- ~NSArrayISyntheticFrontEnd ();
- private:
- ExecutionContextRef m_exe_ctx_ref;
- uint8_t m_ptr_size;
- size_t m_items;
- lldb::addr_t m_data_ptr;
- ClangASTType m_id_type;
- std::vector<lldb::ValueObjectSP> m_children;
- };
-
- class NSArrayCodeRunningSyntheticFrontEnd : public SyntheticChildrenFrontEnd
- {
- public:
- NSArrayCodeRunningSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
-
- virtual size_t
- CalculateNumChildren ();
-
- virtual lldb::ValueObjectSP
- GetChildAtIndex (size_t idx);
-
- virtual bool
- Update();
-
- virtual bool
- MightHaveChildren ();
-
- virtual uint32_t
- GetIndexOfChildWithName (const ConstString &name);
-
- virtual
- ~NSArrayCodeRunningSyntheticFrontEnd ();
- };
-
- SyntheticChildrenFrontEnd* NSArraySyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
-
- class NSDictionaryISyntheticFrontEnd : public SyntheticChildrenFrontEnd
- {
- private:
- struct DataDescriptor_32
- {
- uint32_t _used : 26;
- uint32_t _szidx : 6;
- };
- struct DataDescriptor_64
- {
- uint64_t _used : 58;
- uint32_t _szidx : 6;
- };
-
- struct DictionaryItemDescriptor
- {
- lldb::addr_t key_ptr;
- lldb::addr_t val_ptr;
- lldb::ValueObjectSP valobj_sp;
- };
-
- public:
- NSDictionaryISyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
-
- virtual size_t
- CalculateNumChildren ();
-
- virtual lldb::ValueObjectSP
- GetChildAtIndex (size_t idx);
-
- virtual bool
- Update();
-
- virtual bool
- MightHaveChildren ();
-
- virtual uint32_t
- GetIndexOfChildWithName (const ConstString &name);
-
- virtual
- ~NSDictionaryISyntheticFrontEnd ();
- private:
- ExecutionContextRef m_exe_ctx_ref;
- uint8_t m_ptr_size;
- DataDescriptor_32 *m_data_32;
- DataDescriptor_64 *m_data_64;
- lldb::addr_t m_data_ptr;
- std::vector<DictionaryItemDescriptor> m_children;
- };
-
- class NSDictionaryMSyntheticFrontEnd : public SyntheticChildrenFrontEnd
- {
- private:
- struct DataDescriptor_32
- {
- uint32_t _used : 26;
- uint32_t _kvo : 1;
- uint32_t _size;
- uint32_t _mutations;
- uint32_t _objs_addr;
- uint32_t _keys_addr;
- };
- struct DataDescriptor_64
- {
- uint64_t _used : 58;
- uint32_t _kvo : 1;
- uint64_t _size;
- uint64_t _mutations;
- uint64_t _objs_addr;
- uint64_t _keys_addr;
- };
- struct DictionaryItemDescriptor
- {
- lldb::addr_t key_ptr;
- lldb::addr_t val_ptr;
- lldb::ValueObjectSP valobj_sp;
- };
- public:
- NSDictionaryMSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
-
- virtual size_t
- CalculateNumChildren ();
-
- virtual lldb::ValueObjectSP
- GetChildAtIndex (size_t idx);
-
- virtual bool
- Update();
-
- virtual bool
- MightHaveChildren ();
-
- virtual uint32_t
- GetIndexOfChildWithName (const ConstString &name);
-
- virtual
- ~NSDictionaryMSyntheticFrontEnd ();
- private:
- ExecutionContextRef m_exe_ctx_ref;
- uint8_t m_ptr_size;
- DataDescriptor_32 *m_data_32;
- DataDescriptor_64 *m_data_64;
- std::vector<DictionaryItemDescriptor> m_children;
- };
-
- class NSDictionaryCodeRunningSyntheticFrontEnd : public SyntheticChildrenFrontEnd
- {
- public:
- NSDictionaryCodeRunningSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
-
- virtual size_t
- CalculateNumChildren ();
-
- virtual lldb::ValueObjectSP
- GetChildAtIndex (size_t idx);
-
- virtual bool
- Update();
-
- virtual bool
- MightHaveChildren ();
-
- virtual uint32_t
- GetIndexOfChildWithName (const ConstString &name);
-
- virtual
- ~NSDictionaryCodeRunningSyntheticFrontEnd ();
- };
-
- SyntheticChildrenFrontEnd* NSDictionarySyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
-
- }
-}
-
-#endif
Removed: lldb/trunk/include/lldb/Core/DataVisualization.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/DataVisualization.h?rev=173727&view=auto
==============================================================================
--- lldb/trunk/include/lldb/Core/DataVisualization.h (original)
+++ lldb/trunk/include/lldb/Core/DataVisualization.h (removed)
@@ -1,174 +0,0 @@
-//===-- DataVisualization.h ----------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef lldb_DataVisualization_h_
-#define lldb_DataVisualization_h_
-
-// C Includes
-// C++ Includes
-
-// Other libraries and framework includes
-// Project includes
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/FormatClasses.h"
-#include "lldb/Core/FormatManager.h"
-
-namespace lldb_private {
-
-// this class is the high-level front-end of LLDB Data Visualization
-// code in FormatManager.h/cpp is the low-level implementation of this feature
-// clients should refer to this class as the entry-point into the data formatters
-// unless they have a good reason to bypass this and go to the backend
-class DataVisualization
-{
-public:
-
- // use this call to force the FM to consider itself updated even when there is no apparent reason for that
- static void
- ForceUpdate();
-
- static uint32_t
- GetCurrentRevision ();
-
- class ValueFormats
- {
- public:
- static lldb::TypeFormatImplSP
- GetFormat (ValueObject& valobj, lldb::DynamicValueType use_dynamic);
-
- static lldb::TypeFormatImplSP
- GetFormat (const ConstString &type);
-
- static void
- Add (const ConstString &type, const lldb::TypeFormatImplSP &entry);
-
- static bool
- Delete (const ConstString &type);
-
- static void
- Clear ();
-
- static void
- LoopThrough (TypeFormatImpl::ValueCallback callback, void* callback_baton);
-
- static uint32_t
- GetCount ();
-
- static lldb::TypeNameSpecifierImplSP
- GetTypeNameSpecifierForFormatAtIndex (uint32_t);
-
- static lldb::TypeFormatImplSP
- GetFormatAtIndex (uint32_t);
- };
-
- static lldb::TypeSummaryImplSP
- GetSummaryFormat(ValueObject& valobj,
- lldb::DynamicValueType use_dynamic);
-
- static lldb::TypeSummaryImplSP
- GetSummaryForType (lldb::TypeNameSpecifierImplSP type_sp);
-
-#ifndef LLDB_DISABLE_PYTHON
- static lldb::SyntheticChildrenSP
- GetSyntheticChildrenForType (lldb::TypeNameSpecifierImplSP type_sp);
-#endif
-
- static lldb::TypeFilterImplSP
- GetFilterForType (lldb::TypeNameSpecifierImplSP type_sp);
-
-#ifndef LLDB_DISABLE_PYTHON
- static lldb::TypeSyntheticImplSP
- GetSyntheticForType (lldb::TypeNameSpecifierImplSP type_sp);
-#endif
-
-#ifndef LLDB_DISABLE_PYTHON
- static lldb::SyntheticChildrenSP
- GetSyntheticChildren(ValueObject& valobj,
- lldb::DynamicValueType use_dynamic);
-#endif
-
- static bool
- AnyMatches(ConstString type_name,
- TypeCategoryImpl::FormatCategoryItems items = TypeCategoryImpl::ALL_ITEM_TYPES,
- bool only_enabled = true,
- const char** matching_category = NULL,
- TypeCategoryImpl::FormatCategoryItems* matching_type = NULL);
-
- class NamedSummaryFormats
- {
- public:
- static bool
- GetSummaryFormat (const ConstString &type, lldb::TypeSummaryImplSP &entry);
-
- static void
- Add (const ConstString &type, const lldb::TypeSummaryImplSP &entry);
-
- static bool
- Delete (const ConstString &type);
-
- static void
- Clear ();
-
- static void
- LoopThrough (TypeSummaryImpl::SummaryCallback callback, void* callback_baton);
-
- static uint32_t
- GetCount ();
- };
-
- class Categories
- {
- public:
-
- static bool
- GetCategory (const ConstString &category,
- lldb::TypeCategoryImplSP &entry,
- bool allow_create = true);
-
- static void
- Add (const ConstString &category);
-
- static bool
- Delete (const ConstString &category);
-
- static void
- Clear ();
-
- static void
- Clear (const ConstString &category);
-
- static void
- Enable (const ConstString& category,
- CategoryMap::Position = CategoryMap::Default);
-
- static void
- Disable (const ConstString& category);
-
- static void
- Enable (const lldb::TypeCategoryImplSP& category,
- CategoryMap::Position = CategoryMap::Default);
-
- static void
- Disable (const lldb::TypeCategoryImplSP& category);
-
- static void
- LoopThrough (FormatManager::CategoryCallback callback, void* callback_baton);
-
- static uint32_t
- GetCount ();
-
- static lldb::TypeCategoryImplSP
- GetCategoryAtIndex (uint32_t);
- };
-};
-
-
-} // namespace lldb_private
-
-#endif // lldb_DataVisualization_h_
Modified: lldb/trunk/include/lldb/Core/Debugger.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Debugger.h?rev=173728&r1=173727&r2=173728&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Debugger.h (original)
+++ lldb/trunk/include/lldb/Core/Debugger.h Mon Jan 28 17:47:25 2013
@@ -23,13 +23,13 @@
#include "lldb/Core/Broadcaster.h"
#include "lldb/Core/Communication.h"
-#include "lldb/Core/FormatManager.h"
#include "lldb/Core/InputReaderStack.h"
#include "lldb/Core/Listener.h"
#include "lldb/Core/StreamFile.h"
#include "lldb/Core/SourceManager.h"
#include "lldb/Core/UserID.h"
#include "lldb/Core/UserSettingsController.h"
+#include "lldb/DataFormatters/FormatManager.h"
#include "lldb/Host/Terminal.h"
#include "lldb/Interpreter/OptionValueProperties.h"
#include "lldb/Target/ExecutionContext.h"
Removed: lldb/trunk/include/lldb/Core/FormatClasses.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FormatClasses.h?rev=173727&view=auto
==============================================================================
--- lldb/trunk/include/lldb/Core/FormatClasses.h (original)
+++ lldb/trunk/include/lldb/Core/FormatClasses.h (removed)
@@ -1,1598 +0,0 @@
-//===-- FormatClasses.h -----------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef lldb_FormatClasses_h_
-#define lldb_FormatClasses_h_
-
-// C Includes
-#include <stdint.h>
-#include <unistd.h>
-
-// C++ Includes
-#include <string>
-#include <vector>
-
-// Other libraries and framework includes
-
-// Project includes
-#include "lldb/lldb-public.h"
-#include "lldb/lldb-enumerations.h"
-
-#include "lldb/Core/ValueObject.h"
-#include "lldb/Interpreter/ScriptInterpreterPython.h"
-#include "lldb/Symbol/Type.h"
-
-namespace lldb_private {
-
-class TypeFormatImpl
-{
-public:
- class Flags
- {
- public:
-
- Flags () :
- m_flags (lldb::eTypeOptionCascade)
- {}
-
- Flags (const Flags& other) :
- m_flags (other.m_flags)
- {}
-
- Flags (uint32_t value) :
- m_flags (value)
- {}
-
- Flags&
- operator = (const Flags& rhs)
- {
- if (&rhs != this)
- m_flags = rhs.m_flags;
-
- return *this;
- }
-
- Flags&
- operator = (const uint32_t& rhs)
- {
- m_flags = rhs;
- return *this;
- }
-
- Flags&
- Clear()
- {
- m_flags = 0;
- return *this;
- }
-
- bool
- GetCascades () const
- {
- return (m_flags & lldb::eTypeOptionCascade) == lldb::eTypeOptionCascade;
- }
-
- Flags&
- SetCascades (bool value = true)
- {
- if (value)
- m_flags |= lldb::eTypeOptionCascade;
- else
- m_flags &= ~lldb::eTypeOptionCascade;
- return *this;
- }
-
- bool
- GetSkipPointers () const
- {
- return (m_flags & lldb::eTypeOptionSkipPointers) == lldb::eTypeOptionSkipPointers;
- }
-
- Flags&
- SetSkipPointers (bool value = true)
- {
- if (value)
- m_flags |= lldb::eTypeOptionSkipPointers;
- else
- m_flags &= ~lldb::eTypeOptionSkipPointers;
- return *this;
- }
-
- bool
- GetSkipReferences () const
- {
- return (m_flags & lldb::eTypeOptionSkipReferences) == lldb::eTypeOptionSkipReferences;
- }
-
- Flags&
- SetSkipReferences (bool value = true)
- {
- if (value)
- m_flags |= lldb::eTypeOptionSkipReferences;
- else
- m_flags &= ~lldb::eTypeOptionSkipReferences;
- return *this;
- }
-
- uint32_t
- GetValue ()
- {
- return m_flags;
- }
-
- void
- SetValue (uint32_t value)
- {
- m_flags = value;
- }
-
- private:
- uint32_t m_flags;
- };
-
- TypeFormatImpl (lldb::Format f = lldb::eFormatInvalid,
- const Flags& flags = Flags());
-
- typedef STD_SHARED_PTR(TypeFormatImpl) SharedPointer;
- typedef bool(*ValueCallback)(void*, ConstString, const lldb::TypeFormatImplSP&);
-
- ~TypeFormatImpl ()
- {
- }
-
- bool
- Cascades () const
- {
- return m_flags.GetCascades();
- }
- bool
- SkipsPointers () const
- {
- return m_flags.GetSkipPointers();
- }
- bool
- SkipsReferences () const
- {
- return m_flags.GetSkipReferences();
- }
-
- void
- SetCascades (bool value)
- {
- m_flags.SetCascades(value);
- }
-
- void
- SetSkipsPointers (bool value)
- {
- m_flags.SetSkipPointers(value);
- }
-
- void
- SetSkipsReferences (bool value)
- {
- m_flags.SetSkipReferences(value);
- }
-
- lldb::Format
- GetFormat () const
- {
- return m_format;
- }
-
- void
- SetFormat (lldb::Format fmt)
- {
- m_format = fmt;
- }
-
- uint32_t
- GetOptions ()
- {
- return m_flags.GetValue();
- }
-
- void
- SetOptions (uint32_t value)
- {
- m_flags.SetValue(value);
- }
-
- uint32_t&
- GetRevision ()
- {
- return m_my_revision;
- }
-
- std::string
- GetDescription();
-
-protected:
- Flags m_flags;
- lldb::Format m_format;
- uint32_t m_my_revision;
-
-private:
- DISALLOW_COPY_AND_ASSIGN(TypeFormatImpl);
-};
-
-class SyntheticChildrenFrontEnd
-{
-protected:
- ValueObject &m_backend;
-public:
-
- SyntheticChildrenFrontEnd (ValueObject &backend) :
- m_backend(backend)
- {}
-
- virtual
- ~SyntheticChildrenFrontEnd ()
- {
- }
-
- virtual size_t
- CalculateNumChildren () = 0;
-
- virtual lldb::ValueObjectSP
- GetChildAtIndex (size_t idx) = 0;
-
- virtual uint32_t
- GetIndexOfChildWithName (const ConstString &name) = 0;
-
- // this function is assumed to always succeed and it if fails, the front-end should know to deal
- // with it in the correct way (most probably, by refusing to return any children)
- // the return value of Update() should actually be interpreted as "ValueObjectSyntheticFilter cache is good/bad"
- // if =true, ValueObjectSyntheticFilter is allowed to use the children it fetched previously and cached
- // if =false, ValueObjectSyntheticFilter must throw away its cache, and query again for children
- virtual bool
- Update () = 0;
-
- // if this function returns false, then CalculateNumChildren() MUST return 0 since UI frontends
- // might validly decide not to inquire for children given a false return value from this call
- // if it returns true, then CalculateNumChildren() can return any number >= 0 (0 being valid)
- // it should if at all possible be more efficient than CalculateNumChildren()
- virtual bool
- MightHaveChildren () = 0;
-
- typedef STD_SHARED_PTR(SyntheticChildrenFrontEnd) SharedPointer;
- typedef std::auto_ptr<SyntheticChildrenFrontEnd> AutoPointer;
-
-private:
- DISALLOW_COPY_AND_ASSIGN(SyntheticChildrenFrontEnd);
-};
-
-class SyntheticChildren
-{
-public:
-
- class Flags
- {
- public:
-
- Flags () :
- m_flags (lldb::eTypeOptionCascade)
- {}
-
- Flags (const Flags& other) :
- m_flags (other.m_flags)
- {}
-
- Flags (uint32_t value) :
- m_flags (value)
- {}
-
- Flags&
- operator = (const Flags& rhs)
- {
- if (&rhs != this)
- m_flags = rhs.m_flags;
-
- return *this;
- }
-
- Flags&
- operator = (const uint32_t& rhs)
- {
- m_flags = rhs;
- return *this;
- }
-
- Flags&
- Clear()
- {
- m_flags = 0;
- return *this;
- }
-
- bool
- GetCascades () const
- {
- return (m_flags & lldb::eTypeOptionCascade) == lldb::eTypeOptionCascade;
- }
-
- Flags&
- SetCascades (bool value = true)
- {
- if (value)
- m_flags |= lldb::eTypeOptionCascade;
- else
- m_flags &= ~lldb::eTypeOptionCascade;
- return *this;
- }
-
- bool
- GetSkipPointers () const
- {
- return (m_flags & lldb::eTypeOptionSkipPointers) == lldb::eTypeOptionSkipPointers;
- }
-
- Flags&
- SetSkipPointers (bool value = true)
- {
- if (value)
- m_flags |= lldb::eTypeOptionSkipPointers;
- else
- m_flags &= ~lldb::eTypeOptionSkipPointers;
- return *this;
- }
-
- bool
- GetSkipReferences () const
- {
- return (m_flags & lldb::eTypeOptionSkipReferences) == lldb::eTypeOptionSkipReferences;
- }
-
- Flags&
- SetSkipReferences (bool value = true)
- {
- if (value)
- m_flags |= lldb::eTypeOptionSkipReferences;
- else
- m_flags &= ~lldb::eTypeOptionSkipReferences;
- return *this;
- }
-
- uint32_t
- GetValue ()
- {
- return m_flags;
- }
-
- void
- SetValue (uint32_t value)
- {
- m_flags = value;
- }
-
- private:
- uint32_t m_flags;
- };
-
- SyntheticChildren (const Flags& flags) :
- m_flags(flags)
- {
- }
-
- virtual
- ~SyntheticChildren ()
- {
- }
-
- bool
- Cascades () const
- {
- return m_flags.GetCascades();
- }
- bool
- SkipsPointers () const
- {
- return m_flags.GetSkipPointers();
- }
- bool
- SkipsReferences () const
- {
- return m_flags.GetSkipReferences();
- }
-
- void
- SetCascades (bool value)
- {
- m_flags.SetCascades(value);
- }
-
- void
- SetSkipsPointers (bool value)
- {
- m_flags.SetSkipPointers(value);
- }
-
- void
- SetSkipsReferences (bool value)
- {
- m_flags.SetSkipReferences(value);
- }
-
- uint32_t
- GetOptions ()
- {
- return m_flags.GetValue();
- }
-
- void
- SetOptions (uint32_t value)
- {
- m_flags.SetValue(value);
- }
-
- virtual bool
- IsScripted () = 0;
-
- virtual std::string
- GetDescription () = 0;
-
- virtual SyntheticChildrenFrontEnd::AutoPointer
- GetFrontEnd (ValueObject &backend) = 0;
-
- typedef STD_SHARED_PTR(SyntheticChildren) SharedPointer;
- typedef bool(*SyntheticChildrenCallback)(void*, ConstString, const SyntheticChildren::SharedPointer&);
-
- uint32_t&
- GetRevision ()
- {
- return m_my_revision;
- }
-
-protected:
- uint32_t m_my_revision;
- Flags m_flags;
-
-private:
- DISALLOW_COPY_AND_ASSIGN(SyntheticChildren);
-};
-
-class TypeFilterImpl : public SyntheticChildren
-{
- std::vector<std::string> m_expression_paths;
-public:
- TypeFilterImpl(const SyntheticChildren::Flags& flags) :
- SyntheticChildren(flags),
- m_expression_paths()
- {
- }
-
- void
- AddExpressionPath (const char* path)
- {
- AddExpressionPath(std::string(path));
- }
-
- void
- Clear()
- {
- m_expression_paths.clear();
- }
-
- size_t
- GetCount() const
- {
- return m_expression_paths.size();
- }
-
- const char*
- GetExpressionPathAtIndex(size_t i) const
- {
- return m_expression_paths[i].c_str();
- }
-
- bool
- SetExpressionPathAtIndex (int i, const char* path)
- {
- return SetExpressionPathAtIndex(i, std::string(path));
- }
-
- void
- AddExpressionPath (std::string path)
- {
- bool need_add_dot = true;
- if (path[0] == '.' ||
- (path[0] == '-' && path[1] == '>') ||
- path[0] == '[')
- need_add_dot = false;
- // add a '.' symbol to help forgetful users
- if(!need_add_dot)
- m_expression_paths.push_back(path);
- else
- m_expression_paths.push_back(std::string(".") + path);
- }
-
- bool
- SetExpressionPathAtIndex (int i, std::string path)
- {
- if (i >= GetCount())
- return false;
- bool need_add_dot = true;
- if (path[0] == '.' ||
- (path[0] == '-' && path[1] == '>') ||
- path[0] == '[')
- need_add_dot = false;
- // add a '.' symbol to help forgetful users
- if(!need_add_dot)
- m_expression_paths[i] = path;
- else
- m_expression_paths[i] = std::string(".") + path;
- return true;
- }
-
- bool
- IsScripted()
- {
- return false;
- }
-
- std::string
- GetDescription();
-
- class FrontEnd : public SyntheticChildrenFrontEnd
- {
- private:
- TypeFilterImpl* filter;
- public:
-
- FrontEnd(TypeFilterImpl* flt,
- ValueObject &backend) :
- SyntheticChildrenFrontEnd(backend),
- filter(flt)
- {}
-
- virtual
- ~FrontEnd()
- {
- }
-
- virtual size_t
- CalculateNumChildren()
- {
- return filter->GetCount();
- }
-
- virtual lldb::ValueObjectSP
- GetChildAtIndex (size_t idx)
- {
- if (idx >= filter->GetCount())
- return lldb::ValueObjectSP();
- return m_backend.GetSyntheticExpressionPathChild(filter->GetExpressionPathAtIndex(idx), true);
- }
-
- virtual bool
- Update() { return false; }
-
- virtual bool
- MightHaveChildren ()
- {
- return filter->GetCount() > 0;
- }
-
- virtual uint32_t
- GetIndexOfChildWithName (const ConstString &name)
- {
- const char* name_cstr = name.GetCString();
- for (int i = 0; i < filter->GetCount(); i++)
- {
- const char* expr_cstr = filter->GetExpressionPathAtIndex(i);
- if (expr_cstr)
- {
- if (*expr_cstr == '.')
- expr_cstr++;
- else if (*expr_cstr == '-' && *(expr_cstr+1) == '>')
- expr_cstr += 2;
- }
- if (!::strcmp(name_cstr, expr_cstr))
- return i;
- }
- return UINT32_MAX;
- }
-
- typedef STD_SHARED_PTR(SyntheticChildrenFrontEnd) SharedPointer;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(FrontEnd);
- };
-
- virtual SyntheticChildrenFrontEnd::AutoPointer
- GetFrontEnd(ValueObject &backend)
- {
- return SyntheticChildrenFrontEnd::AutoPointer(new FrontEnd(this, backend));
- }
-
-private:
- DISALLOW_COPY_AND_ASSIGN(TypeFilterImpl);
-};
-
- class CXXSyntheticChildren : public SyntheticChildren
- {
- public:
- typedef SyntheticChildrenFrontEnd* (*CreateFrontEndCallback) (CXXSyntheticChildren*, lldb::ValueObjectSP);
- protected:
- CreateFrontEndCallback m_create_callback;
- std::string m_description;
- public:
- CXXSyntheticChildren(const SyntheticChildren::Flags& flags,
- const char* description,
- CreateFrontEndCallback callback) :
- SyntheticChildren(flags),
- m_create_callback(callback),
- m_description(description ? description : "")
- {
- }
-
- bool
- IsScripted()
- {
- return false;
- }
-
- std::string
- GetDescription();
-
- virtual SyntheticChildrenFrontEnd::AutoPointer
- GetFrontEnd(ValueObject &backend)
- {
- return SyntheticChildrenFrontEnd::AutoPointer(m_create_callback(this, backend.GetSP()));
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(CXXSyntheticChildren);
- };
-
-#ifndef LLDB_DISABLE_PYTHON
-
-class TypeSyntheticImpl : public SyntheticChildren
-{
- std::string m_python_class;
- std::string m_python_code;
-public:
-
- TypeSyntheticImpl(const SyntheticChildren::Flags& flags,
- const char* pclass,
- const char* pcode = NULL) :
- SyntheticChildren(flags),
- m_python_class(),
- m_python_code()
- {
- if (pclass)
- m_python_class = pclass;
- if (pcode)
- m_python_code = pcode;
- }
-
- const char*
- GetPythonClassName()
- {
- return m_python_class.c_str();
- }
-
- const char*
- GetPythonCode()
- {
- return m_python_code.c_str();
- }
-
- void
- SetPythonClassName (const char* fname)
- {
- m_python_class.assign(fname);
- m_python_code.clear();
- }
-
- void
- SetPythonCode (const char* script)
- {
- m_python_code.assign(script);
- }
-
- std::string
- GetDescription();
-
- bool
- IsScripted()
- {
- return true;
- }
-
- class FrontEnd : public SyntheticChildrenFrontEnd
- {
- private:
- std::string m_python_class;
- lldb::ScriptInterpreterObjectSP m_wrapper_sp;
- ScriptInterpreter *m_interpreter;
- public:
-
- FrontEnd(std::string pclass,
- ValueObject &backend);
-
- virtual
- ~FrontEnd();
-
- virtual size_t
- CalculateNumChildren()
- {
- if (!m_wrapper_sp || m_interpreter == NULL)
- return 0;
- return m_interpreter->CalculateNumChildren(m_wrapper_sp);
- }
-
- virtual lldb::ValueObjectSP
- GetChildAtIndex (size_t idx);
-
- virtual bool
- Update()
- {
- if (!m_wrapper_sp || m_interpreter == NULL)
- return false;
-
- return m_interpreter->UpdateSynthProviderInstance(m_wrapper_sp);
- }
-
- virtual bool
- MightHaveChildren()
- {
- if (!m_wrapper_sp || m_interpreter == NULL)
- return false;
-
- return m_interpreter->MightHaveChildrenSynthProviderInstance(m_wrapper_sp);
- }
-
- virtual uint32_t
- GetIndexOfChildWithName (const ConstString &name)
- {
- if (!m_wrapper_sp || m_interpreter == NULL)
- return UINT32_MAX;
- return m_interpreter->GetIndexOfChildWithName(m_wrapper_sp, name.GetCString());
- }
-
- typedef STD_SHARED_PTR(SyntheticChildrenFrontEnd) SharedPointer;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(FrontEnd);
- };
-
- virtual SyntheticChildrenFrontEnd::AutoPointer
- GetFrontEnd(ValueObject &backend)
- {
- return SyntheticChildrenFrontEnd::AutoPointer(new FrontEnd(m_python_class, backend));
- }
-
-private:
- DISALLOW_COPY_AND_ASSIGN(TypeSyntheticImpl);
-};
-
-#endif // #ifndef LLDB_DISABLE_PYTHON
-class SyntheticArrayView : public SyntheticChildren
-{
-public:
-
- struct SyntheticArrayRange
- {
- private:
- int m_low;
- int m_high;
- SyntheticArrayRange* m_next;
-
- public:
-
- SyntheticArrayRange () :
- m_low(-1),
- m_high(-2),
- m_next(NULL)
- {}
-
- SyntheticArrayRange (int L) :
- m_low(L),
- m_high(L),
- m_next(NULL)
- {}
-
- SyntheticArrayRange (int L, int H) :
- m_low(L),
- m_high(H),
- m_next(NULL)
- {}
-
- SyntheticArrayRange (int L, int H, SyntheticArrayRange* N) :
- m_low(L),
- m_high(H),
- m_next(N)
- {}
-
- inline int
- GetLow ()
- {
- return m_low;
- }
-
- inline int
- GetHigh ()
- {
- return m_high;
- }
-
- inline void
- SetLow (int L)
- {
- m_low = L;
- }
-
- inline void
- SetHigh (int H)
- {
- m_high = H;
- }
-
- inline int
- GetSelfCount()
- {
- return GetHigh() - GetLow() + 1;
- }
-
- int
- GetCount()
- {
- int count = GetSelfCount();
- if (m_next)
- count += m_next->GetCount();
- return count;
- }
-
- inline SyntheticArrayRange*
- GetNext()
- {
- return m_next;
- }
-
- void
- SetNext(SyntheticArrayRange* N)
- {
- if (m_next)
- delete m_next;
- m_next = N;
- }
-
- void
- SetNext(int L, int H)
- {
- if (m_next)
- delete m_next;
- m_next = new SyntheticArrayRange(L, H);
- }
-
- void
- SetNext(int L)
- {
- if (m_next)
- delete m_next;
- m_next = new SyntheticArrayRange(L);
- }
-
- ~SyntheticArrayRange()
- {
- delete m_next;
- m_next = NULL;
- }
-
- };
-
- SyntheticArrayView(const SyntheticChildren::Flags& flags) :
- SyntheticChildren(flags),
- m_head(),
- m_tail(&m_head)
- {
- }
-
- void
- AddRange(int L, int H)
- {
- m_tail->SetLow(L);
- m_tail->SetHigh(H);
- m_tail->SetNext(new SyntheticArrayRange());
- m_tail = m_tail->GetNext();
- }
-
- int
- GetCount()
- {
- return m_head.GetCount();
- }
-
- int
- GetRealIndexForIndex(size_t i);
-
- bool
- IsScripted()
- {
- return false;
- }
-
- std::string
- GetDescription();
-
- class FrontEnd : public SyntheticChildrenFrontEnd
- {
- private:
- SyntheticArrayView* filter;
- public:
-
- FrontEnd(SyntheticArrayView* flt,
- ValueObject &backend) :
- SyntheticChildrenFrontEnd(backend),
- filter(flt)
- {}
-
- virtual
- ~FrontEnd()
- {
- }
-
- virtual size_t
- CalculateNumChildren()
- {
- return filter->GetCount();
- }
-
- virtual bool
- MightHaveChildren ()
- {
- return filter->GetCount() > 0;
- }
-
- virtual lldb::ValueObjectSP
- GetChildAtIndex (size_t idx)
- {
- if (idx >= filter->GetCount())
- return lldb::ValueObjectSP();
- return m_backend.GetSyntheticArrayMember(filter->GetRealIndexForIndex(idx), true);
- }
-
- virtual bool
- Update() { return false; }
-
- virtual uint32_t
- GetIndexOfChildWithName (const ConstString &name_cs);
-
- typedef STD_SHARED_PTR(SyntheticChildrenFrontEnd) SharedPointer;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(FrontEnd);
- };
-
- virtual SyntheticChildrenFrontEnd::AutoPointer
- GetFrontEnd(ValueObject &backend)
- {
- return SyntheticChildrenFrontEnd::AutoPointer(new FrontEnd(this, backend));
- }
-private:
- SyntheticArrayRange m_head;
- SyntheticArrayRange *m_tail;
-
-private:
- DISALLOW_COPY_AND_ASSIGN(SyntheticArrayView);
-};
-
-
-class TypeSummaryImpl
-{
-public:
- class Flags
- {
- public:
-
- Flags () :
- m_flags (lldb::eTypeOptionCascade)
- {}
-
- Flags (const Flags& other) :
- m_flags (other.m_flags)
- {}
-
- Flags (uint32_t value) :
- m_flags (value)
- {}
-
- Flags&
- operator = (const Flags& rhs)
- {
- if (&rhs != this)
- m_flags = rhs.m_flags;
-
- return *this;
- }
-
- Flags&
- operator = (const uint32_t& rhs)
- {
- m_flags = rhs;
- return *this;
- }
-
- Flags&
- Clear()
- {
- m_flags = 0;
- return *this;
- }
-
- bool
- GetCascades () const
- {
- return (m_flags & lldb::eTypeOptionCascade) == lldb::eTypeOptionCascade;
- }
-
- Flags&
- SetCascades (bool value = true)
- {
- if (value)
- m_flags |= lldb::eTypeOptionCascade;
- else
- m_flags &= ~lldb::eTypeOptionCascade;
- return *this;
- }
-
- bool
- GetSkipPointers () const
- {
- return (m_flags & lldb::eTypeOptionSkipPointers) == lldb::eTypeOptionSkipPointers;
- }
-
- Flags&
- SetSkipPointers (bool value = true)
- {
- if (value)
- m_flags |= lldb::eTypeOptionSkipPointers;
- else
- m_flags &= ~lldb::eTypeOptionSkipPointers;
- return *this;
- }
-
- bool
- GetSkipReferences () const
- {
- return (m_flags & lldb::eTypeOptionSkipReferences) == lldb::eTypeOptionSkipReferences;
- }
-
- Flags&
- SetSkipReferences (bool value = true)
- {
- if (value)
- m_flags |= lldb::eTypeOptionSkipReferences;
- else
- m_flags &= ~lldb::eTypeOptionSkipReferences;
- return *this;
- }
-
- bool
- GetDontShowChildren () const
- {
- return (m_flags & lldb::eTypeOptionHideChildren) == lldb::eTypeOptionHideChildren;
- }
-
- Flags&
- SetDontShowChildren (bool value = true)
- {
- if (value)
- m_flags |= lldb::eTypeOptionHideChildren;
- else
- m_flags &= ~lldb::eTypeOptionHideChildren;
- return *this;
- }
-
- bool
- GetDontShowValue () const
- {
- return (m_flags & lldb::eTypeOptionHideValue) == lldb::eTypeOptionHideValue;
- }
-
- Flags&
- SetDontShowValue (bool value = true)
- {
- if (value)
- m_flags |= lldb::eTypeOptionHideValue;
- else
- m_flags &= ~lldb::eTypeOptionHideValue;
- return *this;
- }
-
- bool
- GetShowMembersOneLiner () const
- {
- return (m_flags & lldb::eTypeOptionShowOneLiner) == lldb::eTypeOptionShowOneLiner;
- }
-
- Flags&
- SetShowMembersOneLiner (bool value = true)
- {
- if (value)
- m_flags |= lldb::eTypeOptionShowOneLiner;
- else
- m_flags &= ~lldb::eTypeOptionShowOneLiner;
- return *this;
- }
-
- bool
- GetHideItemNames () const
- {
- return (m_flags & lldb::eTypeOptionHideNames) == lldb::eTypeOptionHideNames;
- }
-
- Flags&
- SetHideItemNames (bool value = true)
- {
- if (value)
- m_flags |= lldb::eTypeOptionHideNames;
- else
- m_flags &= ~lldb::eTypeOptionHideNames;
- return *this;
- }
-
- uint32_t
- GetValue ()
- {
- return m_flags;
- }
-
- void
- SetValue (uint32_t value)
- {
- m_flags = value;
- }
-
- private:
- uint32_t m_flags;
- };
-
- typedef enum Type
- {
- eTypeUnknown,
- eTypeString,
- eTypeScript,
- eTypeCallback
- } Type;
-
- TypeSummaryImpl (const TypeSummaryImpl::Flags& flags);
-
- bool
- Cascades () const
- {
- return m_flags.GetCascades();
- }
- bool
- SkipsPointers () const
- {
- return m_flags.GetSkipPointers();
- }
- bool
- SkipsReferences () const
- {
- return m_flags.GetSkipReferences();
- }
-
- bool
- DoesPrintChildren () const
- {
- return !m_flags.GetDontShowChildren();
- }
-
- bool
- DoesPrintValue () const
- {
- return !m_flags.GetDontShowValue();
- }
-
- bool
- IsOneliner () const
- {
- return m_flags.GetShowMembersOneLiner();
- }
-
- bool
- HideNames () const
- {
- return m_flags.GetHideItemNames();
- }
-
- void
- SetCascades (bool value)
- {
- m_flags.SetCascades(value);
- }
-
- void
- SetSkipsPointers (bool value)
- {
- m_flags.SetSkipPointers(value);
- }
-
- void
- SetSkipsReferences (bool value)
- {
- m_flags.SetSkipReferences(value);
- }
-
- void
- SetDoesPrintChildren (bool value)
- {
- m_flags.SetDontShowChildren(!value);
- }
-
- void
- SetDoesPrintValue (bool value)
- {
- m_flags.SetDontShowValue(!value);
- }
-
- void
- SetIsOneliner (bool value)
- {
- m_flags.SetShowMembersOneLiner(value);
- }
-
- void
- SetHideNames (bool value)
- {
- m_flags.SetHideItemNames(value);
- }
-
- uint32_t
- GetOptions ()
- {
- return m_flags.GetValue();
- }
-
- void
- SetOptions (uint32_t value)
- {
- m_flags.SetValue(value);
- }
-
- virtual
- ~TypeSummaryImpl ()
- {
- }
-
- // we are using a ValueObject* instead of a ValueObjectSP because we do not need to hold on to this for
- // extended periods of time and we trust the ValueObject to stay around for as long as it is required
- // for us to generate its summary
- virtual bool
- FormatObject (ValueObject *valobj,
- std::string& dest) = 0;
-
- virtual std::string
- GetDescription () = 0;
-
- virtual bool
- IsScripted() = 0;
-
- virtual Type
- GetType () = 0;
-
- uint32_t&
- GetRevision ()
- {
- return m_my_revision;
- }
-
- typedef STD_SHARED_PTR(TypeSummaryImpl) SharedPointer;
- typedef bool(*SummaryCallback)(void*, ConstString, const lldb::TypeSummaryImplSP&);
- typedef bool(*RegexSummaryCallback)(void*, lldb::RegularExpressionSP, const lldb::TypeSummaryImplSP&);
-
-protected:
- uint32_t m_my_revision;
- Flags m_flags;
-
-private:
- DISALLOW_COPY_AND_ASSIGN(TypeSummaryImpl);
-};
-
-// simple string-based summaries, using ${var to show data
-struct StringSummaryFormat : public TypeSummaryImpl
-{
- std::string m_format;
-
- StringSummaryFormat(const TypeSummaryImpl::Flags& flags,
- const char* f);
-
- const char*
- GetSummaryString () const
- {
- return m_format.c_str();
- }
-
- void
- SetSummaryString (const char* data)
- {
- if (data)
- m_format.assign(data);
- else
- m_format.clear();
- }
-
- virtual
- ~StringSummaryFormat()
- {
- }
-
- virtual bool
- FormatObject(ValueObject *valobj,
- std::string& dest);
-
- virtual std::string
- GetDescription();
-
- virtual bool
- IsScripted()
- {
- return false;
- }
-
-
- virtual Type
- GetType ()
- {
- return TypeSummaryImpl::eTypeString;
- }
-
-private:
- DISALLOW_COPY_AND_ASSIGN(StringSummaryFormat);
-};
-
-// summaries implemented via a C++ function
-struct CXXFunctionSummaryFormat : public TypeSummaryImpl
-{
-
- // we should convert these to SBValue and SBStream if we ever cross
- // the boundary towards the external world
- typedef bool (*Callback)(ValueObject& valobj,
- Stream& dest);
-
-
- Callback m_impl;
- std::string m_description;
-
- CXXFunctionSummaryFormat(const TypeSummaryImpl::Flags& flags,
- Callback impl,
- const char* description);
-
- Callback
- GetBackendFunction () const
- {
- return m_impl;
- }
-
- const char*
- GetTextualInfo () const
- {
- return m_description.c_str();
- }
-
- void
- SetBackendFunction (Callback cb_func)
- {
- m_impl = cb_func;
- }
-
- void
- SetTextualInfo (const char* descr)
- {
- if (descr)
- m_description.assign(descr);
- else
- m_description.clear();
- }
-
- virtual
- ~CXXFunctionSummaryFormat()
- {
- }
-
- virtual bool
- FormatObject(ValueObject *valobj,
- std::string& dest);
-
- virtual std::string
- GetDescription();
-
- virtual bool
- IsScripted()
- {
- return false;
- }
-
- virtual Type
- GetType ()
- {
- return TypeSummaryImpl::eTypeCallback;
- }
-
- typedef STD_SHARED_PTR(CXXFunctionSummaryFormat) SharedPointer;
-
-private:
- DISALLOW_COPY_AND_ASSIGN(CXXFunctionSummaryFormat);
-};
-
-#ifndef LLDB_DISABLE_PYTHON
-
-// Python-based summaries, running script code to show data
-struct ScriptSummaryFormat : public TypeSummaryImpl
-{
- std::string m_function_name;
- std::string m_python_script;
- lldb::ScriptInterpreterObjectSP m_script_function_sp;
-
- ScriptSummaryFormat(const TypeSummaryImpl::Flags& flags,
- const char *function_name,
- const char* python_script = NULL);
-
- const char*
- GetFunctionName () const
- {
- return m_function_name.c_str();
- }
-
- const char*
- GetPythonScript () const
- {
- return m_python_script.c_str();
- }
-
- void
- SetFunctionName (const char* function_name)
- {
- if (function_name)
- m_function_name.assign(function_name);
- else
- m_function_name.clear();
- m_python_script.clear();
- }
-
- void
- SetPythonScript (const char* script)
- {
- if (script)
- m_python_script.assign(script);
- else
- m_python_script.clear();
- }
-
- virtual
- ~ScriptSummaryFormat()
- {
- }
-
- virtual bool
- FormatObject(ValueObject *valobj,
- std::string& dest);
-
- virtual std::string
- GetDescription();
-
- virtual bool
- IsScripted()
- {
- return true;
- }
-
- virtual Type
- GetType ()
- {
- return TypeSummaryImpl::eTypeScript;
- }
-
- typedef STD_SHARED_PTR(ScriptSummaryFormat) SharedPointer;
-
-
-private:
- DISALLOW_COPY_AND_ASSIGN(ScriptSummaryFormat);
-};
-
-#endif // #ifndef LLDB_DISABLE_PYTHON
-
-// TODO: at the moment, this class is only used as a backing store for SBTypeNameSpecifier in the public API
-// In the future, this might be used as the basic unit for typename-to-formatter matching, replacing
-// the current plain/regexp distinction in FormatNavigator<>
-class TypeNameSpecifierImpl
-{
-public:
-
- TypeNameSpecifierImpl() :
- m_is_regex(false),
- m_type()
- {
- }
-
- TypeNameSpecifierImpl (const char* name, bool is_regex) :
- m_is_regex(is_regex),
- m_type()
- {
- if (name)
- m_type.m_type_name.assign(name);
- }
-
- // if constructing with a given type, is_regex cannot be true since we are
- // giving an exact type to match
- TypeNameSpecifierImpl (lldb::TypeSP type) :
- m_is_regex(false),
- m_type()
- {
- if (type)
- {
- m_type.m_type_name.assign(type->GetName().GetCString());
- m_type.m_typeimpl_sp = lldb::TypeImplSP(new TypeImpl(type));
- }
- }
-
- TypeNameSpecifierImpl (ClangASTType type) :
- m_is_regex(false),
- m_type()
- {
- if (type.IsValid())
- {
- m_type.m_type_name.assign(type.GetConstTypeName().GetCString());
- m_type.m_typeimpl_sp = lldb::TypeImplSP(new TypeImpl(type));
- }
- }
-
- const char*
- GetName()
- {
- if (m_type.m_type_name.size())
- return m_type.m_type_name.c_str();
- return NULL;
- }
-
- lldb::TypeSP
- GetTypeSP ()
- {
- if (m_type.m_typeimpl_sp && m_type.m_typeimpl_sp->IsValid())
- return m_type.m_typeimpl_sp->GetTypeSP();
- return lldb::TypeSP();
- }
-
- ClangASTType
- GetClangASTType ()
- {
- if (m_type.m_typeimpl_sp && m_type.m_typeimpl_sp->IsValid())
- return m_type.m_typeimpl_sp->GetClangASTType();
- return ClangASTType();
- }
-
- bool
- IsRegex()
- {
- return m_is_regex;
- }
-
-private:
- bool m_is_regex;
- // this works better than TypeAndOrName because the latter only wraps a TypeSP
- // whereas TypeImplSP can also be backed by a ClangASTType which is more commonly
- // used in LLDB. moreover, TypeImplSP is also what is currently backing SBType
- struct TypeOrName
- {
- std::string m_type_name;
- lldb::TypeImplSP m_typeimpl_sp;
- };
- TypeOrName m_type;
-
-
-private:
- DISALLOW_COPY_AND_ASSIGN(TypeNameSpecifierImpl);
-};
-
-} // namespace lldb_private
-
-#endif // lldb_FormatClasses_h_
Removed: lldb/trunk/include/lldb/Core/FormatManager.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FormatManager.h?rev=173727&view=auto
==============================================================================
--- lldb/trunk/include/lldb/Core/FormatManager.h (original)
+++ lldb/trunk/include/lldb/Core/FormatManager.h (removed)
@@ -1,776 +0,0 @@
-//===-- FormatManager.h -------------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef lldb_FormatManager_h_
-#define lldb_FormatManager_h_
-
-// C Includes
-// C++ Includes
-
-// Other libraries and framework includes
-// Project includes
-#include "lldb/lldb-public.h"
-#include "lldb/lldb-enumerations.h"
-
-#include "lldb/Core/FormatNavigator.h"
-#include "lldb/Interpreter/ScriptInterpreterPython.h"
-#include "lldb/Target/ExecutionContext.h"
-#include "lldb/Target/Platform.h"
-
-using lldb::LogSP;
-
-namespace lldb_private {
-
-// this file (and its. cpp) contain the low-level implementation of LLDB Data Visualization
-// class DataVisualization is the high-level front-end of this feature
-// clients should refer to that class as the entry-point into the data formatters
-// unless they have a good reason to bypass it and prefer to use this file's objects directly
-
-class CategoryMap;
-
-class TypeCategoryImpl
-{
-private:
-
- typedef FormatNavigator<ConstString, TypeSummaryImpl> SummaryNavigator;
- typedef FormatNavigator<lldb::RegularExpressionSP, TypeSummaryImpl> RegexSummaryNavigator;
-
- typedef FormatNavigator<ConstString, TypeFilterImpl> FilterNavigator;
- typedef FormatNavigator<lldb::RegularExpressionSP, TypeFilterImpl> RegexFilterNavigator;
-
-#ifndef LLDB_DISABLE_PYTHON
- typedef FormatNavigator<ConstString, TypeSyntheticImpl> SynthNavigator;
- typedef FormatNavigator<lldb::RegularExpressionSP, TypeSyntheticImpl> RegexSynthNavigator;
-#endif // #ifndef LLDB_DISABLE_PYTHON
-
- typedef SummaryNavigator::MapType SummaryMap;
- typedef RegexSummaryNavigator::MapType RegexSummaryMap;
- typedef FilterNavigator::MapType FilterMap;
- typedef RegexFilterNavigator::MapType RegexFilterMap;
-#ifndef LLDB_DISABLE_PYTHON
- typedef SynthNavigator::MapType SynthMap;
- typedef RegexSynthNavigator::MapType RegexSynthMap;
-#endif // #ifndef LLDB_DISABLE_PYTHON
-
-public:
-
- typedef uint16_t FormatCategoryItems;
- static const uint16_t ALL_ITEM_TYPES = UINT16_MAX;
-
- typedef SummaryNavigator::SharedPointer SummaryNavigatorSP;
- typedef RegexSummaryNavigator::SharedPointer RegexSummaryNavigatorSP;
- typedef FilterNavigator::SharedPointer FilterNavigatorSP;
- typedef RegexFilterNavigator::SharedPointer RegexFilterNavigatorSP;
-#ifndef LLDB_DISABLE_PYTHON
- typedef SynthNavigator::SharedPointer SynthNavigatorSP;
- typedef RegexSynthNavigator::SharedPointer RegexSynthNavigatorSP;
-#endif // #ifndef LLDB_DISABLE_PYTHON
-
- TypeCategoryImpl (IFormatChangeListener* clist,
- ConstString name);
-
- SummaryNavigatorSP
- GetSummaryNavigator ()
- {
- return SummaryNavigatorSP(m_summary_nav);
- }
-
- RegexSummaryNavigatorSP
- GetRegexSummaryNavigator ()
- {
- return RegexSummaryNavigatorSP(m_regex_summary_nav);
- }
-
- FilterNavigatorSP
- GetFilterNavigator ()
- {
- return FilterNavigatorSP(m_filter_nav);
- }
-
- RegexFilterNavigatorSP
- GetRegexFilterNavigator ()
- {
- return RegexFilterNavigatorSP(m_regex_filter_nav);
- }
-
- SummaryNavigator::MapValueType
- GetSummaryForType (lldb::TypeNameSpecifierImplSP type_sp)
- {
- SummaryNavigator::MapValueType retval;
-
- if (type_sp)
- {
- if (type_sp->IsRegex())
- m_regex_summary_nav->GetExact(ConstString(type_sp->GetName()),retval);
- else
- m_summary_nav->GetExact(ConstString(type_sp->GetName()),retval);
- }
-
- return retval;
- }
-
- FilterNavigator::MapValueType
- GetFilterForType (lldb::TypeNameSpecifierImplSP type_sp)
- {
- FilterNavigator::MapValueType retval;
-
- if (type_sp)
- {
- if (type_sp->IsRegex())
- m_regex_filter_nav->GetExact(ConstString(type_sp->GetName()),retval);
- else
- m_filter_nav->GetExact(ConstString(type_sp->GetName()),retval);
- }
-
- return retval;
- }
-
-#ifndef LLDB_DISABLE_PYTHON
- SynthNavigator::MapValueType
- GetSyntheticForType (lldb::TypeNameSpecifierImplSP type_sp)
- {
- SynthNavigator::MapValueType retval;
-
- if (type_sp)
- {
- if (type_sp->IsRegex())
- m_regex_synth_nav->GetExact(ConstString(type_sp->GetName()),retval);
- else
- m_synth_nav->GetExact(ConstString(type_sp->GetName()),retval);
- }
-
- return retval;
- }
-#endif
-
- lldb::TypeNameSpecifierImplSP
- GetTypeNameSpecifierForSummaryAtIndex (size_t index)
- {
- if (index < m_summary_nav->GetCount())
- return m_summary_nav->GetTypeNameSpecifierAtIndex(index);
- else
- return m_regex_summary_nav->GetTypeNameSpecifierAtIndex(index-m_summary_nav->GetCount());
- }
-
- SummaryNavigator::MapValueType
- GetSummaryAtIndex (size_t index)
- {
- if (index < m_summary_nav->GetCount())
- return m_summary_nav->GetAtIndex(index);
- else
- return m_regex_summary_nav->GetAtIndex(index-m_summary_nav->GetCount());
- }
-
- FilterNavigator::MapValueType
- GetFilterAtIndex (size_t index)
- {
- if (index < m_filter_nav->GetCount())
- return m_filter_nav->GetAtIndex(index);
- else
- return m_regex_filter_nav->GetAtIndex(index-m_filter_nav->GetCount());
- }
-
- lldb::TypeNameSpecifierImplSP
- GetTypeNameSpecifierForFilterAtIndex (size_t index)
- {
- if (index < m_filter_nav->GetCount())
- return m_filter_nav->GetTypeNameSpecifierAtIndex(index);
- else
- return m_regex_filter_nav->GetTypeNameSpecifierAtIndex(index-m_filter_nav->GetCount());
- }
-
-#ifndef LLDB_DISABLE_PYTHON
- SynthNavigatorSP
- GetSyntheticNavigator ()
- {
- return SynthNavigatorSP(m_synth_nav);
- }
-
- RegexSynthNavigatorSP
- GetRegexSyntheticNavigator ()
- {
- return RegexSynthNavigatorSP(m_regex_synth_nav);
- }
-
- SynthNavigator::MapValueType
- GetSyntheticAtIndex (size_t index)
- {
- if (index < m_synth_nav->GetCount())
- return m_synth_nav->GetAtIndex(index);
- else
- return m_regex_synth_nav->GetAtIndex(index-m_synth_nav->GetCount());
- }
-
- lldb::TypeNameSpecifierImplSP
- GetTypeNameSpecifierForSyntheticAtIndex (size_t index)
- {
- if (index < m_synth_nav->GetCount())
- return m_synth_nav->GetTypeNameSpecifierAtIndex(index);
- else
- return m_regex_synth_nav->GetTypeNameSpecifierAtIndex(index - m_synth_nav->GetCount());
- }
-
-#endif // #ifndef LLDB_DISABLE_PYTHON
-
- bool
- IsEnabled () const
- {
- return m_enabled;
- }
-
- uint32_t
- GetEnabledPosition()
- {
- if (m_enabled == false)
- return UINT32_MAX;
- else
- return m_enabled_position;
- }
-
- bool
- Get (ValueObject& valobj,
- lldb::TypeSummaryImplSP& entry,
- lldb::DynamicValueType use_dynamic,
- uint32_t* reason = NULL);
-
- bool
- Get (ValueObject& valobj,
- lldb::SyntheticChildrenSP& entry,
- lldb::DynamicValueType use_dynamic,
- uint32_t* reason = NULL);
-
- void
- Clear (FormatCategoryItems items = ALL_ITEM_TYPES);
-
- bool
- Delete (ConstString name,
- FormatCategoryItems items = ALL_ITEM_TYPES);
-
- uint32_t
- GetCount (FormatCategoryItems items = ALL_ITEM_TYPES);
-
- const char*
- GetName ()
- {
- return m_name.GetCString();
- }
-
- bool
- AnyMatches (ConstString type_name,
- FormatCategoryItems items = ALL_ITEM_TYPES,
- bool only_enabled = true,
- const char** matching_category = NULL,
- FormatCategoryItems* matching_type = NULL);
-
- typedef STD_SHARED_PTR(TypeCategoryImpl) SharedPointer;
-
-private:
- SummaryNavigator::SharedPointer m_summary_nav;
- RegexSummaryNavigator::SharedPointer m_regex_summary_nav;
- FilterNavigator::SharedPointer m_filter_nav;
- RegexFilterNavigator::SharedPointer m_regex_filter_nav;
-#ifndef LLDB_DISABLE_PYTHON
- SynthNavigator::SharedPointer m_synth_nav;
- RegexSynthNavigator::SharedPointer m_regex_synth_nav;
-#endif // #ifndef LLDB_DISABLE_PYTHON
-
- bool m_enabled;
-
- IFormatChangeListener* m_change_listener;
-
- Mutex m_mutex;
-
- ConstString m_name;
-
- uint32_t m_enabled_position;
-
- void
- Enable (bool value,
- uint32_t position)
- {
- Mutex::Locker locker(m_mutex);
- m_enabled = value;
- m_enabled_position = position;
- if (m_change_listener)
- m_change_listener->Changed();
- }
-
- void
- Disable ()
- {
- Enable(false, UINT32_MAX);
- }
-
- friend class CategoryMap;
-
- friend class FormatNavigator<ConstString, TypeSummaryImpl>;
- friend class FormatNavigator<lldb::RegularExpressionSP, TypeSummaryImpl>;
-
- friend class FormatNavigator<ConstString, TypeFilterImpl>;
- friend class FormatNavigator<lldb::RegularExpressionSP, TypeFilterImpl>;
-
-#ifndef LLDB_DISABLE_PYTHON
- friend class FormatNavigator<ConstString, TypeSyntheticImpl>;
- friend class FormatNavigator<lldb::RegularExpressionSP, TypeSyntheticImpl>;
-#endif // #ifndef LLDB_DISABLE_PYTHON
-
-
-};
-
-class CategoryMap
-{
-private:
- typedef ConstString KeyType;
- typedef TypeCategoryImpl ValueType;
- typedef ValueType::SharedPointer ValueSP;
- typedef std::list<lldb::TypeCategoryImplSP> ActiveCategoriesList;
- typedef ActiveCategoriesList::iterator ActiveCategoriesIterator;
-
-public:
- typedef std::map<KeyType, ValueSP> MapType;
- typedef MapType::iterator MapIterator;
- typedef bool(*CallbackType)(void*, const ValueSP&);
- typedef uint32_t Position;
-
- static const Position First = 0;
- static const Position Default = 1;
- static const Position Last = UINT32_MAX;
-
- CategoryMap (IFormatChangeListener* lst) :
- m_map_mutex(Mutex::eMutexTypeRecursive),
- listener(lst),
- m_map(),
- m_active_categories()
- {
- ConstString default_cs("default");
- lldb::TypeCategoryImplSP default_sp = lldb::TypeCategoryImplSP(new TypeCategoryImpl(listener, default_cs));
- Add(default_cs,default_sp);
- Enable(default_cs,First);
- }
-
- void
- Add (KeyType name,
- const ValueSP& entry)
- {
- Mutex::Locker locker(m_map_mutex);
- m_map[name] = entry;
- if (listener)
- listener->Changed();
- }
-
- bool
- Delete (KeyType name)
- {
- Mutex::Locker locker(m_map_mutex);
- MapIterator iter = m_map.find(name);
- if (iter == m_map.end())
- return false;
- m_map.erase(name);
- Disable(name);
- if (listener)
- listener->Changed();
- return true;
- }
-
- bool
- Enable (KeyType category_name,
- Position pos = Default)
- {
- Mutex::Locker locker(m_map_mutex);
- ValueSP category;
- if (!Get(category_name,category))
- return false;
- return Enable(category, pos);
- }
-
- bool
- Disable (KeyType category_name)
- {
- Mutex::Locker locker(m_map_mutex);
- ValueSP category;
- if (!Get(category_name,category))
- return false;
- return Disable(category);
- }
-
- bool
- Enable (ValueSP category,
- Position pos = Default)
- {
- Mutex::Locker locker(m_map_mutex);
- if (category.get())
- {
- Position pos_w = pos;
- if (pos == First || m_active_categories.size() == 0)
- m_active_categories.push_front(category);
- else if (pos == Last || pos == m_active_categories.size())
- m_active_categories.push_back(category);
- else if (pos < m_active_categories.size())
- {
- ActiveCategoriesList::iterator iter = m_active_categories.begin();
- while (pos_w)
- {
- pos_w--,iter++;
- }
- m_active_categories.insert(iter,category);
- }
- else
- return false;
- category->Enable(true,
- pos);
- return true;
- }
- return false;
- }
-
- bool
- Disable (ValueSP category)
- {
- Mutex::Locker locker(m_map_mutex);
- if (category.get())
- {
- m_active_categories.remove_if(delete_matching_categories(category));
- category->Disable();
- return true;
- }
- return false;
- }
-
- void
- Clear ()
- {
- Mutex::Locker locker(m_map_mutex);
- m_map.clear();
- m_active_categories.clear();
- if (listener)
- listener->Changed();
- }
-
- bool
- Get (KeyType name,
- ValueSP& entry)
- {
- Mutex::Locker locker(m_map_mutex);
- MapIterator iter = m_map.find(name);
- if (iter == m_map.end())
- return false;
- entry = iter->second;
- return true;
- }
-
- bool
- Get (uint32_t pos,
- ValueSP& entry)
- {
- Mutex::Locker locker(m_map_mutex);
- MapIterator iter = m_map.begin();
- MapIterator end = m_map.end();
- while (pos > 0)
- {
- iter++;
- pos--;
- if (iter == end)
- return false;
- }
- entry = iter->second;
- return false;
- }
-
- void
- LoopThrough (CallbackType callback, void* param);
-
- lldb::TypeCategoryImplSP
- GetAtIndex (size_t index);
-
- bool
- AnyMatches (ConstString type_name,
- TypeCategoryImpl::FormatCategoryItems items = TypeCategoryImpl::ALL_ITEM_TYPES,
- bool only_enabled = true,
- const char** matching_category = NULL,
- TypeCategoryImpl::FormatCategoryItems* matching_type = NULL);
-
- size_t
- GetCount ()
- {
- return m_map.size();
- }
-
- lldb::TypeSummaryImplSP
- GetSummaryFormat (ValueObject& valobj,
- lldb::DynamicValueType use_dynamic);
-
-#ifndef LLDB_DISABLE_PYTHON
- lldb::SyntheticChildrenSP
- GetSyntheticChildren (ValueObject& valobj,
- lldb::DynamicValueType use_dynamic);
-#endif
-
-private:
-
- class delete_matching_categories
- {
- lldb::TypeCategoryImplSP ptr;
- public:
- delete_matching_categories(lldb::TypeCategoryImplSP p) : ptr(p)
- {}
-
- bool operator()(const lldb::TypeCategoryImplSP& other)
- {
- return ptr.get() == other.get();
- }
- };
-
- Mutex m_map_mutex;
- IFormatChangeListener* listener;
-
- MapType m_map;
- ActiveCategoriesList m_active_categories;
-
- MapType& map ()
- {
- return m_map;
- }
-
- ActiveCategoriesList& active_list ()
- {
- return m_active_categories;
- }
-
- Mutex& mutex ()
- {
- return m_map_mutex;
- }
-
- friend class FormatNavigator<KeyType, ValueType>;
- friend class FormatManager;
-};
-
-class FormatManager : public IFormatChangeListener
-{
- typedef FormatNavigator<ConstString, TypeFormatImpl> ValueNavigator;
- typedef ValueNavigator::MapType ValueMap;
- typedef FormatMap<ConstString, TypeSummaryImpl> NamedSummariesMap;
- typedef CategoryMap::MapType::iterator CategoryMapIterator;
-public:
-
- typedef CategoryMap::CallbackType CategoryCallback;
-
- FormatManager ();
-
- ValueNavigator&
- GetValueNavigator ()
- {
- return m_value_nav;
- }
-
- NamedSummariesMap&
- GetNamedSummaryNavigator ()
- {
- return m_named_summaries_map;
- }
-
- void
- EnableCategory (const ConstString& category_name,
- CategoryMap::Position pos = CategoryMap::Default)
- {
- m_categories_map.Enable(category_name,
- pos);
- }
-
- void
- DisableCategory (const ConstString& category_name)
- {
- m_categories_map.Disable(category_name);
- }
-
- void
- EnableCategory (const lldb::TypeCategoryImplSP& category,
- CategoryMap::Position pos = CategoryMap::Default)
- {
- m_categories_map.Enable(category,
- pos);
- }
-
- void
- DisableCategory (const lldb::TypeCategoryImplSP& category)
- {
- m_categories_map.Disable(category);
- }
-
- bool
- DeleteCategory (const ConstString& category_name)
- {
- return m_categories_map.Delete(category_name);
- }
-
- void
- ClearCategories ()
- {
- return m_categories_map.Clear();
- }
-
- size_t
- GetCategoriesCount ()
- {
- return m_categories_map.GetCount();
- }
-
- lldb::TypeCategoryImplSP
- GetCategoryAtIndex (size_t index)
- {
- return m_categories_map.GetAtIndex(index);
- }
-
- void
- LoopThroughCategories (CategoryCallback callback, void* param)
- {
- m_categories_map.LoopThrough(callback, param);
- }
-
- lldb::TypeCategoryImplSP
- GetCategory (const char* category_name = NULL,
- bool can_create = true)
- {
- if (!category_name)
- return GetCategory(m_default_category_name);
- return GetCategory(ConstString(category_name));
- }
-
- lldb::TypeCategoryImplSP
- GetCategory (const ConstString& category_name,
- bool can_create = true);
-
- lldb::TypeSummaryImplSP
- GetSummaryFormat (ValueObject& valobj,
- lldb::DynamicValueType use_dynamic)
- {
- return m_categories_map.GetSummaryFormat(valobj, use_dynamic);
- }
-
- lldb::TypeSummaryImplSP
- GetSummaryForType (lldb::TypeNameSpecifierImplSP type_sp);
-
- lldb::TypeFilterImplSP
- GetFilterForType (lldb::TypeNameSpecifierImplSP type_sp);
-
-#ifndef LLDB_DISABLE_PYTHON
- lldb::TypeSyntheticImplSP
- GetSyntheticForType (lldb::TypeNameSpecifierImplSP type_sp);
-#endif
-
-#ifndef LLDB_DISABLE_PYTHON
- lldb::SyntheticChildrenSP
- GetSyntheticChildrenForType (lldb::TypeNameSpecifierImplSP type_sp);
-#endif
-
-#ifndef LLDB_DISABLE_PYTHON
- lldb::SyntheticChildrenSP
- GetSyntheticChildren (ValueObject& valobj,
- lldb::DynamicValueType use_dynamic)
- {
- return m_categories_map.GetSyntheticChildren(valobj, use_dynamic);
- }
-#endif
-
- bool
- AnyMatches (ConstString type_name,
- TypeCategoryImpl::FormatCategoryItems items = TypeCategoryImpl::ALL_ITEM_TYPES,
- bool only_enabled = true,
- const char** matching_category = NULL,
- TypeCategoryImpl::FormatCategoryItems* matching_type = NULL)
- {
- return m_categories_map.AnyMatches(type_name,
- items,
- only_enabled,
- matching_category,
- matching_type);
- }
-
- static bool
- GetFormatFromCString (const char *format_cstr,
- bool partial_match_ok,
- lldb::Format &format);
-
- static char
- GetFormatAsFormatChar (lldb::Format format);
-
- static const char *
- GetFormatAsCString (lldb::Format format);
-
- // if the user tries to add formatters for, say, "struct Foo"
- // those will not match any type because of the way we strip qualifiers from typenames
- // this method looks for the case where the user is adding a "class","struct","enum" or "union" Foo
- // and strips the unnecessary qualifier
- static ConstString
- GetValidTypeName (const ConstString& type);
-
- // when DataExtractor dumps a vectorOfT, it uses a predefined format for each item
- // this method returns it, or eFormatInvalid if vector_format is not a vectorOf
- static lldb::Format
- GetSingleItemFormat (lldb::Format vector_format);
-
- void
- Changed ()
- {
- __sync_add_and_fetch(&m_last_revision, +1);
- }
-
- uint32_t
- GetCurrentRevision ()
- {
- return m_last_revision;
- }
-
- ~FormatManager ()
- {
- }
-
-private:
- ValueNavigator m_value_nav;
- NamedSummariesMap m_named_summaries_map;
- uint32_t m_last_revision;
- CategoryMap m_categories_map;
-
- ConstString m_default_category_name;
- ConstString m_system_category_name;
- ConstString m_gnu_cpp_category_name;
- ConstString m_libcxx_category_name;
- ConstString m_objc_category_name;
- ConstString m_corefoundation_category_name;
- ConstString m_coregraphics_category_name;
- ConstString m_coreservices_category_name;
- ConstString m_vectortypes_category_name;
- ConstString m_appkit_category_name;
-
- CategoryMap&
- GetCategories ()
- {
- return m_categories_map;
- }
-
- // WARNING: these are temporary functions that setup formatters
- // while a few of these actually should be globally available and setup by LLDB itself
- // most would actually belong to the users' lldbinit file or to some other form of configurable
- // storage
- void
- LoadLibStdcppFormatters ();
-
- void
- LoadLibcxxFormatters ();
-
- void
- LoadSystemFormatters ();
-
- void
- LoadObjCFormatters ();
-};
-
-} // namespace lldb_private
-
-#endif // lldb_FormatManager_h_
Removed: lldb/trunk/include/lldb/Core/FormatNavigator.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FormatNavigator.h?rev=173727&view=auto
==============================================================================
--- lldb/trunk/include/lldb/Core/FormatNavigator.h (original)
+++ lldb/trunk/include/lldb/Core/FormatNavigator.h (removed)
@@ -1,663 +0,0 @@
-//===-- FormatNavigator.h ----------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef lldb_FormatNavigator_h_
-#define lldb_FormatNavigator_h_
-
-// C Includes
-// C++ Includes
-
-// Other libraries and framework includes
-#include "clang/AST/DeclCXX.h"
-#include "clang/AST/Type.h"
-#include "clang/AST/DeclObjC.h"
-
-// Project includes
-#include "lldb/lldb-public.h"
-
-#include "lldb/Core/FormatClasses.h"
-#include "lldb/Core/Log.h"
-#include "lldb/Core/RegularExpression.h"
-#include "lldb/Core/ValueObject.h"
-
-#include "lldb/Symbol/ClangASTContext.h"
-
-#include "lldb/Target/ObjCLanguageRuntime.h"
-#include "lldb/Target/Process.h"
-#include "lldb/Target/StackFrame.h"
-#include "lldb/Target/TargetList.h"
-
-using lldb::LogSP;
-
-namespace lldb_private {
-
-// this file (and its. cpp) contain the low-level implementation of LLDB Data Visualization
-// class DataVisualization is the high-level front-end of this feature
-// clients should refer to that class as the entry-point into the data formatters
-// unless they have a good reason to bypass it and prefer to use this file's objects directly
-class IFormatChangeListener
-{
-public:
- virtual void
- Changed () = 0;
-
- virtual
- ~IFormatChangeListener () {}
-
- virtual uint32_t
- GetCurrentRevision () = 0;
-
-};
-
-static inline bool
-IsWhitespace (char c)
-{
- return ( (c == ' ') || (c == '\t') || (c == '\v') || (c == '\f') );
-}
-
-static inline bool
-HasPrefix (const char* str1, const char* str2)
-{
- return ( ::strstr(str1, str2) == str1 );
-}
-
-// if the user tries to add formatters for, say, "struct Foo"
-// those will not match any type because of the way we strip qualifiers from typenames
-// this method looks for the case where the user is adding a "class","struct","enum" or "union" Foo
-// and strips the unnecessary qualifier
-static ConstString
-GetValidTypeName_Impl (const ConstString& type)
-{
- int strip_len = 0;
-
- if (type == false)
- return type;
-
- const char* type_cstr = type.AsCString();
-
- if ( HasPrefix(type_cstr, "class ") )
- strip_len = 6;
- else if ( HasPrefix(type_cstr, "enum ") )
- strip_len = 5;
- else if ( HasPrefix(type_cstr, "struct ") )
- strip_len = 7;
- else if ( HasPrefix(type_cstr, "union ") )
- strip_len = 6;
-
- if (strip_len == 0)
- return type;
-
- type_cstr += strip_len;
- while (IsWhitespace(*type_cstr) && ++type_cstr)
- ;
-
- return ConstString(type_cstr);
-}
-
-template<typename KeyType, typename ValueType>
-class FormatNavigator;
-
-template<typename KeyType, typename ValueType>
-class FormatMap
-{
-public:
-
- typedef typename ValueType::SharedPointer ValueSP;
- typedef std::map<KeyType, ValueSP> MapType;
- typedef typename MapType::iterator MapIterator;
- typedef bool(*CallbackType)(void*, KeyType, const ValueSP&);
-
- FormatMap(IFormatChangeListener* lst) :
- m_map(),
- m_map_mutex(Mutex::eMutexTypeRecursive),
- listener(lst)
- {
- }
-
- void
- Add(KeyType name,
- const ValueSP& entry)
- {
- if (listener)
- entry->GetRevision() = listener->GetCurrentRevision();
- else
- entry->GetRevision() = 0;
-
- Mutex::Locker locker(m_map_mutex);
- m_map[name] = entry;
- if (listener)
- listener->Changed();
- }
-
- bool
- Delete (KeyType name)
- {
- Mutex::Locker locker(m_map_mutex);
- MapIterator iter = m_map.find(name);
- if (iter == m_map.end())
- return false;
- m_map.erase(name);
- if (listener)
- listener->Changed();
- return true;
- }
-
- void
- Clear ()
- {
- Mutex::Locker locker(m_map_mutex);
- m_map.clear();
- if (listener)
- listener->Changed();
- }
-
- bool
- Get(KeyType name,
- ValueSP& entry)
- {
- Mutex::Locker locker(m_map_mutex);
- MapIterator iter = m_map.find(name);
- if (iter == m_map.end())
- return false;
- entry = iter->second;
- return true;
- }
-
- void
- LoopThrough (CallbackType callback, void* param)
- {
- if (callback)
- {
- Mutex::Locker locker(m_map_mutex);
- MapIterator pos, end = m_map.end();
- for (pos = m_map.begin(); pos != end; pos++)
- {
- KeyType type = pos->first;
- if (!callback(param, type, pos->second))
- break;
- }
- }
- }
-
- size_t
- GetCount ()
- {
- return m_map.size();
- }
-
- ValueSP
- GetValueAtIndex (size_t index)
- {
- Mutex::Locker locker(m_map_mutex);
- MapIterator iter = m_map.begin();
- MapIterator end = m_map.end();
- while (index > 0)
- {
- iter++;
- index--;
- if (end == iter)
- return ValueSP();
- }
- return iter->second;
- }
-
- KeyType
- GetKeyAtIndex (size_t index)
- {
- Mutex::Locker locker(m_map_mutex);
- MapIterator iter = m_map.begin();
- MapIterator end = m_map.end();
- while (index > 0)
- {
- iter++;
- index--;
- if (end == iter)
- return KeyType();
- }
- return iter->first;
- }
-
-protected:
- MapType m_map;
- Mutex m_map_mutex;
- IFormatChangeListener* listener;
-
- MapType&
- map ()
- {
- return m_map;
- }
-
- Mutex&
- mutex ()
- {
- return m_map_mutex;
- }
-
- friend class FormatNavigator<KeyType, ValueType>;
- friend class FormatManager;
-
-};
-
-template<typename KeyType, typename ValueType>
-class FormatNavigator
-{
-protected:
- typedef FormatMap<KeyType,ValueType> BackEndType;
-
-public:
- typedef typename BackEndType::MapType MapType;
- typedef typename MapType::iterator MapIterator;
- typedef typename MapType::key_type MapKeyType;
- typedef typename MapType::mapped_type MapValueType;
- typedef typename BackEndType::CallbackType CallbackType;
-#ifdef _LIBCPP_VERSION
- typedef typename std::shared_ptr<FormatNavigator<KeyType, ValueType> > SharedPointer;
-#else
- typedef typename std::tr1::shared_ptr<FormatNavigator<KeyType, ValueType> > SharedPointer;
-#endif
-
- friend class TypeCategoryImpl;
-
- FormatNavigator(std::string name,
- IFormatChangeListener* lst) :
- m_format_map(lst),
- m_name(name),
- m_id_cs(ConstString("id"))
- {
- }
-
- void
- Add (const MapKeyType &type, const MapValueType& entry)
- {
- Add_Impl(type, entry, (KeyType*)NULL);
- }
-
- bool
- Delete (ConstString type)
- {
- return Delete_Impl(type, (KeyType*)NULL);
- }
-
- bool
- Get(ValueObject& valobj,
- MapValueType& entry,
- lldb::DynamicValueType use_dynamic,
- uint32_t* why = NULL)
- {
- uint32_t value = lldb_private::eFormatterChoiceCriterionDirectChoice;
- clang::QualType type = clang::QualType::getFromOpaquePtr(valobj.GetClangType());
- bool ret = Get(valobj, type, entry, use_dynamic, value);
- if (ret)
- entry = MapValueType(entry);
- else
- entry = MapValueType();
- if (why)
- *why = value;
- return ret;
- }
-
- bool
- Get (ConstString type, MapValueType& entry)
- {
- return Get_Impl(type, entry, (KeyType*)NULL);
- }
-
- bool
- GetExact (ConstString type, MapValueType& entry)
- {
- return GetExact_Impl(type, entry, (KeyType*)NULL);
- }
-
- MapValueType
- GetAtIndex (size_t index)
- {
- return m_format_map.GetValueAtIndex(index);
- }
-
- lldb::TypeNameSpecifierImplSP
- GetTypeNameSpecifierAtIndex (size_t index)
- {
- return GetTypeNameSpecifierAtIndex_Impl(index, (KeyType*)NULL);
- }
-
- void
- Clear ()
- {
- m_format_map.Clear();
- }
-
- void
- LoopThrough (CallbackType callback, void* param)
- {
- m_format_map.LoopThrough(callback,param);
- }
-
- size_t
- GetCount ()
- {
- return m_format_map.GetCount();
- }
-
-protected:
-
- BackEndType m_format_map;
-
- std::string m_name;
-
- DISALLOW_COPY_AND_ASSIGN(FormatNavigator);
-
- ConstString m_id_cs;
-
- void
- Add_Impl (const MapKeyType &type, const MapValueType& entry, lldb::RegularExpressionSP *dummy)
- {
- m_format_map.Add(type,entry);
- }
-
- void Add_Impl (const ConstString &type, const MapValueType& entry, ConstString *dummy)
- {
- m_format_map.Add(GetValidTypeName_Impl(type), entry);
- }
-
- bool
- Delete_Impl (ConstString type, ConstString *dummy)
- {
- return m_format_map.Delete(type);
- }
-
- bool
- Delete_Impl (ConstString type, lldb::RegularExpressionSP *dummy)
- {
- Mutex& x_mutex = m_format_map.mutex();
- lldb_private::Mutex::Locker locker(x_mutex);
- MapIterator pos, end = m_format_map.map().end();
- for (pos = m_format_map.map().begin(); pos != end; pos++)
- {
- lldb::RegularExpressionSP regex = pos->first;
- if ( ::strcmp(type.AsCString(),regex->GetText()) == 0)
- {
- m_format_map.map().erase(pos);
- if (m_format_map.listener)
- m_format_map.listener->Changed();
- return true;
- }
- }
- return false;
- }
-
- bool
- Get_Impl (ConstString type, MapValueType& entry, ConstString *dummy)
- {
- return m_format_map.Get(type, entry);
- }
-
- bool
- GetExact_Impl (ConstString type, MapValueType& entry, ConstString *dummy)
- {
- return Get_Impl(type,entry, (KeyType*)0);
- }
-
- lldb::TypeNameSpecifierImplSP
- GetTypeNameSpecifierAtIndex_Impl (size_t index, ConstString *dummy)
- {
- ConstString key = m_format_map.GetKeyAtIndex(index);
- if (key)
- return lldb::TypeNameSpecifierImplSP(new TypeNameSpecifierImpl(key.AsCString(),
- false));
- else
- return lldb::TypeNameSpecifierImplSP();
- }
-
- lldb::TypeNameSpecifierImplSP
- GetTypeNameSpecifierAtIndex_Impl (size_t index, lldb::RegularExpressionSP *dummy)
- {
- lldb::RegularExpressionSP regex = m_format_map.GetKeyAtIndex(index);
- if (regex.get() == NULL)
- return lldb::TypeNameSpecifierImplSP();
- return lldb::TypeNameSpecifierImplSP(new TypeNameSpecifierImpl(regex->GetText(),
- true));
- }
-
- bool
- Get_Impl (ConstString key, MapValueType& value, lldb::RegularExpressionSP *dummy)
- {
- const char* key_cstr = key.AsCString();
- if (!key_cstr)
- return false;
- Mutex& x_mutex = m_format_map.mutex();
- lldb_private::Mutex::Locker locker(x_mutex);
- MapIterator pos, end = m_format_map.map().end();
- for (pos = m_format_map.map().begin(); pos != end; pos++)
- {
- lldb::RegularExpressionSP regex = pos->first;
- if (regex->Execute(key_cstr))
- {
- value = pos->second;
- return true;
- }
- }
- return false;
- }
-
- bool
- GetExact_Impl (ConstString key, MapValueType& value, lldb::RegularExpressionSP *dummy)
- {
- Mutex& x_mutex = m_format_map.mutex();
- lldb_private::Mutex::Locker locker(x_mutex);
- MapIterator pos, end = m_format_map.map().end();
- for (pos = m_format_map.map().begin(); pos != end; pos++)
- {
- lldb::RegularExpressionSP regex = pos->first;
- if (strcmp(regex->GetText(),key.AsCString()) == 0)
- {
- value = pos->second;
- return true;
- }
- }
- return false;
- }
-
- bool
- Get_BitfieldMatch (ValueObject& valobj,
- ConstString typeName,
- MapValueType& entry,
- uint32_t& reason)
- {
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
- // for bitfields, append size to the typename so one can custom format them
- StreamString sstring;
- sstring.Printf("%s:%d",typeName.AsCString(),valobj.GetBitfieldBitSize());
- ConstString bitfieldname = ConstString(sstring.GetData());
- if (log)
- log->Printf("[Get_BitfieldMatch] appended bitfield info, final result is %s", bitfieldname.GetCString());
- if (Get(bitfieldname, entry))
- {
- if (log)
- log->Printf("[Get_BitfieldMatch] bitfield direct match found, returning");
- return true;
- }
- else
- {
- reason |= lldb_private::eFormatterChoiceCriterionStrippedBitField;
- if (log)
- log->Printf("[Get_BitfieldMatch] no bitfield direct match");
- return false;
- }
- }
-
- bool Get_ObjC (ValueObject& valobj,
- MapValueType& entry)
- {
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
- lldb::ProcessSP process_sp = valobj.GetProcessSP();
- ObjCLanguageRuntime* runtime = process_sp->GetObjCLanguageRuntime();
- if (runtime == NULL)
- {
- if (log)
- log->Printf("[Get_ObjC] no valid ObjC runtime, skipping dynamic");
- return false;
- }
- ObjCLanguageRuntime::ClassDescriptorSP objc_class_sp (runtime->GetClassDescriptor(valobj));
- if (!objc_class_sp)
- {
- if (log)
- log->Printf("[Get_ObjC] invalid ISA, skipping dynamic");
- return false;
- }
- ConstString name (objc_class_sp->GetClassName());
- if (log)
- log->Printf("[Get_ObjC] dynamic type inferred is %s - looking for direct dynamic match", name.GetCString());
- if (Get(name, entry))
- {
- if (log)
- log->Printf("[Get_ObjC] direct dynamic match found, returning");
- return true;
- }
- if (log)
- log->Printf("[Get_ObjC] no dynamic match");
- return false;
- }
-
- // we are separately passing in valobj and type because the valobj is fixed (and is used for ObjC discovery and bitfield size)
- // but the type can change (e.g. stripping pointers, ...)
- bool Get (ValueObject& valobj,
- clang::QualType type,
- MapValueType& entry,
- lldb::DynamicValueType use_dynamic,
- uint32_t& reason)
- {
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
- if (type.isNull())
- {
- if (log)
- log->Printf("[Get] type is NULL, returning");
- return false;
- }
-
- type.removeLocalConst(); type.removeLocalVolatile(); type.removeLocalRestrict();
- const clang::Type* typePtr = type.getTypePtrOrNull();
- if (!typePtr)
- {
- if (log)
- log->Printf("[Get] type is NULL, returning");
- return false;
- }
- ConstString typeName(ClangASTType::GetTypeNameForQualType(valobj.GetClangAST(), type).c_str());
-
- if (valobj.GetBitfieldBitSize() > 0)
- {
- if (Get_BitfieldMatch(valobj, typeName, entry, reason))
- return true;
- }
-
- if (log)
- log->Printf("[Get] trying to get %s for VO name %s of type %s",
- m_name.c_str(),
- valobj.GetName().AsCString(),
- typeName.AsCString());
-
- if (Get(typeName, entry))
- {
- if (log)
- log->Printf("[Get] direct match found, returning");
- return true;
- }
- if (log)
- log->Printf("[Get] no direct match");
-
- // strip pointers and references and see if that helps
- if (typePtr->isReferenceType())
- {
- if (log)
- log->Printf("[Get] stripping reference");
- if (Get(valobj,type.getNonReferenceType(),entry, use_dynamic, reason) && !entry->SkipsReferences())
- {
- reason |= lldb_private::eFormatterChoiceCriterionStrippedPointerReference;
- return true;
- }
- }
- else if (typePtr->isPointerType())
- {
- if (log)
- log->Printf("[Get] stripping pointer");
- clang::QualType pointee = typePtr->getPointeeType();
- if (Get(valobj, pointee, entry, use_dynamic, reason) && !entry->SkipsPointers())
- {
- reason |= lldb_private::eFormatterChoiceCriterionStrippedPointerReference;
- return true;
- }
- }
-
- bool canBeObjCDynamic = ClangASTContext::IsPossibleDynamicType (valobj.GetClangAST(),
- type.getAsOpaquePtr(),
- NULL,
- false, // no C++
- true); // yes ObjC
-
- if (canBeObjCDynamic)
- {
- if (use_dynamic != lldb::eNoDynamicValues)
- {
- if (log)
- log->Printf("[Get] allowed to figure out dynamic ObjC type");
- if (Get_ObjC(valobj,entry))
- {
- reason |= lldb_private::eFormatterChoiceCriterionDynamicObjCDiscovery;
- return true;
- }
- }
- if (log)
- log->Printf("[Get] dynamic disabled or failed - stripping ObjC pointer");
- clang::QualType pointee = typePtr->getPointeeType();
- if (Get(valobj, pointee, entry, use_dynamic, reason) && !entry->SkipsPointers())
- {
- reason |= lldb_private::eFormatterChoiceCriterionStrippedPointerReference;
- return true;
- }
- }
-
- // try to strip typedef chains
- const clang::TypedefType* type_tdef = type->getAs<clang::TypedefType>();
- if (type_tdef)
- {
- if (log)
- log->Printf("[Get] stripping typedef");
- if ((Get(valobj, type_tdef->getDecl()->getUnderlyingType(), entry, use_dynamic, reason)) && entry->Cascades())
- {
- reason |= lldb_private::eFormatterChoiceCriterionNavigatedTypedefs;
- return true;
- }
- }
-
- // if all else fails, go to static type
- if (valobj.IsDynamic())
- {
- if (log)
- log->Printf("[Get] going to static value");
- lldb::ValueObjectSP static_value_sp(valobj.GetStaticValue());
- if (static_value_sp)
- {
- if (log)
- log->Printf("[Get] has a static value - actually use it");
- if (Get(*static_value_sp.get(), clang::QualType::getFromOpaquePtr(static_value_sp->GetClangType()) , entry, use_dynamic, reason))
- {
- reason |= lldb_private::eFormatterChoiceCriterionWentToStaticValue;
- return true;
- }
- }
- }
-
- return false;
- }
-};
-
-} // namespace lldb_private
-
-#endif // lldb_FormatNavigator_h_
Modified: lldb/trunk/include/lldb/Core/ValueObject.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObject.h?rev=173728&r1=173727&r2=173728&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObject.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObject.h Mon Jan 28 17:47:25 2013
@@ -808,10 +808,7 @@ public:
UpdateValueIfNeeded (bool update_format = true);
bool
- UpdateValueIfNeeded (lldb::DynamicValueType use_dynamic, bool update_format = true);
-
- bool
- UpdateFormatsIfNeeded(lldb::DynamicValueType use_dynamic = lldb::eNoDynamicValues);
+ UpdateFormatsIfNeeded();
lldb::ValueObjectSP
GetSP ()
@@ -843,10 +840,7 @@ public:
lldb::ValueObjectSP
GetSyntheticBitFieldChild (uint32_t from, uint32_t to, bool can_create);
-
- lldb::ValueObjectSP
- GetSyntheticArrayRangeChild (uint32_t from, uint32_t to, bool can_create);
-
+
lldb::ValueObjectSP
GetSyntheticExpressionPathChild(const char* expression, bool can_create);
@@ -856,6 +850,15 @@ public:
virtual lldb::ValueObjectSP
GetDynamicValue (lldb::DynamicValueType valueType);
+ virtual lldb::DynamicValueType
+ GetDynamicValueType ()
+ {
+ if (m_parent)
+ return m_parent->GetDynamicValueType ();
+ else
+ return lldb::eNoDynamicValues;
+ }
+
virtual lldb::ValueObjectSP
GetStaticValue ();
@@ -1009,7 +1012,7 @@ public:
lldb::TypeSummaryImplSP
GetSummaryFormat()
{
- UpdateFormatsIfNeeded(m_last_format_mgr_dynamic);
+ UpdateFormatsIfNeeded();
return m_type_summary_sp;
}
@@ -1030,7 +1033,7 @@ public:
lldb::TypeFormatImplSP
GetValueFormat()
{
- UpdateFormatsIfNeeded(m_last_format_mgr_dynamic);
+ UpdateFormatsIfNeeded();
return m_type_format_sp;
}
@@ -1046,7 +1049,7 @@ public:
lldb::SyntheticChildrenSP
GetSyntheticChildren()
{
- UpdateFormatsIfNeeded(m_last_format_mgr_dynamic);
+ UpdateFormatsIfNeeded();
return m_synthetic_children_sp;
}
@@ -1218,7 +1221,6 @@ protected:
lldb::Format m_format;
uint32_t m_last_format_mgr_revision;
- lldb::DynamicValueType m_last_format_mgr_dynamic;
lldb::TypeSummaryImplSP m_type_summary_sp;
lldb::TypeFormatImplSP m_type_format_sp;
lldb::SyntheticChildrenSP m_synthetic_children_sp;
Modified: lldb/trunk/include/lldb/Core/ValueObjectDynamicValue.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObjectDynamicValue.h?rev=173728&r1=173727&r2=173728&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObjectDynamicValue.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObjectDynamicValue.h Mon Jan 28 17:47:25 2013
@@ -90,6 +90,12 @@ public:
virtual bool
SetValueFromCString (const char *value_str, Error& error);
+ virtual lldb::DynamicValueType
+ GetDynamicValueType ()
+ {
+ return m_use_dynamic;
+ }
+
protected:
virtual bool
UpdateValue ();
Modified: lldb/trunk/include/lldb/Core/ValueObjectSyntheticFilter.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObjectSyntheticFilter.h?rev=173728&r1=173727&r2=173728&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObjectSyntheticFilter.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObjectSyntheticFilter.h Mon Jan 28 17:47:25 2013
@@ -38,6 +38,9 @@ public:
virtual ConstString
GetTypeName();
+
+ virtual ConstString
+ GetQualifiedTypeName();
virtual bool
MightHaveChildren();
@@ -57,6 +60,9 @@ public:
virtual size_t
GetIndexOfChildWithName (const ConstString &name);
+ virtual lldb::ValueObjectSP
+ GetDynamicValue (lldb::DynamicValueType valueType);
+
virtual bool
IsInScope ();
Copied: lldb/trunk/include/lldb/DataFormatters/CXXFormatterFunctions.h (from r173281, lldb/trunk/include/lldb/Core/CXXFormatterFunctions.h)
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/CXXFormatterFunctions.h?p2=lldb/trunk/include/lldb/DataFormatters/CXXFormatterFunctions.h&p1=lldb/trunk/include/lldb/Core/CXXFormatterFunctions.h&r1=173281&r2=173728&rev=173728&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/CXXFormatterFunctions.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/CXXFormatterFunctions.h Mon Jan 28 17:47:25 2013
@@ -14,14 +14,13 @@
#include "lldb/lldb-forward.h"
#include "lldb/Core/ConstString.h"
-#include "lldb/Core/FormatClasses.h"
+#include "lldb/DataFormatters/FormatClasses.h"
#include "clang/AST/ASTContext.h"
namespace lldb_private {
namespace formatters
{
-
bool
ExtractValueFromObjCExpression (ValueObject &valobj,
const char* target_type,
@@ -135,11 +134,11 @@ namespace lldb_private {
public:
NSArrayMSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
- virtual uint32_t
+ virtual size_t
CalculateNumChildren ();
virtual lldb::ValueObjectSP
- GetChildAtIndex (uint32_t idx);
+ GetChildAtIndex (size_t idx);
virtual bool
Update();
@@ -147,7 +146,7 @@ namespace lldb_private {
virtual bool
MightHaveChildren ();
- virtual uint32_t
+ virtual size_t
GetIndexOfChildWithName (const ConstString &name);
virtual
@@ -166,11 +165,11 @@ namespace lldb_private {
public:
NSArrayISyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
- virtual uint32_t
+ virtual size_t
CalculateNumChildren ();
virtual lldb::ValueObjectSP
- GetChildAtIndex (uint32_t idx);
+ GetChildAtIndex (size_t idx);
virtual bool
Update();
@@ -178,7 +177,7 @@ namespace lldb_private {
virtual bool
MightHaveChildren ();
- virtual uint32_t
+ virtual size_t
GetIndexOfChildWithName (const ConstString &name);
virtual
@@ -197,11 +196,11 @@ namespace lldb_private {
public:
NSArrayCodeRunningSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
- virtual uint32_t
+ virtual size_t
CalculateNumChildren ();
virtual lldb::ValueObjectSP
- GetChildAtIndex (uint32_t idx);
+ GetChildAtIndex (size_t idx);
virtual bool
Update();
@@ -209,7 +208,7 @@ namespace lldb_private {
virtual bool
MightHaveChildren ();
- virtual uint32_t
+ virtual size_t
GetIndexOfChildWithName (const ConstString &name);
virtual
@@ -242,11 +241,11 @@ namespace lldb_private {
public:
NSDictionaryISyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
- virtual uint32_t
+ virtual size_t
CalculateNumChildren ();
virtual lldb::ValueObjectSP
- GetChildAtIndex (uint32_t idx);
+ GetChildAtIndex (size_t idx);
virtual bool
Update();
@@ -254,7 +253,7 @@ namespace lldb_private {
virtual bool
MightHaveChildren ();
- virtual uint32_t
+ virtual size_t
GetIndexOfChildWithName (const ConstString &name);
virtual
@@ -298,11 +297,11 @@ namespace lldb_private {
public:
NSDictionaryMSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
- virtual uint32_t
+ virtual size_t
CalculateNumChildren ();
virtual lldb::ValueObjectSP
- GetChildAtIndex (uint32_t idx);
+ GetChildAtIndex (size_t idx);
virtual bool
Update();
@@ -310,7 +309,7 @@ namespace lldb_private {
virtual bool
MightHaveChildren ();
- virtual uint32_t
+ virtual size_t
GetIndexOfChildWithName (const ConstString &name);
virtual
@@ -328,11 +327,11 @@ namespace lldb_private {
public:
NSDictionaryCodeRunningSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
- virtual uint32_t
+ virtual size_t
CalculateNumChildren ();
virtual lldb::ValueObjectSP
- GetChildAtIndex (uint32_t idx);
+ GetChildAtIndex (size_t idx);
virtual bool
Update();
@@ -340,7 +339,7 @@ namespace lldb_private {
virtual bool
MightHaveChildren ();
- virtual uint32_t
+ virtual size_t
GetIndexOfChildWithName (const ConstString &name);
virtual
Copied: lldb/trunk/include/lldb/DataFormatters/DataVisualization.h (from r173281, lldb/trunk/include/lldb/Core/DataVisualization.h)
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/DataVisualization.h?p2=lldb/trunk/include/lldb/DataFormatters/DataVisualization.h&p1=lldb/trunk/include/lldb/Core/DataVisualization.h&r1=173281&r2=173728&rev=173728&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/DataVisualization.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/DataVisualization.h Mon Jan 28 17:47:25 2013
@@ -16,8 +16,8 @@
// Other libraries and framework includes
// Project includes
#include "lldb/Core/ConstString.h"
-#include "lldb/Core/FormatClasses.h"
-#include "lldb/Core/FormatManager.h"
+#include "lldb/DataFormatters/FormatClasses.h"
+#include "lldb/DataFormatters/FormatManager.h"
namespace lldb_private {
@@ -57,14 +57,14 @@ public:
static void
LoopThrough (TypeFormatImpl::ValueCallback callback, void* callback_baton);
- static uint32_t
+ static size_t
GetCount ();
static lldb::TypeNameSpecifierImplSP
- GetTypeNameSpecifierForFormatAtIndex (uint32_t);
+ GetTypeNameSpecifierForFormatAtIndex (size_t);
static lldb::TypeFormatImplSP
- GetFormatAtIndex (uint32_t);
+ GetFormatAtIndex (size_t);
};
static lldb::TypeSummaryImplSP
@@ -83,7 +83,7 @@ public:
GetFilterForType (lldb::TypeNameSpecifierImplSP type_sp);
#ifndef LLDB_DISABLE_PYTHON
- static lldb::TypeSyntheticImplSP
+ static lldb::ScriptedSyntheticChildrenSP
GetSyntheticForType (lldb::TypeNameSpecifierImplSP type_sp);
#endif
@@ -145,14 +145,14 @@ public:
static void
Enable (const ConstString& category,
- CategoryMap::Position = CategoryMap::Default);
+ TypeCategoryMap::Position = TypeCategoryMap::Default);
static void
Disable (const ConstString& category);
static void
Enable (const lldb::TypeCategoryImplSP& category,
- CategoryMap::Position = CategoryMap::Default);
+ TypeCategoryMap::Position = TypeCategoryMap::Default);
static void
Disable (const lldb::TypeCategoryImplSP& category);
@@ -164,7 +164,7 @@ public:
GetCount ();
static lldb::TypeCategoryImplSP
- GetCategoryAtIndex (uint32_t);
+ GetCategoryAtIndex (size_t);
};
};
Added: lldb/trunk/include/lldb/DataFormatters/FormatCache.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/FormatCache.h?rev=173728&view=auto
==============================================================================
--- lldb/trunk/include/lldb/DataFormatters/FormatCache.h (added)
+++ lldb/trunk/include/lldb/DataFormatters/FormatCache.h Mon Jan 28 17:47:25 2013
@@ -0,0 +1,105 @@
+//===-- FormatCache.h ---------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef lldb_FormatCache_h_
+#define lldb_FormatCache_h_
+
+// C Includes
+// C++ Includes
+#include <map>
+
+// Other libraries and framework includes
+// Project includes
+#include "lldb/lldb-public.h"
+#include "lldb/Core/ConstString.h"
+#include "lldb/DataFormatters/FormatClasses.h"
+
+namespace lldb_private {
+class FormatCache
+{
+private:
+ struct Entry
+ {
+ private:
+ bool m_summary_cached : 1;
+ bool m_synthetic_cached : 1;
+
+ lldb::TypeSummaryImplSP m_summary_sp;
+ lldb::SyntheticChildrenSP m_synthetic_sp;
+ public:
+ Entry ();
+ Entry (lldb::TypeSummaryImplSP);
+ Entry (lldb::SyntheticChildrenSP);
+ Entry (lldb::TypeSummaryImplSP,lldb::SyntheticChildrenSP);
+
+ bool
+ IsSummaryCached ();
+
+ bool
+ IsSyntheticCached ();
+
+ lldb::TypeSummaryImplSP
+ GetSummary ();
+
+ lldb::SyntheticChildrenSP
+ GetSynthetic ();
+
+ void
+ SetSummary (lldb::TypeSummaryImplSP);
+
+ void
+ SetSynthetic (lldb::SyntheticChildrenSP);
+ };
+ typedef std::map<ConstString,Entry> CacheMap;
+ CacheMap m_map;
+ Mutex m_mutex;
+
+#ifdef LLDB_CONFIGURATION_DEBUG
+ uint64_t m_cache_hits;
+ uint64_t m_cache_misses;
+#endif
+
+ Entry&
+ GetEntry (const ConstString& type);
+
+public:
+ FormatCache ();
+
+ bool
+ GetSummary (const ConstString& type,lldb::TypeSummaryImplSP& summary_sp);
+
+ bool
+ GetSynthetic (const ConstString& type,lldb::SyntheticChildrenSP& synthetic_sp);
+
+ void
+ SetSummary (const ConstString& type,lldb::TypeSummaryImplSP& summary_sp);
+
+ void
+ SetSynthetic (const ConstString& type,lldb::SyntheticChildrenSP& synthetic_sp);
+
+ void
+ Clear ();
+
+#ifdef LLDB_CONFIGURATION_DEBUG
+ uint64_t
+ GetCacheHits ()
+ {
+ return m_cache_hits;
+ }
+
+ uint64_t
+ GetCacheMisses ()
+ {
+ return m_cache_misses;
+ }
+#endif
+};
+} // namespace lldb_private
+
+#endif // lldb_FormatCache_h_
Copied: lldb/trunk/include/lldb/DataFormatters/FormatClasses.h (from r173281, lldb/trunk/include/lldb/Core/FormatClasses.h)
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/FormatClasses.h?p2=lldb/trunk/include/lldb/DataFormatters/FormatClasses.h&p1=lldb/trunk/include/lldb/Core/FormatClasses.h&r1=173281&r2=173728&rev=173728&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/FormatClasses.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/FormatClasses.h Mon Jan 28 17:47:25 2013
@@ -26,1488 +26,18 @@
#include "lldb/Core/ValueObject.h"
#include "lldb/Interpreter/ScriptInterpreterPython.h"
+#include "lldb/Symbol/ClangASTType.h"
#include "lldb/Symbol/Type.h"
-namespace lldb_private {
-
-class TypeFormatImpl
-{
-public:
- class Flags
- {
- public:
-
- Flags () :
- m_flags (lldb::eTypeOptionCascade)
- {}
-
- Flags (const Flags& other) :
- m_flags (other.m_flags)
- {}
-
- Flags (uint32_t value) :
- m_flags (value)
- {}
-
- Flags&
- operator = (const Flags& rhs)
- {
- if (&rhs != this)
- m_flags = rhs.m_flags;
-
- return *this;
- }
-
- Flags&
- operator = (const uint32_t& rhs)
- {
- m_flags = rhs;
- return *this;
- }
-
- Flags&
- Clear()
- {
- m_flags = 0;
- return *this;
- }
-
- bool
- GetCascades () const
- {
- return (m_flags & lldb::eTypeOptionCascade) == lldb::eTypeOptionCascade;
- }
-
- Flags&
- SetCascades (bool value = true)
- {
- if (value)
- m_flags |= lldb::eTypeOptionCascade;
- else
- m_flags &= ~lldb::eTypeOptionCascade;
- return *this;
- }
-
- bool
- GetSkipPointers () const
- {
- return (m_flags & lldb::eTypeOptionSkipPointers) == lldb::eTypeOptionSkipPointers;
- }
-
- Flags&
- SetSkipPointers (bool value = true)
- {
- if (value)
- m_flags |= lldb::eTypeOptionSkipPointers;
- else
- m_flags &= ~lldb::eTypeOptionSkipPointers;
- return *this;
- }
-
- bool
- GetSkipReferences () const
- {
- return (m_flags & lldb::eTypeOptionSkipReferences) == lldb::eTypeOptionSkipReferences;
- }
-
- Flags&
- SetSkipReferences (bool value = true)
- {
- if (value)
- m_flags |= lldb::eTypeOptionSkipReferences;
- else
- m_flags &= ~lldb::eTypeOptionSkipReferences;
- return *this;
- }
-
- uint32_t
- GetValue ()
- {
- return m_flags;
- }
-
- void
- SetValue (uint32_t value)
- {
- m_flags = value;
- }
-
- private:
- uint32_t m_flags;
- };
-
- TypeFormatImpl (lldb::Format f = lldb::eFormatInvalid,
- const Flags& flags = Flags());
-
- typedef STD_SHARED_PTR(TypeFormatImpl) SharedPointer;
- typedef bool(*ValueCallback)(void*, ConstString, const lldb::TypeFormatImplSP&);
-
- ~TypeFormatImpl ()
- {
- }
-
- bool
- Cascades () const
- {
- return m_flags.GetCascades();
- }
- bool
- SkipsPointers () const
- {
- return m_flags.GetSkipPointers();
- }
- bool
- SkipsReferences () const
- {
- return m_flags.GetSkipReferences();
- }
-
- void
- SetCascades (bool value)
- {
- m_flags.SetCascades(value);
- }
-
- void
- SetSkipsPointers (bool value)
- {
- m_flags.SetSkipPointers(value);
- }
-
- void
- SetSkipsReferences (bool value)
- {
- m_flags.SetSkipReferences(value);
- }
-
- lldb::Format
- GetFormat () const
- {
- return m_format;
- }
-
- void
- SetFormat (lldb::Format fmt)
- {
- m_format = fmt;
- }
-
- uint32_t
- GetOptions ()
- {
- return m_flags.GetValue();
- }
-
- void
- SetOptions (uint32_t value)
- {
- m_flags.SetValue(value);
- }
-
- uint32_t&
- GetRevision ()
- {
- return m_my_revision;
- }
-
- std::string
- GetDescription();
-
-protected:
- Flags m_flags;
- lldb::Format m_format;
- uint32_t m_my_revision;
-
-private:
- DISALLOW_COPY_AND_ASSIGN(TypeFormatImpl);
-};
-
-class SyntheticChildrenFrontEnd
-{
-protected:
- ValueObject &m_backend;
-public:
-
- SyntheticChildrenFrontEnd (ValueObject &backend) :
- m_backend(backend)
- {}
-
- virtual
- ~SyntheticChildrenFrontEnd ()
- {
- }
-
- virtual uint32_t
- CalculateNumChildren () = 0;
-
- virtual lldb::ValueObjectSP
- GetChildAtIndex (uint32_t idx) = 0;
-
- virtual uint32_t
- GetIndexOfChildWithName (const ConstString &name) = 0;
-
- // this function is assumed to always succeed and it if fails, the front-end should know to deal
- // with it in the correct way (most probably, by refusing to return any children)
- // the return value of Update() should actually be interpreted as "ValueObjectSyntheticFilter cache is good/bad"
- // if =true, ValueObjectSyntheticFilter is allowed to use the children it fetched previously and cached
- // if =false, ValueObjectSyntheticFilter must throw away its cache, and query again for children
- virtual bool
- Update () = 0;
-
- // if this function returns false, then CalculateNumChildren() MUST return 0 since UI frontends
- // might validly decide not to inquire for children given a false return value from this call
- // if it returns true, then CalculateNumChildren() can return any number >= 0 (0 being valid)
- // it should if at all possible be more efficient than CalculateNumChildren()
- virtual bool
- MightHaveChildren () = 0;
-
- typedef STD_SHARED_PTR(SyntheticChildrenFrontEnd) SharedPointer;
- typedef std::auto_ptr<SyntheticChildrenFrontEnd> AutoPointer;
-
-private:
- DISALLOW_COPY_AND_ASSIGN(SyntheticChildrenFrontEnd);
-};
-
-class SyntheticChildren
-{
-public:
-
- class Flags
- {
- public:
-
- Flags () :
- m_flags (lldb::eTypeOptionCascade)
- {}
-
- Flags (const Flags& other) :
- m_flags (other.m_flags)
- {}
-
- Flags (uint32_t value) :
- m_flags (value)
- {}
-
- Flags&
- operator = (const Flags& rhs)
- {
- if (&rhs != this)
- m_flags = rhs.m_flags;
-
- return *this;
- }
-
- Flags&
- operator = (const uint32_t& rhs)
- {
- m_flags = rhs;
- return *this;
- }
-
- Flags&
- Clear()
- {
- m_flags = 0;
- return *this;
- }
-
- bool
- GetCascades () const
- {
- return (m_flags & lldb::eTypeOptionCascade) == lldb::eTypeOptionCascade;
- }
-
- Flags&
- SetCascades (bool value = true)
- {
- if (value)
- m_flags |= lldb::eTypeOptionCascade;
- else
- m_flags &= ~lldb::eTypeOptionCascade;
- return *this;
- }
-
- bool
- GetSkipPointers () const
- {
- return (m_flags & lldb::eTypeOptionSkipPointers) == lldb::eTypeOptionSkipPointers;
- }
-
- Flags&
- SetSkipPointers (bool value = true)
- {
- if (value)
- m_flags |= lldb::eTypeOptionSkipPointers;
- else
- m_flags &= ~lldb::eTypeOptionSkipPointers;
- return *this;
- }
-
- bool
- GetSkipReferences () const
- {
- return (m_flags & lldb::eTypeOptionSkipReferences) == lldb::eTypeOptionSkipReferences;
- }
-
- Flags&
- SetSkipReferences (bool value = true)
- {
- if (value)
- m_flags |= lldb::eTypeOptionSkipReferences;
- else
- m_flags &= ~lldb::eTypeOptionSkipReferences;
- return *this;
- }
-
- uint32_t
- GetValue ()
- {
- return m_flags;
- }
-
- void
- SetValue (uint32_t value)
- {
- m_flags = value;
- }
-
- private:
- uint32_t m_flags;
- };
-
- SyntheticChildren (const Flags& flags) :
- m_flags(flags)
- {
- }
-
- virtual
- ~SyntheticChildren ()
- {
- }
-
- bool
- Cascades () const
- {
- return m_flags.GetCascades();
- }
- bool
- SkipsPointers () const
- {
- return m_flags.GetSkipPointers();
- }
- bool
- SkipsReferences () const
- {
- return m_flags.GetSkipReferences();
- }
-
- void
- SetCascades (bool value)
- {
- m_flags.SetCascades(value);
- }
-
- void
- SetSkipsPointers (bool value)
- {
- m_flags.SetSkipPointers(value);
- }
-
- void
- SetSkipsReferences (bool value)
- {
- m_flags.SetSkipReferences(value);
- }
-
- uint32_t
- GetOptions ()
- {
- return m_flags.GetValue();
- }
-
- void
- SetOptions (uint32_t value)
- {
- m_flags.SetValue(value);
- }
-
- virtual bool
- IsScripted () = 0;
-
- virtual std::string
- GetDescription () = 0;
-
- virtual SyntheticChildrenFrontEnd::AutoPointer
- GetFrontEnd (ValueObject &backend) = 0;
-
- typedef STD_SHARED_PTR(SyntheticChildren) SharedPointer;
- typedef bool(*SyntheticChildrenCallback)(void*, ConstString, const SyntheticChildren::SharedPointer&);
-
- uint32_t&
- GetRevision ()
- {
- return m_my_revision;
- }
-
-protected:
- uint32_t m_my_revision;
- Flags m_flags;
-
-private:
- DISALLOW_COPY_AND_ASSIGN(SyntheticChildren);
-};
-
-class TypeFilterImpl : public SyntheticChildren
-{
- std::vector<std::string> m_expression_paths;
-public:
- TypeFilterImpl(const SyntheticChildren::Flags& flags) :
- SyntheticChildren(flags),
- m_expression_paths()
- {
- }
-
- void
- AddExpressionPath (const char* path)
- {
- AddExpressionPath(std::string(path));
- }
-
- void
- Clear()
- {
- m_expression_paths.clear();
- }
-
- int
- GetCount() const
- {
- return m_expression_paths.size();
- }
-
- const char*
- GetExpressionPathAtIndex(int i) const
- {
- return m_expression_paths[i].c_str();
- }
-
- bool
- SetExpressionPathAtIndex (int i, const char* path)
- {
- return SetExpressionPathAtIndex(i, std::string(path));
- }
-
- void
- AddExpressionPath (std::string path)
- {
- bool need_add_dot = true;
- if (path[0] == '.' ||
- (path[0] == '-' && path[1] == '>') ||
- path[0] == '[')
- need_add_dot = false;
- // add a '.' symbol to help forgetful users
- if(!need_add_dot)
- m_expression_paths.push_back(path);
- else
- m_expression_paths.push_back(std::string(".") + path);
- }
-
- bool
- SetExpressionPathAtIndex (int i, std::string path)
- {
- if (i >= GetCount())
- return false;
- bool need_add_dot = true;
- if (path[0] == '.' ||
- (path[0] == '-' && path[1] == '>') ||
- path[0] == '[')
- need_add_dot = false;
- // add a '.' symbol to help forgetful users
- if(!need_add_dot)
- m_expression_paths[i] = path;
- else
- m_expression_paths[i] = std::string(".") + path;
- return true;
- }
-
- bool
- IsScripted()
- {
- return false;
- }
-
- std::string
- GetDescription();
-
- class FrontEnd : public SyntheticChildrenFrontEnd
- {
- private:
- TypeFilterImpl* filter;
- public:
-
- FrontEnd(TypeFilterImpl* flt,
- ValueObject &backend) :
- SyntheticChildrenFrontEnd(backend),
- filter(flt)
- {}
-
- virtual
- ~FrontEnd()
- {
- }
-
- virtual uint32_t
- CalculateNumChildren()
- {
- return filter->GetCount();
- }
-
- virtual lldb::ValueObjectSP
- GetChildAtIndex (uint32_t idx)
- {
- if (idx >= filter->GetCount())
- return lldb::ValueObjectSP();
- return m_backend.GetSyntheticExpressionPathChild(filter->GetExpressionPathAtIndex(idx), true);
- }
-
- virtual bool
- Update() { return false; }
-
- virtual bool
- MightHaveChildren ()
- {
- return filter->GetCount() > 0;
- }
-
- virtual uint32_t
- GetIndexOfChildWithName (const ConstString &name)
- {
- const char* name_cstr = name.GetCString();
- for (int i = 0; i < filter->GetCount(); i++)
- {
- const char* expr_cstr = filter->GetExpressionPathAtIndex(i);
- if (expr_cstr)
- {
- if (*expr_cstr == '.')
- expr_cstr++;
- else if (*expr_cstr == '-' && *(expr_cstr+1) == '>')
- expr_cstr += 2;
- }
- if (!::strcmp(name_cstr, expr_cstr))
- return i;
- }
- return UINT32_MAX;
- }
-
- typedef STD_SHARED_PTR(SyntheticChildrenFrontEnd) SharedPointer;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(FrontEnd);
- };
-
- virtual SyntheticChildrenFrontEnd::AutoPointer
- GetFrontEnd(ValueObject &backend)
- {
- return SyntheticChildrenFrontEnd::AutoPointer(new FrontEnd(this, backend));
- }
-
-private:
- DISALLOW_COPY_AND_ASSIGN(TypeFilterImpl);
-};
-
- class CXXSyntheticChildren : public SyntheticChildren
- {
- public:
- typedef SyntheticChildrenFrontEnd* (*CreateFrontEndCallback) (CXXSyntheticChildren*, lldb::ValueObjectSP);
- protected:
- CreateFrontEndCallback m_create_callback;
- std::string m_description;
- public:
- CXXSyntheticChildren(const SyntheticChildren::Flags& flags,
- const char* description,
- CreateFrontEndCallback callback) :
- SyntheticChildren(flags),
- m_create_callback(callback),
- m_description(description ? description : "")
- {
- }
-
- bool
- IsScripted()
- {
- return false;
- }
-
- std::string
- GetDescription();
-
- virtual SyntheticChildrenFrontEnd::AutoPointer
- GetFrontEnd(ValueObject &backend)
- {
- return SyntheticChildrenFrontEnd::AutoPointer(m_create_callback(this, backend.GetSP()));
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(CXXSyntheticChildren);
- };
-
-#ifndef LLDB_DISABLE_PYTHON
-
-class TypeSyntheticImpl : public SyntheticChildren
-{
- std::string m_python_class;
- std::string m_python_code;
-public:
-
- TypeSyntheticImpl(const SyntheticChildren::Flags& flags,
- const char* pclass,
- const char* pcode = NULL) :
- SyntheticChildren(flags),
- m_python_class(),
- m_python_code()
- {
- if (pclass)
- m_python_class = pclass;
- if (pcode)
- m_python_code = pcode;
- }
-
- const char*
- GetPythonClassName()
- {
- return m_python_class.c_str();
- }
-
- const char*
- GetPythonCode()
- {
- return m_python_code.c_str();
- }
-
- void
- SetPythonClassName (const char* fname)
- {
- m_python_class.assign(fname);
- m_python_code.clear();
- }
-
- void
- SetPythonCode (const char* script)
- {
- m_python_code.assign(script);
- }
-
- std::string
- GetDescription();
-
- bool
- IsScripted()
- {
- return true;
- }
-
- class FrontEnd : public SyntheticChildrenFrontEnd
- {
- private:
- std::string m_python_class;
- lldb::ScriptInterpreterObjectSP m_wrapper_sp;
- ScriptInterpreter *m_interpreter;
- public:
-
- FrontEnd(std::string pclass,
- ValueObject &backend);
-
- virtual
- ~FrontEnd();
-
- virtual uint32_t
- CalculateNumChildren()
- {
- if (!m_wrapper_sp || m_interpreter == NULL)
- return 0;
- return m_interpreter->CalculateNumChildren(m_wrapper_sp);
- }
-
- virtual lldb::ValueObjectSP
- GetChildAtIndex (uint32_t idx);
-
- virtual bool
- Update()
- {
- if (!m_wrapper_sp || m_interpreter == NULL)
- return false;
-
- return m_interpreter->UpdateSynthProviderInstance(m_wrapper_sp);
- }
-
- virtual bool
- MightHaveChildren()
- {
- if (!m_wrapper_sp || m_interpreter == NULL)
- return false;
-
- return m_interpreter->MightHaveChildrenSynthProviderInstance(m_wrapper_sp);
- }
-
- virtual uint32_t
- GetIndexOfChildWithName (const ConstString &name)
- {
- if (!m_wrapper_sp || m_interpreter == NULL)
- return UINT32_MAX;
- return m_interpreter->GetIndexOfChildWithName(m_wrapper_sp, name.GetCString());
- }
-
- typedef STD_SHARED_PTR(SyntheticChildrenFrontEnd) SharedPointer;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(FrontEnd);
- };
-
- virtual SyntheticChildrenFrontEnd::AutoPointer
- GetFrontEnd(ValueObject &backend)
- {
- return SyntheticChildrenFrontEnd::AutoPointer(new FrontEnd(m_python_class, backend));
- }
-
-private:
- DISALLOW_COPY_AND_ASSIGN(TypeSyntheticImpl);
-};
-
-#endif // #ifndef LLDB_DISABLE_PYTHON
-class SyntheticArrayView : public SyntheticChildren
-{
-public:
-
- struct SyntheticArrayRange
- {
- private:
- int m_low;
- int m_high;
- SyntheticArrayRange* m_next;
-
- public:
-
- SyntheticArrayRange () :
- m_low(-1),
- m_high(-2),
- m_next(NULL)
- {}
-
- SyntheticArrayRange (int L) :
- m_low(L),
- m_high(L),
- m_next(NULL)
- {}
-
- SyntheticArrayRange (int L, int H) :
- m_low(L),
- m_high(H),
- m_next(NULL)
- {}
-
- SyntheticArrayRange (int L, int H, SyntheticArrayRange* N) :
- m_low(L),
- m_high(H),
- m_next(N)
- {}
-
- inline int
- GetLow ()
- {
- return m_low;
- }
-
- inline int
- GetHigh ()
- {
- return m_high;
- }
-
- inline void
- SetLow (int L)
- {
- m_low = L;
- }
-
- inline void
- SetHigh (int H)
- {
- m_high = H;
- }
-
- inline int
- GetSelfCount()
- {
- return GetHigh() - GetLow() + 1;
- }
-
- int
- GetCount()
- {
- int count = GetSelfCount();
- if (m_next)
- count += m_next->GetCount();
- return count;
- }
-
- inline SyntheticArrayRange*
- GetNext()
- {
- return m_next;
- }
-
- void
- SetNext(SyntheticArrayRange* N)
- {
- if (m_next)
- delete m_next;
- m_next = N;
- }
-
- void
- SetNext(int L, int H)
- {
- if (m_next)
- delete m_next;
- m_next = new SyntheticArrayRange(L, H);
- }
-
- void
- SetNext(int L)
- {
- if (m_next)
- delete m_next;
- m_next = new SyntheticArrayRange(L);
- }
-
- ~SyntheticArrayRange()
- {
- delete m_next;
- m_next = NULL;
- }
-
- };
-
- SyntheticArrayView(const SyntheticChildren::Flags& flags) :
- SyntheticChildren(flags),
- m_head(),
- m_tail(&m_head)
- {
- }
-
- void
- AddRange(int L, int H)
- {
- m_tail->SetLow(L);
- m_tail->SetHigh(H);
- m_tail->SetNext(new SyntheticArrayRange());
- m_tail = m_tail->GetNext();
- }
-
- int
- GetCount()
- {
- return m_head.GetCount();
- }
-
- int
- GetRealIndexForIndex(int i);
-
- bool
- IsScripted()
- {
- return false;
- }
-
- std::string
- GetDescription();
-
- class FrontEnd : public SyntheticChildrenFrontEnd
- {
- private:
- SyntheticArrayView* filter;
- public:
-
- FrontEnd(SyntheticArrayView* flt,
- ValueObject &backend) :
- SyntheticChildrenFrontEnd(backend),
- filter(flt)
- {}
-
- virtual
- ~FrontEnd()
- {
- }
-
- virtual uint32_t
- CalculateNumChildren()
- {
- return filter->GetCount();
- }
-
- virtual bool
- MightHaveChildren ()
- {
- return filter->GetCount() > 0;
- }
-
- virtual lldb::ValueObjectSP
- GetChildAtIndex (uint32_t idx)
- {
- if (idx >= filter->GetCount())
- return lldb::ValueObjectSP();
- return m_backend.GetSyntheticArrayMember(filter->GetRealIndexForIndex(idx), true);
- }
-
- virtual bool
- Update() { return false; }
-
- virtual uint32_t
- GetIndexOfChildWithName (const ConstString &name_cs);
-
- typedef STD_SHARED_PTR(SyntheticChildrenFrontEnd) SharedPointer;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(FrontEnd);
- };
-
- virtual SyntheticChildrenFrontEnd::AutoPointer
- GetFrontEnd(ValueObject &backend)
- {
- return SyntheticChildrenFrontEnd::AutoPointer(new FrontEnd(this, backend));
- }
-private:
- SyntheticArrayRange m_head;
- SyntheticArrayRange *m_tail;
-
-private:
- DISALLOW_COPY_AND_ASSIGN(SyntheticArrayView);
-};
-
-
-class TypeSummaryImpl
-{
-public:
- class Flags
- {
- public:
-
- Flags () :
- m_flags (lldb::eTypeOptionCascade)
- {}
-
- Flags (const Flags& other) :
- m_flags (other.m_flags)
- {}
-
- Flags (uint32_t value) :
- m_flags (value)
- {}
-
- Flags&
- operator = (const Flags& rhs)
- {
- if (&rhs != this)
- m_flags = rhs.m_flags;
-
- return *this;
- }
-
- Flags&
- operator = (const uint32_t& rhs)
- {
- m_flags = rhs;
- return *this;
- }
-
- Flags&
- Clear()
- {
- m_flags = 0;
- return *this;
- }
-
- bool
- GetCascades () const
- {
- return (m_flags & lldb::eTypeOptionCascade) == lldb::eTypeOptionCascade;
- }
-
- Flags&
- SetCascades (bool value = true)
- {
- if (value)
- m_flags |= lldb::eTypeOptionCascade;
- else
- m_flags &= ~lldb::eTypeOptionCascade;
- return *this;
- }
-
- bool
- GetSkipPointers () const
- {
- return (m_flags & lldb::eTypeOptionSkipPointers) == lldb::eTypeOptionSkipPointers;
- }
-
- Flags&
- SetSkipPointers (bool value = true)
- {
- if (value)
- m_flags |= lldb::eTypeOptionSkipPointers;
- else
- m_flags &= ~lldb::eTypeOptionSkipPointers;
- return *this;
- }
-
- bool
- GetSkipReferences () const
- {
- return (m_flags & lldb::eTypeOptionSkipReferences) == lldb::eTypeOptionSkipReferences;
- }
-
- Flags&
- SetSkipReferences (bool value = true)
- {
- if (value)
- m_flags |= lldb::eTypeOptionSkipReferences;
- else
- m_flags &= ~lldb::eTypeOptionSkipReferences;
- return *this;
- }
-
- bool
- GetDontShowChildren () const
- {
- return (m_flags & lldb::eTypeOptionHideChildren) == lldb::eTypeOptionHideChildren;
- }
-
- Flags&
- SetDontShowChildren (bool value = true)
- {
- if (value)
- m_flags |= lldb::eTypeOptionHideChildren;
- else
- m_flags &= ~lldb::eTypeOptionHideChildren;
- return *this;
- }
-
- bool
- GetDontShowValue () const
- {
- return (m_flags & lldb::eTypeOptionHideValue) == lldb::eTypeOptionHideValue;
- }
-
- Flags&
- SetDontShowValue (bool value = true)
- {
- if (value)
- m_flags |= lldb::eTypeOptionHideValue;
- else
- m_flags &= ~lldb::eTypeOptionHideValue;
- return *this;
- }
-
- bool
- GetShowMembersOneLiner () const
- {
- return (m_flags & lldb::eTypeOptionShowOneLiner) == lldb::eTypeOptionShowOneLiner;
- }
-
- Flags&
- SetShowMembersOneLiner (bool value = true)
- {
- if (value)
- m_flags |= lldb::eTypeOptionShowOneLiner;
- else
- m_flags &= ~lldb::eTypeOptionShowOneLiner;
- return *this;
- }
-
- bool
- GetHideItemNames () const
- {
- return (m_flags & lldb::eTypeOptionHideNames) == lldb::eTypeOptionHideNames;
- }
-
- Flags&
- SetHideItemNames (bool value = true)
- {
- if (value)
- m_flags |= lldb::eTypeOptionHideNames;
- else
- m_flags &= ~lldb::eTypeOptionHideNames;
- return *this;
- }
-
- uint32_t
- GetValue ()
- {
- return m_flags;
- }
-
- void
- SetValue (uint32_t value)
- {
- m_flags = value;
- }
-
- private:
- uint32_t m_flags;
- };
-
- typedef enum Type
- {
- eTypeUnknown,
- eTypeString,
- eTypeScript,
- eTypeCallback
- } Type;
-
- TypeSummaryImpl (const TypeSummaryImpl::Flags& flags);
-
- bool
- Cascades () const
- {
- return m_flags.GetCascades();
- }
- bool
- SkipsPointers () const
- {
- return m_flags.GetSkipPointers();
- }
- bool
- SkipsReferences () const
- {
- return m_flags.GetSkipReferences();
- }
-
- bool
- DoesPrintChildren () const
- {
- return !m_flags.GetDontShowChildren();
- }
-
- bool
- DoesPrintValue () const
- {
- return !m_flags.GetDontShowValue();
- }
-
- bool
- IsOneliner () const
- {
- return m_flags.GetShowMembersOneLiner();
- }
-
- bool
- HideNames () const
- {
- return m_flags.GetHideItemNames();
- }
-
- void
- SetCascades (bool value)
- {
- m_flags.SetCascades(value);
- }
-
- void
- SetSkipsPointers (bool value)
- {
- m_flags.SetSkipPointers(value);
- }
-
- void
- SetSkipsReferences (bool value)
- {
- m_flags.SetSkipReferences(value);
- }
-
- void
- SetDoesPrintChildren (bool value)
- {
- m_flags.SetDontShowChildren(!value);
- }
-
- void
- SetDoesPrintValue (bool value)
- {
- m_flags.SetDontShowValue(!value);
- }
-
- void
- SetIsOneliner (bool value)
- {
- m_flags.SetShowMembersOneLiner(value);
- }
-
- void
- SetHideNames (bool value)
- {
- m_flags.SetHideItemNames(value);
- }
-
- uint32_t
- GetOptions ()
- {
- return m_flags.GetValue();
- }
-
- void
- SetOptions (uint32_t value)
- {
- m_flags.SetValue(value);
- }
-
- virtual
- ~TypeSummaryImpl ()
- {
- }
-
- // we are using a ValueObject* instead of a ValueObjectSP because we do not need to hold on to this for
- // extended periods of time and we trust the ValueObject to stay around for as long as it is required
- // for us to generate its summary
- virtual bool
- FormatObject (ValueObject *valobj,
- std::string& dest) = 0;
-
- virtual std::string
- GetDescription () = 0;
-
- virtual bool
- IsScripted() = 0;
-
- virtual Type
- GetType () = 0;
-
- uint32_t&
- GetRevision ()
- {
- return m_my_revision;
- }
-
- typedef STD_SHARED_PTR(TypeSummaryImpl) SharedPointer;
- typedef bool(*SummaryCallback)(void*, ConstString, const lldb::TypeSummaryImplSP&);
- typedef bool(*RegexSummaryCallback)(void*, lldb::RegularExpressionSP, const lldb::TypeSummaryImplSP&);
-
-protected:
- uint32_t m_my_revision;
- Flags m_flags;
-
-private:
- DISALLOW_COPY_AND_ASSIGN(TypeSummaryImpl);
-};
-
-// simple string-based summaries, using ${var to show data
-struct StringSummaryFormat : public TypeSummaryImpl
-{
- std::string m_format;
-
- StringSummaryFormat(const TypeSummaryImpl::Flags& flags,
- const char* f);
-
- const char*
- GetSummaryString () const
- {
- return m_format.c_str();
- }
-
- void
- SetSummaryString (const char* data)
- {
- if (data)
- m_format.assign(data);
- else
- m_format.clear();
- }
-
- virtual
- ~StringSummaryFormat()
- {
- }
-
- virtual bool
- FormatObject(ValueObject *valobj,
- std::string& dest);
-
- virtual std::string
- GetDescription();
-
- virtual bool
- IsScripted()
- {
- return false;
- }
-
-
- virtual Type
- GetType ()
- {
- return TypeSummaryImpl::eTypeString;
- }
-
-private:
- DISALLOW_COPY_AND_ASSIGN(StringSummaryFormat);
-};
-
-// summaries implemented via a C++ function
-struct CXXFunctionSummaryFormat : public TypeSummaryImpl
-{
-
- // we should convert these to SBValue and SBStream if we ever cross
- // the boundary towards the external world
- typedef bool (*Callback)(ValueObject& valobj,
- Stream& dest);
-
-
- Callback m_impl;
- std::string m_description;
-
- CXXFunctionSummaryFormat(const TypeSummaryImpl::Flags& flags,
- Callback impl,
- const char* description);
-
- Callback
- GetBackendFunction () const
- {
- return m_impl;
- }
-
- const char*
- GetTextualInfo () const
- {
- return m_description.c_str();
- }
-
- void
- SetBackendFunction (Callback cb_func)
- {
- m_impl = cb_func;
- }
-
- void
- SetTextualInfo (const char* descr)
- {
- if (descr)
- m_description.assign(descr);
- else
- m_description.clear();
- }
-
- virtual
- ~CXXFunctionSummaryFormat()
- {
- }
-
- virtual bool
- FormatObject(ValueObject *valobj,
- std::string& dest);
-
- virtual std::string
- GetDescription();
-
- virtual bool
- IsScripted()
- {
- return false;
- }
-
- virtual Type
- GetType ()
- {
- return TypeSummaryImpl::eTypeCallback;
- }
-
- typedef STD_SHARED_PTR(CXXFunctionSummaryFormat) SharedPointer;
-
-private:
- DISALLOW_COPY_AND_ASSIGN(CXXFunctionSummaryFormat);
-};
-
-#ifndef LLDB_DISABLE_PYTHON
-
-// Python-based summaries, running script code to show data
-struct ScriptSummaryFormat : public TypeSummaryImpl
-{
- std::string m_function_name;
- std::string m_python_script;
- lldb::ScriptInterpreterObjectSP m_script_function_sp;
-
- ScriptSummaryFormat(const TypeSummaryImpl::Flags& flags,
- const char *function_name,
- const char* python_script = NULL);
-
- const char*
- GetFunctionName () const
- {
- return m_function_name.c_str();
- }
-
- const char*
- GetPythonScript () const
- {
- return m_python_script.c_str();
- }
-
- void
- SetFunctionName (const char* function_name)
- {
- if (function_name)
- m_function_name.assign(function_name);
- else
- m_function_name.clear();
- m_python_script.clear();
- }
-
- void
- SetPythonScript (const char* script)
- {
- if (script)
- m_python_script.assign(script);
- else
- m_python_script.clear();
- }
-
- virtual
- ~ScriptSummaryFormat()
- {
- }
-
- virtual bool
- FormatObject(ValueObject *valobj,
- std::string& dest);
-
- virtual std::string
- GetDescription();
-
- virtual bool
- IsScripted()
- {
- return true;
- }
-
- virtual Type
- GetType ()
- {
- return TypeSummaryImpl::eTypeScript;
- }
-
- typedef STD_SHARED_PTR(ScriptSummaryFormat) SharedPointer;
-
-
-private:
- DISALLOW_COPY_AND_ASSIGN(ScriptSummaryFormat);
-};
+#include "lldb/DataFormatters/TypeFormat.h"
+#include "lldb/DataFormatters/TypeSummary.h"
+#include "lldb/DataFormatters/TypeSynthetic.h"
-#endif // #ifndef LLDB_DISABLE_PYTHON
+namespace lldb_private {
-// TODO: at the moment, this class is only used as a backing store for SBTypeNameSpecifier in the public API
-// In the future, this might be used as the basic unit for typename-to-formatter matching, replacing
-// the current plain/regexp distinction in FormatNavigator<>
class TypeNameSpecifierImpl
{
public:
-
TypeNameSpecifierImpl() :
m_is_regex(false),
m_type()
Copied: lldb/trunk/include/lldb/DataFormatters/FormatManager.h (from r173281, lldb/trunk/include/lldb/Core/FormatManager.h)
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/FormatManager.h?p2=lldb/trunk/include/lldb/DataFormatters/FormatManager.h&p1=lldb/trunk/include/lldb/Core/FormatManager.h&r1=173281&r2=173728&rev=173728&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/FormatManager.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/FormatManager.h Mon Jan 28 17:47:25 2013
@@ -18,12 +18,10 @@
#include "lldb/lldb-public.h"
#include "lldb/lldb-enumerations.h"
-#include "lldb/Core/FormatNavigator.h"
-#include "lldb/Interpreter/ScriptInterpreterPython.h"
-#include "lldb/Target/ExecutionContext.h"
-#include "lldb/Target/Platform.h"
-
-using lldb::LogSP;
+#include "lldb/DataFormatters/FormatCache.h"
+#include "lldb/DataFormatters/FormatNavigator.h"
+#include "lldb/DataFormatters/TypeCategory.h"
+#include "lldb/DataFormatters/TypeCategoryMap.h"
namespace lldb_private {
@@ -31,535 +29,16 @@ namespace lldb_private {
// class DataVisualization is the high-level front-end of this feature
// clients should refer to that class as the entry-point into the data formatters
// unless they have a good reason to bypass it and prefer to use this file's objects directly
-
-class CategoryMap;
-
-class TypeCategoryImpl
-{
-private:
-
- typedef FormatNavigator<ConstString, TypeSummaryImpl> SummaryNavigator;
- typedef FormatNavigator<lldb::RegularExpressionSP, TypeSummaryImpl> RegexSummaryNavigator;
-
- typedef FormatNavigator<ConstString, TypeFilterImpl> FilterNavigator;
- typedef FormatNavigator<lldb::RegularExpressionSP, TypeFilterImpl> RegexFilterNavigator;
-
-#ifndef LLDB_DISABLE_PYTHON
- typedef FormatNavigator<ConstString, TypeSyntheticImpl> SynthNavigator;
- typedef FormatNavigator<lldb::RegularExpressionSP, TypeSyntheticImpl> RegexSynthNavigator;
-#endif // #ifndef LLDB_DISABLE_PYTHON
-
- typedef SummaryNavigator::MapType SummaryMap;
- typedef RegexSummaryNavigator::MapType RegexSummaryMap;
- typedef FilterNavigator::MapType FilterMap;
- typedef RegexFilterNavigator::MapType RegexFilterMap;
-#ifndef LLDB_DISABLE_PYTHON
- typedef SynthNavigator::MapType SynthMap;
- typedef RegexSynthNavigator::MapType RegexSynthMap;
-#endif // #ifndef LLDB_DISABLE_PYTHON
-
-public:
-
- typedef uint16_t FormatCategoryItems;
- static const uint16_t ALL_ITEM_TYPES = UINT16_MAX;
-
- typedef SummaryNavigator::SharedPointer SummaryNavigatorSP;
- typedef RegexSummaryNavigator::SharedPointer RegexSummaryNavigatorSP;
- typedef FilterNavigator::SharedPointer FilterNavigatorSP;
- typedef RegexFilterNavigator::SharedPointer RegexFilterNavigatorSP;
-#ifndef LLDB_DISABLE_PYTHON
- typedef SynthNavigator::SharedPointer SynthNavigatorSP;
- typedef RegexSynthNavigator::SharedPointer RegexSynthNavigatorSP;
-#endif // #ifndef LLDB_DISABLE_PYTHON
-
- TypeCategoryImpl (IFormatChangeListener* clist,
- ConstString name);
-
- SummaryNavigatorSP
- GetSummaryNavigator ()
- {
- return SummaryNavigatorSP(m_summary_nav);
- }
-
- RegexSummaryNavigatorSP
- GetRegexSummaryNavigator ()
- {
- return RegexSummaryNavigatorSP(m_regex_summary_nav);
- }
-
- FilterNavigatorSP
- GetFilterNavigator ()
- {
- return FilterNavigatorSP(m_filter_nav);
- }
-
- RegexFilterNavigatorSP
- GetRegexFilterNavigator ()
- {
- return RegexFilterNavigatorSP(m_regex_filter_nav);
- }
-
- SummaryNavigator::MapValueType
- GetSummaryForType (lldb::TypeNameSpecifierImplSP type_sp)
- {
- SummaryNavigator::MapValueType retval;
-
- if (type_sp)
- {
- if (type_sp->IsRegex())
- m_regex_summary_nav->GetExact(ConstString(type_sp->GetName()),retval);
- else
- m_summary_nav->GetExact(ConstString(type_sp->GetName()),retval);
- }
-
- return retval;
- }
-
- FilterNavigator::MapValueType
- GetFilterForType (lldb::TypeNameSpecifierImplSP type_sp)
- {
- FilterNavigator::MapValueType retval;
-
- if (type_sp)
- {
- if (type_sp->IsRegex())
- m_regex_filter_nav->GetExact(ConstString(type_sp->GetName()),retval);
- else
- m_filter_nav->GetExact(ConstString(type_sp->GetName()),retval);
- }
-
- return retval;
- }
-
-#ifndef LLDB_DISABLE_PYTHON
- SynthNavigator::MapValueType
- GetSyntheticForType (lldb::TypeNameSpecifierImplSP type_sp)
- {
- SynthNavigator::MapValueType retval;
-
- if (type_sp)
- {
- if (type_sp->IsRegex())
- m_regex_synth_nav->GetExact(ConstString(type_sp->GetName()),retval);
- else
- m_synth_nav->GetExact(ConstString(type_sp->GetName()),retval);
- }
-
- return retval;
- }
-#endif
-
- lldb::TypeNameSpecifierImplSP
- GetTypeNameSpecifierForSummaryAtIndex (uint32_t index)
- {
- if (index < m_summary_nav->GetCount())
- return m_summary_nav->GetTypeNameSpecifierAtIndex(index);
- else
- return m_regex_summary_nav->GetTypeNameSpecifierAtIndex(index-m_summary_nav->GetCount());
- }
-
- SummaryNavigator::MapValueType
- GetSummaryAtIndex (uint32_t index)
- {
- if (index < m_summary_nav->GetCount())
- return m_summary_nav->GetAtIndex(index);
- else
- return m_regex_summary_nav->GetAtIndex(index-m_summary_nav->GetCount());
- }
-
- FilterNavigator::MapValueType
- GetFilterAtIndex (uint32_t index)
- {
- if (index < m_filter_nav->GetCount())
- return m_filter_nav->GetAtIndex(index);
- else
- return m_regex_filter_nav->GetAtIndex(index-m_filter_nav->GetCount());
- }
-
- lldb::TypeNameSpecifierImplSP
- GetTypeNameSpecifierForFilterAtIndex (uint32_t index)
- {
- if (index < m_filter_nav->GetCount())
- return m_filter_nav->GetTypeNameSpecifierAtIndex(index);
- else
- return m_regex_filter_nav->GetTypeNameSpecifierAtIndex(index-m_filter_nav->GetCount());
- }
-
-#ifndef LLDB_DISABLE_PYTHON
- SynthNavigatorSP
- GetSyntheticNavigator ()
- {
- return SynthNavigatorSP(m_synth_nav);
- }
-
- RegexSynthNavigatorSP
- GetRegexSyntheticNavigator ()
- {
- return RegexSynthNavigatorSP(m_regex_synth_nav);
- }
-
- SynthNavigator::MapValueType
- GetSyntheticAtIndex (uint32_t index)
- {
- if (index < m_synth_nav->GetCount())
- return m_synth_nav->GetAtIndex(index);
- else
- return m_regex_synth_nav->GetAtIndex(index-m_synth_nav->GetCount());
- }
-
- lldb::TypeNameSpecifierImplSP
- GetTypeNameSpecifierForSyntheticAtIndex (uint32_t index)
- {
- if (index < m_synth_nav->GetCount())
- return m_synth_nav->GetTypeNameSpecifierAtIndex(index);
- else
- return m_regex_synth_nav->GetTypeNameSpecifierAtIndex(index - m_synth_nav->GetCount());
- }
-
-#endif // #ifndef LLDB_DISABLE_PYTHON
-
- bool
- IsEnabled () const
- {
- return m_enabled;
- }
-
- uint32_t
- GetEnabledPosition()
- {
- if (m_enabled == false)
- return UINT32_MAX;
- else
- return m_enabled_position;
- }
-
- bool
- Get (ValueObject& valobj,
- lldb::TypeSummaryImplSP& entry,
- lldb::DynamicValueType use_dynamic,
- uint32_t* reason = NULL);
-
- bool
- Get (ValueObject& valobj,
- lldb::SyntheticChildrenSP& entry,
- lldb::DynamicValueType use_dynamic,
- uint32_t* reason = NULL);
-
- void
- Clear (FormatCategoryItems items = ALL_ITEM_TYPES);
-
- bool
- Delete (ConstString name,
- FormatCategoryItems items = ALL_ITEM_TYPES);
-
- uint32_t
- GetCount (FormatCategoryItems items = ALL_ITEM_TYPES);
-
- const char*
- GetName ()
- {
- return m_name.GetCString();
- }
-
- bool
- AnyMatches (ConstString type_name,
- FormatCategoryItems items = ALL_ITEM_TYPES,
- bool only_enabled = true,
- const char** matching_category = NULL,
- FormatCategoryItems* matching_type = NULL);
-
- typedef STD_SHARED_PTR(TypeCategoryImpl) SharedPointer;
-
-private:
- SummaryNavigator::SharedPointer m_summary_nav;
- RegexSummaryNavigator::SharedPointer m_regex_summary_nav;
- FilterNavigator::SharedPointer m_filter_nav;
- RegexFilterNavigator::SharedPointer m_regex_filter_nav;
-#ifndef LLDB_DISABLE_PYTHON
- SynthNavigator::SharedPointer m_synth_nav;
- RegexSynthNavigator::SharedPointer m_regex_synth_nav;
-#endif // #ifndef LLDB_DISABLE_PYTHON
-
- bool m_enabled;
-
- IFormatChangeListener* m_change_listener;
-
- Mutex m_mutex;
-
- ConstString m_name;
-
- uint32_t m_enabled_position;
-
- void
- Enable (bool value,
- uint32_t position)
- {
- Mutex::Locker locker(m_mutex);
- m_enabled = value;
- m_enabled_position = position;
- if (m_change_listener)
- m_change_listener->Changed();
- }
-
- void
- Disable ()
- {
- Enable(false, UINT32_MAX);
- }
-
- friend class CategoryMap;
-
- friend class FormatNavigator<ConstString, TypeSummaryImpl>;
- friend class FormatNavigator<lldb::RegularExpressionSP, TypeSummaryImpl>;
-
- friend class FormatNavigator<ConstString, TypeFilterImpl>;
- friend class FormatNavigator<lldb::RegularExpressionSP, TypeFilterImpl>;
-
-#ifndef LLDB_DISABLE_PYTHON
- friend class FormatNavigator<ConstString, TypeSyntheticImpl>;
- friend class FormatNavigator<lldb::RegularExpressionSP, TypeSyntheticImpl>;
-#endif // #ifndef LLDB_DISABLE_PYTHON
-
-
-};
-
-class CategoryMap
-{
-private:
- typedef ConstString KeyType;
- typedef TypeCategoryImpl ValueType;
- typedef ValueType::SharedPointer ValueSP;
- typedef std::list<lldb::TypeCategoryImplSP> ActiveCategoriesList;
- typedef ActiveCategoriesList::iterator ActiveCategoriesIterator;
-
-public:
- typedef std::map<KeyType, ValueSP> MapType;
- typedef MapType::iterator MapIterator;
- typedef bool(*CallbackType)(void*, const ValueSP&);
- typedef uint32_t Position;
-
- static const Position First = 0;
- static const Position Default = 1;
- static const Position Last = UINT32_MAX;
-
- CategoryMap (IFormatChangeListener* lst) :
- m_map_mutex(Mutex::eMutexTypeRecursive),
- listener(lst),
- m_map(),
- m_active_categories()
- {
- ConstString default_cs("default");
- lldb::TypeCategoryImplSP default_sp = lldb::TypeCategoryImplSP(new TypeCategoryImpl(listener, default_cs));
- Add(default_cs,default_sp);
- Enable(default_cs,First);
- }
-
- void
- Add (KeyType name,
- const ValueSP& entry)
- {
- Mutex::Locker locker(m_map_mutex);
- m_map[name] = entry;
- if (listener)
- listener->Changed();
- }
-
- bool
- Delete (KeyType name)
- {
- Mutex::Locker locker(m_map_mutex);
- MapIterator iter = m_map.find(name);
- if (iter == m_map.end())
- return false;
- m_map.erase(name);
- Disable(name);
- if (listener)
- listener->Changed();
- return true;
- }
-
- bool
- Enable (KeyType category_name,
- Position pos = Default)
- {
- Mutex::Locker locker(m_map_mutex);
- ValueSP category;
- if (!Get(category_name,category))
- return false;
- return Enable(category, pos);
- }
-
- bool
- Disable (KeyType category_name)
- {
- Mutex::Locker locker(m_map_mutex);
- ValueSP category;
- if (!Get(category_name,category))
- return false;
- return Disable(category);
- }
-
- bool
- Enable (ValueSP category,
- Position pos = Default)
- {
- Mutex::Locker locker(m_map_mutex);
- if (category.get())
- {
- Position pos_w = pos;
- if (pos == First || m_active_categories.size() == 0)
- m_active_categories.push_front(category);
- else if (pos == Last || pos == m_active_categories.size())
- m_active_categories.push_back(category);
- else if (pos < m_active_categories.size())
- {
- ActiveCategoriesList::iterator iter = m_active_categories.begin();
- while (pos_w)
- {
- pos_w--,iter++;
- }
- m_active_categories.insert(iter,category);
- }
- else
- return false;
- category->Enable(true,
- pos);
- return true;
- }
- return false;
- }
-
- bool
- Disable (ValueSP category)
- {
- Mutex::Locker locker(m_map_mutex);
- if (category.get())
- {
- m_active_categories.remove_if(delete_matching_categories(category));
- category->Disable();
- return true;
- }
- return false;
- }
-
- void
- Clear ()
- {
- Mutex::Locker locker(m_map_mutex);
- m_map.clear();
- m_active_categories.clear();
- if (listener)
- listener->Changed();
- }
-
- bool
- Get (KeyType name,
- ValueSP& entry)
- {
- Mutex::Locker locker(m_map_mutex);
- MapIterator iter = m_map.find(name);
- if (iter == m_map.end())
- return false;
- entry = iter->second;
- return true;
- }
-
- bool
- Get (uint32_t pos,
- ValueSP& entry)
- {
- Mutex::Locker locker(m_map_mutex);
- MapIterator iter = m_map.begin();
- MapIterator end = m_map.end();
- while (pos > 0)
- {
- iter++;
- pos--;
- if (iter == end)
- return false;
- }
- entry = iter->second;
- return false;
- }
-
- void
- LoopThrough (CallbackType callback, void* param);
-
- lldb::TypeCategoryImplSP
- GetAtIndex (uint32_t);
-
- bool
- AnyMatches (ConstString type_name,
- TypeCategoryImpl::FormatCategoryItems items = TypeCategoryImpl::ALL_ITEM_TYPES,
- bool only_enabled = true,
- const char** matching_category = NULL,
- TypeCategoryImpl::FormatCategoryItems* matching_type = NULL);
-
- uint32_t
- GetCount ()
- {
- return m_map.size();
- }
-
- lldb::TypeSummaryImplSP
- GetSummaryFormat (ValueObject& valobj,
- lldb::DynamicValueType use_dynamic);
-
-#ifndef LLDB_DISABLE_PYTHON
- lldb::SyntheticChildrenSP
- GetSyntheticChildren (ValueObject& valobj,
- lldb::DynamicValueType use_dynamic);
-#endif
-
-private:
-
- class delete_matching_categories
- {
- lldb::TypeCategoryImplSP ptr;
- public:
- delete_matching_categories(lldb::TypeCategoryImplSP p) : ptr(p)
- {}
-
- bool operator()(const lldb::TypeCategoryImplSP& other)
- {
- return ptr.get() == other.get();
- }
- };
-
- Mutex m_map_mutex;
- IFormatChangeListener* listener;
-
- MapType m_map;
- ActiveCategoriesList m_active_categories;
-
- MapType& map ()
- {
- return m_map;
- }
-
- ActiveCategoriesList& active_list ()
- {
- return m_active_categories;
- }
-
- Mutex& mutex ()
- {
- return m_map_mutex;
- }
-
- friend class FormatNavigator<KeyType, ValueType>;
- friend class FormatManager;
-};
class FormatManager : public IFormatChangeListener
{
typedef FormatNavigator<ConstString, TypeFormatImpl> ValueNavigator;
typedef ValueNavigator::MapType ValueMap;
typedef FormatMap<ConstString, TypeSummaryImpl> NamedSummariesMap;
- typedef CategoryMap::MapType::iterator CategoryMapIterator;
+ typedef TypeCategoryMap::MapType::iterator CategoryMapIterator;
public:
- typedef CategoryMap::CallbackType CategoryCallback;
+ typedef TypeCategoryMap::CallbackType CategoryCallback;
FormatManager ();
@@ -577,7 +56,7 @@ public:
void
EnableCategory (const ConstString& category_name,
- CategoryMap::Position pos = CategoryMap::Default)
+ TypeCategoryMap::Position pos = TypeCategoryMap::Default)
{
m_categories_map.Enable(category_name,
pos);
@@ -591,7 +70,7 @@ public:
void
EnableCategory (const lldb::TypeCategoryImplSP& category,
- CategoryMap::Position pos = CategoryMap::Default)
+ TypeCategoryMap::Position pos = TypeCategoryMap::Default)
{
m_categories_map.Enable(category,
pos);
@@ -622,7 +101,7 @@ public:
}
lldb::TypeCategoryImplSP
- GetCategoryAtIndex (uint32_t index)
+ GetCategoryAtIndex (size_t index)
{
return m_categories_map.GetAtIndex(index);
}
@@ -647,20 +126,13 @@ public:
bool can_create = true);
lldb::TypeSummaryImplSP
- GetSummaryFormat (ValueObject& valobj,
- lldb::DynamicValueType use_dynamic)
- {
- return m_categories_map.GetSummaryFormat(valobj, use_dynamic);
- }
-
- lldb::TypeSummaryImplSP
GetSummaryForType (lldb::TypeNameSpecifierImplSP type_sp);
lldb::TypeFilterImplSP
GetFilterForType (lldb::TypeNameSpecifierImplSP type_sp);
#ifndef LLDB_DISABLE_PYTHON
- lldb::TypeSyntheticImplSP
+ lldb::ScriptedSyntheticChildrenSP
GetSyntheticForType (lldb::TypeNameSpecifierImplSP type_sp);
#endif
@@ -669,13 +141,14 @@ public:
GetSyntheticChildrenForType (lldb::TypeNameSpecifierImplSP type_sp);
#endif
+ lldb::TypeSummaryImplSP
+ GetSummaryFormat (ValueObject& valobj,
+ lldb::DynamicValueType use_dynamic);
+
#ifndef LLDB_DISABLE_PYTHON
lldb::SyntheticChildrenSP
GetSyntheticChildren (ValueObject& valobj,
- lldb::DynamicValueType use_dynamic)
- {
- return m_categories_map.GetSyntheticChildren(valobj, use_dynamic);
- }
+ lldb::DynamicValueType use_dynamic);
#endif
bool
@@ -719,6 +192,7 @@ public:
Changed ()
{
__sync_add_and_fetch(&m_last_revision, +1);
+ m_format_cache.Clear ();
}
uint32_t
@@ -731,11 +205,12 @@ public:
{
}
-private:
+private:
+ FormatCache m_format_cache;
ValueNavigator m_value_nav;
NamedSummariesMap m_named_summaries_map;
uint32_t m_last_revision;
- CategoryMap m_categories_map;
+ TypeCategoryMap m_categories_map;
ConstString m_default_category_name;
ConstString m_system_category_name;
@@ -748,7 +223,7 @@ private:
ConstString m_vectortypes_category_name;
ConstString m_appkit_category_name;
- CategoryMap&
+ TypeCategoryMap&
GetCategories ()
{
return m_categories_map;
Copied: lldb/trunk/include/lldb/DataFormatters/FormatNavigator.h (from r173281, lldb/trunk/include/lldb/Core/FormatNavigator.h)
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/FormatNavigator.h?p2=lldb/trunk/include/lldb/DataFormatters/FormatNavigator.h&p1=lldb/trunk/include/lldb/Core/FormatNavigator.h&r1=173281&r2=173728&rev=173728&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/FormatNavigator.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/FormatNavigator.h Mon Jan 28 17:47:25 2013
@@ -21,11 +21,12 @@
// Project includes
#include "lldb/lldb-public.h"
-#include "lldb/Core/FormatClasses.h"
#include "lldb/Core/Log.h"
#include "lldb/Core/RegularExpression.h"
#include "lldb/Core/ValueObject.h"
+#include "lldb/DataFormatters/FormatClasses.h"
+
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Target/ObjCLanguageRuntime.h"
@@ -192,7 +193,7 @@ public:
}
ValueSP
- GetValueAtIndex (uint32_t index)
+ GetValueAtIndex (size_t index)
{
Mutex::Locker locker(m_map_mutex);
MapIterator iter = m_map.begin();
@@ -208,7 +209,7 @@ public:
}
KeyType
- GetKeyAtIndex (uint32_t index)
+ GetKeyAtIndex (size_t index)
{
Mutex::Locker locker(m_map_mutex);
MapIterator iter = m_map.begin();
@@ -316,13 +317,13 @@ public:
}
MapValueType
- GetAtIndex (uint32_t index)
+ GetAtIndex (size_t index)
{
return m_format_map.GetValueAtIndex(index);
}
lldb::TypeNameSpecifierImplSP
- GetTypeNameSpecifierAtIndex (uint32_t index)
+ GetTypeNameSpecifierAtIndex (size_t index)
{
return GetTypeNameSpecifierAtIndex_Impl(index, (KeyType*)NULL);
}
@@ -405,7 +406,7 @@ protected:
}
lldb::TypeNameSpecifierImplSP
- GetTypeNameSpecifierAtIndex_Impl (uint32_t index, ConstString *dummy)
+ GetTypeNameSpecifierAtIndex_Impl (size_t index, ConstString *dummy)
{
ConstString key = m_format_map.GetKeyAtIndex(index);
if (key)
@@ -416,7 +417,7 @@ protected:
}
lldb::TypeNameSpecifierImplSP
- GetTypeNameSpecifierAtIndex_Impl (uint32_t index, lldb::RegularExpressionSP *dummy)
+ GetTypeNameSpecifierAtIndex_Impl (size_t index, lldb::RegularExpressionSP *dummy)
{
lldb::RegularExpressionSP regex = m_format_map.GetKeyAtIndex(index);
if (regex.get() == NULL)
@@ -525,28 +526,28 @@ protected:
return false;
}
- // we are separately passing in valobj and type because the valobj is fixed (and is used for ObjC discovery and bitfield size)
- // but the type can change (e.g. stripping pointers, ...)
- bool Get (ValueObject& valobj,
+ bool
+ Get_Impl (ValueObject& valobj,
clang::QualType type,
MapValueType& entry,
lldb::DynamicValueType use_dynamic,
uint32_t& reason)
{
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
+
if (type.isNull())
{
if (log)
- log->Printf("[Get] type is NULL, returning");
+ log->Printf("[Get_Impl] type is NULL, returning");
return false;
}
-
+
type.removeLocalConst(); type.removeLocalVolatile(); type.removeLocalRestrict();
const clang::Type* typePtr = type.getTypePtrOrNull();
if (!typePtr)
{
if (log)
- log->Printf("[Get] type is NULL, returning");
+ log->Printf("[Get_Impl] type is NULL, returning");
return false;
}
ConstString typeName(ClangASTType::GetTypeNameForQualType(valobj.GetClangAST(), type).c_str());
@@ -558,7 +559,7 @@ protected:
}
if (log)
- log->Printf("[Get] trying to get %s for VO name %s of type %s",
+ log->Printf("[Get_Impl] trying to get %s for VO name %s of type %s",
m_name.c_str(),
valobj.GetName().AsCString(),
typeName.AsCString());
@@ -570,14 +571,14 @@ protected:
return true;
}
if (log)
- log->Printf("[Get] no direct match");
-
+ log->Printf("[Get_Impl] no direct match");
+
// strip pointers and references and see if that helps
if (typePtr->isReferenceType())
{
if (log)
- log->Printf("[Get] stripping reference");
- if (Get(valobj,type.getNonReferenceType(),entry, use_dynamic, reason) && !entry->SkipsReferences())
+ log->Printf("[Get_Impl] stripping reference");
+ if (Get_Impl(valobj,type.getNonReferenceType(),entry, use_dynamic, reason) && !entry->SkipsReferences())
{
reason |= lldb_private::eFormatterChoiceCriterionStrippedPointerReference;
return true;
@@ -586,15 +587,15 @@ protected:
else if (typePtr->isPointerType())
{
if (log)
- log->Printf("[Get] stripping pointer");
+ log->Printf("[Get_Impl] stripping pointer");
clang::QualType pointee = typePtr->getPointeeType();
- if (Get(valobj, pointee, entry, use_dynamic, reason) && !entry->SkipsPointers())
+ if (Get_Impl(valobj, pointee, entry, use_dynamic, reason) && !entry->SkipsPointers())
{
reason |= lldb_private::eFormatterChoiceCriterionStrippedPointerReference;
return true;
}
}
-
+
bool canBeObjCDynamic = ClangASTContext::IsPossibleDynamicType (valobj.GetClangAST(),
type.getAsOpaquePtr(),
NULL,
@@ -606,7 +607,7 @@ protected:
if (use_dynamic != lldb::eNoDynamicValues)
{
if (log)
- log->Printf("[Get] allowed to figure out dynamic ObjC type");
+ log->Printf("[Get_Impl] allowed to figure out dynamic ObjC type");
if (Get_ObjC(valobj,entry))
{
reason |= lldb_private::eFormatterChoiceCriterionDynamicObjCDiscovery;
@@ -614,28 +615,45 @@ protected:
}
}
if (log)
- log->Printf("[Get] dynamic disabled or failed - stripping ObjC pointer");
+ log->Printf("[Get_Impl] dynamic disabled or failed - stripping ObjC pointer");
clang::QualType pointee = typePtr->getPointeeType();
- if (Get(valobj, pointee, entry, use_dynamic, reason) && !entry->SkipsPointers())
+ if (Get_Impl(valobj, pointee, entry, use_dynamic, reason) && !entry->SkipsPointers())
{
reason |= lldb_private::eFormatterChoiceCriterionStrippedPointerReference;
return true;
}
}
-
+
// try to strip typedef chains
const clang::TypedefType* type_tdef = type->getAs<clang::TypedefType>();
if (type_tdef)
{
if (log)
- log->Printf("[Get] stripping typedef");
- if ((Get(valobj, type_tdef->getDecl()->getUnderlyingType(), entry, use_dynamic, reason)) && entry->Cascades())
+ log->Printf("[Get_Impl] stripping typedef");
+ if ((Get_Impl(valobj, type_tdef->getDecl()->getUnderlyingType(), entry, use_dynamic, reason)) && entry->Cascades())
{
reason |= lldb_private::eFormatterChoiceCriterionNavigatedTypedefs;
return true;
}
}
+ // out of luck here
+ return false;
+ }
+
+ // we are separately passing in valobj and type because the valobj is fixed (and is used for ObjC discovery and bitfield size)
+ // but the type can change (e.g. stripping pointers, ...)
+ bool Get (ValueObject& valobj,
+ clang::QualType type,
+ MapValueType& entry,
+ lldb::DynamicValueType use_dynamic,
+ uint32_t& reason)
+ {
+ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
+
+ if (Get_Impl (valobj,type,entry,use_dynamic,reason))
+ return true;
+
// if all else fails, go to static type
if (valobj.IsDynamic())
{
Added: lldb/trunk/include/lldb/DataFormatters/TypeCategory.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/TypeCategory.h?rev=173728&view=auto
==============================================================================
--- lldb/trunk/include/lldb/DataFormatters/TypeCategory.h (added)
+++ lldb/trunk/include/lldb/DataFormatters/TypeCategory.h Mon Jan 28 17:47:25 2013
@@ -0,0 +1,230 @@
+//===-- TypeCategory.h -------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef lldb_TypeCategory_h_
+#define lldb_TypeCategory_h_
+
+// C Includes
+// C++ Includes
+
+// Other libraries and framework includes
+// Project includes
+#include "lldb/lldb-public.h"
+#include "lldb/lldb-enumerations.h"
+
+#include "lldb/DataFormatters/FormatNavigator.h"
+
+namespace lldb_private {
+ class TypeCategoryImpl
+ {
+ private:
+
+ typedef FormatNavigator<ConstString, TypeSummaryImpl> SummaryNavigator;
+ typedef FormatNavigator<lldb::RegularExpressionSP, TypeSummaryImpl> RegexSummaryNavigator;
+
+ typedef FormatNavigator<ConstString, TypeFilterImpl> FilterNavigator;
+ typedef FormatNavigator<lldb::RegularExpressionSP, TypeFilterImpl> RegexFilterNavigator;
+
+#ifndef LLDB_DISABLE_PYTHON
+ typedef FormatNavigator<ConstString, ScriptedSyntheticChildren> SynthNavigator;
+ typedef FormatNavigator<lldb::RegularExpressionSP, ScriptedSyntheticChildren> RegexSynthNavigator;
+#endif // #ifndef LLDB_DISABLE_PYTHON
+
+ typedef SummaryNavigator::MapType SummaryMap;
+ typedef RegexSummaryNavigator::MapType RegexSummaryMap;
+ typedef FilterNavigator::MapType FilterMap;
+ typedef RegexFilterNavigator::MapType RegexFilterMap;
+#ifndef LLDB_DISABLE_PYTHON
+ typedef SynthNavigator::MapType SynthMap;
+ typedef RegexSynthNavigator::MapType RegexSynthMap;
+#endif // #ifndef LLDB_DISABLE_PYTHON
+
+ public:
+
+ typedef uint16_t FormatCategoryItems;
+ static const uint16_t ALL_ITEM_TYPES = UINT16_MAX;
+
+ typedef SummaryNavigator::SharedPointer SummaryNavigatorSP;
+ typedef RegexSummaryNavigator::SharedPointer RegexSummaryNavigatorSP;
+ typedef FilterNavigator::SharedPointer FilterNavigatorSP;
+ typedef RegexFilterNavigator::SharedPointer RegexFilterNavigatorSP;
+#ifndef LLDB_DISABLE_PYTHON
+ typedef SynthNavigator::SharedPointer SynthNavigatorSP;
+ typedef RegexSynthNavigator::SharedPointer RegexSynthNavigatorSP;
+#endif // #ifndef LLDB_DISABLE_PYTHON
+
+ TypeCategoryImpl (IFormatChangeListener* clist,
+ ConstString name);
+
+ SummaryNavigatorSP
+ GetSummaryNavigator ()
+ {
+ return SummaryNavigatorSP(m_summary_nav);
+ }
+
+ RegexSummaryNavigatorSP
+ GetRegexSummaryNavigator ()
+ {
+ return RegexSummaryNavigatorSP(m_regex_summary_nav);
+ }
+
+ FilterNavigatorSP
+ GetFilterNavigator ()
+ {
+ return FilterNavigatorSP(m_filter_nav);
+ }
+
+ RegexFilterNavigatorSP
+ GetRegexFilterNavigator ()
+ {
+ return RegexFilterNavigatorSP(m_regex_filter_nav);
+ }
+
+ SummaryNavigator::MapValueType
+ GetSummaryForType (lldb::TypeNameSpecifierImplSP type_sp);
+
+ FilterNavigator::MapValueType
+ GetFilterForType (lldb::TypeNameSpecifierImplSP type_sp);
+
+#ifndef LLDB_DISABLE_PYTHON
+ SynthNavigator::MapValueType
+ GetSyntheticForType (lldb::TypeNameSpecifierImplSP type_sp);
+#endif
+
+ lldb::TypeNameSpecifierImplSP
+ GetTypeNameSpecifierForSummaryAtIndex (size_t index);
+
+ SummaryNavigator::MapValueType
+ GetSummaryAtIndex (size_t index);
+
+ FilterNavigator::MapValueType
+ GetFilterAtIndex (size_t index);
+
+ lldb::TypeNameSpecifierImplSP
+ GetTypeNameSpecifierForFilterAtIndex (size_t index);
+
+#ifndef LLDB_DISABLE_PYTHON
+ SynthNavigatorSP
+ GetSyntheticNavigator ()
+ {
+ return SynthNavigatorSP(m_synth_nav);
+ }
+
+ RegexSynthNavigatorSP
+ GetRegexSyntheticNavigator ()
+ {
+ return RegexSynthNavigatorSP(m_regex_synth_nav);
+ }
+
+ SynthNavigator::MapValueType
+ GetSyntheticAtIndex (size_t index);
+
+ lldb::TypeNameSpecifierImplSP
+ GetTypeNameSpecifierForSyntheticAtIndex (size_t index);
+
+#endif // #ifndef LLDB_DISABLE_PYTHON
+
+ bool
+ IsEnabled () const
+ {
+ return m_enabled;
+ }
+
+ uint32_t
+ GetEnabledPosition()
+ {
+ if (m_enabled == false)
+ return UINT32_MAX;
+ else
+ return m_enabled_position;
+ }
+
+ bool
+ Get (ValueObject& valobj,
+ lldb::TypeSummaryImplSP& entry,
+ lldb::DynamicValueType use_dynamic,
+ uint32_t* reason = NULL);
+
+ bool
+ Get (ValueObject& valobj,
+ lldb::SyntheticChildrenSP& entry,
+ lldb::DynamicValueType use_dynamic,
+ uint32_t* reason = NULL);
+
+ void
+ Clear (FormatCategoryItems items = ALL_ITEM_TYPES);
+
+ bool
+ Delete (ConstString name,
+ FormatCategoryItems items = ALL_ITEM_TYPES);
+
+ uint32_t
+ GetCount (FormatCategoryItems items = ALL_ITEM_TYPES);
+
+ const char*
+ GetName ()
+ {
+ return m_name.GetCString();
+ }
+
+ bool
+ AnyMatches (ConstString type_name,
+ FormatCategoryItems items = ALL_ITEM_TYPES,
+ bool only_enabled = true,
+ const char** matching_category = NULL,
+ FormatCategoryItems* matching_type = NULL);
+
+ typedef STD_SHARED_PTR(TypeCategoryImpl) SharedPointer;
+
+ private:
+ SummaryNavigator::SharedPointer m_summary_nav;
+ RegexSummaryNavigator::SharedPointer m_regex_summary_nav;
+ FilterNavigator::SharedPointer m_filter_nav;
+ RegexFilterNavigator::SharedPointer m_regex_filter_nav;
+#ifndef LLDB_DISABLE_PYTHON
+ SynthNavigator::SharedPointer m_synth_nav;
+ RegexSynthNavigator::SharedPointer m_regex_synth_nav;
+#endif // #ifndef LLDB_DISABLE_PYTHON
+
+ bool m_enabled;
+
+ IFormatChangeListener* m_change_listener;
+
+ Mutex m_mutex;
+
+ ConstString m_name;
+
+ uint32_t m_enabled_position;
+
+ void
+ Enable (bool value, uint32_t position);
+
+ void
+ Disable ()
+ {
+ Enable(false, UINT32_MAX);
+ }
+
+ friend class TypeCategoryMap;
+
+ friend class FormatNavigator<ConstString, TypeSummaryImpl>;
+ friend class FormatNavigator<lldb::RegularExpressionSP, TypeSummaryImpl>;
+
+ friend class FormatNavigator<ConstString, TypeFilterImpl>;
+ friend class FormatNavigator<lldb::RegularExpressionSP, TypeFilterImpl>;
+
+#ifndef LLDB_DISABLE_PYTHON
+ friend class FormatNavigator<ConstString, ScriptedSyntheticChildren>;
+ friend class FormatNavigator<lldb::RegularExpressionSP, ScriptedSyntheticChildren>;
+#endif // #ifndef LLDB_DISABLE_PYTHON
+ };
+
+} // namespace lldb_private
+
+#endif // lldb_TypeCategory_h_
Added: lldb/trunk/include/lldb/DataFormatters/TypeCategoryMap.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/TypeCategoryMap.h?rev=173728&view=auto
==============================================================================
--- lldb/trunk/include/lldb/DataFormatters/TypeCategoryMap.h (added)
+++ lldb/trunk/include/lldb/DataFormatters/TypeCategoryMap.h Mon Jan 28 17:47:25 2013
@@ -0,0 +1,148 @@
+//===-- TypeCategoryMap.h ----------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef lldb_TypeCategoryMap_h_
+#define lldb_TypeCategoryMap_h_
+
+// C Includes
+// C++ Includes
+
+// Other libraries and framework includes
+// Project includes
+#include "lldb/lldb-public.h"
+#include "lldb/lldb-enumerations.h"
+
+#include "lldb/DataFormatters/FormatNavigator.h"
+#include "lldb/DataFormatters/TypeCategory.h"
+
+namespace lldb_private {
+ class TypeCategoryMap
+ {
+ private:
+ typedef ConstString KeyType;
+ typedef TypeCategoryImpl ValueType;
+ typedef ValueType::SharedPointer ValueSP;
+ typedef std::list<lldb::TypeCategoryImplSP> ActiveCategoriesList;
+ typedef ActiveCategoriesList::iterator ActiveCategoriesIterator;
+
+ public:
+ typedef std::map<KeyType, ValueSP> MapType;
+ typedef MapType::iterator MapIterator;
+ typedef bool(*CallbackType)(void*, const ValueSP&);
+ typedef uint32_t Position;
+
+ static const Position First = 0;
+ static const Position Default = 1;
+ static const Position Last = UINT32_MAX;
+
+ TypeCategoryMap (IFormatChangeListener* lst);
+
+ void
+ Add (KeyType name,
+ const ValueSP& entry);
+
+ bool
+ Delete (KeyType name);
+
+ bool
+ Enable (KeyType category_name,
+ Position pos = Default);
+
+ bool
+ Disable (KeyType category_name);
+
+ bool
+ Enable (ValueSP category,
+ Position pos = Default);
+
+ bool
+ Disable (ValueSP category);
+
+ void
+ Clear ();
+
+ bool
+ Get (KeyType name,
+ ValueSP& entry);
+
+ bool
+ Get (uint32_t pos,
+ ValueSP& entry);
+
+ void
+ LoopThrough (CallbackType callback, void* param);
+
+ lldb::TypeCategoryImplSP
+ GetAtIndex (uint32_t);
+
+ bool
+ AnyMatches (ConstString type_name,
+ TypeCategoryImpl::FormatCategoryItems items = TypeCategoryImpl::ALL_ITEM_TYPES,
+ bool only_enabled = true,
+ const char** matching_category = NULL,
+ TypeCategoryImpl::FormatCategoryItems* matching_type = NULL);
+
+ uint32_t
+ GetCount ()
+ {
+ return m_map.size();
+ }
+
+ lldb::TypeSummaryImplSP
+ GetSummaryFormat (ValueObject& valobj,
+ lldb::DynamicValueType use_dynamic);
+
+#ifndef LLDB_DISABLE_PYTHON
+ lldb::SyntheticChildrenSP
+ GetSyntheticChildren (ValueObject& valobj,
+ lldb::DynamicValueType use_dynamic);
+#endif
+
+ private:
+
+ class delete_matching_categories
+ {
+ lldb::TypeCategoryImplSP ptr;
+ public:
+ delete_matching_categories(lldb::TypeCategoryImplSP p) : ptr(p)
+ {}
+
+ bool operator()(const lldb::TypeCategoryImplSP& other)
+ {
+ return ptr.get() == other.get();
+ }
+ };
+
+ Mutex m_map_mutex;
+ IFormatChangeListener* listener;
+
+ MapType m_map;
+ ActiveCategoriesList m_active_categories;
+
+ MapType& map ()
+ {
+ return m_map;
+ }
+
+ ActiveCategoriesList& active_list ()
+ {
+ return m_active_categories;
+ }
+
+ Mutex& mutex ()
+ {
+ return m_map_mutex;
+ }
+
+ friend class FormatNavigator<KeyType, ValueType>;
+ friend class FormatManager;
+ };
+} // namespace lldb_private
+
+#endif // lldb_TypeCategoryMap_h_
Added: lldb/trunk/include/lldb/DataFormatters/TypeFormat.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/TypeFormat.h?rev=173728&view=auto
==============================================================================
--- lldb/trunk/include/lldb/DataFormatters/TypeFormat.h (added)
+++ lldb/trunk/include/lldb/DataFormatters/TypeFormat.h Mon Jan 28 17:47:25 2013
@@ -0,0 +1,220 @@
+//===-- TypeFormat.h ----------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef lldb_TypeFormat_h_
+#define lldb_TypeFormat_h_
+
+// C Includes
+
+// C++ Includes
+#include <string>
+
+// Other libraries and framework includes
+
+// Project includes
+#include "lldb/lldb-public.h"
+#include "lldb/lldb-enumerations.h"
+
+#include "lldb/Core/ValueObject.h"
+
+namespace lldb_private {
+ class TypeFormatImpl
+ {
+ public:
+ class Flags
+ {
+ public:
+
+ Flags () :
+ m_flags (lldb::eTypeOptionCascade)
+ {}
+
+ Flags (const Flags& other) :
+ m_flags (other.m_flags)
+ {}
+
+ Flags (uint32_t value) :
+ m_flags (value)
+ {}
+
+ Flags&
+ operator = (const Flags& rhs)
+ {
+ if (&rhs != this)
+ m_flags = rhs.m_flags;
+
+ return *this;
+ }
+
+ Flags&
+ operator = (const uint32_t& rhs)
+ {
+ m_flags = rhs;
+ return *this;
+ }
+
+ Flags&
+ Clear()
+ {
+ m_flags = 0;
+ return *this;
+ }
+
+ bool
+ GetCascades () const
+ {
+ return (m_flags & lldb::eTypeOptionCascade) == lldb::eTypeOptionCascade;
+ }
+
+ Flags&
+ SetCascades (bool value = true)
+ {
+ if (value)
+ m_flags |= lldb::eTypeOptionCascade;
+ else
+ m_flags &= ~lldb::eTypeOptionCascade;
+ return *this;
+ }
+
+ bool
+ GetSkipPointers () const
+ {
+ return (m_flags & lldb::eTypeOptionSkipPointers) == lldb::eTypeOptionSkipPointers;
+ }
+
+ Flags&
+ SetSkipPointers (bool value = true)
+ {
+ if (value)
+ m_flags |= lldb::eTypeOptionSkipPointers;
+ else
+ m_flags &= ~lldb::eTypeOptionSkipPointers;
+ return *this;
+ }
+
+ bool
+ GetSkipReferences () const
+ {
+ return (m_flags & lldb::eTypeOptionSkipReferences) == lldb::eTypeOptionSkipReferences;
+ }
+
+ Flags&
+ SetSkipReferences (bool value = true)
+ {
+ if (value)
+ m_flags |= lldb::eTypeOptionSkipReferences;
+ else
+ m_flags &= ~lldb::eTypeOptionSkipReferences;
+ return *this;
+ }
+
+ uint32_t
+ GetValue ()
+ {
+ return m_flags;
+ }
+
+ void
+ SetValue (uint32_t value)
+ {
+ m_flags = value;
+ }
+
+ private:
+ uint32_t m_flags;
+ };
+
+ TypeFormatImpl (lldb::Format f = lldb::eFormatInvalid,
+ const Flags& flags = Flags());
+
+ typedef STD_SHARED_PTR(TypeFormatImpl) SharedPointer;
+ typedef bool(*ValueCallback)(void*, ConstString, const lldb::TypeFormatImplSP&);
+
+ ~TypeFormatImpl ()
+ {
+ }
+
+ bool
+ Cascades () const
+ {
+ return m_flags.GetCascades();
+ }
+ bool
+ SkipsPointers () const
+ {
+ return m_flags.GetSkipPointers();
+ }
+ bool
+ SkipsReferences () const
+ {
+ return m_flags.GetSkipReferences();
+ }
+
+ void
+ SetCascades (bool value)
+ {
+ m_flags.SetCascades(value);
+ }
+
+ void
+ SetSkipsPointers (bool value)
+ {
+ m_flags.SetSkipPointers(value);
+ }
+
+ void
+ SetSkipsReferences (bool value)
+ {
+ m_flags.SetSkipReferences(value);
+ }
+
+ lldb::Format
+ GetFormat () const
+ {
+ return m_format;
+ }
+
+ void
+ SetFormat (lldb::Format fmt)
+ {
+ m_format = fmt;
+ }
+
+ uint32_t
+ GetOptions ()
+ {
+ return m_flags.GetValue();
+ }
+
+ void
+ SetOptions (uint32_t value)
+ {
+ m_flags.SetValue(value);
+ }
+
+ uint32_t&
+ GetRevision ()
+ {
+ return m_my_revision;
+ }
+
+ std::string
+ GetDescription();
+
+ protected:
+ Flags m_flags;
+ lldb::Format m_format;
+ uint32_t m_my_revision;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(TypeFormatImpl);
+ };
+} // namespace lldb_private
+
+#endif // lldb_TypeFormat_h_
Added: lldb/trunk/include/lldb/DataFormatters/TypeSummary.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/TypeSummary.h?rev=173728&view=auto
==============================================================================
--- lldb/trunk/include/lldb/DataFormatters/TypeSummary.h (added)
+++ lldb/trunk/include/lldb/DataFormatters/TypeSummary.h Mon Jan 28 17:47:25 2013
@@ -0,0 +1,547 @@
+//===-- TypeSummary.h --------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef lldb_TypeSummary_h_
+#define lldb_TypeSummary_h_
+
+// C Includes
+#include <stdint.h>
+#include <unistd.h>
+
+// C++ Includes
+#include <string>
+#include <vector>
+
+// Other libraries and framework includes
+
+// Project includes
+#include "lldb/lldb-public.h"
+#include "lldb/lldb-enumerations.h"
+
+#include "lldb/Core/ValueObject.h"
+#include "lldb/Interpreter/ScriptInterpreterPython.h"
+#include "lldb/Symbol/Type.h"
+
+namespace lldb_private {
+
+ class TypeSummaryImpl
+ {
+ public:
+ class Flags
+ {
+ public:
+
+ Flags () :
+ m_flags (lldb::eTypeOptionCascade)
+ {}
+
+ Flags (const Flags& other) :
+ m_flags (other.m_flags)
+ {}
+
+ Flags (uint32_t value) :
+ m_flags (value)
+ {}
+
+ Flags&
+ operator = (const Flags& rhs)
+ {
+ if (&rhs != this)
+ m_flags = rhs.m_flags;
+
+ return *this;
+ }
+
+ Flags&
+ operator = (const uint32_t& rhs)
+ {
+ m_flags = rhs;
+ return *this;
+ }
+
+ Flags&
+ Clear()
+ {
+ m_flags = 0;
+ return *this;
+ }
+
+ bool
+ GetCascades () const
+ {
+ return (m_flags & lldb::eTypeOptionCascade) == lldb::eTypeOptionCascade;
+ }
+
+ Flags&
+ SetCascades (bool value = true)
+ {
+ if (value)
+ m_flags |= lldb::eTypeOptionCascade;
+ else
+ m_flags &= ~lldb::eTypeOptionCascade;
+ return *this;
+ }
+
+ bool
+ GetSkipPointers () const
+ {
+ return (m_flags & lldb::eTypeOptionSkipPointers) == lldb::eTypeOptionSkipPointers;
+ }
+
+ Flags&
+ SetSkipPointers (bool value = true)
+ {
+ if (value)
+ m_flags |= lldb::eTypeOptionSkipPointers;
+ else
+ m_flags &= ~lldb::eTypeOptionSkipPointers;
+ return *this;
+ }
+
+ bool
+ GetSkipReferences () const
+ {
+ return (m_flags & lldb::eTypeOptionSkipReferences) == lldb::eTypeOptionSkipReferences;
+ }
+
+ Flags&
+ SetSkipReferences (bool value = true)
+ {
+ if (value)
+ m_flags |= lldb::eTypeOptionSkipReferences;
+ else
+ m_flags &= ~lldb::eTypeOptionSkipReferences;
+ return *this;
+ }
+
+ bool
+ GetDontShowChildren () const
+ {
+ return (m_flags & lldb::eTypeOptionHideChildren) == lldb::eTypeOptionHideChildren;
+ }
+
+ Flags&
+ SetDontShowChildren (bool value = true)
+ {
+ if (value)
+ m_flags |= lldb::eTypeOptionHideChildren;
+ else
+ m_flags &= ~lldb::eTypeOptionHideChildren;
+ return *this;
+ }
+
+ bool
+ GetDontShowValue () const
+ {
+ return (m_flags & lldb::eTypeOptionHideValue) == lldb::eTypeOptionHideValue;
+ }
+
+ Flags&
+ SetDontShowValue (bool value = true)
+ {
+ if (value)
+ m_flags |= lldb::eTypeOptionHideValue;
+ else
+ m_flags &= ~lldb::eTypeOptionHideValue;
+ return *this;
+ }
+
+ bool
+ GetShowMembersOneLiner () const
+ {
+ return (m_flags & lldb::eTypeOptionShowOneLiner) == lldb::eTypeOptionShowOneLiner;
+ }
+
+ Flags&
+ SetShowMembersOneLiner (bool value = true)
+ {
+ if (value)
+ m_flags |= lldb::eTypeOptionShowOneLiner;
+ else
+ m_flags &= ~lldb::eTypeOptionShowOneLiner;
+ return *this;
+ }
+
+ bool
+ GetHideItemNames () const
+ {
+ return (m_flags & lldb::eTypeOptionHideNames) == lldb::eTypeOptionHideNames;
+ }
+
+ Flags&
+ SetHideItemNames (bool value = true)
+ {
+ if (value)
+ m_flags |= lldb::eTypeOptionHideNames;
+ else
+ m_flags &= ~lldb::eTypeOptionHideNames;
+ return *this;
+ }
+
+ uint32_t
+ GetValue ()
+ {
+ return m_flags;
+ }
+
+ void
+ SetValue (uint32_t value)
+ {
+ m_flags = value;
+ }
+
+ private:
+ uint32_t m_flags;
+ };
+
+ typedef enum Type
+ {
+ eTypeUnknown,
+ eTypeString,
+ eTypeScript,
+ eTypeCallback
+ } Type;
+
+ TypeSummaryImpl (const TypeSummaryImpl::Flags& flags);
+
+ bool
+ Cascades () const
+ {
+ return m_flags.GetCascades();
+ }
+ bool
+ SkipsPointers () const
+ {
+ return m_flags.GetSkipPointers();
+ }
+ bool
+ SkipsReferences () const
+ {
+ return m_flags.GetSkipReferences();
+ }
+
+ bool
+ DoesPrintChildren () const
+ {
+ return !m_flags.GetDontShowChildren();
+ }
+
+ bool
+ DoesPrintValue () const
+ {
+ return !m_flags.GetDontShowValue();
+ }
+
+ bool
+ IsOneliner () const
+ {
+ return m_flags.GetShowMembersOneLiner();
+ }
+
+ bool
+ HideNames () const
+ {
+ return m_flags.GetHideItemNames();
+ }
+
+ void
+ SetCascades (bool value)
+ {
+ m_flags.SetCascades(value);
+ }
+
+ void
+ SetSkipsPointers (bool value)
+ {
+ m_flags.SetSkipPointers(value);
+ }
+
+ void
+ SetSkipsReferences (bool value)
+ {
+ m_flags.SetSkipReferences(value);
+ }
+
+ void
+ SetDoesPrintChildren (bool value)
+ {
+ m_flags.SetDontShowChildren(!value);
+ }
+
+ void
+ SetDoesPrintValue (bool value)
+ {
+ m_flags.SetDontShowValue(!value);
+ }
+
+ void
+ SetIsOneliner (bool value)
+ {
+ m_flags.SetShowMembersOneLiner(value);
+ }
+
+ void
+ SetHideNames (bool value)
+ {
+ m_flags.SetHideItemNames(value);
+ }
+
+ uint32_t
+ GetOptions ()
+ {
+ return m_flags.GetValue();
+ }
+
+ void
+ SetOptions (uint32_t value)
+ {
+ m_flags.SetValue(value);
+ }
+
+ virtual
+ ~TypeSummaryImpl ()
+ {
+ }
+
+ // we are using a ValueObject* instead of a ValueObjectSP because we do not need to hold on to this for
+ // extended periods of time and we trust the ValueObject to stay around for as long as it is required
+ // for us to generate its summary
+ virtual bool
+ FormatObject (ValueObject *valobj,
+ std::string& dest) = 0;
+
+ virtual std::string
+ GetDescription () = 0;
+
+ virtual bool
+ IsScripted () = 0;
+
+ virtual Type
+ GetType () = 0;
+
+ uint32_t&
+ GetRevision ()
+ {
+ return m_my_revision;
+ }
+
+ typedef STD_SHARED_PTR(TypeSummaryImpl) SharedPointer;
+ typedef bool(*SummaryCallback)(void*, ConstString, const lldb::TypeSummaryImplSP&);
+ typedef bool(*RegexSummaryCallback)(void*, lldb::RegularExpressionSP, const lldb::TypeSummaryImplSP&);
+
+ protected:
+ uint32_t m_my_revision;
+ Flags m_flags;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(TypeSummaryImpl);
+ };
+
+ // simple string-based summaries, using ${var to show data
+ struct StringSummaryFormat : public TypeSummaryImpl
+ {
+ std::string m_format;
+
+ StringSummaryFormat(const TypeSummaryImpl::Flags& flags,
+ const char* f);
+
+ const char*
+ GetSummaryString () const
+ {
+ return m_format.c_str();
+ }
+
+ void
+ SetSummaryString (const char* data)
+ {
+ if (data)
+ m_format.assign(data);
+ else
+ m_format.clear();
+ }
+
+ virtual
+ ~StringSummaryFormat()
+ {
+ }
+
+ virtual bool
+ FormatObject(ValueObject *valobj,
+ std::string& dest);
+
+ virtual std::string
+ GetDescription();
+
+ virtual bool
+ IsScripted ()
+ {
+ return false;
+ }
+
+
+ virtual Type
+ GetType ()
+ {
+ return TypeSummaryImpl::eTypeString;
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(StringSummaryFormat);
+ };
+
+ // summaries implemented via a C++ function
+ struct CXXFunctionSummaryFormat : public TypeSummaryImpl
+ {
+
+ // we should convert these to SBValue and SBStream if we ever cross
+ // the boundary towards the external world
+ typedef bool (*Callback)(ValueObject& valobj, Stream& dest);
+
+ Callback m_impl;
+ std::string m_description;
+
+ CXXFunctionSummaryFormat (const TypeSummaryImpl::Flags& flags,
+ Callback impl,
+ const char* description);
+
+ Callback
+ GetBackendFunction () const
+ {
+ return m_impl;
+ }
+
+ const char*
+ GetTextualInfo () const
+ {
+ return m_description.c_str();
+ }
+
+ void
+ SetBackendFunction (Callback cb_func)
+ {
+ m_impl = cb_func;
+ }
+
+ void
+ SetTextualInfo (const char* descr)
+ {
+ if (descr)
+ m_description.assign(descr);
+ else
+ m_description.clear();
+ }
+
+ virtual
+ ~CXXFunctionSummaryFormat ()
+ {
+ }
+
+ virtual bool
+ FormatObject (ValueObject *valobj,
+ std::string& dest);
+
+ virtual std::string
+ GetDescription ();
+
+ virtual bool
+ IsScripted ()
+ {
+ return false;
+ }
+
+ virtual Type
+ GetType ()
+ {
+ return TypeSummaryImpl::eTypeCallback;
+ }
+
+ typedef STD_SHARED_PTR(CXXFunctionSummaryFormat) SharedPointer;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(CXXFunctionSummaryFormat);
+ };
+
+#ifndef LLDB_DISABLE_PYTHON
+
+ // Python-based summaries, running script code to show data
+ struct ScriptSummaryFormat : public TypeSummaryImpl
+ {
+ std::string m_function_name;
+ std::string m_python_script;
+ lldb::ScriptInterpreterObjectSP m_script_function_sp;
+
+ ScriptSummaryFormat(const TypeSummaryImpl::Flags& flags,
+ const char *function_name,
+ const char* python_script = NULL);
+
+ const char*
+ GetFunctionName () const
+ {
+ return m_function_name.c_str();
+ }
+
+ const char*
+ GetPythonScript () const
+ {
+ return m_python_script.c_str();
+ }
+
+ void
+ SetFunctionName (const char* function_name)
+ {
+ if (function_name)
+ m_function_name.assign(function_name);
+ else
+ m_function_name.clear();
+ m_python_script.clear();
+ }
+
+ void
+ SetPythonScript (const char* script)
+ {
+ if (script)
+ m_python_script.assign(script);
+ else
+ m_python_script.clear();
+ }
+
+ virtual
+ ~ScriptSummaryFormat ()
+ {
+ }
+
+ virtual bool
+ FormatObject (ValueObject *valobj,
+ std::string& dest);
+
+ virtual std::string
+ GetDescription ();
+
+ virtual bool
+ IsScripted ()
+ {
+ return true;
+ }
+
+ virtual Type
+ GetType ()
+ {
+ return TypeSummaryImpl::eTypeScript;
+ }
+
+ typedef STD_SHARED_PTR(ScriptSummaryFormat) SharedPointer;
+
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ScriptSummaryFormat);
+ };
+#endif
+} // namespace lldb_private
+
+#endif // lldb_TypeSummary_h_
Added: lldb/trunk/include/lldb/DataFormatters/TypeSynthetic.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/TypeSynthetic.h?rev=173728&view=auto
==============================================================================
--- lldb/trunk/include/lldb/DataFormatters/TypeSynthetic.h (added)
+++ lldb/trunk/include/lldb/DataFormatters/TypeSynthetic.h Mon Jan 28 17:47:25 2013
@@ -0,0 +1,585 @@
+//===-- TypeSynthetic.h -------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef lldb_TypeSynthetic_h_
+#define lldb_TypeSynthetic_h_
+
+// C Includes
+#include <stdint.h>
+#include <unistd.h>
+
+// C++ Includes
+#include <string>
+#include <vector>
+
+// Other libraries and framework includes
+
+// Project includes
+#include "lldb/lldb-public.h"
+#include "lldb/lldb-enumerations.h"
+
+#include "lldb/Core/ValueObject.h"
+#include "lldb/Interpreter/ScriptInterpreterPython.h"
+#include "lldb/Symbol/Type.h"
+
+namespace lldb_private {
+ class SyntheticChildrenFrontEnd
+ {
+ protected:
+ ValueObject &m_backend;
+ public:
+
+ SyntheticChildrenFrontEnd (ValueObject &backend) :
+ m_backend(backend)
+ {}
+
+ virtual
+ ~SyntheticChildrenFrontEnd ()
+ {
+ }
+
+ virtual size_t
+ CalculateNumChildren () = 0;
+
+ virtual lldb::ValueObjectSP
+ GetChildAtIndex (size_t idx) = 0;
+
+ virtual size_t
+ GetIndexOfChildWithName (const ConstString &name) = 0;
+
+ // this function is assumed to always succeed and it if fails, the front-end should know to deal
+ // with it in the correct way (most probably, by refusing to return any children)
+ // the return value of Update() should actually be interpreted as "ValueObjectSyntheticFilter cache is good/bad"
+ // if =true, ValueObjectSyntheticFilter is allowed to use the children it fetched previously and cached
+ // if =false, ValueObjectSyntheticFilter must throw away its cache, and query again for children
+ virtual bool
+ Update () = 0;
+
+ // if this function returns false, then CalculateNumChildren() MUST return 0 since UI frontends
+ // might validly decide not to inquire for children given a false return value from this call
+ // if it returns true, then CalculateNumChildren() can return any number >= 0 (0 being valid)
+ // it should if at all possible be more efficient than CalculateNumChildren()
+ virtual bool
+ MightHaveChildren () = 0;
+
+ typedef STD_SHARED_PTR(SyntheticChildrenFrontEnd) SharedPointer;
+ typedef std::auto_ptr<SyntheticChildrenFrontEnd> AutoPointer;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(SyntheticChildrenFrontEnd);
+ };
+
+ class SyntheticChildren
+ {
+ public:
+
+ class Flags
+ {
+ public:
+
+ Flags () :
+ m_flags (lldb::eTypeOptionCascade)
+ {}
+
+ Flags (const Flags& other) :
+ m_flags (other.m_flags)
+ {}
+
+ Flags (uint32_t value) :
+ m_flags (value)
+ {}
+
+ Flags&
+ operator = (const Flags& rhs)
+ {
+ if (&rhs != this)
+ m_flags = rhs.m_flags;
+
+ return *this;
+ }
+
+ Flags&
+ operator = (const uint32_t& rhs)
+ {
+ m_flags = rhs;
+ return *this;
+ }
+
+ Flags&
+ Clear()
+ {
+ m_flags = 0;
+ return *this;
+ }
+
+ bool
+ GetCascades () const
+ {
+ return (m_flags & lldb::eTypeOptionCascade) == lldb::eTypeOptionCascade;
+ }
+
+ Flags&
+ SetCascades (bool value = true)
+ {
+ if (value)
+ m_flags |= lldb::eTypeOptionCascade;
+ else
+ m_flags &= ~lldb::eTypeOptionCascade;
+ return *this;
+ }
+
+ bool
+ GetSkipPointers () const
+ {
+ return (m_flags & lldb::eTypeOptionSkipPointers) == lldb::eTypeOptionSkipPointers;
+ }
+
+ Flags&
+ SetSkipPointers (bool value = true)
+ {
+ if (value)
+ m_flags |= lldb::eTypeOptionSkipPointers;
+ else
+ m_flags &= ~lldb::eTypeOptionSkipPointers;
+ return *this;
+ }
+
+ bool
+ GetSkipReferences () const
+ {
+ return (m_flags & lldb::eTypeOptionSkipReferences) == lldb::eTypeOptionSkipReferences;
+ }
+
+ Flags&
+ SetSkipReferences (bool value = true)
+ {
+ if (value)
+ m_flags |= lldb::eTypeOptionSkipReferences;
+ else
+ m_flags &= ~lldb::eTypeOptionSkipReferences;
+ return *this;
+ }
+
+ uint32_t
+ GetValue ()
+ {
+ return m_flags;
+ }
+
+ void
+ SetValue (uint32_t value)
+ {
+ m_flags = value;
+ }
+
+ private:
+ uint32_t m_flags;
+ };
+
+ SyntheticChildren (const Flags& flags) :
+ m_flags(flags)
+ {
+ }
+
+ virtual
+ ~SyntheticChildren ()
+ {
+ }
+
+ bool
+ Cascades () const
+ {
+ return m_flags.GetCascades();
+ }
+ bool
+ SkipsPointers () const
+ {
+ return m_flags.GetSkipPointers();
+ }
+ bool
+ SkipsReferences () const
+ {
+ return m_flags.GetSkipReferences();
+ }
+
+ void
+ SetCascades (bool value)
+ {
+ m_flags.SetCascades(value);
+ }
+
+ void
+ SetSkipsPointers (bool value)
+ {
+ m_flags.SetSkipPointers(value);
+ }
+
+ void
+ SetSkipsReferences (bool value)
+ {
+ m_flags.SetSkipReferences(value);
+ }
+
+ uint32_t
+ GetOptions ()
+ {
+ return m_flags.GetValue();
+ }
+
+ void
+ SetOptions (uint32_t value)
+ {
+ m_flags.SetValue(value);
+ }
+
+ virtual bool
+ IsScripted () = 0;
+
+ virtual std::string
+ GetDescription () = 0;
+
+ virtual SyntheticChildrenFrontEnd::AutoPointer
+ GetFrontEnd (ValueObject &backend) = 0;
+
+ typedef STD_SHARED_PTR(SyntheticChildren) SharedPointer;
+ typedef bool(*SyntheticChildrenCallback)(void*, ConstString, const SyntheticChildren::SharedPointer&);
+
+ uint32_t&
+ GetRevision ()
+ {
+ return m_my_revision;
+ }
+
+ protected:
+ uint32_t m_my_revision;
+ Flags m_flags;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(SyntheticChildren);
+ };
+
+ class TypeFilterImpl : public SyntheticChildren
+ {
+ std::vector<std::string> m_expression_paths;
+ public:
+ TypeFilterImpl(const SyntheticChildren::Flags& flags) :
+ SyntheticChildren(flags),
+ m_expression_paths()
+ {
+ }
+
+ void
+ AddExpressionPath (const char* path)
+ {
+ AddExpressionPath(std::string(path));
+ }
+
+ void
+ Clear()
+ {
+ m_expression_paths.clear();
+ }
+
+ int
+ GetCount() const
+ {
+ return m_expression_paths.size();
+ }
+
+ const char*
+ GetExpressionPathAtIndex(int i) const
+ {
+ return m_expression_paths[i].c_str();
+ }
+
+ bool
+ SetExpressionPathAtIndex (int i, const char* path)
+ {
+ return SetExpressionPathAtIndex(i, std::string(path));
+ }
+
+ void
+ AddExpressionPath (std::string path)
+ {
+ bool need_add_dot = true;
+ if (path[0] == '.' ||
+ (path[0] == '-' && path[1] == '>') ||
+ path[0] == '[')
+ need_add_dot = false;
+ // add a '.' symbol to help forgetful users
+ if(!need_add_dot)
+ m_expression_paths.push_back(path);
+ else
+ m_expression_paths.push_back(std::string(".") + path);
+ }
+
+ bool
+ SetExpressionPathAtIndex (int i, std::string path)
+ {
+ if (i >= GetCount())
+ return false;
+ bool need_add_dot = true;
+ if (path[0] == '.' ||
+ (path[0] == '-' && path[1] == '>') ||
+ path[0] == '[')
+ need_add_dot = false;
+ // add a '.' symbol to help forgetful users
+ if(!need_add_dot)
+ m_expression_paths[i] = path;
+ else
+ m_expression_paths[i] = std::string(".") + path;
+ return true;
+ }
+
+ bool
+ IsScripted ()
+ {
+ return false;
+ }
+
+ std::string
+ GetDescription ();
+
+ class FrontEnd : public SyntheticChildrenFrontEnd
+ {
+ private:
+ TypeFilterImpl* filter;
+ public:
+
+ FrontEnd(TypeFilterImpl* flt,
+ ValueObject &backend) :
+ SyntheticChildrenFrontEnd(backend),
+ filter(flt)
+ {}
+
+ virtual
+ ~FrontEnd ()
+ {
+ }
+
+ virtual size_t
+ CalculateNumChildren ()
+ {
+ return filter->GetCount();
+ }
+
+ virtual lldb::ValueObjectSP
+ GetChildAtIndex (size_t idx)
+ {
+ if (idx >= filter->GetCount())
+ return lldb::ValueObjectSP();
+ return m_backend.GetSyntheticExpressionPathChild(filter->GetExpressionPathAtIndex(idx), true);
+ }
+
+ virtual bool
+ Update() { return false; }
+
+ virtual bool
+ MightHaveChildren ()
+ {
+ return filter->GetCount() > 0;
+ }
+
+ virtual size_t
+ GetIndexOfChildWithName (const ConstString &name)
+ {
+ const char* name_cstr = name.GetCString();
+ for (int i = 0; i < filter->GetCount(); i++)
+ {
+ const char* expr_cstr = filter->GetExpressionPathAtIndex(i);
+ if (expr_cstr)
+ {
+ if (*expr_cstr == '.')
+ expr_cstr++;
+ else if (*expr_cstr == '-' && *(expr_cstr+1) == '>')
+ expr_cstr += 2;
+ }
+ if (!::strcmp(name_cstr, expr_cstr))
+ return i;
+ }
+ return UINT32_MAX;
+ }
+
+ typedef STD_SHARED_PTR(SyntheticChildrenFrontEnd) SharedPointer;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(FrontEnd);
+ };
+
+ virtual SyntheticChildrenFrontEnd::AutoPointer
+ GetFrontEnd(ValueObject &backend)
+ {
+ return SyntheticChildrenFrontEnd::AutoPointer(new FrontEnd(this, backend));
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(TypeFilterImpl);
+ };
+
+ class CXXSyntheticChildren : public SyntheticChildren
+ {
+ public:
+ typedef SyntheticChildrenFrontEnd* (*CreateFrontEndCallback) (CXXSyntheticChildren*, lldb::ValueObjectSP);
+ protected:
+ CreateFrontEndCallback m_create_callback;
+ std::string m_description;
+ public:
+ CXXSyntheticChildren (const SyntheticChildren::Flags& flags,
+ const char* description,
+ CreateFrontEndCallback callback) :
+ SyntheticChildren(flags),
+ m_create_callback(callback),
+ m_description(description ? description : "")
+ {
+ }
+
+ bool
+ IsScripted ()
+ {
+ return false;
+ }
+
+ std::string
+ GetDescription ();
+
+ virtual SyntheticChildrenFrontEnd::AutoPointer
+ GetFrontEnd (ValueObject &backend)
+ {
+ return SyntheticChildrenFrontEnd::AutoPointer(m_create_callback(this, backend.GetSP()));
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(CXXSyntheticChildren);
+ };
+
+#ifndef LLDB_DISABLE_PYTHON
+
+ class ScriptedSyntheticChildren : public SyntheticChildren
+ {
+ std::string m_python_class;
+ std::string m_python_code;
+ public:
+
+ ScriptedSyntheticChildren (const SyntheticChildren::Flags& flags,
+ const char* pclass,
+ const char* pcode = NULL) :
+ SyntheticChildren(flags),
+ m_python_class(),
+ m_python_code()
+ {
+ if (pclass)
+ m_python_class = pclass;
+ if (pcode)
+ m_python_code = pcode;
+ }
+
+ const char*
+ GetPythonClassName ()
+ {
+ return m_python_class.c_str();
+ }
+
+ const char*
+ GetPythonCode ()
+ {
+ return m_python_code.c_str();
+ }
+
+ void
+ SetPythonClassName (const char* fname)
+ {
+ m_python_class.assign(fname);
+ m_python_code.clear();
+ }
+
+ void
+ SetPythonCode (const char* script)
+ {
+ m_python_code.assign(script);
+ }
+
+ std::string
+ GetDescription ();
+
+ bool
+ IsScripted ()
+ {
+ return true;
+ }
+
+ class FrontEnd : public SyntheticChildrenFrontEnd
+ {
+ private:
+ std::string m_python_class;
+ lldb::ScriptInterpreterObjectSP m_wrapper_sp;
+ ScriptInterpreter *m_interpreter;
+ public:
+
+ FrontEnd (std::string pclass,
+ ValueObject &backend);
+
+ virtual
+ ~FrontEnd ();
+
+ virtual size_t
+ CalculateNumChildren ()
+ {
+ if (!m_wrapper_sp || m_interpreter == NULL)
+ return 0;
+ return m_interpreter->CalculateNumChildren(m_wrapper_sp);
+ }
+
+ virtual lldb::ValueObjectSP
+ GetChildAtIndex (size_t idx);
+
+ virtual bool
+ Update ()
+ {
+ if (!m_wrapper_sp || m_interpreter == NULL)
+ return false;
+
+ return m_interpreter->UpdateSynthProviderInstance(m_wrapper_sp);
+ }
+
+ virtual bool
+ MightHaveChildren ()
+ {
+ if (!m_wrapper_sp || m_interpreter == NULL)
+ return false;
+
+ return m_interpreter->MightHaveChildrenSynthProviderInstance(m_wrapper_sp);
+ }
+
+ virtual size_t
+ GetIndexOfChildWithName (const ConstString &name)
+ {
+ if (!m_wrapper_sp || m_interpreter == NULL)
+ return UINT32_MAX;
+ return m_interpreter->GetIndexOfChildWithName(m_wrapper_sp, name.GetCString());
+ }
+
+ typedef STD_SHARED_PTR(SyntheticChildrenFrontEnd) SharedPointer;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(FrontEnd);
+ };
+
+ virtual SyntheticChildrenFrontEnd::AutoPointer
+ GetFrontEnd(ValueObject &backend)
+ {
+ return SyntheticChildrenFrontEnd::AutoPointer(new FrontEnd(m_python_class, backend));
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ScriptedSyntheticChildren);
+ };
+#endif
+} // namespace lldb_private
+
+#endif // lldb_TypeSynthetic_h_
Modified: lldb/trunk/include/lldb/lldb-forward.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-forward.h?rev=173728&r1=173727&r2=173728&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-forward.h (original)
+++ lldb/trunk/include/lldb/lldb-forward.h Mon Jan 28 17:47:25 2013
@@ -218,7 +218,7 @@ class SyntheticChildren;
class SyntheticChildrenFrontEnd;
class TypeFilterImpl;
#ifndef LLDB_DISABLE_PYTHON
-class TypeSyntheticImpl;
+class ScriptedSyntheticChildren;
#endif
class Target;
class TargetList;
@@ -236,6 +236,7 @@ class ThreadPlanTracer;
class ThreadSpec;
class TimeValue;
class Type;
+class TypeCategoryMap;
class TypeImpl;
class TypeAndOrName;
class TypeList;
@@ -373,7 +374,7 @@ namespace lldb {
typedef STD_SHARED_PTR(lldb_private::TypeNameSpecifierImpl) TypeNameSpecifierImplSP;
typedef STD_SHARED_PTR(lldb_private::TypeSummaryImpl) TypeSummaryImplSP;
#ifndef LLDB_DISABLE_PYTHON
- typedef STD_SHARED_PTR(lldb_private::TypeSyntheticImpl) TypeSyntheticImplSP;
+ typedef STD_SHARED_PTR(lldb_private::ScriptedSyntheticChildren) ScriptedSyntheticChildrenSP;
#endif
typedef STD_SHARED_PTR(lldb_private::UnwindPlan) UnwindPlanSP;
typedef lldb_private::SharingPtr<lldb_private::ValueObject> ValueObjectSP;
Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=173728&r1=173727&r2=173728&view=diff
==============================================================================
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Mon Jan 28 17:47:25 2013
@@ -514,7 +514,6 @@
4CF52AF8142829390051E832 /* SBFileSpecList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CF52AF7142829390051E832 /* SBFileSpecList.cpp */; };
94031A9E13CF486700DCFF3C /* InputReaderEZ.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94031A9D13CF486600DCFF3C /* InputReaderEZ.cpp */; };
94094C6B163B6F840083A547 /* ValueObjectCast.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94094C69163B6CD90083A547 /* ValueObjectCast.cpp */; };
- 9415F61813B2C0EF00A52B36 /* FormatManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9415F61713B2C0EF00A52B36 /* FormatManager.cpp */; };
941BCC7F14E48C4000BB969C /* SBTypeFilter.h in Headers */ = {isa = PBXBuildFile; fileRef = 9461568614E355F2003A195C /* SBTypeFilter.h */; settings = {ATTRIBUTES = (Public, ); }; };
941BCC8014E48C4000BB969C /* SBTypeFormat.h in Headers */ = {isa = PBXBuildFile; fileRef = 9461568714E355F2003A195C /* SBTypeFormat.h */; settings = {ATTRIBUTES = (Public, ); }; };
941BCC8114E48C4000BB969C /* SBTypeSummary.h in Headers */ = {isa = PBXBuildFile; fileRef = 9461568814E355F2003A195C /* SBTypeSummary.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -530,7 +529,6 @@
9461569D14E358A6003A195C /* SBTypeSynthetic.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9461568D14E35621003A195C /* SBTypeSynthetic.cpp */; };
9463D4CD13B1798800C230D4 /* CommandObjectType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9463D4CC13B1798800C230D4 /* CommandObjectType.cpp */; };
9467E65213C3D97600B3B6F3 /* TypeHierarchyNavigator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9467E65113C3D97600B3B6F3 /* TypeHierarchyNavigator.cpp */; };
- 9470A8F01402DFFB0056FF61 /* DataVisualization.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9470A8EF1402DFFB0056FF61 /* DataVisualization.cpp */; };
9475C18814E5E9FA001BFC6D /* SBTypeCategory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9475C18714E5E9FA001BFC6D /* SBTypeCategory.cpp */; };
9475C18914E5EA08001BFC6D /* SBTypeCategory.h in Headers */ = {isa = PBXBuildFile; fileRef = 9475C18514E5E9C5001BFC6D /* SBTypeCategory.h */; settings = {ATTRIBUTES = (Public, ); }; };
9475C18E14E5F834001BFC6D /* SBTypeNameSpecifier.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9475C18D14E5F834001BFC6D /* SBTypeNameSpecifier.cpp */; };
@@ -539,7 +537,16 @@
947A1D651616476B0017C8D1 /* CommandObjectPlugin.h in Headers */ = {isa = PBXBuildFile; fileRef = 947A1D631616476A0017C8D1 /* CommandObjectPlugin.h */; };
949ADF031406F648004833E1 /* ValueObjectConstResultImpl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 949ADF021406F648004833E1 /* ValueObjectConstResultImpl.cpp */; };
94B6E76213D88365005F417F /* ValueObjectSyntheticFilter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94B6E76113D88362005F417F /* ValueObjectSyntheticFilter.cpp */; };
- 94CDEB9D15F0258500DD2A7A /* CXXFormatterFunctions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94CDEB9C15F0258400DD2A7A /* CXXFormatterFunctions.cpp */; };
+ 94CB255B16B069770059775D /* CXXFormatterFunctions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94CB255716B069770059775D /* CXXFormatterFunctions.cpp */; };
+ 94CB255C16B069770059775D /* DataVisualization.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94CB255816B069770059775D /* DataVisualization.cpp */; };
+ 94CB255D16B069770059775D /* FormatClasses.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94CB255916B069770059775D /* FormatClasses.cpp */; };
+ 94CB255E16B069770059775D /* FormatManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94CB255A16B069770059775D /* FormatManager.cpp */; };
+ 94CB256616B096F10059775D /* TypeCategory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94CB256416B096F10059775D /* TypeCategory.cpp */; };
+ 94CB256716B096F10059775D /* TypeCategoryMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94CB256516B096F10059775D /* TypeCategoryMap.cpp */; };
+ 94CB257016B0A4270059775D /* TypeFormat.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94CB256D16B0A4260059775D /* TypeFormat.cpp */; };
+ 94CB257116B0A4270059775D /* TypeSummary.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94CB256E16B0A4260059775D /* TypeSummary.cpp */; };
+ 94CB257216B0A4270059775D /* TypeSynthetic.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94CB256F16B0A4270059775D /* TypeSynthetic.cpp */; };
+ 94CB257416B1D3880059775D /* FormatCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94CB257316B1D3870059775D /* FormatCache.cpp */; };
94EA1D5C15E6C9B400D4171A /* PythonDataObjects.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94EA1D5B15E6C9B400D4171A /* PythonDataObjects.cpp */; };
94FA3DE01405D50400833217 /* ValueObjectConstResultChild.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94FA3DDF1405D50300833217 /* ValueObjectConstResultChild.cpp */; };
9A19A6AF1163BBB200E0D453 /* SBValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A19A6A51163BB7E00E0D453 /* SBValue.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -568,7 +575,6 @@
B207C4931429607D00F36E4E /* CommandObjectWatchpoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B207C4921429607D00F36E4E /* CommandObjectWatchpoint.cpp */; };
B21EB71515CC99F100E60059 /* cxa_demangle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B21EB71415CC99F100E60059 /* cxa_demangle.cpp */; settings = {COMPILER_FLAGS = "-frtti"; }; };
B2462247141AD37D00F3D409 /* OptionGroupWatchpoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B2462246141AD37D00F3D409 /* OptionGroupWatchpoint.cpp */; };
- B271B11413D6139300C3FEDB /* FormatClasses.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94A9112D13D5DF210046D8A6 /* FormatClasses.cpp */; };
B27318421416AC12006039C8 /* WatchpointList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B27318411416AC12006039C8 /* WatchpointList.cpp */; };
B28058A1139988B0002D96D0 /* InferiorCallPOSIX.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B28058A0139988B0002D96D0 /* InferiorCallPOSIX.cpp */; };
B299580B14F2FA1400050A04 /* DisassemblerLLVMC.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B299580A14F2FA1400050A04 /* DisassemblerLLVMC.cpp */; };
@@ -1519,8 +1525,6 @@
94031A9F13CF5B3D00DCFF3C /* PriorityPointerPair.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = PriorityPointerPair.h; path = include/lldb/Utility/PriorityPointerPair.h; sourceTree = "<group>"; };
94094C68163B6CCC0083A547 /* ValueObjectCast.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ValueObjectCast.h; path = include/lldb/Core/ValueObjectCast.h; sourceTree = "<group>"; };
94094C69163B6CD90083A547 /* ValueObjectCast.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ValueObjectCast.cpp; path = source/Core/ValueObjectCast.cpp; sourceTree = "<group>"; };
- 9415F61613B2C0DC00A52B36 /* FormatManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = FormatManager.h; path = include/lldb/Core/FormatManager.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
- 9415F61713B2C0EF00A52B36 /* FormatManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; name = FormatManager.cpp; path = source/Core/FormatManager.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
9443B120140C18A90013457C /* SBData.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SBData.h; path = include/lldb/API/SBData.h; sourceTree = "<group>"; };
9443B121140C18C10013457C /* SBData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBData.cpp; path = source/API/SBData.cpp; sourceTree = "<group>"; };
9452573616262CD000325455 /* SBDeclaration.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; path = SBDeclaration.i; sourceTree = "<group>"; };
@@ -1546,8 +1550,6 @@
9463D4CE13B179A500C230D4 /* CommandObjectType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = CommandObjectType.h; path = source/Commands/CommandObjectType.h; sourceTree = "<group>"; };
9467E65113C3D97600B3B6F3 /* TypeHierarchyNavigator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TypeHierarchyNavigator.cpp; path = source/Symbol/TypeHierarchyNavigator.cpp; sourceTree = "<group>"; };
9467E65413C3D98900B3B6F3 /* TypeHierarchyNavigator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = TypeHierarchyNavigator.h; path = include/lldb/Symbol/TypeHierarchyNavigator.h; sourceTree = "<group>"; };
- 9470A8EE1402DF940056FF61 /* DataVisualization.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = DataVisualization.h; path = include/lldb/Core/DataVisualization.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
- 9470A8EF1402DFFB0056FF61 /* DataVisualization.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; name = DataVisualization.cpp; path = source/Core/DataVisualization.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
9475C18514E5E9C5001BFC6D /* SBTypeCategory.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SBTypeCategory.h; path = include/lldb/API/SBTypeCategory.h; sourceTree = "<group>"; };
9475C18714E5E9FA001BFC6D /* SBTypeCategory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBTypeCategory.cpp; path = source/API/SBTypeCategory.cpp; sourceTree = "<group>"; };
9475C18A14E5EA1C001BFC6D /* SBTypeCategory.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; path = SBTypeCategory.i; sourceTree = "<group>"; };
@@ -1558,13 +1560,29 @@
947A1D631616476A0017C8D1 /* CommandObjectPlugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectPlugin.h; path = source/Commands/CommandObjectPlugin.h; sourceTree = "<group>"; };
949ADF001406F62E004833E1 /* ValueObjectConstResultImpl.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ValueObjectConstResultImpl.h; path = include/lldb/Core/ValueObjectConstResultImpl.h; sourceTree = "<group>"; };
949ADF021406F648004833E1 /* ValueObjectConstResultImpl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ValueObjectConstResultImpl.cpp; path = source/Core/ValueObjectConstResultImpl.cpp; sourceTree = "<group>"; };
- 94A8287514031D05006C37A8 /* FormatNavigator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = FormatNavigator.h; path = include/lldb/Core/FormatNavigator.h; sourceTree = "<group>"; };
- 94A9112B13D5DEF80046D8A6 /* FormatClasses.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = FormatClasses.h; path = include/lldb/Core/FormatClasses.h; sourceTree = "<group>"; };
- 94A9112D13D5DF210046D8A6 /* FormatClasses.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FormatClasses.cpp; path = source/Core/FormatClasses.cpp; sourceTree = "<group>"; };
94B6E76013D8833C005F417F /* ValueObjectSyntheticFilter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ValueObjectSyntheticFilter.h; path = include/lldb/Core/ValueObjectSyntheticFilter.h; sourceTree = "<group>"; };
94B6E76113D88362005F417F /* ValueObjectSyntheticFilter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ValueObjectSyntheticFilter.cpp; path = source/Core/ValueObjectSyntheticFilter.cpp; sourceTree = "<group>"; };
- 94CDEB9A15F0226900DD2A7A /* CXXFormatterFunctions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = CXXFormatterFunctions.h; path = include/lldb/Core/CXXFormatterFunctions.h; sourceTree = "<group>"; };
- 94CDEB9C15F0258400DD2A7A /* CXXFormatterFunctions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CXXFormatterFunctions.cpp; path = source/Core/CXXFormatterFunctions.cpp; sourceTree = "<group>"; };
+ 94CB255716B069770059775D /* CXXFormatterFunctions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CXXFormatterFunctions.cpp; path = source/DataFormatters/CXXFormatterFunctions.cpp; sourceTree = "<group>"; };
+ 94CB255816B069770059775D /* DataVisualization.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DataVisualization.cpp; path = source/DataFormatters/DataVisualization.cpp; sourceTree = "<group>"; };
+ 94CB255916B069770059775D /* FormatClasses.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FormatClasses.cpp; path = source/DataFormatters/FormatClasses.cpp; sourceTree = "<group>"; };
+ 94CB255A16B069770059775D /* FormatManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FormatManager.cpp; path = source/DataFormatters/FormatManager.cpp; sourceTree = "<group>"; };
+ 94CB255F16B069800059775D /* CXXFormatterFunctions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = CXXFormatterFunctions.h; path = include/lldb/DataFormatters/CXXFormatterFunctions.h; sourceTree = "<group>"; };
+ 94CB256016B069800059775D /* DataVisualization.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = DataVisualization.h; path = include/lldb/DataFormatters/DataVisualization.h; sourceTree = "<group>"; };
+ 94CB256116B069800059775D /* FormatClasses.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = FormatClasses.h; path = include/lldb/DataFormatters/FormatClasses.h; sourceTree = "<group>"; };
+ 94CB256216B069800059775D /* FormatManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = FormatManager.h; path = include/lldb/DataFormatters/FormatManager.h; sourceTree = "<group>"; };
+ 94CB256316B069800059775D /* FormatNavigator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = FormatNavigator.h; path = include/lldb/DataFormatters/FormatNavigator.h; sourceTree = "<group>"; };
+ 94CB256416B096F10059775D /* TypeCategory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TypeCategory.cpp; path = source/DataFormatters/TypeCategory.cpp; sourceTree = "<group>"; };
+ 94CB256516B096F10059775D /* TypeCategoryMap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TypeCategoryMap.cpp; path = source/DataFormatters/TypeCategoryMap.cpp; sourceTree = "<group>"; };
+ 94CB256816B096F90059775D /* TypeCategory.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = TypeCategory.h; path = include/lldb/DataFormatters/TypeCategory.h; sourceTree = "<group>"; };
+ 94CB256916B096FA0059775D /* TypeCategoryMap.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = TypeCategoryMap.h; path = include/lldb/DataFormatters/TypeCategoryMap.h; sourceTree = "<group>"; };
+ 94CB256A16B0A4030059775D /* TypeFormat.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = TypeFormat.h; path = include/lldb/DataFormatters/TypeFormat.h; sourceTree = "<group>"; };
+ 94CB256B16B0A4030059775D /* TypeSummary.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = TypeSummary.h; path = include/lldb/DataFormatters/TypeSummary.h; sourceTree = "<group>"; };
+ 94CB256C16B0A4040059775D /* TypeSynthetic.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = TypeSynthetic.h; path = include/lldb/DataFormatters/TypeSynthetic.h; sourceTree = "<group>"; };
+ 94CB256D16B0A4260059775D /* TypeFormat.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TypeFormat.cpp; path = source/DataFormatters/TypeFormat.cpp; sourceTree = "<group>"; };
+ 94CB256E16B0A4260059775D /* TypeSummary.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TypeSummary.cpp; path = source/DataFormatters/TypeSummary.cpp; sourceTree = "<group>"; };
+ 94CB256F16B0A4270059775D /* TypeSynthetic.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TypeSynthetic.cpp; path = source/DataFormatters/TypeSynthetic.cpp; sourceTree = "<group>"; };
+ 94CB257316B1D3870059775D /* FormatCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FormatCache.cpp; path = source/DataFormatters/FormatCache.cpp; sourceTree = "<group>"; };
+ 94CB257516B1D3910059775D /* FormatCache.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = FormatCache.h; path = include/lldb/DataFormatters/FormatCache.h; sourceTree = "<group>"; };
94E367CC140C4EC4001C7A5A /* modify-python-lldb.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = "modify-python-lldb.py"; sourceTree = "<group>"; };
94E367CE140C4EEA001C7A5A /* python-typemaps.swig */ = {isa = PBXFileReference; lastKnownFileType = text; path = "python-typemaps.swig"; sourceTree = "<group>"; };
94EA1D5A15E6C99B00D4171A /* PythonDataObjects.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = PythonDataObjects.h; path = include/lldb/Interpreter/PythonDataObjects.h; sourceTree = "<group>"; };
@@ -1785,6 +1803,7 @@
26BC7CEB10F1B70800F91463 /* Breakpoint */,
26BC7D0D10F1B71D00F91463 /* Commands */,
26BC7C1010F1B34800F91463 /* Core */,
+ 94CB255616B0683B0059775D /* DataFormatters */,
26BC7DBE10F1B78200F91463 /* Expression */,
26BC7DD010F1B7C100F91463 /* Host */,
26BC7DDF10F1B7E200F91463 /* Interpreter */,
@@ -2492,8 +2511,6 @@
266603C91345B5A8004DA8B6 /* ConnectionSharedMemory.cpp */,
26BC7D7C10F1B77400F91463 /* ConstString.h */,
26BC7E9410F1B85900F91463 /* ConstString.cpp */,
- 94CDEB9A15F0226900DD2A7A /* CXXFormatterFunctions.h */,
- 94CDEB9C15F0258400DD2A7A /* CXXFormatterFunctions.cpp */,
26BC7D5910F1B77400F91463 /* DataBuffer.h */,
26BC7D5B10F1B77400F91463 /* DataBufferHeap.h */,
26BC7E7210F1B85900F91463 /* DataBufferHeap.cpp */,
@@ -2503,8 +2520,6 @@
268ED0A4140FF54200DE830F /* DataEncoder.cpp */,
26BC7D5A10F1B77400F91463 /* DataExtractor.h */,
26BC7E7110F1B85900F91463 /* DataExtractor.cpp */,
- 9470A8EE1402DF940056FF61 /* DataVisualization.h */,
- 9470A8EF1402DFFB0056FF61 /* DataVisualization.cpp */,
263664941140A4C10075843B /* Debugger.h */,
263664921140A4930075843B /* Debugger.cpp */,
26BC7D5E10F1B77400F91463 /* Disassembler.h */,
@@ -2521,11 +2536,6 @@
26BC7D6310F1B77400F91463 /* FileSpecList.h */,
26BC7E7B10F1B85900F91463 /* FileSpecList.cpp */,
26BC7D6410F1B77400F91463 /* Flags.h */,
- 94A9112B13D5DEF80046D8A6 /* FormatClasses.h */,
- 94A9112D13D5DF210046D8A6 /* FormatClasses.cpp */,
- 9415F61613B2C0DC00A52B36 /* FormatManager.h */,
- 9415F61713B2C0EF00A52B36 /* FormatManager.cpp */,
- 94A8287514031D05006C37A8 /* FormatNavigator.h */,
26F7305F139D8FC900FD51C7 /* History.h */,
26F73061139D8FDB00FD51C7 /* History.cpp */,
9AA69DBB118A029E00D753A0 /* InputReader.h */,
@@ -3328,6 +3338,34 @@
path = source/Host/common;
sourceTree = "<group>";
};
+ 94CB255616B0683B0059775D /* DataFormatters */ = {
+ isa = PBXGroup;
+ children = (
+ 94CB255F16B069800059775D /* CXXFormatterFunctions.h */,
+ 94CB255716B069770059775D /* CXXFormatterFunctions.cpp */,
+ 94CB256016B069800059775D /* DataVisualization.h */,
+ 94CB255816B069770059775D /* DataVisualization.cpp */,
+ 94CB257516B1D3910059775D /* FormatCache.h */,
+ 94CB257316B1D3870059775D /* FormatCache.cpp */,
+ 94CB256116B069800059775D /* FormatClasses.h */,
+ 94CB255916B069770059775D /* FormatClasses.cpp */,
+ 94CB256216B069800059775D /* FormatManager.h */,
+ 94CB255A16B069770059775D /* FormatManager.cpp */,
+ 94CB256316B069800059775D /* FormatNavigator.h */,
+ 94CB256816B096F90059775D /* TypeCategory.h */,
+ 94CB256416B096F10059775D /* TypeCategory.cpp */,
+ 94CB256916B096FA0059775D /* TypeCategoryMap.h */,
+ 94CB256516B096F10059775D /* TypeCategoryMap.cpp */,
+ 94CB256A16B0A4030059775D /* TypeFormat.h */,
+ 94CB256D16B0A4260059775D /* TypeFormat.cpp */,
+ 94CB256B16B0A4030059775D /* TypeSummary.h */,
+ 94CB256E16B0A4260059775D /* TypeSummary.cpp */,
+ 94CB256C16B0A4040059775D /* TypeSynthetic.h */,
+ 94CB256F16B0A4270059775D /* TypeSynthetic.cpp */,
+ );
+ name = DataFormatters;
+ sourceTree = "<group>";
+ };
EDC6D49114E5C15C001B75F8 /* launcherXPCService */ = {
isa = PBXGroup;
children = (
@@ -4094,7 +4132,6 @@
4CCA645613B40B82003BDF98 /* AppleObjCTrampolineHandler.cpp in Sources */,
4CCA645813B40B82003BDF98 /* AppleThreadPlanStepThroughObjCTrampoline.cpp in Sources */,
9463D4CD13B1798800C230D4 /* CommandObjectType.cpp in Sources */,
- 9415F61813B2C0EF00A52B36 /* FormatManager.cpp in Sources */,
49D8FB3913B5598F00411094 /* ClangASTImporter.cpp in Sources */,
9467E65213C3D97600B3B6F3 /* TypeHierarchyNavigator.cpp in Sources */,
26ED3D6D13C563810017D45E /* OptionGroupVariable.cpp in Sources */,
@@ -4111,13 +4148,11 @@
265205AC13D3E3F700132FE2 /* RegisterContextKDP_x86_64.cpp in Sources */,
2628A4D513D4977900F5487A /* ThreadKDP.cpp in Sources */,
26D7E45D13D5E30A007FD12B /* SocketAddress.cpp in Sources */,
- B271B11413D6139300C3FEDB /* FormatClasses.cpp in Sources */,
94B6E76213D88365005F417F /* ValueObjectSyntheticFilter.cpp in Sources */,
262D24E613FB8710002D1960 /* RegisterContextMemory.cpp in Sources */,
26F4A21C13FBA31A0064B613 /* ThreadMemory.cpp in Sources */,
266DFE9713FD656E00D0C574 /* OperatingSystem.cpp in Sources */,
26954EBE1401EE8B00294D09 /* DynamicRegisterInfo.cpp in Sources */,
- 9470A8F01402DFFB0056FF61 /* DataVisualization.cpp in Sources */,
26274FA214030EEF006BA130 /* OperatingSystemDarwinKernel.cpp in Sources */,
26274FA714030F79006BA130 /* DynamicLoaderDarwinKernel.cpp in Sources */,
94FA3DE01405D50400833217 /* ValueObjectConstResultChild.cpp in Sources */,
@@ -4165,10 +4200,19 @@
2697A39315E404B1003E682C /* OptionValueArch.cpp in Sources */,
94EA1D5C15E6C9B400D4171A /* PythonDataObjects.cpp in Sources */,
2698699B15E6CBD0002415FF /* OperatingSystemPython.cpp in Sources */,
- 94CDEB9D15F0258500DD2A7A /* CXXFormatterFunctions.cpp in Sources */,
947A1D641616476B0017C8D1 /* CommandObjectPlugin.cpp in Sources */,
262ED0081631FA3A00879631 /* OptionGroupString.cpp in Sources */,
94094C6B163B6F840083A547 /* ValueObjectCast.cpp in Sources */,
+ 94CB255B16B069770059775D /* CXXFormatterFunctions.cpp in Sources */,
+ 94CB255C16B069770059775D /* DataVisualization.cpp in Sources */,
+ 94CB255D16B069770059775D /* FormatClasses.cpp in Sources */,
+ 94CB255E16B069770059775D /* FormatManager.cpp in Sources */,
+ 94CB256616B096F10059775D /* TypeCategory.cpp in Sources */,
+ 94CB256716B096F10059775D /* TypeCategoryMap.cpp in Sources */,
+ 94CB257016B0A4270059775D /* TypeFormat.cpp in Sources */,
+ 94CB257116B0A4270059775D /* TypeSummary.cpp in Sources */,
+ 94CB257216B0A4270059775D /* TypeSynthetic.cpp in Sources */,
+ 94CB257416B1D3880059775D /* FormatCache.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Modified: lldb/trunk/source/API/SBDebugger.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBDebugger.cpp?rev=173728&r1=173727&r2=173728&view=diff
==============================================================================
--- lldb/trunk/source/API/SBDebugger.cpp (original)
+++ lldb/trunk/source/API/SBDebugger.cpp Mon Jan 28 17:47:25 2013
@@ -35,9 +35,9 @@
#include "lldb/API/SBTypeSynthetic.h"
-#include "lldb/Core/DataVisualization.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/State.h"
+#include "lldb/DataFormatters/DataVisualization.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/OptionGroupPlatform.h"
Modified: lldb/trunk/source/API/SBTypeCategory.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTypeCategory.cpp?rev=173728&r1=173727&r2=173728&view=diff
==============================================================================
--- lldb/trunk/source/API/SBTypeCategory.cpp (original)
+++ lldb/trunk/source/API/SBTypeCategory.cpp Mon Jan 28 17:47:25 2013
@@ -18,8 +18,8 @@
#include "lldb/API/SBTypeNameSpecifier.h"
#include "lldb/API/SBStream.h"
-#include "lldb/Core/DataVisualization.h"
#include "lldb/Core/Debugger.h"
+#include "lldb/DataFormatters/DataVisualization.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/ScriptInterpreter.h"
@@ -233,7 +233,7 @@ SBTypeCategory::GetSyntheticForType (SBT
if (!children_sp)
return lldb::SBTypeSynthetic();
- TypeSyntheticImplSP synth_sp = STD_STATIC_POINTER_CAST(TypeSyntheticImpl,children_sp);
+ ScriptedSyntheticChildrenSP synth_sp = STD_STATIC_POINTER_CAST(ScriptedSyntheticChildren,children_sp);
return lldb::SBTypeSynthetic(synth_sp);
}
@@ -285,7 +285,7 @@ SBTypeCategory::GetSyntheticAtIndex (uin
if (!children_sp.get())
return lldb::SBTypeSynthetic();
- TypeSyntheticImplSP synth_sp = STD_STATIC_POINTER_CAST(TypeSyntheticImpl,children_sp);
+ ScriptedSyntheticChildrenSP synth_sp = STD_STATIC_POINTER_CAST(ScriptedSyntheticChildren,children_sp);
return lldb::SBTypeSynthetic(synth_sp);
}
Modified: lldb/trunk/source/API/SBTypeFilter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTypeFilter.cpp?rev=173728&r1=173727&r2=173728&view=diff
==============================================================================
--- lldb/trunk/source/API/SBTypeFilter.cpp (original)
+++ lldb/trunk/source/API/SBTypeFilter.cpp Mon Jan 28 17:47:25 2013
@@ -13,7 +13,7 @@
#include "lldb/API/SBStream.h"
-#include "lldb/Core/DataVisualization.h"
+#include "lldb/DataFormatters/DataVisualization.h"
using namespace lldb;
using namespace lldb_private;
Modified: lldb/trunk/source/API/SBTypeFormat.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTypeFormat.cpp?rev=173728&r1=173727&r2=173728&view=diff
==============================================================================
--- lldb/trunk/source/API/SBTypeFormat.cpp (original)
+++ lldb/trunk/source/API/SBTypeFormat.cpp Mon Jan 28 17:47:25 2013
@@ -13,7 +13,7 @@
#include "lldb/API/SBStream.h"
-#include "lldb/Core/DataVisualization.h"
+#include "lldb/DataFormatters/DataVisualization.h"
using namespace lldb;
using namespace lldb_private;
Modified: lldb/trunk/source/API/SBTypeNameSpecifier.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTypeNameSpecifier.cpp?rev=173728&r1=173727&r2=173728&view=diff
==============================================================================
--- lldb/trunk/source/API/SBTypeNameSpecifier.cpp (original)
+++ lldb/trunk/source/API/SBTypeNameSpecifier.cpp Mon Jan 28 17:47:25 2013
@@ -14,7 +14,7 @@
#include "lldb/API/SBStream.h"
#include "lldb/API/SBType.h"
-#include "lldb/Core/DataVisualization.h"
+#include "lldb/DataFormatters/DataVisualization.h"
using namespace lldb;
using namespace lldb_private;
Modified: lldb/trunk/source/API/SBTypeSummary.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTypeSummary.cpp?rev=173728&r1=173727&r2=173728&view=diff
==============================================================================
--- lldb/trunk/source/API/SBTypeSummary.cpp (original)
+++ lldb/trunk/source/API/SBTypeSummary.cpp Mon Jan 28 17:47:25 2013
@@ -13,7 +13,7 @@
#include "lldb/API/SBStream.h"
-#include "lldb/Core/DataVisualization.h"
+#include "lldb/DataFormatters/DataVisualization.h"
using namespace lldb;
using namespace lldb_private;
Modified: lldb/trunk/source/API/SBTypeSynthetic.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTypeSynthetic.cpp?rev=173728&r1=173727&r2=173728&view=diff
==============================================================================
--- lldb/trunk/source/API/SBTypeSynthetic.cpp (original)
+++ lldb/trunk/source/API/SBTypeSynthetic.cpp Mon Jan 28 17:47:25 2013
@@ -13,7 +13,7 @@
#include "lldb/API/SBStream.h"
-#include "lldb/Core/DataVisualization.h"
+#include "lldb/DataFormatters/DataVisualization.h"
using namespace lldb;
using namespace lldb_private;
@@ -30,7 +30,7 @@ SBTypeSynthetic::CreateWithClassName (co
{
if (!data || data[0] == 0)
return SBTypeSynthetic();
- return SBTypeSynthetic(TypeSyntheticImplSP(new TypeSyntheticImpl(options, data, "")));
+ return SBTypeSynthetic(ScriptedSyntheticChildrenSP(new ScriptedSyntheticChildren(options, data, "")));
}
SBTypeSynthetic
@@ -38,7 +38,7 @@ SBTypeSynthetic::CreateWithScriptCode (c
{
if (!data || data[0] == 0)
return SBTypeSynthetic();
- return SBTypeSynthetic(TypeSyntheticImplSP(new TypeSyntheticImpl(options, "", data)));
+ return SBTypeSynthetic(ScriptedSyntheticChildrenSP(new ScriptedSyntheticChildren(options, "", data)));
}
SBTypeSynthetic::SBTypeSynthetic (const lldb::SBTypeSynthetic &rhs) :
@@ -172,19 +172,19 @@ SBTypeSynthetic::operator != (lldb::SBTy
return m_opaque_sp != rhs.m_opaque_sp;
}
-lldb::TypeSyntheticImplSP
+lldb::ScriptedSyntheticChildrenSP
SBTypeSynthetic::GetSP ()
{
return m_opaque_sp;
}
void
-SBTypeSynthetic::SetSP (const lldb::TypeSyntheticImplSP &TypeSynthetic_impl_sp)
+SBTypeSynthetic::SetSP (const lldb::ScriptedSyntheticChildrenSP &TypeSynthetic_impl_sp)
{
m_opaque_sp = TypeSynthetic_impl_sp;
}
-SBTypeSynthetic::SBTypeSynthetic (const lldb::TypeSyntheticImplSP &TypeSynthetic_impl_sp) :
+SBTypeSynthetic::SBTypeSynthetic (const lldb::ScriptedSyntheticChildrenSP &TypeSynthetic_impl_sp) :
m_opaque_sp(TypeSynthetic_impl_sp)
{
}
@@ -197,7 +197,7 @@ SBTypeSynthetic::CopyOnWrite_Impl()
if (m_opaque_sp.unique())
return true;
- TypeSyntheticImplSP new_sp(new TypeSyntheticImpl(m_opaque_sp->GetOptions(),
+ ScriptedSyntheticChildrenSP new_sp(new ScriptedSyntheticChildren(m_opaque_sp->GetOptions(),
m_opaque_sp->GetPythonClassName(),
m_opaque_sp->GetPythonCode()));
Modified: lldb/trunk/source/API/SBValue.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBValue.cpp?rev=173728&r1=173727&r2=173728&view=diff
==============================================================================
--- lldb/trunk/source/API/SBValue.cpp (original)
+++ lldb/trunk/source/API/SBValue.cpp Mon Jan 28 17:47:25 2013
@@ -20,7 +20,6 @@
#include "lldb/Breakpoint/Watchpoint.h"
#include "lldb/Core/DataExtractor.h"
-#include "lldb/Core/DataVisualization.h"
#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/Scalar.h"
@@ -30,6 +29,7 @@
#include "lldb/Core/Value.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
+#include "lldb/DataFormatters/DataVisualization.h"
#include "lldb/Symbol/Block.h"
#include "lldb/Symbol/Declaration.h"
#include "lldb/Symbol/ObjectFile.h"
@@ -740,7 +740,7 @@ SBValue::GetTypeSynthetic ()
if (children_sp && children_sp->IsScripted())
{
- TypeSyntheticImplSP synth_sp = STD_STATIC_POINTER_CAST(TypeSyntheticImpl,children_sp);
+ ScriptedSyntheticChildrenSP synth_sp = STD_STATIC_POINTER_CAST(ScriptedSyntheticChildren,children_sp);
synthetic.SetSP(synth_sp);
}
}
Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFrame.cpp?rev=173728&r1=173727&r2=173728&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Mon Jan 28 17:47:25 2013
@@ -16,7 +16,6 @@
#include <string>
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/DataVisualization.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/StreamFile.h"
@@ -25,6 +24,7 @@
#include "lldb/Core/Value.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectVariable.h"
+#include "lldb/DataFormatters/DataVisualization.h"
#include "lldb/Host/Host.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Interpreter/CommandInterpreter.h"
Modified: lldb/trunk/source/Commands/CommandObjectType.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectType.cpp?rev=173728&r1=173727&r2=173728&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectType.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectType.cpp Mon Jan 28 17:47:25 2013
@@ -17,13 +17,13 @@
// C++ Includes
-#include "lldb/Core/DataVisualization.h"
#include "lldb/Core/ConstString.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/InputReaderEZ.h"
#include "lldb/Core/RegularExpression.h"
#include "lldb/Core/State.h"
#include "lldb/Core/StringList.h"
+#include "lldb/DataFormatters/DataVisualization.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandObject.h"
#include "lldb/Interpreter/CommandReturnObject.h"
@@ -1961,7 +1961,7 @@ protected:
if (argc == 1 && strcmp(command.GetArgumentAtIndex(0),"*") == 0)
{
// we want to make sure to enable "system" last and "default" first
- DataVisualization::Categories::Enable(ConstString("default"), CategoryMap::First);
+ DataVisualization::Categories::Enable(ConstString("default"), TypeCategoryMap::First);
uint32_t num_categories = DataVisualization::Categories::GetCount();
for (uint32_t i = 0; i < num_categories; i++)
{
@@ -1972,10 +1972,10 @@ protected:
::strcmp(category_sp->GetName(), "default") == 0 )
continue;
else
- DataVisualization::Categories::Enable(category_sp, CategoryMap::Default);
+ DataVisualization::Categories::Enable(category_sp, TypeCategoryMap::Default);
}
}
- DataVisualization::Categories::Enable(ConstString("system"), CategoryMap::Last);
+ DataVisualization::Categories::Enable(ConstString("system"), TypeCategoryMap::Last);
}
else
{
@@ -3385,10 +3385,10 @@ public:
// everything should be fine now, let's add the synth provider class
SyntheticChildrenSP synth_provider;
- synth_provider.reset(new TypeSyntheticImpl(SyntheticChildren::Flags().SetCascades(options->m_cascade).
- SetSkipPointers(options->m_skip_pointers).
- SetSkipReferences(options->m_skip_references),
- class_name_str.c_str()));
+ synth_provider.reset(new ScriptedSyntheticChildren(SyntheticChildren::Flags().SetCascades(options->m_cascade).
+ SetSkipPointers(options->m_skip_pointers).
+ SetSkipReferences(options->m_skip_references),
+ class_name_str.c_str()));
lldb::TypeCategoryImplSP category;
@@ -3504,11 +3504,11 @@ CommandObjectTypeSynthAdd::Execute_Pytho
SyntheticChildrenSP entry;
- 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());
+ ScriptedSyntheticChildren* impl = new ScriptedSyntheticChildren(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);
Removed: lldb/trunk/source/Core/CXXFormatterFunctions.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/CXXFormatterFunctions.cpp?rev=173727&view=auto
==============================================================================
--- lldb/trunk/source/Core/CXXFormatterFunctions.cpp (original)
+++ lldb/trunk/source/Core/CXXFormatterFunctions.cpp (removed)
@@ -1,1808 +0,0 @@
-//===-- CXXFormatterFunctions.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/lldb-python.h"
-
-#include "lldb/Core/CXXFormatterFunctions.h"
-
-// needed to get ConvertUTF16/32ToUTF8
-#define CLANG_NEEDS_THESE_ONE_DAY
-#include "clang/Basic/ConvertUTF.h"
-
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Stream.h"
-#include "lldb/Core/ValueObject.h"
-#include "lldb/Core/ValueObjectConstResult.h"
-#include "lldb/Host/Endian.h"
-#include "lldb/Symbol/ClangASTContext.h"
-#include "lldb/Target/ObjCLanguageRuntime.h"
-#include "lldb/Target/Target.h"
-
-using namespace lldb;
-using namespace lldb_private;
-using namespace lldb_private::formatters;
-
-bool
-lldb_private::formatters::ExtractValueFromObjCExpression (ValueObject &valobj,
- const char* target_type,
- const char* selector,
- uint64_t &value)
-{
- if (!target_type || !*target_type)
- return false;
- if (!selector || !*selector)
- return false;
- StreamString expr;
- expr.Printf("(%s)[(id)0x%" PRIx64 " %s]",target_type,valobj.GetPointerValue(),selector);
- ExecutionContext exe_ctx (valobj.GetExecutionContextRef());
- lldb::ValueObjectSP result_sp;
- Target* target = exe_ctx.GetTargetPtr();
- StackFrame* stack_frame = exe_ctx.GetFramePtr();
- if (!target || !stack_frame)
- return false;
-
- EvaluateExpressionOptions options;
- options.SetCoerceToId(false)
- .SetUnwindOnError(true)
- .SetKeepInMemory(true);
-
- target->EvaluateExpression(expr.GetData(),
- stack_frame,
- result_sp,
- options);
- if (!result_sp)
- return false;
- value = result_sp->GetValueAsUnsigned(0);
- return true;
-}
-
-lldb::ValueObjectSP
-lldb_private::formatters::CallSelectorOnObject (ValueObject &valobj,
- const char* return_type,
- const char* selector,
- uint64_t index)
-{
- lldb::ValueObjectSP valobj_sp;
- if (!return_type || !*return_type)
- return valobj_sp;
- if (!selector || !*selector)
- return valobj_sp;
- StreamString expr_path_stream;
- valobj.GetExpressionPath(expr_path_stream, false);
- StreamString expr;
- expr.Printf("(%s)[%s %s:%" PRId64 "]",return_type,expr_path_stream.GetData(),selector,index);
- ExecutionContext exe_ctx (valobj.GetExecutionContextRef());
- lldb::ValueObjectSP result_sp;
- Target* target = exe_ctx.GetTargetPtr();
- StackFrame* stack_frame = exe_ctx.GetFramePtr();
- if (!target || !stack_frame)
- return valobj_sp;
-
- EvaluateExpressionOptions options;
- options.SetCoerceToId(false)
- .SetUnwindOnError(true)
- .SetKeepInMemory(true)
- .SetUseDynamic(lldb::eDynamicCanRunTarget);
-
- target->EvaluateExpression(expr.GetData(),
- stack_frame,
- valobj_sp,
- options);
- return valobj_sp;
-}
-
-lldb::ValueObjectSP
-lldb_private::formatters::CallSelectorOnObject (ValueObject &valobj,
- const char* return_type,
- const char* selector,
- const char* key)
-{
- lldb::ValueObjectSP valobj_sp;
- if (!return_type || !*return_type)
- return valobj_sp;
- if (!selector || !*selector)
- return valobj_sp;
- if (!key || !*key)
- return valobj_sp;
- StreamString expr_path_stream;
- valobj.GetExpressionPath(expr_path_stream, false);
- StreamString expr;
- expr.Printf("(%s)[%s %s:%s]",return_type,expr_path_stream.GetData(),selector,key);
- ExecutionContext exe_ctx (valobj.GetExecutionContextRef());
- lldb::ValueObjectSP result_sp;
- Target* target = exe_ctx.GetTargetPtr();
- StackFrame* stack_frame = exe_ctx.GetFramePtr();
- if (!target || !stack_frame)
- return valobj_sp;
-
- EvaluateExpressionOptions options;
- options.SetCoerceToId(false)
- .SetUnwindOnError(true)
- .SetKeepInMemory(true)
- .SetUseDynamic(lldb::eDynamicCanRunTarget);
-
- target->EvaluateExpression(expr.GetData(),
- stack_frame,
- valobj_sp,
- options);
- return valobj_sp;
-}
-
-// use this call if you already have an LLDB-side buffer for the data
-template<typename SourceDataType>
-static bool
-DumpUTFBufferToStream (ConversionResult (*ConvertFunction) (const SourceDataType**,
- const SourceDataType*,
- UTF8**,
- UTF8*,
- ConversionFlags),
- DataExtractor& data,
- Stream& stream,
- char prefix_token = '@',
- char quote = '"',
- int sourceSize = 0)
-{
- if (prefix_token != 0)
- stream.Printf("%c",prefix_token);
- if (quote != 0)
- stream.Printf("%c",quote);
- if (data.GetByteSize() && data.GetDataStart() && data.GetDataEnd())
- {
- const int bufferSPSize = data.GetByteSize();
- if (sourceSize == 0)
- {
- const int origin_encoding = 8*sizeof(SourceDataType);
- sourceSize = bufferSPSize/(origin_encoding >> 2);
- }
-
- SourceDataType *data_ptr = (SourceDataType*)data.GetDataStart();
- SourceDataType *data_end_ptr = data_ptr + sourceSize;
-
- while (data_ptr < data_end_ptr)
- {
- if (!*data_ptr)
- {
- data_end_ptr = data_ptr;
- break;
- }
- data_ptr++;
- }
-
- *data_ptr = 0;
- data_ptr = (SourceDataType*)data.GetDataStart();
-
- lldb::DataBufferSP utf8_data_buffer_sp;
- UTF8* utf8_data_ptr = nullptr;
- UTF8* utf8_data_end_ptr = nullptr;
-
- if (ConvertFunction)
- {
- utf8_data_buffer_sp.reset(new DataBufferHeap(bufferSPSize,0));
- utf8_data_ptr = (UTF8*)utf8_data_buffer_sp->GetBytes();
- utf8_data_end_ptr = utf8_data_ptr + bufferSPSize;
- ConvertFunction ( (const SourceDataType**)&data_ptr, data_end_ptr, &utf8_data_ptr, utf8_data_end_ptr, lenientConversion );
- utf8_data_ptr = (UTF8*)utf8_data_buffer_sp->GetBytes(); // needed because the ConvertFunction will change the value of the data_ptr
- }
- else
- {
- // just copy the pointers - the cast is necessary to make the compiler happy
- // but this should only happen if we are reading UTF8 data
- utf8_data_ptr = (UTF8*)data_ptr;
- utf8_data_end_ptr = (UTF8*)data_end_ptr;
- }
-
- // since we tend to accept partial data (and even partially malformed data)
- // we might end up with no NULL terminator before the end_ptr
- // hence we need to take a slower route and ensure we stay within boundaries
- for (;utf8_data_ptr != utf8_data_end_ptr; utf8_data_ptr++)
- {
- if (!*utf8_data_ptr)
- break;
- stream.Printf("%c",*utf8_data_ptr);
- }
- }
- if (quote != 0)
- stream.Printf("%c",quote);
- return true;
-}
-
-template<typename SourceDataType>
-static bool
-ReadUTFBufferAndDumpToStream (ConversionResult (*ConvertFunction) (const SourceDataType**,
- const SourceDataType*,
- UTF8**,
- UTF8*,
- ConversionFlags),
- uint64_t location,
- const ProcessSP& process_sp,
- Stream& stream,
- char prefix_token = '@',
- char quote = '"',
- int sourceSize = 0)
-{
- if (location == 0 || location == LLDB_INVALID_ADDRESS)
- return false;
- if (!process_sp)
- return false;
-
- const int origin_encoding = 8*sizeof(SourceDataType);
- if (origin_encoding != 8 && origin_encoding != 16 && origin_encoding != 32)
- return false;
- // if not UTF8, I need a conversion function to return proper UTF8
- if (origin_encoding != 8 && !ConvertFunction)
- return false;
-
- if (sourceSize == 0)
- sourceSize = process_sp->GetTarget().GetMaximumSizeOfStringSummary();
- const int bufferSPSize = sourceSize * (origin_encoding >> 2);
-
- Error error;
- lldb::DataBufferSP buffer_sp(new DataBufferHeap(bufferSPSize,0));
-
- if (!buffer_sp->GetBytes())
- return false;
-
- size_t data_read = process_sp->ReadMemoryFromInferior(location, (char*)buffer_sp->GetBytes(), bufferSPSize, error);
- if (error.Fail() || data_read == 0)
- {
- stream.Printf("unable to read data");
- return true;
- }
-
- DataExtractor data(buffer_sp, process_sp->GetByteOrder(), process_sp->GetAddressByteSize());
-
- return DumpUTFBufferToStream(ConvertFunction, data, stream, prefix_token, quote, sourceSize);
-}
-
-bool
-lldb_private::formatters::Char16StringSummaryProvider (ValueObject& valobj, Stream& stream)
-{
- ProcessSP process_sp = valobj.GetProcessSP();
- if (!process_sp)
- return false;
-
- lldb::addr_t valobj_addr = valobj.GetValueAsUnsigned(0);
-
- if (!valobj_addr)
- return false;
-
- if (!ReadUTFBufferAndDumpToStream<UTF16>(ConvertUTF16toUTF8,valobj_addr,
- process_sp,
- stream,
- 'u'))
- {
- stream.Printf("Summary Unavailable");
- return true;
- }
-
- return true;
-}
-
-bool
-lldb_private::formatters::Char32StringSummaryProvider (ValueObject& valobj, Stream& stream)
-{
- ProcessSP process_sp = valobj.GetProcessSP();
- if (!process_sp)
- return false;
-
- lldb::addr_t valobj_addr = valobj.GetValueAsUnsigned(0);
-
- if (!valobj_addr)
- return false;
-
- if (!ReadUTFBufferAndDumpToStream<UTF32>(ConvertUTF32toUTF8,valobj_addr,
- process_sp,
- stream,
- 'U'))
- {
- stream.Printf("Summary Unavailable");
- return true;
- }
-
- return true;
-}
-
-bool
-lldb_private::formatters::WCharStringSummaryProvider (ValueObject& valobj, Stream& stream)
-{
- ProcessSP process_sp = valobj.GetProcessSP();
- if (!process_sp)
- return false;
-
- lldb::addr_t data_addr = 0;
-
- if (valobj.IsPointerType())
- data_addr = valobj.GetValueAsUnsigned(0);
- else if (valobj.IsArrayType())
- data_addr = valobj.GetAddressOf();
-
- if (data_addr == 0 || data_addr == LLDB_INVALID_ADDRESS)
- return false;
-
- clang::ASTContext* ast = valobj.GetClangAST();
-
- if (!ast)
- return false;
-
- uint32_t wchar_size = ClangASTType::GetClangTypeBitWidth(ast, ClangASTType::GetBasicType(ast, lldb::eBasicTypeWChar).GetOpaqueQualType());
-
- switch (wchar_size)
- {
- case 8:
- // utf 8
- return ReadUTFBufferAndDumpToStream<UTF8>(nullptr, data_addr,
- process_sp,
- stream,
- 'L');
- case 16:
- // utf 16
- return ReadUTFBufferAndDumpToStream<UTF16>(ConvertUTF16toUTF8, data_addr,
- process_sp,
- stream,
- 'L');
- case 32:
- // utf 32
- return ReadUTFBufferAndDumpToStream<UTF32>(ConvertUTF32toUTF8, data_addr,
- process_sp,
- stream,
- 'L');
- default:
- stream.Printf("size for wchar_t is not valid");
- return true;
- }
- return true;
-}
-
-bool
-lldb_private::formatters::Char16SummaryProvider (ValueObject& valobj, Stream& stream)
-{
- DataExtractor data;
- valobj.GetData(data);
-
- std::string value;
- valobj.GetValueAsCString(lldb::eFormatUnicode16, value);
- if (!value.empty())
- stream.Printf("%s ", value.c_str());
-
- return DumpUTFBufferToStream<UTF16>(ConvertUTF16toUTF8,data,stream, 'u','\'',1);
-}
-
-bool
-lldb_private::formatters::Char32SummaryProvider (ValueObject& valobj, Stream& stream)
-{
- DataExtractor data;
- valobj.GetData(data);
-
- std::string value;
- valobj.GetValueAsCString(lldb::eFormatUnicode32, value);
- if (!value.empty())
- stream.Printf("%s ", value.c_str());
-
- return DumpUTFBufferToStream<UTF32>(ConvertUTF32toUTF8,data,stream, 'U','\'',1);
-}
-
-bool
-lldb_private::formatters::WCharSummaryProvider (ValueObject& valobj, Stream& stream)
-{
- DataExtractor data;
- valobj.GetData(data);
-
- clang::ASTContext* ast = valobj.GetClangAST();
-
- if (!ast)
- return false;
-
- std::string value;
-
- uint32_t wchar_size = ClangASTType::GetClangTypeBitWidth(ast, ClangASTType::GetBasicType(ast, lldb::eBasicTypeWChar).GetOpaqueQualType());
-
- switch (wchar_size)
- {
- case 8:
- // utf 8
- valobj.GetValueAsCString(lldb::eFormatChar, value);
- if (!value.empty())
- stream.Printf("%s ", value.c_str());
- return DumpUTFBufferToStream<UTF8>(nullptr,
- data,
- stream,
- 'L',
- '\'',
- 1);
- case 16:
- // utf 16
- valobj.GetValueAsCString(lldb::eFormatUnicode16, value);
- if (!value.empty())
- stream.Printf("%s ", value.c_str());
- return DumpUTFBufferToStream<UTF16>(ConvertUTF16toUTF8,
- data,
- stream,
- 'L',
- '\'',
- 1);
- case 32:
- // utf 32
- valobj.GetValueAsCString(lldb::eFormatUnicode32, value);
- if (!value.empty())
- stream.Printf("%s ", value.c_str());
- return DumpUTFBufferToStream<UTF32>(ConvertUTF32toUTF8,
- data,
- stream,
- 'L',
- '\'',
- 1);
- default:
- stream.Printf("size for wchar_t is not valid");
- return true;
- }
- return true;
-}
-
-// this function extracts information from a libcxx std::basic_string<>
-// irregardless of template arguments. it reports the size (in item count not bytes)
-// and the location in memory where the string data can be found
-static bool
-ExtractLibcxxStringInfo (ValueObject& valobj,
- ValueObjectSP &location_sp,
- uint64_t& size)
-{
- ValueObjectSP D(valobj.GetChildAtIndexPath({0,0,0,0}));
- if (!D)
- return false;
-
- ValueObjectSP size_mode(D->GetChildAtIndexPath({1,0,0}));
- if (!size_mode)
- return false;
-
- uint64_t size_mode_value(size_mode->GetValueAsUnsigned(0));
-
- if ((size_mode_value & 1) == 0) // this means the string is in short-mode and the data is stored inline
- {
- ValueObjectSP s(D->GetChildAtIndex(1, true));
- if (!s)
- return false;
- size = ((size_mode_value >> 1) % 256);
- location_sp = s->GetChildAtIndex(1, true);
- return (location_sp.get() != nullptr);
- }
- else
- {
- ValueObjectSP l(D->GetChildAtIndex(0, true));
- if (!l)
- return false;
- location_sp = l->GetChildAtIndex(2, true);
- ValueObjectSP size_vo(l->GetChildAtIndex(1, true));
- if (!size_vo || !location_sp)
- return false;
- size = size_vo->GetValueAsUnsigned(0);
- return true;
- }
-}
-
-bool
-lldb_private::formatters::LibcxxWStringSummaryProvider (ValueObject& valobj, Stream& stream)
-{
- uint64_t size = 0;
- ValueObjectSP location_sp((ValueObject*)nullptr);
- if (!ExtractLibcxxStringInfo(valobj, location_sp, size))
- return false;
- if (size == 0)
- {
- stream.Printf("L\"\"");
- return true;
- }
- if (!location_sp)
- return false;
- return WCharStringSummaryProvider(*location_sp.get(), stream);
-}
-
-bool
-lldb_private::formatters::LibcxxStringSummaryProvider (ValueObject& valobj, Stream& stream)
-{
- uint64_t size = 0;
- ValueObjectSP location_sp((ValueObject*)nullptr);
- if (!ExtractLibcxxStringInfo(valobj, location_sp, size))
- return false;
- if (size == 0)
- {
- stream.Printf("\"\"");
- return true;
- }
- if (!location_sp)
- return false;
- Error error;
- location_sp->ReadPointedString(stream,
- error,
- 0, // max length is decided by the settings
- false); // do not honor array (terminates on first 0 byte even for a char[])
- return error.Success();
-}
-
-template<bool name_entries>
-bool
-lldb_private::formatters::NSDictionarySummaryProvider (ValueObject& valobj, Stream& stream)
-{
- ProcessSP process_sp = valobj.GetProcessSP();
- if (!process_sp)
- return false;
-
- ObjCLanguageRuntime* runtime = (ObjCLanguageRuntime*)process_sp->GetLanguageRuntime(lldb::eLanguageTypeObjC);
-
- if (!runtime)
- return false;
-
- ObjCLanguageRuntime::ClassDescriptorSP descriptor(runtime->GetClassDescriptor(valobj));
-
- if (!descriptor.get() || !descriptor->IsValid())
- return false;
-
- uint32_t ptr_size = process_sp->GetAddressByteSize();
- bool is_64bit = (ptr_size == 8);
-
- lldb::addr_t valobj_addr = valobj.GetValueAsUnsigned(0);
-
- if (!valobj_addr)
- return false;
-
- uint64_t value = 0;
-
- const char* class_name = descriptor->GetClassName().GetCString();
-
- if (!class_name || !*class_name)
- return false;
-
- if (!strcmp(class_name,"__NSDictionaryI"))
- {
- Error error;
- value = process_sp->ReadUnsignedIntegerFromMemory(valobj_addr + ptr_size, ptr_size, 0, error);
- if (error.Fail())
- return false;
- value &= (is_64bit ? ~0xFC00000000000000UL : ~0xFC000000U);
- }
- else if (!strcmp(class_name,"__NSDictionaryM"))
- {
- Error error;
- value = process_sp->ReadUnsignedIntegerFromMemory(valobj_addr + ptr_size, ptr_size, 0, error);
- if (error.Fail())
- return false;
- value &= (is_64bit ? ~0xFC00000000000000UL : ~0xFC000000U);
- }
- else if (!strcmp(class_name,"__NSCFDictionary"))
- {
- Error error;
- value = process_sp->ReadUnsignedIntegerFromMemory(valobj_addr + (is_64bit ? 20 : 12), ptr_size, 0, error);
- if (error.Fail())
- return false;
- if (is_64bit)
- value &= ~0x0f1f000000000000UL;
- }
- else
- {
- if (!ExtractValueFromObjCExpression(valobj, "int", "count", value))
- return false;
- }
-
- stream.Printf("%s%" PRIu64 " %s%s",
- (name_entries ? "@\"" : ""),
- value,
- (name_entries ? (value == 1 ? "entry" : "entries") : (value == 1 ? "key/value pair" : "key/value pairs")),
- (name_entries ? "\"" : ""));
- return true;
-}
-
-bool
-lldb_private::formatters::NSArraySummaryProvider (ValueObject& valobj, Stream& stream)
-{
- ProcessSP process_sp = valobj.GetProcessSP();
- if (!process_sp)
- return false;
-
- ObjCLanguageRuntime* runtime = (ObjCLanguageRuntime*)process_sp->GetLanguageRuntime(lldb::eLanguageTypeObjC);
-
- if (!runtime)
- return false;
-
- ObjCLanguageRuntime::ClassDescriptorSP descriptor(runtime->GetClassDescriptor(valobj));
-
- if (!descriptor.get() || !descriptor->IsValid())
- return false;
-
- uint32_t ptr_size = process_sp->GetAddressByteSize();
-
- lldb::addr_t valobj_addr = valobj.GetValueAsUnsigned(0);
-
- if (!valobj_addr)
- return false;
-
- uint64_t value = 0;
-
- const char* class_name = descriptor->GetClassName().GetCString();
-
- if (!class_name || !*class_name)
- return false;
-
- if (!strcmp(class_name,"__NSArrayI"))
- {
- Error error;
- value = process_sp->ReadUnsignedIntegerFromMemory(valobj_addr + ptr_size, ptr_size, 0, error);
- if (error.Fail())
- return false;
- }
- else if (!strcmp(class_name,"__NSArrayM"))
- {
- Error error;
- value = process_sp->ReadUnsignedIntegerFromMemory(valobj_addr + ptr_size, ptr_size, 0, error);
- if (error.Fail())
- return false;
- }
- else if (!strcmp(class_name,"__NSCFArray"))
- {
- Error error;
- value = process_sp->ReadUnsignedIntegerFromMemory(valobj_addr + 2 * ptr_size, ptr_size, 0, error);
- if (error.Fail())
- return false;
- }
- else
- {
- if (!ExtractValueFromObjCExpression(valobj, "int", "count", value))
- return false;
- }
-
- stream.Printf("@\"%" PRIu64 " object%s\"",
- value,
- value == 1 ? "" : "s");
- return true;
-}
-
-template<bool needs_at>
-bool
-lldb_private::formatters::NSDataSummaryProvider (ValueObject& valobj, Stream& stream)
-{
- ProcessSP process_sp = valobj.GetProcessSP();
- if (!process_sp)
- return false;
-
- ObjCLanguageRuntime* runtime = (ObjCLanguageRuntime*)process_sp->GetLanguageRuntime(lldb::eLanguageTypeObjC);
-
- if (!runtime)
- return false;
-
- ObjCLanguageRuntime::ClassDescriptorSP descriptor(runtime->GetClassDescriptor(valobj));
-
- if (!descriptor.get() || !descriptor->IsValid())
- return false;
-
- bool is_64bit = (process_sp->GetAddressByteSize() == 8);
- lldb::addr_t valobj_addr = valobj.GetValueAsUnsigned(0);
-
- if (!valobj_addr)
- return false;
-
- uint64_t value = 0;
-
- const char* class_name = descriptor->GetClassName().GetCString();
-
- if (!class_name || !*class_name)
- return false;
-
- if (!strcmp(class_name,"NSConcreteData") ||
- !strcmp(class_name,"NSConcreteMutableData") ||
- !strcmp(class_name,"__NSCFData"))
- {
- uint32_t offset = (is_64bit ? 16 : 8);
- Error error;
- value = process_sp->ReadUnsignedIntegerFromMemory(valobj_addr + offset, is_64bit ? 8 : 4, 0, error);
- if (error.Fail())
- return false;
- }
- else
- {
- if (!ExtractValueFromObjCExpression(valobj, "int", "length", value))
- return false;
- }
-
- stream.Printf("%s%" PRIu64 " byte%s%s",
- (needs_at ? "@\"" : ""),
- value,
- (value > 1 ? "s" : ""),
- (needs_at ? "\"" : ""));
-
- return true;
-}
-
-bool
-lldb_private::formatters::NSNumberSummaryProvider (ValueObject& valobj, Stream& stream)
-{
- ProcessSP process_sp = valobj.GetProcessSP();
- if (!process_sp)
- return false;
-
- ObjCLanguageRuntime* runtime = (ObjCLanguageRuntime*)process_sp->GetLanguageRuntime(lldb::eLanguageTypeObjC);
-
- if (!runtime)
- return false;
-
- ObjCLanguageRuntime::ClassDescriptorSP descriptor(runtime->GetClassDescriptor(valobj));
-
- if (!descriptor.get() || !descriptor->IsValid())
- return false;
-
- uint32_t ptr_size = process_sp->GetAddressByteSize();
-
- lldb::addr_t valobj_addr = valobj.GetValueAsUnsigned(0);
-
- if (!valobj_addr)
- return false;
-
- const char* class_name = descriptor->GetClassName().GetCString();
-
- if (!class_name || !*class_name)
- return false;
-
- if (!strcmp(class_name,"NSNumber") || !strcmp(class_name,"__NSCFNumber"))
- {
- if (descriptor->IsTagged())
- {
- // we have a call to get info and value bits in the tagged descriptor. but we prefer not to cast and replicate them
- int64_t value = (valobj_addr & ~0x0000000000000000FFL) >> 8;
- uint64_t i_bits = (valobj_addr & 0xF0) >> 4;
-
- switch (i_bits)
- {
- case 0:
- stream.Printf("(char)%hhd",(char)value);
- break;
- case 4:
- stream.Printf("(short)%hd",(short)value);
- break;
- case 8:
- stream.Printf("(int)%d",(int)value);
- break;
- case 12:
- stream.Printf("(long)%" PRId64,value);
- break;
- default:
- stream.Printf("unexpected value:(info=%" PRIu64 ", value=%" PRIu64,i_bits,value);
- break;
- }
- return true;
- }
- else
- {
- Error error;
- uint8_t data_type = (process_sp->ReadUnsignedIntegerFromMemory(valobj_addr + ptr_size, 1, 0, error) & 0x1F);
- uint64_t data_location = valobj_addr + 2*ptr_size;
- uint64_t value = 0;
- if (error.Fail())
- return false;
- switch (data_type)
- {
- case 1: // 0B00001
- value = process_sp->ReadUnsignedIntegerFromMemory(data_location, 1, 0, error);
- if (error.Fail())
- return false;
- stream.Printf("(char)%hhd",(char)value);
- break;
- case 2: // 0B0010
- value = process_sp->ReadUnsignedIntegerFromMemory(data_location, 2, 0, error);
- if (error.Fail())
- return false;
- stream.Printf("(short)%hd",(short)value);
- break;
- case 3: // 0B0011
- value = process_sp->ReadUnsignedIntegerFromMemory(data_location, 4, 0, error);
- if (error.Fail())
- return false;
- stream.Printf("(int)%d",(int)value);
- break;
- case 17: // 0B10001
- data_location += 8;
- case 4: // 0B0100
- value = process_sp->ReadUnsignedIntegerFromMemory(data_location, 8, 0, error);
- if (error.Fail())
- return false;
- stream.Printf("(long)%" PRId64,value);
- break;
- case 5: // 0B0101
- {
- uint32_t flt_as_int = process_sp->ReadUnsignedIntegerFromMemory(data_location, 4, 0, error);
- if (error.Fail())
- return false;
- float flt_value = *((float*)&flt_as_int);
- stream.Printf("(float)%f",flt_value);
- break;
- }
- case 6: // 0B0110
- {
- uint64_t dbl_as_lng = process_sp->ReadUnsignedIntegerFromMemory(data_location, 8, 0, error);
- if (error.Fail())
- return false;
- double dbl_value = *((double*)&dbl_as_lng);
- stream.Printf("(double)%g",dbl_value);
- break;
- }
- default:
- stream.Printf("absurd: dt=%d",data_type);
- break;
- }
- return true;
- }
- }
- else
- {
- // similar to ExtractValueFromObjCExpression but uses summary instead of value
- StreamString expr_path_stream;
- valobj.GetExpressionPath(expr_path_stream, false);
- StreamString expr;
- expr.Printf("(NSString*)[%s stringValue]",expr_path_stream.GetData());
- ExecutionContext exe_ctx (valobj.GetExecutionContextRef());
- lldb::ValueObjectSP result_sp;
- Target* target = exe_ctx.GetTargetPtr();
- StackFrame* stack_frame = exe_ctx.GetFramePtr();
- if (!target || !stack_frame)
- return false;
-
- EvaluateExpressionOptions options;
- options.SetCoerceToId(false)
- .SetUnwindOnError(true)
- .SetKeepInMemory(true)
- .SetUseDynamic(lldb::eDynamicCanRunTarget);
-
- target->EvaluateExpression(expr.GetData(),
- stack_frame,
- result_sp,
- options);
- if (!result_sp)
- return false;
- stream.Printf("%s",result_sp->GetSummaryAsCString());
- return true;
- }
-}
-
-bool
-lldb_private::formatters::NSStringSummaryProvider (ValueObject& valobj, Stream& stream)
-{
- ProcessSP process_sp = valobj.GetProcessSP();
- if (!process_sp)
- return false;
-
- ObjCLanguageRuntime* runtime = (ObjCLanguageRuntime*)process_sp->GetLanguageRuntime(lldb::eLanguageTypeObjC);
-
- if (!runtime)
- return false;
-
- ObjCLanguageRuntime::ClassDescriptorSP descriptor(runtime->GetClassDescriptor(valobj));
-
- if (!descriptor.get() || !descriptor->IsValid())
- return false;
-
- uint32_t ptr_size = process_sp->GetAddressByteSize();
-
- lldb::addr_t valobj_addr = valobj.GetValueAsUnsigned(0);
-
- if (!valobj_addr)
- return false;
-
- const char* class_name = descriptor->GetClassName().GetCString();
-
- if (!class_name || !*class_name)
- return false;
-
- uint64_t info_bits_location = valobj_addr + ptr_size;
- if (process_sp->GetByteOrder() != lldb::eByteOrderLittle)
- info_bits_location += 3;
-
- Error error;
-
- uint8_t info_bits = process_sp->ReadUnsignedIntegerFromMemory(info_bits_location, 1, 0, error);
- if (error.Fail())
- return false;
-
- bool is_mutable = (info_bits & 1) == 1;
- bool is_inline = (info_bits & 0x60) == 0;
- bool has_explicit_length = (info_bits & (1 | 4)) != 4;
- bool is_unicode = (info_bits & 0x10) == 0x10;
- bool is_special = strcmp(class_name,"NSPathStore2") == 0;
-
- if (strcmp(class_name,"NSString") &&
- strcmp(class_name,"CFStringRef") &&
- strcmp(class_name,"CFMutableStringRef") &&
- strcmp(class_name,"__NSCFConstantString") &&
- strcmp(class_name,"__NSCFString") &&
- strcmp(class_name,"NSCFConstantString") &&
- strcmp(class_name,"NSCFString") &&
- strcmp(class_name,"NSPathStore2"))
- {
- // probably not one of us - bail out
- return false;
- }
-
- if (is_mutable)
- {
- uint64_t location = 2 * ptr_size + valobj_addr;
- location = process_sp->ReadPointerFromMemory(location, error);
- if (error.Fail())
- return false;
- if (has_explicit_length and is_unicode)
- return ReadUTFBufferAndDumpToStream<UTF16> (ConvertUTF16toUTF8,location, process_sp, stream, '@');
- else
- {
- location++;
- lldb::DataBufferSP buffer_sp(new DataBufferHeap(1024,0));
- size_t data_read = process_sp->ReadCStringFromMemory(location, (char*)buffer_sp->GetBytes(), 1024, error);
- if (error.Fail())
- return false;
- if (data_read)
- stream.Printf("@\"%s\"",(char*)buffer_sp->GetBytes());
- return true;
- }
- }
- else if (is_inline && has_explicit_length && !is_unicode && !is_special && !is_mutable)
- {
- uint64_t location = 3 * ptr_size + valobj_addr;
- lldb::DataBufferSP buffer_sp(new DataBufferHeap(1024,0));
- size_t data_read = process_sp->ReadCStringFromMemory(location, (char*)buffer_sp->GetBytes(), 1024, error);
- if (error.Fail())
- return false;
- if (data_read)
- stream.Printf("@\"%s\"",(char*)buffer_sp->GetBytes());
- return true;
- }
- else if (is_unicode)
- {
- uint64_t location = valobj_addr + ptr_size + 4 + (ptr_size == 8 ? 4 : 0);
- if (is_inline)
- {
- if (!has_explicit_length)
- {
- stream.Printf("found new combo");
- return true;
- }
- else
- location += ptr_size;
- }
- else
- {
- location = process_sp->ReadPointerFromMemory(location, error);
- if (error.Fail())
- return false;
- }
- return ReadUTFBufferAndDumpToStream<UTF16> (ConvertUTF16toUTF8, location, process_sp, stream, '@');
- }
- else if (is_special)
- {
- uint64_t location = valobj_addr + (ptr_size == 8 ? 12 : 8);
- return ReadUTFBufferAndDumpToStream<UTF16> (ConvertUTF16toUTF8, location, process_sp, stream, '@');
- }
- else if (is_inline)
- {
- uint64_t location = valobj_addr + ptr_size + 4 + (ptr_size == 8 ? 4 : 0);
- if (!has_explicit_length)
- location++;
- lldb::DataBufferSP buffer_sp(new DataBufferHeap(1024,0));
- size_t data_read = process_sp->ReadCStringFromMemory(location, (char*)buffer_sp->GetBytes(), 1024, error);
- if (error.Fail())
- return false;
- if (data_read)
- stream.Printf("@\"%s\"",(char*)buffer_sp->GetBytes());
- return true;
- }
- else
- {
- uint64_t location = valobj_addr + ptr_size + 4 + (ptr_size == 8 ? 4 : 0);
- location = process_sp->ReadPointerFromMemory(location, error);
- if (error.Fail())
- return false;
- lldb::DataBufferSP buffer_sp(new DataBufferHeap(1024,0));
- size_t data_read = process_sp->ReadCStringFromMemory(location, (char*)buffer_sp->GetBytes(), 1024, error);
- if (error.Fail())
- return false;
- if (data_read)
- stream.Printf("@\"%s\"",(char*)buffer_sp->GetBytes());
- return true;
- }
-
- stream.Printf("class name = %s",class_name);
- return true;
-
-}
-
-bool
-lldb_private::formatters::RuntimeSpecificDescriptionSummaryProvider (ValueObject& valobj, Stream& stream)
-{
- stream.Printf("%s",valobj.GetObjectDescription());
- return true;
-}
-
-bool
-lldb_private::formatters::ObjCBOOLSummaryProvider (ValueObject& valobj, Stream& stream)
-{
- const uint32_t type_info = ClangASTContext::GetTypeInfo(valobj.GetClangType(),
- valobj.GetClangAST(),
- NULL);
-
- ValueObjectSP real_guy_sp = valobj.GetSP();
-
- if (type_info & ClangASTContext::eTypeIsPointer)
- {
- Error err;
- real_guy_sp = valobj.Dereference(err);
- if (err.Fail() || !real_guy_sp)
- return false;
- }
- else if (type_info & ClangASTContext::eTypeIsReference)
- {
- real_guy_sp = valobj.GetChildAtIndex(0, true);
- if (!real_guy_sp)
- return false;
- }
- uint64_t value = real_guy_sp->GetValueAsUnsigned(0);
- if (value == 0)
- {
- stream.Printf("NO");
- return true;
- }
- stream.Printf("YES");
- return true;
-}
-
-template <bool is_sel_ptr>
-bool
-lldb_private::formatters::ObjCSELSummaryProvider (ValueObject& valobj, Stream& stream)
-{
- lldb::addr_t data_address = LLDB_INVALID_ADDRESS;
-
- if (is_sel_ptr)
- data_address = valobj.GetValueAsUnsigned(LLDB_INVALID_ADDRESS);
- else
- data_address = valobj.GetAddressOf();
-
- if (data_address == LLDB_INVALID_ADDRESS)
- return false;
-
- ExecutionContext exe_ctx(valobj.GetExecutionContextRef());
-
- void* char_opaque_type = valobj.GetClangAST()->CharTy.getAsOpaquePtr();
- ClangASTType charstar(valobj.GetClangAST(),ClangASTType::GetPointerType(valobj.GetClangAST(), char_opaque_type));
-
- ValueObjectSP valobj_sp(ValueObject::CreateValueObjectFromAddress("text", data_address, exe_ctx, charstar));
-
- stream.Printf("%s",valobj_sp->GetSummaryAsCString());
- return true;
-}
-
-lldb_private::formatters::NSArrayMSyntheticFrontEnd::NSArrayMSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) :
-SyntheticChildrenFrontEnd(*valobj_sp.get()),
-m_exe_ctx_ref(),
-m_ptr_size(8),
-m_data_32(NULL),
-m_data_64(NULL)
-{
- if (valobj_sp)
- {
- m_id_type = ClangASTType(valobj_sp->GetClangAST(),valobj_sp->GetClangAST()->ObjCBuiltinIdTy.getAsOpaquePtr());
- Update();
- }
-}
-
-size_t
-lldb_private::formatters::NSArrayMSyntheticFrontEnd::CalculateNumChildren ()
-{
- if (m_data_32)
- return m_data_32->_used;
- if (m_data_64)
- return m_data_64->_used;
- return 0;
-}
-
-lldb::ValueObjectSP
-lldb_private::formatters::NSArrayMSyntheticFrontEnd::GetChildAtIndex (size_t idx)
-{
- if (!m_data_32 && !m_data_64)
- return lldb::ValueObjectSP();
- if (idx >= CalculateNumChildren())
- return lldb::ValueObjectSP();
- lldb::addr_t object_at_idx = (m_data_32 ? m_data_32->_data : m_data_64->_data);
- object_at_idx += (idx * m_ptr_size);
- StreamString idx_name;
- idx_name.Printf("[%zu]",idx);
- lldb::ValueObjectSP retval_sp = ValueObject::CreateValueObjectFromAddress(idx_name.GetData(),
- object_at_idx,
- m_exe_ctx_ref,
- m_id_type);
- m_children.push_back(retval_sp);
- return retval_sp;
-}
-
-bool
-lldb_private::formatters::NSArrayMSyntheticFrontEnd::Update()
-{
- m_children.clear();
- ValueObjectSP valobj_sp = m_backend.GetSP();
- m_ptr_size = 0;
- delete m_data_32;
- m_data_32 = NULL;
- delete m_data_64;
- m_data_64 = NULL;
- if (valobj_sp->IsDynamic())
- valobj_sp = valobj_sp->GetStaticValue();
- if (!valobj_sp)
- return false;
- m_exe_ctx_ref = valobj_sp->GetExecutionContextRef();
- Error error;
- if (valobj_sp->IsPointerType())
- {
- valobj_sp = valobj_sp->Dereference(error);
- if (error.Fail() || !valobj_sp)
- return false;
- }
- error.Clear();
- lldb::ProcessSP process_sp(valobj_sp->GetProcessSP());
- if (!process_sp)
- return false;
- m_ptr_size = process_sp->GetAddressByteSize();
- uint64_t data_location = valobj_sp->GetAddressOf() + m_ptr_size;
- if (m_ptr_size == 4)
- {
- m_data_32 = new DataDescriptor_32();
- process_sp->ReadMemory (data_location, m_data_32, sizeof(DataDescriptor_32), error);
- }
- else
- {
- m_data_64 = new DataDescriptor_64();
- process_sp->ReadMemory (data_location, m_data_64, sizeof(DataDescriptor_64), error);
- }
- if (error.Fail())
- return false;
- return false;
-}
-
-bool
-lldb_private::formatters::NSArrayMSyntheticFrontEnd::MightHaveChildren ()
-{
- return true;
-}
-
-static uint32_t
-ExtractIndexFromString (const char* item_name)
-{
- if (!item_name || !*item_name)
- return UINT32_MAX;
- if (*item_name != '[')
- return UINT32_MAX;
- item_name++;
- uint32_t idx = 0;
- while(*item_name)
- {
- char x = *item_name;
- if (x == ']')
- break;
- if (x < '0' || x > '9')
- return UINT32_MAX;
- idx = 10*idx + (x-'0');
- item_name++;
- }
- return idx;
-}
-
-uint32_t
-lldb_private::formatters::NSArrayMSyntheticFrontEnd::GetIndexOfChildWithName (const ConstString &name)
-{
- if (!m_data_32 && !m_data_64)
- return UINT32_MAX;
- const char* item_name = name.GetCString();
- uint32_t idx = ExtractIndexFromString(item_name);
- if (idx < UINT32_MAX && idx >= CalculateNumChildren())
- return UINT32_MAX;
- return idx;
-}
-
-lldb_private::formatters::NSArrayMSyntheticFrontEnd::~NSArrayMSyntheticFrontEnd ()
-{
- delete m_data_32;
- m_data_32 = NULL;
- delete m_data_64;
- m_data_64 = NULL;
-}
-
-lldb_private::formatters::NSArrayISyntheticFrontEnd::NSArrayISyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) :
-SyntheticChildrenFrontEnd(*valobj_sp.get()),
-m_exe_ctx_ref(),
-m_ptr_size(8),
-m_items(0),
-m_data_ptr(0)
-{
- if (valobj_sp)
- {
- m_id_type = ClangASTType(valobj_sp->GetClangAST(),valobj_sp->GetClangAST()->ObjCBuiltinIdTy.getAsOpaquePtr());
- Update();
- }
-}
-
-lldb_private::formatters::NSArrayISyntheticFrontEnd::~NSArrayISyntheticFrontEnd ()
-{
-}
-
-uint32_t
-lldb_private::formatters::NSArrayISyntheticFrontEnd::GetIndexOfChildWithName (const ConstString &name)
-{
- const char* item_name = name.GetCString();
- uint32_t idx = ExtractIndexFromString(item_name);
- if (idx < UINT32_MAX && idx >= CalculateNumChildren())
- return UINT32_MAX;
- return idx;
-}
-
-size_t
-lldb_private::formatters::NSArrayISyntheticFrontEnd::CalculateNumChildren ()
-{
- return m_items;
-}
-
-bool
-lldb_private::formatters::NSArrayISyntheticFrontEnd::Update()
-{
- m_ptr_size = 0;
- m_items = 0;
- m_data_ptr = 0;
- m_children.clear();
- ValueObjectSP valobj_sp = m_backend.GetSP();
- if (valobj_sp->IsDynamic())
- valobj_sp = valobj_sp->GetStaticValue();
- if (!valobj_sp)
- return false;
- m_exe_ctx_ref = valobj_sp->GetExecutionContextRef();
- Error error;
- if (valobj_sp->IsPointerType())
- {
- valobj_sp = valobj_sp->Dereference(error);
- if (error.Fail() || !valobj_sp)
- return false;
- }
- error.Clear();
- lldb::ProcessSP process_sp(valobj_sp->GetProcessSP());
- if (!process_sp)
- return false;
- m_ptr_size = process_sp->GetAddressByteSize();
- uint64_t data_location = valobj_sp->GetAddressOf() + m_ptr_size;
- m_items = process_sp->ReadPointerFromMemory(data_location, error);
- if (error.Fail())
- return false;
- m_data_ptr = data_location+m_ptr_size;
- return false;
-}
-
-bool
-lldb_private::formatters::NSArrayISyntheticFrontEnd::MightHaveChildren ()
-{
- return true;
-}
-
-lldb::ValueObjectSP
-lldb_private::formatters::NSArrayISyntheticFrontEnd::GetChildAtIndex (size_t idx)
-{
- if (idx >= CalculateNumChildren())
- return lldb::ValueObjectSP();
- lldb::addr_t object_at_idx = m_data_ptr;
- object_at_idx += (idx * m_ptr_size);
- ProcessSP process_sp = m_exe_ctx_ref.GetProcessSP();
- if (!process_sp)
- return lldb::ValueObjectSP();
- Error error;
- object_at_idx = process_sp->ReadPointerFromMemory(object_at_idx, error);
- if (error.Fail())
- return lldb::ValueObjectSP();
- StreamString expr;
- expr.Printf("(id)%" PRIu64,object_at_idx);
- StreamString idx_name;
- idx_name.Printf("[%zu]",idx);
- lldb::ValueObjectSP retval_sp = ValueObject::CreateValueObjectFromExpression(idx_name.GetData(), expr.GetData(), m_exe_ctx_ref);
- m_children.push_back(retval_sp);
- return retval_sp;
-}
-
-SyntheticChildrenFrontEnd* lldb_private::formatters::NSArraySyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP valobj_sp)
-{
- lldb::ProcessSP process_sp (valobj_sp->GetProcessSP());
- if (!process_sp)
- return NULL;
- ObjCLanguageRuntime *runtime = (ObjCLanguageRuntime*)process_sp->GetLanguageRuntime(lldb::eLanguageTypeObjC);
- if (!runtime)
- return NULL;
-
- if (!valobj_sp->IsPointerType())
- {
- Error error;
- valobj_sp = valobj_sp->AddressOf(error);
- if (error.Fail() || !valobj_sp)
- return NULL;
- }
-
- ObjCLanguageRuntime::ClassDescriptorSP descriptor(runtime->GetClassDescriptor(*valobj_sp.get()));
-
- if (!descriptor.get() || !descriptor->IsValid())
- return NULL;
-
- const char* class_name = descriptor->GetClassName().GetCString();
-
- if (!class_name || !*class_name)
- return NULL;
-
- if (!strcmp(class_name,"__NSArrayI"))
- {
- return (new NSArrayISyntheticFrontEnd(valobj_sp));
- }
- else if (!strcmp(class_name,"__NSArrayM"))
- {
- return (new NSArrayMSyntheticFrontEnd(valobj_sp));
- }
- else
- {
- return (new NSArrayCodeRunningSyntheticFrontEnd(valobj_sp));
- }
-}
-
-lldb_private::formatters::NSArrayCodeRunningSyntheticFrontEnd::NSArrayCodeRunningSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) :
-SyntheticChildrenFrontEnd(*valobj_sp.get())
-{}
-
-size_t
-lldb_private::formatters::NSArrayCodeRunningSyntheticFrontEnd::CalculateNumChildren ()
-{
- uint64_t count = 0;
- if (ExtractValueFromObjCExpression(m_backend, "int", "count", count))
- return count;
- return 0;
-}
-
-lldb::ValueObjectSP
-lldb_private::formatters::NSArrayCodeRunningSyntheticFrontEnd::GetChildAtIndex (size_t idx)
-{
- StreamString idx_name;
- idx_name.Printf("[%zu]",idx);
- lldb::ValueObjectSP valobj_sp = CallSelectorOnObject(m_backend,"id","objectAtIndex:",idx);
- if (valobj_sp)
- valobj_sp->SetName(ConstString(idx_name.GetData()));
- return valobj_sp;
-}
-
-bool
-lldb_private::formatters::NSArrayCodeRunningSyntheticFrontEnd::Update()
-{
- return false;
-}
-
-bool
-lldb_private::formatters::NSArrayCodeRunningSyntheticFrontEnd::MightHaveChildren ()
-{
- return true;
-}
-
-uint32_t
-lldb_private::formatters::NSArrayCodeRunningSyntheticFrontEnd::GetIndexOfChildWithName (const ConstString &name)
-{
- return 0;
-}
-
-lldb_private::formatters::NSArrayCodeRunningSyntheticFrontEnd::~NSArrayCodeRunningSyntheticFrontEnd ()
-{}
-
-SyntheticChildrenFrontEnd* lldb_private::formatters::NSDictionarySyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP valobj_sp)
-{
-
- lldb::ProcessSP process_sp (valobj_sp->GetProcessSP());
- if (!process_sp)
- return NULL;
- ObjCLanguageRuntime *runtime = (ObjCLanguageRuntime*)process_sp->GetLanguageRuntime(lldb::eLanguageTypeObjC);
- if (!runtime)
- return NULL;
-
- if (!valobj_sp->IsPointerType())
- {
- Error error;
- valobj_sp = valobj_sp->AddressOf(error);
- if (error.Fail() || !valobj_sp)
- return NULL;
- }
-
- ObjCLanguageRuntime::ClassDescriptorSP descriptor(runtime->GetClassDescriptor(*valobj_sp.get()));
-
- if (!descriptor.get() || !descriptor->IsValid())
- return NULL;
-
- const char* class_name = descriptor->GetClassName().GetCString();
-
- if (!class_name || !*class_name)
- return NULL;
-
- if (!strcmp(class_name,"__NSDictionaryI"))
- {
- return (new NSDictionaryISyntheticFrontEnd(valobj_sp));
- }
- else if (!strcmp(class_name,"__NSDictionaryM"))
- {
- return (new NSDictionaryMSyntheticFrontEnd(valobj_sp));
- }
- else
- {
- return (new NSDictionaryCodeRunningSyntheticFrontEnd(valobj_sp));
- }
-}
-
-lldb_private::formatters::NSDictionaryCodeRunningSyntheticFrontEnd::NSDictionaryCodeRunningSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) :
-SyntheticChildrenFrontEnd(*valobj_sp.get())
-{}
-
-size_t
-lldb_private::formatters::NSDictionaryCodeRunningSyntheticFrontEnd::CalculateNumChildren ()
-{
- uint64_t count = 0;
- if (ExtractValueFromObjCExpression(m_backend, "int", "count", count))
- return count;
- return 0;
-}
-
-lldb::ValueObjectSP
-lldb_private::formatters::NSDictionaryCodeRunningSyntheticFrontEnd::GetChildAtIndex (size_t idx)
-{
- StreamString idx_name;
- idx_name.Printf("[%zu]",idx);
- StreamString valobj_expr_path;
- m_backend.GetExpressionPath(valobj_expr_path, false);
- StreamString key_fetcher_expr;
- key_fetcher_expr.Printf("(id)[(NSArray*)[%s allKeys] objectAtIndex:%zu]",valobj_expr_path.GetData(),idx);
- StreamString value_fetcher_expr;
- value_fetcher_expr.Printf("(id)[%s objectForKey:%s]",valobj_expr_path.GetData(),key_fetcher_expr.GetData());
- StreamString object_fetcher_expr;
- object_fetcher_expr.Printf("struct __lldb_autogen_nspair { id key; id value; } _lldb_valgen_item; _lldb_valgen_item.key = %s; _lldb_valgen_item.value = %s; _lldb_valgen_item;",key_fetcher_expr.GetData(),value_fetcher_expr.GetData());
- lldb::ValueObjectSP child_sp;
- m_backend.GetTargetSP()->EvaluateExpression(object_fetcher_expr.GetData(), m_backend.GetFrameSP().get(), child_sp,
- EvaluateExpressionOptions().SetKeepInMemory(true));
- if (child_sp)
- child_sp->SetName(ConstString(idx_name.GetData()));
- return child_sp;
-}
-
-bool
-lldb_private::formatters::NSDictionaryCodeRunningSyntheticFrontEnd::Update()
-{
- return false;
-}
-
-bool
-lldb_private::formatters::NSDictionaryCodeRunningSyntheticFrontEnd::MightHaveChildren ()
-{
- return true;
-}
-
-uint32_t
-lldb_private::formatters::NSDictionaryCodeRunningSyntheticFrontEnd::GetIndexOfChildWithName (const ConstString &name)
-{
- return 0;
-}
-
-lldb_private::formatters::NSDictionaryCodeRunningSyntheticFrontEnd::~NSDictionaryCodeRunningSyntheticFrontEnd ()
-{}
-
-lldb_private::formatters::NSDictionaryISyntheticFrontEnd::NSDictionaryISyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) :
- SyntheticChildrenFrontEnd(*valobj_sp.get()),
- m_exe_ctx_ref(),
- m_ptr_size(8),
- m_data_32(NULL),
- m_data_64(NULL)
-{
- if (valobj_sp)
- Update();
-}
-
-lldb_private::formatters::NSDictionaryISyntheticFrontEnd::~NSDictionaryISyntheticFrontEnd ()
-{
- delete m_data_32;
- m_data_32 = NULL;
- delete m_data_64;
- m_data_64 = NULL;
-}
-
-uint32_t
-lldb_private::formatters::NSDictionaryISyntheticFrontEnd::GetIndexOfChildWithName (const ConstString &name)
-{
- const char* item_name = name.GetCString();
- uint32_t idx = ExtractIndexFromString(item_name);
- if (idx < UINT32_MAX && idx >= CalculateNumChildren())
- return UINT32_MAX;
- return idx;
-}
-
-size_t
-lldb_private::formatters::NSDictionaryISyntheticFrontEnd::CalculateNumChildren ()
-{
- if (!m_data_32 && !m_data_64)
- return 0;
- return (m_data_32 ? m_data_32->_used : m_data_64->_used);
-}
-
-bool
-lldb_private::formatters::NSDictionaryISyntheticFrontEnd::Update()
-{
- m_children.clear();
- delete m_data_32;
- m_data_32 = NULL;
- delete m_data_64;
- m_data_64 = NULL;
- m_ptr_size = 0;
- ValueObjectSP valobj_sp = m_backend.GetSP();
- if (!valobj_sp)
- return false;
- if (valobj_sp->IsDynamic())
- valobj_sp = valobj_sp->GetStaticValue();
- if (!valobj_sp)
- return false;
- m_exe_ctx_ref = valobj_sp->GetExecutionContextRef();
- Error error;
- if (valobj_sp->IsPointerType())
- {
- valobj_sp = valobj_sp->Dereference(error);
- if (error.Fail() || !valobj_sp)
- return false;
- }
- error.Clear();
- lldb::ProcessSP process_sp(valobj_sp->GetProcessSP());
- if (!process_sp)
- return false;
- m_ptr_size = process_sp->GetAddressByteSize();
- uint64_t data_location = valobj_sp->GetAddressOf() + m_ptr_size;
- if (m_ptr_size == 4)
- {
- m_data_32 = new DataDescriptor_32();
- process_sp->ReadMemory (data_location, m_data_32, sizeof(DataDescriptor_32), error);
- }
- else
- {
- m_data_64 = new DataDescriptor_64();
- process_sp->ReadMemory (data_location, m_data_64, sizeof(DataDescriptor_64), error);
- }
- if (error.Fail())
- return false;
- m_data_ptr = data_location + m_ptr_size;
- return false;
-}
-
-bool
-lldb_private::formatters::NSDictionaryISyntheticFrontEnd::MightHaveChildren ()
-{
- return true;
-}
-
-lldb::ValueObjectSP
-lldb_private::formatters::NSDictionaryISyntheticFrontEnd::GetChildAtIndex (size_t idx)
-{
- uint32_t num_children = CalculateNumChildren();
-
- if (idx >= num_children)
- return lldb::ValueObjectSP();
-
- if (m_children.empty())
- {
- // do the scan phase
- lldb::addr_t key_at_idx = 0, val_at_idx = 0;
-
- uint32_t tries = 0;
- uint32_t test_idx = 0;
-
- while(tries < num_children)
- {
- key_at_idx = m_data_ptr + (2*test_idx * m_ptr_size);
- val_at_idx = key_at_idx + m_ptr_size;
- ProcessSP process_sp = m_exe_ctx_ref.GetProcessSP();
- if (!process_sp)
- return lldb::ValueObjectSP();
- Error error;
- key_at_idx = process_sp->ReadPointerFromMemory(key_at_idx, error);
- if (error.Fail())
- return lldb::ValueObjectSP();
- val_at_idx = process_sp->ReadPointerFromMemory(val_at_idx, error);
- if (error.Fail())
- return lldb::ValueObjectSP();
-
- test_idx++;
-
- if (!key_at_idx || !val_at_idx)
- continue;
- tries++;
-
- DictionaryItemDescriptor descriptor = {key_at_idx,val_at_idx,lldb::ValueObjectSP()};
-
- m_children.push_back(descriptor);
- }
- }
-
- if (idx >= m_children.size()) // should never happen
- return lldb::ValueObjectSP();
-
- DictionaryItemDescriptor &dict_item = m_children[idx];
- if (!dict_item.valobj_sp)
- {
- // make the new ValueObject
- StreamString expr;
- expr.Printf("struct __lldb_autogen_nspair { id key; id value; } _lldb_valgen_item; _lldb_valgen_item.key = (id)%" PRIu64 " ; _lldb_valgen_item.value = (id)%" PRIu64 "; _lldb_valgen_item;",dict_item.key_ptr,dict_item.val_ptr);
- StreamString idx_name;
- idx_name.Printf("[%zu]",idx);
- dict_item.valobj_sp = ValueObject::CreateValueObjectFromExpression(idx_name.GetData(), expr.GetData(), m_exe_ctx_ref);
- }
- return dict_item.valobj_sp;
-}
-
-lldb_private::formatters::NSDictionaryMSyntheticFrontEnd::NSDictionaryMSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) :
- SyntheticChildrenFrontEnd(*valobj_sp.get()),
- m_exe_ctx_ref(),
- m_ptr_size(8),
- m_data_32(NULL),
- m_data_64(NULL)
-{
- if (valobj_sp)
- Update ();
-}
-
-lldb_private::formatters::NSDictionaryMSyntheticFrontEnd::~NSDictionaryMSyntheticFrontEnd ()
-{
- delete m_data_32;
- m_data_32 = NULL;
- delete m_data_64;
- m_data_64 = NULL;
-}
-
-uint32_t
-lldb_private::formatters::NSDictionaryMSyntheticFrontEnd::GetIndexOfChildWithName (const ConstString &name)
-{
- const char* item_name = name.GetCString();
- uint32_t idx = ExtractIndexFromString(item_name);
- if (idx < UINT32_MAX && idx >= CalculateNumChildren())
- return UINT32_MAX;
- return idx;
-}
-
-size_t
-lldb_private::formatters::NSDictionaryMSyntheticFrontEnd::CalculateNumChildren ()
-{
- if (!m_data_32 && !m_data_64)
- return 0;
- return (m_data_32 ? m_data_32->_used : m_data_64->_used);
-}
-
-bool
-lldb_private::formatters::NSDictionaryMSyntheticFrontEnd::Update()
-{
- m_children.clear();
- ValueObjectSP valobj_sp = m_backend.GetSP();
- m_ptr_size = 0;
- delete m_data_32;
- m_data_32 = NULL;
- delete m_data_64;
- m_data_64 = NULL;
- if (!valobj_sp)
- return false;
- if (valobj_sp->IsDynamic())
- valobj_sp = valobj_sp->GetStaticValue();
- if (!valobj_sp)
- return false;
- m_exe_ctx_ref = valobj_sp->GetExecutionContextRef();
- Error error;
- if (valobj_sp->IsPointerType())
- {
- valobj_sp = valobj_sp->Dereference(error);
- if (error.Fail() || !valobj_sp)
- return false;
- }
- error.Clear();
- lldb::ProcessSP process_sp(valobj_sp->GetProcessSP());
- if (!process_sp)
- return false;
- m_ptr_size = process_sp->GetAddressByteSize();
- uint64_t data_location = valobj_sp->GetAddressOf() + m_ptr_size;
- if (m_ptr_size == 4)
- {
- m_data_32 = new DataDescriptor_32();
- process_sp->ReadMemory (data_location, m_data_32, sizeof(DataDescriptor_32), error);
- }
- else
- {
- m_data_64 = new DataDescriptor_64();
- process_sp->ReadMemory (data_location, m_data_64, sizeof(DataDescriptor_64), error);
- }
- if (error.Fail())
- return false;
- return false;
-}
-
-bool
-lldb_private::formatters::NSDictionaryMSyntheticFrontEnd::MightHaveChildren ()
-{
- return true;
-}
-
-lldb::ValueObjectSP
-lldb_private::formatters::NSDictionaryMSyntheticFrontEnd::GetChildAtIndex (size_t idx)
-{
- lldb::addr_t m_keys_ptr = (m_data_32 ? m_data_32->_keys_addr : m_data_64->_keys_addr);
- lldb::addr_t m_values_ptr = (m_data_32 ? m_data_32->_objs_addr : m_data_64->_objs_addr);
-
- uint32_t num_children = CalculateNumChildren();
-
- if (idx >= num_children)
- return lldb::ValueObjectSP();
-
- if (m_children.empty())
- {
- // do the scan phase
- lldb::addr_t key_at_idx = 0, val_at_idx = 0;
-
- uint32_t tries = 0;
- uint32_t test_idx = 0;
-
- while(tries < num_children)
- {
- key_at_idx = m_keys_ptr + (test_idx * m_ptr_size);
- val_at_idx = m_values_ptr + (test_idx * m_ptr_size);;
- ProcessSP process_sp = m_exe_ctx_ref.GetProcessSP();
- if (!process_sp)
- return lldb::ValueObjectSP();
- Error error;
- key_at_idx = process_sp->ReadPointerFromMemory(key_at_idx, error);
- if (error.Fail())
- return lldb::ValueObjectSP();
- val_at_idx = process_sp->ReadPointerFromMemory(val_at_idx, error);
- if (error.Fail())
- return lldb::ValueObjectSP();
-
- test_idx++;
-
- if (!key_at_idx || !val_at_idx)
- continue;
- tries++;
-
- DictionaryItemDescriptor descriptor = {key_at_idx,val_at_idx,lldb::ValueObjectSP()};
-
- m_children.push_back(descriptor);
- }
- }
-
- if (idx >= m_children.size()) // should never happen
- return lldb::ValueObjectSP();
-
- DictionaryItemDescriptor &dict_item = m_children[idx];
- if (!dict_item.valobj_sp)
- {
- // make the new ValueObject
- StreamString expr;
- expr.Printf("struct __lldb_autogen_nspair { id key; id value; } _lldb_valgen_item; _lldb_valgen_item.key = (id)%" PRIu64 " ; _lldb_valgen_item.value = (id)%" PRIu64 "; _lldb_valgen_item;",dict_item.key_ptr,dict_item.val_ptr);
- StreamString idx_name;
- idx_name.Printf("[%zu]",idx);
- dict_item.valobj_sp = ValueObject::CreateValueObjectFromExpression(idx_name.GetData(), expr.GetData(), m_exe_ctx_ref);
- }
- return dict_item.valobj_sp;
-}
-
-template bool
-lldb_private::formatters::NSDictionarySummaryProvider<true> (ValueObject&, Stream&) ;
-
-template bool
-lldb_private::formatters::NSDictionarySummaryProvider<false> (ValueObject&, Stream&) ;
-
-template bool
-lldb_private::formatters::NSDataSummaryProvider<true> (ValueObject&, Stream&) ;
-
-template bool
-lldb_private::formatters::NSDataSummaryProvider<false> (ValueObject&, Stream&) ;
-
-template bool
-lldb_private::formatters::ObjCSELSummaryProvider<true> (ValueObject&, Stream&) ;
-
-template bool
-lldb_private::formatters::ObjCSELSummaryProvider<false> (ValueObject&, Stream&) ;
Removed: lldb/trunk/source/Core/DataVisualization.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/DataVisualization.cpp?rev=173727&view=auto
==============================================================================
--- lldb/trunk/source/Core/DataVisualization.cpp (original)
+++ lldb/trunk/source/Core/DataVisualization.cpp (removed)
@@ -1,279 +0,0 @@
-//===-- DataVisualization.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/lldb-python.h"
-
-#include "lldb/Core/DataVisualization.h"
-
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
-
-#include "lldb/Core/Debugger.h"
-
-using namespace lldb;
-using namespace lldb_private;
-
-static FormatManager&
-GetFormatManager()
-{
- static FormatManager g_format_manager;
- return g_format_manager;
-}
-
-void
-DataVisualization::ForceUpdate ()
-{
- GetFormatManager().Changed();
-}
-
-uint32_t
-DataVisualization::GetCurrentRevision ()
-{
- return GetFormatManager().GetCurrentRevision();
-}
-
-lldb::TypeFormatImplSP
-DataVisualization::ValueFormats::GetFormat (ValueObject& valobj, lldb::DynamicValueType use_dynamic)
-{
- 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::TypeFormatImplSP &entry)
-{
- GetFormatManager().GetValueNavigator().Add(FormatManager::GetValidTypeName(type),entry);
-}
-
-bool
-DataVisualization::ValueFormats::Delete (const ConstString &type)
-{
- return GetFormatManager().GetValueNavigator().Delete(type);
-}
-
-void
-DataVisualization::ValueFormats::Clear ()
-{
- GetFormatManager().GetValueNavigator().Clear();
-}
-
-void
-DataVisualization::ValueFormats::LoopThrough (TypeFormatImpl::ValueCallback callback, void* callback_baton)
-{
- GetFormatManager().GetValueNavigator().LoopThrough(callback, callback_baton);
-}
-
-uint32_t
-DataVisualization::ValueFormats::GetCount ()
-{
- return GetFormatManager().GetValueNavigator().GetCount();
-}
-
-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)
-{
- return GetFormatManager().GetSummaryFormat(valobj, use_dynamic);
-}
-
-lldb::TypeSummaryImplSP
-DataVisualization::GetSummaryForType (lldb::TypeNameSpecifierImplSP type_sp)
-{
- return GetFormatManager().GetSummaryForType(type_sp);
-}
-
-#ifndef LLDB_DISABLE_PYTHON
-lldb::SyntheticChildrenSP
-DataVisualization::GetSyntheticChildren (ValueObject& valobj,
- lldb::DynamicValueType use_dynamic)
-{
- return GetFormatManager().GetSyntheticChildren(valobj, use_dynamic);
-}
-#endif
-
-#ifndef LLDB_DISABLE_PYTHON
-lldb::SyntheticChildrenSP
-DataVisualization::GetSyntheticChildrenForType (lldb::TypeNameSpecifierImplSP type_sp)
-{
- return GetFormatManager().GetSyntheticChildrenForType(type_sp);
-}
-#endif
-
-lldb::TypeFilterImplSP
-DataVisualization::GetFilterForType (lldb::TypeNameSpecifierImplSP type_sp)
-{
- return GetFormatManager().GetFilterForType(type_sp);
-}
-
-#ifndef LLDB_DISABLE_PYTHON
-lldb::TypeSyntheticImplSP
-DataVisualization::GetSyntheticForType (lldb::TypeNameSpecifierImplSP type_sp)
-{
- return GetFormatManager().GetSyntheticForType(type_sp);
-}
-#endif
-
-bool
-DataVisualization::AnyMatches (ConstString type_name,
- TypeCategoryImpl::FormatCategoryItems items,
- bool only_enabled,
- const char** matching_category,
- TypeCategoryImpl::FormatCategoryItems* matching_type)
-{
- return GetFormatManager().AnyMatches(type_name,
- items,
- only_enabled,
- matching_category,
- matching_type);
-}
-
-bool
-DataVisualization::Categories::GetCategory (const ConstString &category, lldb::TypeCategoryImplSP &entry,
- bool allow_create)
-{
- entry = GetFormatManager().GetCategory(category, allow_create);
- return (entry.get() != NULL);
-}
-
-void
-DataVisualization::Categories::Add (const ConstString &category)
-{
- GetFormatManager().GetCategory(category);
-}
-
-bool
-DataVisualization::Categories::Delete (const ConstString &category)
-{
- GetFormatManager().DisableCategory(category);
- return GetFormatManager().DeleteCategory(category);
-}
-
-void
-DataVisualization::Categories::Clear ()
-{
- GetFormatManager().ClearCategories();
-}
-
-void
-DataVisualization::Categories::Clear (const ConstString &category)
-{
- GetFormatManager().GetCategory(category)->Clear(eFormatCategoryItemSummary | eFormatCategoryItemRegexSummary);
-}
-
-void
-DataVisualization::Categories::Enable (const ConstString& category,
- CategoryMap::Position pos)
-{
- if (GetFormatManager().GetCategory(category)->IsEnabled())
- GetFormatManager().DisableCategory(category);
- GetFormatManager().EnableCategory(category, pos);
-}
-
-void
-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);
-}
-
-uint32_t
-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::TypeSummaryImplSP &entry)
-{
- return GetFormatManager().GetNamedSummaryNavigator().Get(type,entry);
-}
-
-void
-DataVisualization::NamedSummaryFormats::Add (const ConstString &type, const lldb::TypeSummaryImplSP &entry)
-{
- GetFormatManager().GetNamedSummaryNavigator().Add(FormatManager::GetValidTypeName(type),entry);
-}
-
-bool
-DataVisualization::NamedSummaryFormats::Delete (const ConstString &type)
-{
- return GetFormatManager().GetNamedSummaryNavigator().Delete(type);
-}
-
-void
-DataVisualization::NamedSummaryFormats::Clear ()
-{
- GetFormatManager().GetNamedSummaryNavigator().Clear();
-}
-
-void
-DataVisualization::NamedSummaryFormats::LoopThrough (TypeSummaryImpl::SummaryCallback callback, void* callback_baton)
-{
- GetFormatManager().GetNamedSummaryNavigator().LoopThrough(callback, callback_baton);
-}
-
-uint32_t
-DataVisualization::NamedSummaryFormats::GetCount ()
-{
- return GetFormatManager().GetNamedSummaryNavigator().GetCount();
-}
Modified: lldb/trunk/source/Core/Debugger.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=173728&r1=173727&r2=173728&view=diff
==============================================================================
--- lldb/trunk/source/Core/Debugger.cpp (original)
+++ lldb/trunk/source/Core/Debugger.cpp Mon Jan 28 17:47:25 2013
@@ -20,8 +20,6 @@
#include "lldb/lldb-private.h"
#include "lldb/Core/ConnectionFileDescriptor.h"
-#include "lldb/Core/DataVisualization.h"
-#include "lldb/Core/FormatManager.h"
#include "lldb/Core/InputReader.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
@@ -33,6 +31,8 @@
#include "lldb/Core/Timer.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectVariable.h"
+#include "lldb/DataFormatters/DataVisualization.h"
+#include "lldb/DataFormatters/FormatManager.h"
#include "lldb/Host/DynamicLibrary.h"
#include "lldb/Host/Terminal.h"
#include "lldb/Interpreter/CommandInterpreter.h"
Removed: lldb/trunk/source/Core/FormatClasses.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/FormatClasses.cpp?rev=173727&view=auto
==============================================================================
--- lldb/trunk/source/Core/FormatClasses.cpp (original)
+++ lldb/trunk/source/Core/FormatClasses.cpp (removed)
@@ -1,409 +0,0 @@
-//===-- FormatClasses.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/lldb-python.h"
-
-// C Includes
-
-// C++ Includes
-
-// 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/Core/Timer.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;
-
-TypeFormatImpl::TypeFormatImpl (lldb::Format f,
- const Flags& flags) :
- m_flags(flags),
- m_format (f)
-{
-}
-
-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();
-}
-
-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);
-}
-
-bool
-StringSummaryFormat::FormatObject(ValueObject *valobj,
- std::string& retval)
-{
- if (!valobj)
- {
- retval.assign("NULL ValueObject");
- return false;
- }
-
- StreamString s;
- ExecutionContext exe_ctx (valobj->GetExecutionContextRef());
- SymbolContext sc;
- StackFrame *frame = exe_ctx.GetFramePtr();
- if (frame)
- sc = frame->GetSymbolContext(lldb::eSymbolContextEverything);
-
- if (IsOneliner())
- {
- ValueObject* object;
-
- ValueObjectSP synth_valobj = valobj->GetSyntheticValue();
- if (synth_valobj)
- object = synth_valobj.get();
- else
- object = valobj;
-
- 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(", ");
- if (!HideNames())
- {
- s.PutCString(child_sp.get()->GetName().AsCString());
- s.PutCString(" = ");
- }
- child_sp.get()->DumpPrintableRepresentation(s,
- ValueObject::eValueObjectRepresentationStyleSummary,
- lldb::eFormatInvalid,
- ValueObject::ePrintableRepresentationSpecialCasesDisable);
- }
- }
-
- s.PutChar(')');
-
- retval.assign(s.GetString());
- return true;
- }
- else
- {
- retval.assign("error: oneliner for no children");
- return false;
- }
-
- }
- else
- {
- if (Debugger::FormatPrompt(m_format.c_str(), &sc, &exe_ctx, &sc.line_entry.range.GetBaseAddress(), s, NULL, valobj))
- {
- retval.assign(s.GetString());
- return true;
- }
- else
- {
- retval.assign("error: summary string parsing error");
- return false;
- }
- }
-}
-
-std::string
-StringSummaryFormat::GetDescription()
-{
- StreamString sstr;
-
- sstr.Printf ("`%s`%s%s%s%s%s%s%s", m_format.c_str(),
- Cascades() ? "" : " (not cascading)",
- !DoesPrintChildren() ? "" : " (show children)",
- !DoesPrintValue() ? " (hide value)" : "",
- IsOneliner() ? " (one-line printout)" : "",
- SkipsPointers() ? " (skip pointers)" : "",
- SkipsReferences() ? " (skip references)" : "",
- HideNames() ? " (hide member names)" : "");
- return sstr.GetString();
-}
-
-CXXFunctionSummaryFormat::CXXFunctionSummaryFormat (const TypeSummaryImpl::Flags& flags,
- Callback impl,
- const char* description) :
- TypeSummaryImpl(flags),
- m_impl(impl),
- m_description(description ? description : "")
-{
-}
-
-bool
-CXXFunctionSummaryFormat::FormatObject(ValueObject *valobj,
- std::string& dest)
-{
- dest.clear();
- StreamString stream;
- if (!m_impl || m_impl(*valobj,stream) == false)
- return false;
- dest.assign(stream.GetData());
- return true;
-}
-
-std::string
-CXXFunctionSummaryFormat::GetDescription()
-{
- StreamString sstr;
- sstr.Printf ("`%s (%p) `%s%s%s%s%s%s%s", m_description.c_str(),m_impl,
- Cascades() ? "" : " (not cascading)",
- !DoesPrintChildren() ? "" : " (show children)",
- !DoesPrintValue() ? " (hide value)" : "",
- IsOneliner() ? " (one-line printout)" : "",
- SkipsPointers() ? " (skip pointers)" : "",
- SkipsReferences() ? " (skip references)" : "",
- HideNames() ? " (hide member names)" : "");
- return sstr.GetString();
-}
-
-#ifndef LLDB_DISABLE_PYTHON
-
-
-ScriptSummaryFormat::ScriptSummaryFormat(const TypeSummaryImpl::Flags& flags,
- const char * function_name,
- const char * python_script) :
- TypeSummaryImpl(flags),
- m_function_name(),
- m_python_script(),
- m_script_function_sp()
-{
- if (function_name)
- m_function_name.assign(function_name);
- if (python_script)
- m_python_script.assign(python_script);
-}
-
-bool
-ScriptSummaryFormat::FormatObject(ValueObject *valobj,
- std::string& retval)
-{
- Timer scoped_timer (__PRETTY_FUNCTION__, __PRETTY_FUNCTION__);
-
- TargetSP target_sp(valobj->GetTargetSP());
-
- if (!target_sp)
- {
- retval.assign("error: no target");
- return false;
- }
-
- ScriptInterpreter *script_interpreter = target_sp->GetDebugger().GetCommandInterpreter().GetScriptInterpreter();
-
- if (!script_interpreter)
- {
- retval.assign("error: no ScriptInterpreter");
- return false;
- }
-
- return script_interpreter->GetScriptedSummary(m_function_name.c_str(),
- valobj->GetSP(),
- m_script_function_sp,
- retval);
-
-}
-
-std::string
-ScriptSummaryFormat::GetDescription()
-{
- StreamString sstr;
- sstr.Printf ("%s%s%s%s%s%s%s\n%s", Cascades() ? "" : " (not cascading)",
- !DoesPrintChildren() ? "" : " (show children)",
- !DoesPrintValue() ? " (hide value)" : "",
- IsOneliner() ? " (one-line printout)" : "",
- SkipsPointers() ? " (skip pointers)" : "",
- SkipsReferences() ? " (skip references)" : "",
- HideNames() ? " (hide member names)" : "",
- m_python_script.c_str());
- return sstr.GetString();
-
-}
-
-#endif // #ifndef LLDB_DISABLE_PYTHON
-
-std::string
-TypeFilterImpl::GetDescription()
-{
- StreamString sstr;
- sstr.Printf("%s%s%s {\n",
- Cascades() ? "" : " (not cascading)",
- SkipsPointers() ? " (skip pointers)" : "",
- SkipsReferences() ? " (skip references)" : "");
-
- for (int i = 0; i < GetCount(); i++)
- {
- sstr.Printf(" %s\n",
- GetExpressionPathAtIndex(i));
- }
-
- sstr.Printf("}");
- return sstr.GetString();
-}
-
-std::string
-CXXSyntheticChildren::GetDescription()
-{
- StreamString sstr;
- sstr.Printf("%s%s%s Generator at %p - %s\n",
- Cascades() ? "" : " (not cascading)",
- SkipsPointers() ? " (skip pointers)" : "",
- SkipsReferences() ? " (skip references)" : "",
- m_create_callback,
- m_description.c_str());
-
- return sstr.GetString();
-}
-
-std::string
-SyntheticArrayView::GetDescription()
-{
- StreamString sstr;
- sstr.Printf("%s%s%s {\n",
- Cascades() ? "" : " (not cascading)",
- SkipsPointers() ? " (skip pointers)" : "",
- SkipsReferences() ? " (skip references)" : "");
-
- SyntheticArrayRange* ptr = &m_head;
- while (ptr && ptr != m_tail)
- {
- if (ptr->GetLow() == ptr->GetHigh())
- sstr.Printf(" [%d]\n",
- ptr->GetLow());
- else
- sstr.Printf(" [%d-%d]\n",
- ptr->GetLow(),
- ptr->GetHigh());
- ptr = ptr->GetNext();
- }
-
- sstr.Printf("}");
- return sstr.GetString();
-}
-
-#ifndef LLDB_DISABLE_PYTHON
-
-TypeSyntheticImpl::FrontEnd::FrontEnd(std::string pclass, ValueObject &backend) :
- SyntheticChildrenFrontEnd(backend),
- m_python_class(pclass),
- m_wrapper_sp(),
- m_interpreter(NULL)
-{
- if (backend == LLDB_INVALID_UID)
- return;
-
- TargetSP target_sp = backend.GetTargetSP();
-
- if (!target_sp)
- return;
-
- m_interpreter = target_sp->GetDebugger().GetCommandInterpreter().GetScriptInterpreter();
-
- if (m_interpreter != NULL)
- m_wrapper_sp = m_interpreter->CreateSyntheticScriptedProvider(m_python_class.c_str(), backend.GetSP());
-}
-
-TypeSyntheticImpl::FrontEnd::~FrontEnd()
-{
-}
-
-lldb::ValueObjectSP
-TypeSyntheticImpl::FrontEnd::GetChildAtIndex (size_t idx)
-{
- if (!m_wrapper_sp || !m_interpreter)
- return lldb::ValueObjectSP();
-
- return m_interpreter->GetChildAtIndex(m_wrapper_sp, idx);
-}
-
-std::string
-TypeSyntheticImpl::GetDescription()
-{
- StreamString sstr;
- sstr.Printf("%s%s%s Python class %s",
- Cascades() ? "" : " (not cascading)",
- SkipsPointers() ? " (skip pointers)" : "",
- SkipsReferences() ? " (skip references)" : "",
- m_python_class.c_str());
-
- return sstr.GetString();
-}
-
-#endif // #ifndef LLDB_DISABLE_PYTHON
-
-int
-SyntheticArrayView::GetRealIndexForIndex(size_t i)
-{
- if (i >= GetCount())
- return -1;
-
- SyntheticArrayRange* ptr = &m_head;
-
- int residual = i;
-
- while(ptr && ptr != m_tail)
- {
- if (residual >= ptr->GetSelfCount())
- {
- residual -= ptr->GetSelfCount();
- ptr = ptr->GetNext();
- }
-
- return ptr->GetLow() + residual;
- }
-
- return -1;
-}
-
-uint32_t
-SyntheticArrayView::FrontEnd::GetIndexOfChildWithName (const ConstString &name_cs)
-{
- const char* name_cstr = name_cs.GetCString();
- if (*name_cstr != '[')
- return UINT32_MAX;
- std::string name(name_cstr+1);
- if (name[name.size()-1] != ']')
- return UINT32_MAX;
- name = name.erase(name.size()-1,1);
- int index = Args::StringToSInt32 (name.c_str(), -1);
- if (index < 0)
- return UINT32_MAX;
- return index;
-}
Removed: lldb/trunk/source/Core/FormatManager.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/FormatManager.cpp?rev=173727&view=auto
==============================================================================
--- lldb/trunk/source/Core/FormatManager.cpp (original)
+++ lldb/trunk/source/Core/FormatManager.cpp (removed)
@@ -1,1313 +0,0 @@
-//===-- FormatManager.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/lldb-python.h"
-
-#include "lldb/Core/FormatManager.h"
-
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
-
-#include "lldb/Core/CXXFormatterFunctions.h"
-#include "lldb/Core/Debugger.h"
-
-using namespace lldb;
-using namespace lldb_private;
-
-
-struct FormatInfo
-{
- Format format;
- const char format_char; // One or more format characters that can be used for this format.
- const char *format_name; // Long format name that can be used to specify the current format
-};
-
-static FormatInfo
-g_format_infos[] =
-{
- { eFormatDefault , '\0' , "default" },
- { eFormatBoolean , 'B' , "boolean" },
- { eFormatBinary , 'b' , "binary" },
- { eFormatBytes , 'y' , "bytes" },
- { eFormatBytesWithASCII , 'Y' , "bytes with ASCII" },
- { eFormatChar , 'c' , "character" },
- { eFormatCharPrintable , 'C' , "printable character" },
- { eFormatComplexFloat , 'F' , "complex float" },
- { eFormatCString , 's' , "c-string" },
- { eFormatDecimal , 'd' , "decimal" },
- { eFormatEnum , 'E' , "enumeration" },
- { eFormatHex , 'x' , "hex" },
- { eFormatHexUppercase , 'X' , "uppercase hex" },
- { eFormatFloat , 'f' , "float" },
- { eFormatOctal , 'o' , "octal" },
- { eFormatOSType , 'O' , "OSType" },
- { eFormatUnicode16 , 'U' , "unicode16" },
- { eFormatUnicode32 , '\0' , "unicode32" },
- { eFormatUnsigned , 'u' , "unsigned decimal" },
- { eFormatPointer , 'p' , "pointer" },
- { eFormatVectorOfChar , '\0' , "char[]" },
- { eFormatVectorOfSInt8 , '\0' , "int8_t[]" },
- { eFormatVectorOfUInt8 , '\0' , "uint8_t[]" },
- { eFormatVectorOfSInt16 , '\0' , "int16_t[]" },
- { eFormatVectorOfUInt16 , '\0' , "uint16_t[]" },
- { eFormatVectorOfSInt32 , '\0' , "int32_t[]" },
- { eFormatVectorOfUInt32 , '\0' , "uint32_t[]" },
- { eFormatVectorOfSInt64 , '\0' , "int64_t[]" },
- { eFormatVectorOfUInt64 , '\0' , "uint64_t[]" },
- { eFormatVectorOfFloat32, '\0' , "float32[]" },
- { eFormatVectorOfFloat64, '\0' , "float64[]" },
- { eFormatVectorOfUInt128, '\0' , "uint128_t[]" },
- { eFormatComplexInteger , 'I' , "complex integer" },
- { eFormatCharArray , 'a' , "character array" },
- { eFormatAddressInfo , 'A' , "address" },
- { eFormatHexFloat , '\0' , "hex float" },
- { eFormatInstruction , 'i' , "instruction" },
- { eFormatVoid , 'v' , "void" }
-};
-
-static uint32_t
-g_num_format_infos = sizeof(g_format_infos)/sizeof(FormatInfo);
-
-static bool
-GetFormatFromFormatChar (char format_char, Format &format)
-{
- for (uint32_t i=0; i<g_num_format_infos; ++i)
- {
- if (g_format_infos[i].format_char == format_char)
- {
- format = g_format_infos[i].format;
- return true;
- }
- }
- format = eFormatInvalid;
- return false;
-}
-
-static bool
-GetFormatFromFormatName (const char *format_name, bool partial_match_ok, Format &format)
-{
- uint32_t i;
- for (i=0; i<g_num_format_infos; ++i)
- {
- if (strcasecmp (g_format_infos[i].format_name, format_name) == 0)
- {
- format = g_format_infos[i].format;
- return true;
- }
- }
-
- if (partial_match_ok)
- {
- for (i=0; i<g_num_format_infos; ++i)
- {
- if (strcasestr (g_format_infos[i].format_name, format_name) == g_format_infos[i].format_name)
- {
- format = g_format_infos[i].format;
- return true;
- }
- }
- }
- format = eFormatInvalid;
- return false;
-}
-
-bool
-FormatManager::GetFormatFromCString (const char *format_cstr,
- bool partial_match_ok,
- lldb::Format &format)
-{
- bool success = false;
- if (format_cstr && format_cstr[0])
- {
- if (format_cstr[1] == '\0')
- {
- success = GetFormatFromFormatChar (format_cstr[0], format);
- if (success)
- return true;
- }
-
- success = GetFormatFromFormatName (format_cstr, partial_match_ok, format);
- }
- if (!success)
- format = eFormatInvalid;
- return success;
-}
-
-char
-FormatManager::GetFormatAsFormatChar (lldb::Format format)
-{
- for (uint32_t i=0; i<g_num_format_infos; ++i)
- {
- if (g_format_infos[i].format == format)
- return g_format_infos[i].format_char;
- }
- return '\0';
-}
-
-
-
-const char *
-FormatManager::GetFormatAsCString (Format format)
-{
- if (format >= eFormatDefault && format < kNumFormats)
- return g_format_infos[format].format_name;
- return NULL;
-}
-
-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)),
- m_regex_filter_nav(new RegexFilterNavigator("regex-filter",clist)),
-#ifndef LLDB_DISABLE_PYTHON
- m_synth_nav(new SynthNavigator("synth",clist)),
- m_regex_synth_nav(new RegexSynthNavigator("regex-synth",clist)),
-#endif
- m_enabled(false),
- m_change_listener(clist),
- m_mutex(Mutex::eMutexTypeRecursive),
- m_name(name)
-{}
-
-bool
-TypeCategoryImpl::Get (ValueObject& valobj,
- lldb::TypeSummaryImplSP& entry,
- lldb::DynamicValueType use_dynamic,
- uint32_t* reason)
-{
- if (!IsEnabled())
- return false;
- if (GetSummaryNavigator()->Get(valobj, entry, use_dynamic, reason))
- return true;
- bool regex = GetRegexSummaryNavigator()->Get(valobj, entry, use_dynamic, reason);
- if (regex && reason)
- *reason |= lldb_private::eFormatterChoiceCriterionRegularExpressionSummary;
- return regex;
-}
-
-bool
-TypeCategoryImpl::Get(ValueObject& valobj,
- lldb::SyntheticChildrenSP& entry_sp,
- lldb::DynamicValueType use_dynamic,
- uint32_t* reason)
-{
- if (!IsEnabled())
- return false;
- 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
-
- if (!GetFilterNavigator()->Get(valobj, filter_sp, use_dynamic, &reason_filter))
- regex_filter = GetRegexFilterNavigator()->Get (valobj, filter_sp, use_dynamic, &reason_filter);
-
-#ifndef LLDB_DISABLE_PYTHON
- bool regex_synth = false;
- uint32_t reason_synth = 0;
- bool pick_synth = false;
- 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())
- return false;
- else if (!filter_sp.get() && synth.get())
- pick_synth = true;
-
- else if (filter_sp.get() && !synth.get())
- pick_synth = false;
-
- else /*if (filter_sp.get() && synth.get())*/
- {
- if (filter_sp->GetRevision() > synth->GetRevision())
- pick_synth = false;
- else
- pick_synth = true;
- }
- if (pick_synth)
- {
- if (regex_synth && reason)
- *reason |= lldb_private::eFormatterChoiceCriterionRegularExpressionFilter;
- entry_sp = synth;
- return true;
- }
- else
- {
- if (regex_filter && reason)
- *reason |= lldb_private::eFormatterChoiceCriterionRegularExpressionFilter;
- entry_sp = filter_sp;
- return true;
- }
-
-#else
- if (filter_sp)
- {
- entry_sp = filter_sp;
- return true;
- }
-#endif
-
- return false;
-
-}
-
-void
-TypeCategoryImpl::Clear (FormatCategoryItems items)
-{
- if ( (items & eFormatCategoryItemSummary) == eFormatCategoryItemSummary )
- m_summary_nav->Clear();
- if ( (items & eFormatCategoryItemRegexSummary) == eFormatCategoryItemRegexSummary )
- m_regex_summary_nav->Clear();
- if ( (items & eFormatCategoryItemFilter) == eFormatCategoryItemFilter )
- m_filter_nav->Clear();
- if ( (items & eFormatCategoryItemRegexFilter) == eFormatCategoryItemRegexFilter )
- m_regex_filter_nav->Clear();
-#ifndef LLDB_DISABLE_PYTHON
- if ( (items & eFormatCategoryItemSynth) == eFormatCategoryItemSynth )
- m_synth_nav->Clear();
- if ( (items & eFormatCategoryItemRegexSynth) == eFormatCategoryItemRegexSynth )
- m_regex_synth_nav->Clear();
-#endif
-}
-
-bool
-TypeCategoryImpl::Delete (ConstString name,
- FormatCategoryItems items)
-{
- bool success = false;
- if ( (items & eFormatCategoryItemSummary) == eFormatCategoryItemSummary )
- success = m_summary_nav->Delete(name) || success;
- if ( (items & eFormatCategoryItemRegexSummary) == eFormatCategoryItemRegexSummary )
- success = m_regex_summary_nav->Delete(name) || success;
- if ( (items & eFormatCategoryItemFilter) == eFormatCategoryItemFilter )
- success = m_filter_nav->Delete(name) || success;
- if ( (items & eFormatCategoryItemRegexFilter) == eFormatCategoryItemRegexFilter )
- success = m_regex_filter_nav->Delete(name) || success;
-#ifndef LLDB_DISABLE_PYTHON
- if ( (items & eFormatCategoryItemSynth) == eFormatCategoryItemSynth )
- success = m_synth_nav->Delete(name) || success;
- if ( (items & eFormatCategoryItemRegexSynth) == eFormatCategoryItemRegexSynth )
- success = m_regex_synth_nav->Delete(name) || success;
-#endif
- return success;
-}
-
-uint32_t
-TypeCategoryImpl::GetCount (FormatCategoryItems items)
-{
- uint32_t count = 0;
- if ( (items & eFormatCategoryItemSummary) == eFormatCategoryItemSummary )
- count += m_summary_nav->GetCount();
- if ( (items & eFormatCategoryItemRegexSummary) == eFormatCategoryItemRegexSummary )
- count += m_regex_summary_nav->GetCount();
- if ( (items & eFormatCategoryItemFilter) == eFormatCategoryItemFilter )
- count += m_filter_nav->GetCount();
- if ( (items & eFormatCategoryItemRegexFilter) == eFormatCategoryItemRegexFilter )
- count += m_regex_filter_nav->GetCount();
-#ifndef LLDB_DISABLE_PYTHON
- if ( (items & eFormatCategoryItemSynth) == eFormatCategoryItemSynth )
- count += m_synth_nav->GetCount();
- if ( (items & eFormatCategoryItemRegexSynth) == eFormatCategoryItemRegexSynth )
- count += m_regex_synth_nav->GetCount();
-#endif
- return count;
-}
-
-bool
-TypeCategoryImpl::AnyMatches(ConstString type_name,
- FormatCategoryItems items,
- bool only_enabled,
- const char** matching_category,
- FormatCategoryItems* matching_type)
-{
- if (!IsEnabled() && only_enabled)
- return false;
-
- lldb::TypeSummaryImplSP summary;
- TypeFilterImpl::SharedPointer filter;
-#ifndef LLDB_DISABLE_PYTHON
- TypeSyntheticImpl::SharedPointer synth;
-#endif
-
- if ( (items & eFormatCategoryItemSummary) == eFormatCategoryItemSummary )
- {
- if (m_summary_nav->Get(type_name, summary))
- {
- if (matching_category)
- *matching_category = m_name.GetCString();
- if (matching_type)
- *matching_type = eFormatCategoryItemSummary;
- return true;
- }
- }
- if ( (items & eFormatCategoryItemRegexSummary) == eFormatCategoryItemRegexSummary )
- {
- if (m_regex_summary_nav->Get(type_name, summary))
- {
- if (matching_category)
- *matching_category = m_name.GetCString();
- if (matching_type)
- *matching_type = eFormatCategoryItemRegexSummary;
- return true;
- }
- }
- if ( (items & eFormatCategoryItemFilter) == eFormatCategoryItemFilter )
- {
- if (m_filter_nav->Get(type_name, filter))
- {
- if (matching_category)
- *matching_category = m_name.GetCString();
- if (matching_type)
- *matching_type = eFormatCategoryItemFilter;
- return true;
- }
- }
- if ( (items & eFormatCategoryItemRegexFilter) == eFormatCategoryItemRegexFilter )
- {
- if (m_regex_filter_nav->Get(type_name, filter))
- {
- if (matching_category)
- *matching_category = m_name.GetCString();
- if (matching_type)
- *matching_type = eFormatCategoryItemRegexFilter;
- return true;
- }
- }
-#ifndef LLDB_DISABLE_PYTHON
- if ( (items & eFormatCategoryItemSynth) == eFormatCategoryItemSynth )
- {
- if (m_synth_nav->Get(type_name, synth))
- {
- if (matching_category)
- *matching_category = m_name.GetCString();
- if (matching_type)
- *matching_type = eFormatCategoryItemSynth;
- return true;
- }
- }
- if ( (items & eFormatCategoryItemRegexSynth) == eFormatCategoryItemRegexSynth )
- {
- if (m_regex_synth_nav->Get(type_name, synth))
- {
- if (matching_category)
- *matching_category = m_name.GetCString();
- if (matching_type)
- *matching_type = eFormatCategoryItemRegexSynth;
- return true;
- }
- }
-#endif
- return false;
-}
-
-bool
-CategoryMap::AnyMatches (ConstString type_name,
- TypeCategoryImpl::FormatCategoryItems items,
- bool only_enabled,
- const char** matching_category,
- TypeCategoryImpl::FormatCategoryItems* matching_type)
-{
- Mutex::Locker locker(m_map_mutex);
-
- MapIterator pos, end = m_map.end();
- for (pos = m_map.begin(); pos != end; pos++)
- {
- if (pos->second->AnyMatches(type_name,
- items,
- only_enabled,
- matching_category,
- matching_type))
- return true;
- }
- return false;
-}
-
-lldb::TypeSummaryImplSP
-CategoryMap::GetSummaryFormat (ValueObject& valobj,
- lldb::DynamicValueType use_dynamic)
-{
- Mutex::Locker locker(m_map_mutex);
-
- uint32_t reason_why;
- ActiveCategoriesIterator begin, end = m_active_categories.end();
-
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
-
- for (begin = m_active_categories.begin(); begin != end; begin++)
- {
- lldb::TypeCategoryImplSP category_sp = *begin;
- lldb::TypeSummaryImplSP current_format;
- if (log)
- log->Printf("[CategoryMap::GetSummaryFormat] Trying to use category %s\n", category_sp->GetName());
- if (!category_sp->Get(valobj, current_format, use_dynamic, &reason_why))
- continue;
- return current_format;
- }
- if (log)
- log->Printf("[CategoryMap::GetSummaryFormat] nothing found - returning empty SP\n");
- return lldb::TypeSummaryImplSP();
-}
-
-lldb::TypeSummaryImplSP
-FormatManager::GetSummaryForType (lldb::TypeNameSpecifierImplSP type_sp)
-{
- if (!type_sp)
- return lldb::TypeSummaryImplSP();
- lldb::TypeSummaryImplSP summary_chosen_sp;
- uint32_t num_categories = m_categories_map.GetCount();
- lldb::TypeCategoryImplSP category_sp;
- uint32_t prio_category = UINT32_MAX;
- for (uint32_t category_id = 0;
- category_id < num_categories;
- category_id++)
- {
- category_sp = GetCategoryAtIndex(category_id);
- if (category_sp->IsEnabled() == false)
- continue;
- lldb::TypeSummaryImplSP summary_current_sp = category_sp->GetSummaryForType(type_sp);
- if (summary_current_sp && (summary_chosen_sp.get() == NULL || (prio_category > category_sp->GetEnabledPosition())))
- {
- prio_category = category_sp->GetEnabledPosition();
- summary_chosen_sp = summary_current_sp;
- }
- }
- return summary_chosen_sp;
-}
-
-lldb::TypeFilterImplSP
-FormatManager::GetFilterForType (lldb::TypeNameSpecifierImplSP type_sp)
-{
- if (!type_sp)
- return lldb::TypeFilterImplSP();
- lldb::TypeFilterImplSP filter_chosen_sp;
- uint32_t num_categories = m_categories_map.GetCount();
- lldb::TypeCategoryImplSP category_sp;
- uint32_t prio_category = UINT32_MAX;
- for (uint32_t category_id = 0;
- category_id < num_categories;
- category_id++)
- {
- category_sp = GetCategoryAtIndex(category_id);
- if (category_sp->IsEnabled() == false)
- continue;
- lldb::TypeFilterImplSP filter_current_sp((TypeFilterImpl*)category_sp->GetFilterForType(type_sp).get());
- if (filter_current_sp && (filter_chosen_sp.get() == NULL || (prio_category > category_sp->GetEnabledPosition())))
- {
- prio_category = category_sp->GetEnabledPosition();
- filter_chosen_sp = filter_current_sp;
- }
- }
- return filter_chosen_sp;
-}
-
-#ifndef LLDB_DISABLE_PYTHON
-lldb::TypeSyntheticImplSP
-FormatManager::GetSyntheticForType (lldb::TypeNameSpecifierImplSP type_sp)
-{
- if (!type_sp)
- return lldb::TypeSyntheticImplSP();
- lldb::TypeSyntheticImplSP synth_chosen_sp;
- uint32_t num_categories = m_categories_map.GetCount();
- lldb::TypeCategoryImplSP category_sp;
- uint32_t prio_category = UINT32_MAX;
- for (uint32_t category_id = 0;
- category_id < num_categories;
- category_id++)
- {
- category_sp = GetCategoryAtIndex(category_id);
- if (category_sp->IsEnabled() == false)
- continue;
- lldb::TypeSyntheticImplSP synth_current_sp((TypeSyntheticImpl*)category_sp->GetSyntheticForType(type_sp).get());
- if (synth_current_sp && (synth_chosen_sp.get() == NULL || (prio_category > category_sp->GetEnabledPosition())))
- {
- prio_category = category_sp->GetEnabledPosition();
- synth_chosen_sp = synth_current_sp;
- }
- }
- return synth_chosen_sp;
-}
-#endif
-
-#ifndef LLDB_DISABLE_PYTHON
-lldb::SyntheticChildrenSP
-FormatManager::GetSyntheticChildrenForType (lldb::TypeNameSpecifierImplSP type_sp)
-{
- if (!type_sp)
- return lldb::SyntheticChildrenSP();
- lldb::TypeFilterImplSP filter_sp = GetFilterForType(type_sp);
- lldb::TypeSyntheticImplSP synth_sp = GetSyntheticForType(type_sp);
- if (filter_sp->GetRevision() > synth_sp->GetRevision())
- return lldb::SyntheticChildrenSP(filter_sp.get());
- else
- return lldb::SyntheticChildrenSP(synth_sp.get());
-}
-#endif
-
-#ifndef LLDB_DISABLE_PYTHON
-lldb::SyntheticChildrenSP
-CategoryMap::GetSyntheticChildren (ValueObject& valobj,
- lldb::DynamicValueType use_dynamic)
-{
- Mutex::Locker locker(m_map_mutex);
-
- uint32_t reason_why;
-
- ActiveCategoriesIterator begin, end = m_active_categories.end();
-
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
-
- for (begin = m_active_categories.begin(); begin != end; begin++)
- {
- lldb::TypeCategoryImplSP category_sp = *begin;
- lldb::SyntheticChildrenSP current_format;
- if (log)
- log->Printf("[CategoryMap::GetSyntheticChildren] Trying to use category %s\n", category_sp->GetName());
- if (!category_sp->Get(valobj, current_format, use_dynamic, &reason_why))
- continue;
- return current_format;
- }
- if (log)
- log->Printf("[CategoryMap::GetSyntheticChildren] nothing found - returning empty SP\n");
- return lldb::SyntheticChildrenSP();
-}
-#endif
-
-void
-CategoryMap::LoopThrough(CallbackType callback, void* param)
-{
- if (callback)
- {
- Mutex::Locker locker(m_map_mutex);
-
- // loop through enabled categories in respective order
- {
- ActiveCategoriesIterator begin, end = m_active_categories.end();
- for (begin = m_active_categories.begin(); begin != end; begin++)
- {
- lldb::TypeCategoryImplSP category = *begin;
- ConstString type = ConstString(category->GetName());
- if (!callback(param, category))
- break;
- }
- }
-
- // loop through disabled categories in just any order
- {
- MapIterator pos, end = m_map.end();
- for (pos = m_map.begin(); pos != end; pos++)
- {
- if (pos->second->IsEnabled())
- continue;
- KeyType type = pos->first;
- if (!callback(param, pos->second))
- break;
- }
- }
- }
-}
-
-TypeCategoryImplSP
-CategoryMap::GetAtIndex (size_t index)
-{
- Mutex::Locker 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::TypeCategoryImplSP category;
- if (m_categories_map.Get(category_name, category))
- return category;
-
- if (!can_create)
- return lldb::TypeCategoryImplSP();
-
- m_categories_map.Add(category_name,lldb::TypeCategoryImplSP(new TypeCategoryImpl(this, category_name)));
- return GetCategory(category_name);
-}
-
-lldb::Format
-FormatManager::GetSingleItemFormat(lldb::Format vector_format)
-{
- switch(vector_format)
- {
- case eFormatVectorOfChar:
- return eFormatCharArray;
-
- case eFormatVectorOfSInt8:
- case eFormatVectorOfSInt16:
- case eFormatVectorOfSInt32:
- case eFormatVectorOfSInt64:
- return eFormatDecimal;
-
- case eFormatVectorOfUInt8:
- case eFormatVectorOfUInt16:
- case eFormatVectorOfUInt32:
- case eFormatVectorOfUInt64:
- case eFormatVectorOfUInt128:
- return eFormatHex;
-
- case eFormatVectorOfFloat32:
- case eFormatVectorOfFloat64:
- return eFormatFloat;
-
- default:
- return lldb::eFormatInvalid;
- }
-}
-
-ConstString
-FormatManager::GetValidTypeName (const ConstString& type)
-{
- return ::GetValidTypeName_Impl(type);
-}
-
-FormatManager::FormatManager() :
- m_value_nav("format",this),
- m_named_summaries_map(this),
- m_last_revision(0),
- m_categories_map(this),
- m_default_category_name(ConstString("default")),
- m_system_category_name(ConstString("system")),
- m_gnu_cpp_category_name(ConstString("gnu-libstdc++")),
- m_libcxx_category_name(ConstString("libcxx")),
- m_objc_category_name(ConstString("objc")),
- m_corefoundation_category_name(ConstString("CoreFoundation")),
- m_coregraphics_category_name(ConstString("CoreGraphics")),
- m_coreservices_category_name(ConstString("CoreServices")),
- m_vectortypes_category_name(ConstString("VectorTypes")),
- m_appkit_category_name(ConstString("AppKit"))
-{
-
- LoadSystemFormatters();
- LoadLibStdcppFormatters();
- LoadLibcxxFormatters();
- LoadObjCFormatters();
-
- EnableCategory(m_objc_category_name,CategoryMap::Last);
- EnableCategory(m_corefoundation_category_name,CategoryMap::Last);
- EnableCategory(m_appkit_category_name,CategoryMap::Last);
- EnableCategory(m_coreservices_category_name,CategoryMap::Last);
- EnableCategory(m_coregraphics_category_name,CategoryMap::Last);
- EnableCategory(m_gnu_cpp_category_name,CategoryMap::Last);
- EnableCategory(m_libcxx_category_name,CategoryMap::Last);
- EnableCategory(m_vectortypes_category_name,CategoryMap::Last);
- EnableCategory(m_system_category_name,CategoryMap::Last);
-}
-
-static void
-AddStringSummary(TypeCategoryImpl::SharedPointer category_sp,
- const char* string,
- ConstString type_name,
- TypeSummaryImpl::Flags flags)
-{
- lldb::TypeSummaryImplSP summary_sp(new StringSummaryFormat(flags,
- string));
- category_sp->GetSummaryNavigator()->Add(type_name,
- summary_sp);
-}
-
-#ifndef LLDB_DISABLE_PYTHON
-static void
-AddScriptSummary(TypeCategoryImpl::SharedPointer category_sp,
- const char* funct_name,
- ConstString type_name,
- TypeSummaryImpl::Flags flags)
-{
-
- std::string code(" ");
- code.append(funct_name).append("(valobj,internal_dict)");
-
- lldb::TypeSummaryImplSP summary_sp(new ScriptSummaryFormat(flags,
- funct_name,
- code.c_str()));
- category_sp->GetSummaryNavigator()->Add(type_name,
- summary_sp);
-}
-#endif
-
-#ifndef LLDB_DISABLE_PYTHON
-static void
-AddCXXSummary (TypeCategoryImpl::SharedPointer category_sp,
- CXXFunctionSummaryFormat::Callback funct,
- const char* description,
- ConstString type_name,
- TypeSummaryImpl::Flags flags)
-{
- lldb::TypeSummaryImplSP summary_sp(new CXXFunctionSummaryFormat(flags,funct,description));
- category_sp->GetSummaryNavigator()->Add(type_name,
- summary_sp);
-}
-#endif
-
-#ifndef LLDB_DISABLE_PYTHON
-static void AddCXXSynthetic (TypeCategoryImpl::SharedPointer category_sp,
- CXXSyntheticChildren::CreateFrontEndCallback generator,
- const char* description,
- ConstString type_name,
- TypeSyntheticImpl::Flags flags)
-{
- lldb::SyntheticChildrenSP synth_sp(new CXXSyntheticChildren(flags,description,generator));
- category_sp->GetSyntheticNavigator()->Add(type_name,synth_sp);
-}
-#endif
-
-void
-FormatManager::LoadLibStdcppFormatters()
-{
- TypeSummaryImpl::Flags stl_summary_flags;
- stl_summary_flags.SetCascades(true)
- .SetSkipPointers(false)
- .SetSkipReferences(false)
- .SetDontShowChildren(true)
- .SetDontShowValue(true)
- .SetShowMembersOneLiner(false)
- .SetHideItemNames(false);
-
- lldb::TypeSummaryImplSP std_string_summary_sp(new StringSummaryFormat(stl_summary_flags,
- "${var._M_dataplus._M_p}"));
-
- TypeCategoryImpl::SharedPointer gnu_category_sp = GetCategory(m_gnu_cpp_category_name);
-
- gnu_category_sp->GetSummaryNavigator()->Add(ConstString("std::string"),
- std_string_summary_sp);
- gnu_category_sp->GetSummaryNavigator()->Add(ConstString("std::basic_string<char>"),
- std_string_summary_sp);
- gnu_category_sp->GetSummaryNavigator()->Add(ConstString("std::basic_string<char,std::char_traits<char>,std::allocator<char> >"),
- std_string_summary_sp);
- gnu_category_sp->GetSummaryNavigator()->Add(ConstString("std::basic_string<char, std::char_traits<char>, std::allocator<char> >"),
- std_string_summary_sp);
-
- // making sure we force-pick the summary for printing wstring (_M_p is a wchar_t*)
- lldb::TypeSummaryImplSP std_wstring_summary_sp(new StringSummaryFormat(stl_summary_flags,
- "${var._M_dataplus._M_p%S}"));
-
- gnu_category_sp->GetSummaryNavigator()->Add(ConstString("std::wstring"),
- std_wstring_summary_sp);
- gnu_category_sp->GetSummaryNavigator()->Add(ConstString("std::basic_string<wchar_t>"),
- std_wstring_summary_sp);
- gnu_category_sp->GetSummaryNavigator()->Add(ConstString("std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> >"),
- std_wstring_summary_sp);
- gnu_category_sp->GetSummaryNavigator()->Add(ConstString("std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >"),
- std_wstring_summary_sp);
-
-
-#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 TypeSyntheticImpl(stl_synth_flags,
- "lldb.formatters.cpp.gnu_libstdcpp.StdVectorSynthProvider")));
- gnu_category_sp->GetRegexSyntheticNavigator()->Add(RegularExpressionSP(new RegularExpression("^std::map<.+> >(( )?&)?$")),
- SyntheticChildrenSP(new TypeSyntheticImpl(stl_synth_flags,
- "lldb.formatters.cpp.gnu_libstdcpp.StdMapSynthProvider")));
- gnu_category_sp->GetRegexSyntheticNavigator()->Add(RegularExpressionSP(new RegularExpression("^std::list<.+>(( )?&)?$")),
- SyntheticChildrenSP(new TypeSyntheticImpl(stl_synth_flags,
- "lldb.formatters.cpp.gnu_libstdcpp.StdListSynthProvider")));
-
- stl_summary_flags.SetDontShowChildren(false);
- gnu_category_sp->GetRegexSummaryNavigator()->Add(RegularExpressionSP(new RegularExpression("^std::vector<.+>(( )?&)?$")),
- TypeSummaryImplSP(new StringSummaryFormat(stl_summary_flags,
- "size=${svar%#}")));
- gnu_category_sp->GetRegexSummaryNavigator()->Add(RegularExpressionSP(new RegularExpression("^std::map<.+> >(( )?&)?$")),
- TypeSummaryImplSP(new StringSummaryFormat(stl_summary_flags,
- "size=${svar%#}")));
- gnu_category_sp->GetRegexSummaryNavigator()->Add(RegularExpressionSP(new RegularExpression("^std::list<.+>(( )?&)?$")),
- TypeSummaryImplSP(new StringSummaryFormat(stl_summary_flags,
- "size=${svar%#}")));
-#endif
-}
-
-void
-FormatManager::LoadLibcxxFormatters()
-{
- TypeSummaryImpl::Flags stl_summary_flags;
- stl_summary_flags.SetCascades(true)
- .SetSkipPointers(false)
- .SetSkipReferences(false)
- .SetDontShowChildren(true)
- .SetDontShowValue(true)
- .SetShowMembersOneLiner(false)
- .SetHideItemNames(false);
-
-#ifndef LLDB_DISABLE_PYTHON
- //std::string code(" lldb.formatters.cpp.libcxx.stdstring_SummaryProvider(valobj,internal_dict)");
- //lldb::TypeSummaryImplSP std_string_summary_sp(new ScriptSummaryFormat(stl_summary_flags, "lldb.formatters.cpp.libcxx.stdstring_SummaryProvider",code.c_str()));
-
- lldb::TypeSummaryImplSP std_string_summary_sp(new CXXFunctionSummaryFormat(stl_summary_flags, lldb_private::formatters::LibcxxStringSummaryProvider, "std::string summary provider"));
- lldb::TypeSummaryImplSP std_wstring_summary_sp(new CXXFunctionSummaryFormat(stl_summary_flags, lldb_private::formatters::LibcxxWStringSummaryProvider, "std::wstring summary provider"));
-
- TypeCategoryImpl::SharedPointer libcxx_category_sp = GetCategory(m_libcxx_category_name);
-
- libcxx_category_sp->GetSummaryNavigator()->Add(ConstString("std::__1::string"),
- std_string_summary_sp);
- libcxx_category_sp->GetSummaryNavigator()->Add(ConstString("std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >"),
- std_string_summary_sp);
-
- libcxx_category_sp->GetSummaryNavigator()->Add(ConstString("std::__1::wstring"),
- std_wstring_summary_sp);
- libcxx_category_sp->GetSummaryNavigator()->Add(ConstString("std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> >"),
- std_wstring_summary_sp);
-
- SyntheticChildren::Flags stl_synth_flags;
- stl_synth_flags.SetCascades(true).SetSkipPointers(false).SetSkipReferences(false);
-
- libcxx_category_sp->GetRegexSyntheticNavigator()->Add(RegularExpressionSP(new RegularExpression("^std::__1::vector<.+>(( )?&)?$")),
- SyntheticChildrenSP(new TypeSyntheticImpl(stl_synth_flags,
- "lldb.formatters.cpp.libcxx.stdvector_SynthProvider")));
- libcxx_category_sp->GetRegexSyntheticNavigator()->Add(RegularExpressionSP(new RegularExpression("^std::__1::list<.+>(( )?&)?$")),
- SyntheticChildrenSP(new TypeSyntheticImpl(stl_synth_flags,
- "lldb.formatters.cpp.libcxx.stdlist_SynthProvider")));
- libcxx_category_sp->GetRegexSyntheticNavigator()->Add(RegularExpressionSP(new RegularExpression("^std::__1::map<.+> >(( )?&)?$")),
- SyntheticChildrenSP(new TypeSyntheticImpl(stl_synth_flags,
- "lldb.formatters.cpp.libcxx.stdmap_SynthProvider")));
- libcxx_category_sp->GetRegexSyntheticNavigator()->Add(RegularExpressionSP(new RegularExpression("^(std::__1::)deque<.+>(( )?&)?$")),
- SyntheticChildrenSP(new TypeSyntheticImpl(stl_synth_flags,
- "lldb.formatters.cpp.libcxx.stddeque_SynthProvider")));
- libcxx_category_sp->GetRegexSyntheticNavigator()->Add(RegularExpressionSP(new RegularExpression("^(std::__1::)shared_ptr<.+>(( )?&)?$")),
- SyntheticChildrenSP(new TypeSyntheticImpl(stl_synth_flags,
- "lldb.formatters.cpp.libcxx.stdsharedptr_SynthProvider")));
- libcxx_category_sp->GetRegexSyntheticNavigator()->Add(RegularExpressionSP(new RegularExpression("^(std::__1::)weak_ptr<.+>(( )?&)?$")),
- SyntheticChildrenSP(new TypeSyntheticImpl(stl_synth_flags,
- "lldb.formatters.cpp.libcxx.stdsharedptr_SynthProvider")));
-
- stl_summary_flags.SetDontShowChildren(false);stl_summary_flags.SetSkipPointers(true);
- libcxx_category_sp->GetRegexSummaryNavigator()->Add(RegularExpressionSP(new RegularExpression("^std::__1::vector<.+>(( )?&)?$")),
- TypeSummaryImplSP(new StringSummaryFormat(stl_summary_flags, "size=${svar%#}")));
- libcxx_category_sp->GetRegexSummaryNavigator()->Add(RegularExpressionSP(new RegularExpression("^std::__1::list<.+>(( )?&)?$")),
- TypeSummaryImplSP(new StringSummaryFormat(stl_summary_flags, "size=${svar%#}")));
- libcxx_category_sp->GetRegexSummaryNavigator()->Add(RegularExpressionSP(new RegularExpression("^std::__1::map<.+> >(( )?&)?$")),
- TypeSummaryImplSP(new StringSummaryFormat(stl_summary_flags, "size=${svar%#}")));
- libcxx_category_sp->GetRegexSummaryNavigator()->Add(RegularExpressionSP(new RegularExpression("^std::__1::deque<.+>(( )?&)?$")),
- TypeSummaryImplSP(new StringSummaryFormat(stl_summary_flags, "size=${svar%#}")));
- libcxx_category_sp->GetRegexSummaryNavigator()->Add(RegularExpressionSP(new RegularExpression("^std::__1::shared_ptr<.+>(( )?&)?$")),
- TypeSummaryImplSP(new StringSummaryFormat(stl_summary_flags, "{${var.__ptr_%S}} (strong=${var.count} weak=${var.weak_count})")));
- libcxx_category_sp->GetRegexSummaryNavigator()->Add(RegularExpressionSP(new RegularExpression("^std::__1::weak_ptr<.+>(( )?&)?$")),
- TypeSummaryImplSP(new StringSummaryFormat(stl_summary_flags, "{${var.__ptr_%S}} (strong=${var.count} weak=${var.weak_count})")));
-
- // this summary prevails on the regex std::vector<> because we do exact matches before regex ones
- libcxx_category_sp->GetSummaryNavigator()->Add(ConstString("std::__1::vector<std::__1::allocator<bool> >"),
- TypeSummaryImplSP(new StringSummaryFormat(stl_summary_flags, "size=${var.__size_}")));
-
-#endif
-}
-
-void
-FormatManager::LoadSystemFormatters()
-{
-
- TypeSummaryImpl::Flags string_flags;
- string_flags.SetCascades(false)
- .SetSkipPointers(true)
- .SetSkipReferences(false)
- .SetDontShowChildren(true)
- .SetDontShowValue(false)
- .SetShowMembersOneLiner(false)
- .SetHideItemNames(false);
-
- lldb::TypeSummaryImplSP string_format(new StringSummaryFormat(string_flags, "${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]+\\]"));
-
- 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);
-
- lldb::TypeSummaryImplSP ostype_summary(new StringSummaryFormat(TypeSummaryImpl::Flags().SetCascades(false)
- .SetSkipPointers(true)
- .SetSkipReferences(true)
- .SetDontShowChildren(true)
- .SetDontShowValue(false)
- .SetShowMembersOneLiner(false)
- .SetHideItemNames(false),
- "${var%O}"));
-
- sys_category_sp->GetSummaryNavigator()->Add(ConstString("OSType"), ostype_summary);
-
-#ifndef LLDB_DISABLE_PYTHON
- // FIXME because of a bug in the FormatNavigator we need to add a summary for both X* and const X* (<rdar://problem/12717717>)
- AddCXXSummary(sys_category_sp, lldb_private::formatters::Char16StringSummaryProvider, "char16_t * summary provider", ConstString("char16_t *"), string_flags);
- AddCXXSummary(sys_category_sp, lldb_private::formatters::Char16StringSummaryProvider, "char16_t * summary provider", ConstString("const char16_t *"), string_flags);
-
- AddCXXSummary(sys_category_sp, lldb_private::formatters::Char32StringSummaryProvider, "char32_t * summary provider", ConstString("char32_t *"), string_flags);
- AddCXXSummary(sys_category_sp, lldb_private::formatters::Char32StringSummaryProvider, "char32_t * summary provider", ConstString("const char32_t *"), string_flags);
-
- AddCXXSummary(sys_category_sp, lldb_private::formatters::WCharStringSummaryProvider, "wchar_t * summary provider", ConstString("wchar_t *"), string_flags);
- AddCXXSummary(sys_category_sp, lldb_private::formatters::WCharStringSummaryProvider, "wchar_t * summary provider", ConstString("const wchar_t *"), string_flags);
-
- AddCXXSummary(sys_category_sp, lldb_private::formatters::Char16StringSummaryProvider, "unichar * summary provider", ConstString("unichar *"), string_flags);
- AddCXXSummary(sys_category_sp, lldb_private::formatters::Char16StringSummaryProvider, "unichar * summary provider", ConstString("const unichar *"), string_flags);
-
- TypeSummaryImpl::Flags widechar_flags;
- widechar_flags.SetDontShowValue(true)
- .SetSkipPointers(true)
- .SetSkipReferences(false)
- .SetCascades(true)
- .SetDontShowChildren(true)
- .SetHideItemNames(true)
- .SetShowMembersOneLiner(false);
-
- AddCXXSummary(sys_category_sp, lldb_private::formatters::Char16SummaryProvider, "char16_t summary provider", ConstString("char16_t"), widechar_flags);
- AddCXXSummary(sys_category_sp, lldb_private::formatters::Char32SummaryProvider, "char32_t summary provider", ConstString("char32_t"), widechar_flags);
- AddCXXSummary(sys_category_sp, lldb_private::formatters::WCharSummaryProvider, "wchar_t summary provider", ConstString("wchar_t"), widechar_flags);
-
- AddCXXSummary(sys_category_sp, lldb_private::formatters::Char16SummaryProvider, "unichar summary provider", ConstString("unichar"), widechar_flags);
-
-#endif
-}
-
-void
-FormatManager::LoadObjCFormatters()
-{
- TypeSummaryImpl::Flags objc_flags;
- objc_flags.SetCascades(false)
- .SetSkipPointers(true)
- .SetSkipReferences(true)
- .SetDontShowChildren(true)
- .SetDontShowValue(true)
- .SetShowMembersOneLiner(false)
- .SetHideItemNames(false);
-
- TypeCategoryImpl::SharedPointer objc_category_sp = GetCategory(m_objc_category_name);
-
- lldb::TypeSummaryImplSP ObjC_BOOL_summary(new CXXFunctionSummaryFormat(objc_flags, lldb_private::formatters::ObjCBOOLSummaryProvider,""));
- objc_category_sp->GetSummaryNavigator()->Add(ConstString("BOOL"),
- ObjC_BOOL_summary);
- objc_category_sp->GetSummaryNavigator()->Add(ConstString("BOOL &"),
- ObjC_BOOL_summary);
- objc_category_sp->GetSummaryNavigator()->Add(ConstString("BOOL *"),
- ObjC_BOOL_summary);
-
-#ifndef LLDB_DISABLE_PYTHON
- // we need to skip pointers here since we are special casing a SEL* when retrieving its value
- objc_flags.SetSkipPointers(true);
- AddCXXSummary(objc_category_sp, lldb_private::formatters::ObjCSELSummaryProvider<false>, "SEL summary provider", ConstString("SEL"), objc_flags);
- AddCXXSummary(objc_category_sp, lldb_private::formatters::ObjCSELSummaryProvider<false>, "SEL summary provider", ConstString("struct objc_selector"), objc_flags);
- AddCXXSummary(objc_category_sp, lldb_private::formatters::ObjCSELSummaryProvider<false>, "SEL summary provider", ConstString("objc_selector"), objc_flags);
- AddCXXSummary(objc_category_sp, lldb_private::formatters::ObjCSELSummaryProvider<true>, "SEL summary provider", ConstString("objc_selector *"), objc_flags);
-
- AddScriptSummary(objc_category_sp, "lldb.formatters.objc.Class.Class_Summary", ConstString("Class"), objc_flags);
-#endif // LLDB_DISABLE_PYTHON
-
- objc_flags.SetSkipPointers(false);
-
- TypeCategoryImpl::SharedPointer corefoundation_category_sp = GetCategory(m_corefoundation_category_name);
-
- AddStringSummary(corefoundation_category_sp,
- "${var.years} years, ${var.months} months, ${var.days} days, ${var.hours} hours, ${var.minutes} minutes ${var.seconds} seconds",
- ConstString("CFGregorianUnits"),
- objc_flags);
- AddStringSummary(corefoundation_category_sp,
- "location=${var.location} length=${var.length}",
- ConstString("CFRange"),
- objc_flags);
- AddStringSummary(corefoundation_category_sp,
- "(x=${var.x}, y=${var.y})",
- ConstString("NSPoint"),
- objc_flags);
- AddStringSummary(corefoundation_category_sp,
- "location=${var.location}, length=${var.length}",
- ConstString("NSRange"),
- objc_flags);
- AddStringSummary(corefoundation_category_sp,
- "${var.origin}, ${var.size}",
- ConstString("NSRect"),
- objc_flags);
- AddStringSummary(corefoundation_category_sp,
- "(${var.origin}, ${var.size}), ...",
- ConstString("NSRectArray"),
- objc_flags);
- AddStringSummary(objc_category_sp,
- "(width=${var.width}, height=${var.height})",
- ConstString("NSSize"),
- objc_flags);
-
- TypeCategoryImpl::SharedPointer coregraphics_category_sp = GetCategory(m_coregraphics_category_name);
-
- AddStringSummary(coregraphics_category_sp,
- "(width=${var.width}, height=${var.height})",
- ConstString("CGSize"),
- objc_flags);
- AddStringSummary(coregraphics_category_sp,
- "(x=${var.x}, y=${var.y})",
- ConstString("CGPoint"),
- objc_flags);
- AddStringSummary(coregraphics_category_sp,
- "origin=${var.origin} size=${var.size}",
- ConstString("CGRect"),
- objc_flags);
-
- TypeCategoryImpl::SharedPointer coreservices_category_sp = GetCategory(m_coreservices_category_name);
-
- AddStringSummary(coreservices_category_sp,
- "red=${var.red} green=${var.green} blue=${var.blue}",
- ConstString("RGBColor"),
- objc_flags);
- AddStringSummary(coreservices_category_sp,
- "(t=${var.top}, l=${var.left}, b=${var.bottom}, r=${var.right})",
- ConstString("Rect"),
- objc_flags);
- AddStringSummary(coreservices_category_sp,
- "(v=${var.v}, h=${var.h})",
- ConstString("Point"),
- objc_flags);
- AddStringSummary(coreservices_category_sp,
- "${var.month}/${var.day}/${var.year} ${var.hour} :${var.minute} :${var.second} dayOfWeek:${var.dayOfWeek}",
- ConstString("DateTimeRect *"),
- objc_flags);
- AddStringSummary(coreservices_category_sp,
- "${var.ld.month}/${var.ld.day}/${var.ld.year} ${var.ld.hour} :${var.ld.minute} :${var.ld.second} dayOfWeek:${var.ld.dayOfWeek}",
- ConstString("LongDateRect"),
- objc_flags);
- AddStringSummary(coreservices_category_sp,
- "(x=${var.x}, y=${var.y})",
- ConstString("HIPoint"),
- objc_flags);
- AddStringSummary(coreservices_category_sp,
- "origin=${var.origin} size=${var.size}",
- ConstString("HIRect"),
- objc_flags);
-
- TypeCategoryImpl::SharedPointer appkit_category_sp = GetCategory(m_appkit_category_name);
-
- TypeSummaryImpl::Flags appkit_flags;
- appkit_flags.SetCascades(true)
- .SetSkipPointers(false)
- .SetSkipReferences(false)
- .SetDontShowChildren(true)
- .SetDontShowValue(false)
- .SetShowMembersOneLiner(false)
- .SetHideItemNames(false);
-
- appkit_flags.SetDontShowChildren(false);
-
-
-#ifndef LLDB_DISABLE_PYTHON
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSArraySummaryProvider, "NSArray summary provider", ConstString("NSArray"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSArraySummaryProvider, "NSArray summary provider", ConstString("NSMutableArray"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSArraySummaryProvider, "NSArray summary provider", ConstString("__NSArrayI"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSArraySummaryProvider, "NSArray summary provider", ConstString("__NSArrayM"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSArraySummaryProvider, "NSArray summary provider", ConstString("__NSCFArray"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSArraySummaryProvider, "NSArray summary provider", ConstString("CFArrayRef"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSArraySummaryProvider, "NSArray summary provider", ConstString("CFMutableArrayRef"), appkit_flags);
-
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSDictionarySummaryProvider<false>, "NSDictionary summary provider", ConstString("NSDictionary"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSDictionarySummaryProvider<false>, "NSDictionary summary provider", ConstString("NSMutableDictionary"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSDictionarySummaryProvider<false>, "NSDictionary summary provider", ConstString("__NSCFDictionary"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSDictionarySummaryProvider<false>, "NSDictionary summary provider", ConstString("__NSDictionaryI"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSDictionarySummaryProvider<false>, "NSDictionary summary provider", ConstString("__NSDictionaryM"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSDictionarySummaryProvider<true>, "NSDictionary summary provider", ConstString("CFDictionaryRef"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSDictionarySummaryProvider<true>, "NSDictionary summary provider", ConstString("CFMutableDictionaryRef"), appkit_flags);
-
- // AddSummary(appkit_category_sp, "${var.key%@} -> ${var.value%@}", ConstString("$_lldb_typegen_nspair"), appkit_flags);
-
- appkit_flags.SetDontShowChildren(true);
-
- AddCXXSynthetic(appkit_category_sp, lldb_private::formatters::NSArraySyntheticFrontEndCreator, "NSArray synthetic children", ConstString("__NSArrayM"), TypeSyntheticImpl::Flags());
- AddCXXSynthetic(appkit_category_sp, lldb_private::formatters::NSArraySyntheticFrontEndCreator, "NSArray synthetic children", ConstString("__NSArrayI"), TypeSyntheticImpl::Flags());
- AddCXXSynthetic(appkit_category_sp, lldb_private::formatters::NSArraySyntheticFrontEndCreator, "NSArray synthetic children", ConstString("NSArray"), TypeSyntheticImpl::Flags());
- AddCXXSynthetic(appkit_category_sp, lldb_private::formatters::NSArraySyntheticFrontEndCreator, "NSArray synthetic children", ConstString("NSMutableArray"), TypeSyntheticImpl::Flags());
- AddCXXSynthetic(appkit_category_sp, lldb_private::formatters::NSArraySyntheticFrontEndCreator, "NSArray synthetic children", ConstString("__NSCFArray"), TypeSyntheticImpl::Flags());
-
- AddCXXSynthetic(appkit_category_sp, lldb_private::formatters::NSDictionarySyntheticFrontEndCreator, "NSDictionary synthetic children", ConstString("__NSDictionaryM"), TypeSyntheticImpl::Flags());
- AddCXXSynthetic(appkit_category_sp, lldb_private::formatters::NSDictionarySyntheticFrontEndCreator, "NSDictionary synthetic children", ConstString("__NSDictionaryI"), TypeSyntheticImpl::Flags());
- AddCXXSynthetic(appkit_category_sp, lldb_private::formatters::NSDictionarySyntheticFrontEndCreator, "NSDictionary synthetic children", ConstString("NSDictionary"), TypeSyntheticImpl::Flags());
- AddCXXSynthetic(appkit_category_sp, lldb_private::formatters::NSDictionarySyntheticFrontEndCreator, "NSDictionary synthetic children", ConstString("NSMutableDictionary"), TypeSyntheticImpl::Flags());
- AddCXXSynthetic(appkit_category_sp, lldb_private::formatters::NSDictionarySyntheticFrontEndCreator, "NSDictionary synthetic children", ConstString("CFDictionaryRef"), TypeSyntheticImpl::Flags());
- AddCXXSynthetic(appkit_category_sp, lldb_private::formatters::NSDictionarySyntheticFrontEndCreator, "NSDictionary synthetic children", ConstString("CFMutableDictionaryRef"), TypeSyntheticImpl::Flags());
-
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.CFBag.CFBag_SummaryProvider", ConstString("CFBagRef"), appkit_flags);
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.CFBag.CFBag_SummaryProvider", ConstString("__CFBag"), appkit_flags);
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.CFBag.CFBag_SummaryProvider", ConstString("const struct __CFBag"), appkit_flags);
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.CFBag.CFBag_SummaryProvider", ConstString("CFMutableBagRef"), appkit_flags);
-
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.CFBinaryHeap.CFBinaryHeap_SummaryProvider", ConstString("CFBinaryHeapRef"), appkit_flags);
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.CFBinaryHeap.CFBinaryHeap_SummaryProvider", ConstString("__CFBinaryHeap"), appkit_flags);
-
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSStringSummaryProvider, "NSString summary provider", ConstString("NSString"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSStringSummaryProvider, "NSString summary provider", ConstString("CFStringRef"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSStringSummaryProvider, "NSString summary provider", ConstString("CFMutableStringRef"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSStringSummaryProvider, "NSString summary provider", ConstString("__NSCFConstantString"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSStringSummaryProvider, "NSString summary provider", ConstString("__NSCFString"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSStringSummaryProvider, "NSString summary provider", ConstString("NSCFConstantString"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSStringSummaryProvider, "NSString summary provider", ConstString("NSCFString"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSStringSummaryProvider, "NSString summary provider", ConstString("NSPathStore2"), appkit_flags);
-
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.CFString.CFAttributedString_SummaryProvider", ConstString("NSAttributedString"), appkit_flags);
-
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSBundle.NSBundle_SummaryProvider", ConstString("NSBundle"), appkit_flags);
-
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSDataSummaryProvider<false>, "NSData summary provider", ConstString("NSData"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSDataSummaryProvider<false>, "NSData summary provider", ConstString("NSConcreteData"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSDataSummaryProvider<false>, "NSData summary provider", ConstString("NSConcreteMutableData"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSDataSummaryProvider<false>, "NSData summary provider", ConstString("__NSCFData"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSDataSummaryProvider<true>, "NSData summary provider", ConstString("CFDataRef"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSDataSummaryProvider<true>, "NSData summary provider", ConstString("CFMutableDataRef"), appkit_flags);
-
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSException.NSException_SummaryProvider", ConstString("NSException"), appkit_flags);
-
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSMachPort.NSMachPort_SummaryProvider", ConstString("NSMachPort"), appkit_flags);
-
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSNotification.NSNotification_SummaryProvider", ConstString("NSNotification"), appkit_flags);
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSNotification.NSNotification_SummaryProvider", ConstString("NSConcreteNotification"), appkit_flags);
-
- AddStringSummary(appkit_category_sp, "domain: ${var._domain} - code: ${var._code}", ConstString("NSError"), appkit_flags);
-
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSNumberSummaryProvider, "NSNumber summary provider", ConstString("NSNumber"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSNumberSummaryProvider, "NSNumber summary provider", ConstString("__NSCFBoolean"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSNumberSummaryProvider, "NSNumber summary provider", ConstString("__NSCFNumber"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSNumberSummaryProvider, "NSNumber summary provider", ConstString("NSCFBoolean"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSNumberSummaryProvider, "NSNumber summary provider", ConstString("NSCFNumber"), appkit_flags);
-
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::RuntimeSpecificDescriptionSummaryProvider, "NSDecimalNumber summary provider", ConstString("NSDecimalNumber"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::RuntimeSpecificDescriptionSummaryProvider, "NSHost summary provider", ConstString("NSHost"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::RuntimeSpecificDescriptionSummaryProvider, "NSTask summary provider", ConstString("NSTask"), appkit_flags);
- AddCXXSummary(appkit_category_sp, lldb_private::formatters::RuntimeSpecificDescriptionSummaryProvider, "NSValue summary provider", ConstString("NSValue"), appkit_flags);
-
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSSet.NSSet_SummaryProvider", ConstString("NSSet"), appkit_flags);
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSSet.NSSet_SummaryProvider2", ConstString("CFSetRef"), appkit_flags);
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSSet.NSSet_SummaryProvider2", ConstString("CFMutableSetRef"), appkit_flags);
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSSet.NSSet_SummaryProvider", ConstString("__NSCFSet"), appkit_flags);
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSSet.NSSet_SummaryProvider", ConstString("__NSSetI"), appkit_flags);
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSSet.NSSet_SummaryProvider", ConstString("__NSSetM"), appkit_flags);
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSSet.NSSet_SummaryProvider", ConstString("NSCountedSet"), appkit_flags);
-
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSURL.NSURL_SummaryProvider", ConstString("NSURL"), appkit_flags);
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSURL.NSURL_SummaryProvider", ConstString("CFURLRef"), appkit_flags);
-
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSDate.NSDate_SummaryProvider", ConstString("NSDate"), appkit_flags);
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSDate.NSDate_SummaryProvider", ConstString("__NSDate"), appkit_flags);
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSDate.NSDate_SummaryProvider", ConstString("__NSTaggedDate"), appkit_flags);
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSDate.NSDate_SummaryProvider", ConstString("NSCalendarDate"), appkit_flags);
-
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSDate.NSTimeZone_SummaryProvider", ConstString("NSTimeZone"), appkit_flags);
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSDate.NSTimeZone_SummaryProvider", ConstString("CFTimeZoneRef"), appkit_flags);
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSDate.NSTimeZone_SummaryProvider", ConstString("__NSTimeZone"), appkit_flags);
-
- // CFAbsoluteTime is actually a double rather than a pointer to an object
- // we do not care about the numeric value, since it is probably meaningless to users
- appkit_flags.SetDontShowValue(true);
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSDate.CFAbsoluteTime_SummaryProvider", ConstString("CFAbsoluteTime"), appkit_flags);
- appkit_flags.SetDontShowValue(false);
-
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSIndexSet.NSIndexSet_SummaryProvider", ConstString("NSIndexSet"), appkit_flags);
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSIndexSet.NSIndexSet_SummaryProvider", ConstString("NSMutableIndexSet"), appkit_flags);
-
- AddStringSummary(appkit_category_sp,
- "@\"${var.month%d}/${var.day%d}/${var.year%d} ${var.hour%d}:${var.minute%d}:${var.second}\"",
- ConstString("CFGregorianDate"),
- appkit_flags);
-
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.CFBitVector.CFBitVector_SummaryProvider", ConstString("CFBitVectorRef"), appkit_flags);
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.CFBitVector.CFBitVector_SummaryProvider", ConstString("CFMutableBitVectorRef"), appkit_flags);
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.CFBitVector.CFBitVector_SummaryProvider", ConstString("__CFBitVector"), appkit_flags);
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.CFBitVector.CFBitVector_SummaryProvider", ConstString("__CFMutableBitVector"), appkit_flags);
-#endif // LLDB_DISABLE_PYTHON
-
- TypeCategoryImpl::SharedPointer vectors_category_sp = GetCategory(m_vectortypes_category_name);
-
- TypeSummaryImpl::Flags vector_flags;
- vector_flags.SetCascades(true)
- .SetSkipPointers(true)
- .SetSkipReferences(false)
- .SetDontShowChildren(true)
- .SetDontShowValue(false)
- .SetShowMembersOneLiner(true)
- .SetHideItemNames(true);
-
- AddStringSummary(vectors_category_sp,
- "${var.uint128}",
- ConstString("builtin_type_vec128"),
- objc_flags);
-
- AddStringSummary(vectors_category_sp,
- "",
- ConstString("float [4]"),
- vector_flags);
- AddStringSummary(vectors_category_sp,
- "",
- ConstString("int32_t [4]"),
- vector_flags);
- AddStringSummary(vectors_category_sp,
- "",
- ConstString("int16_t [8]"),
- vector_flags);
- AddStringSummary(vectors_category_sp,
- "",
- ConstString("vDouble"),
- vector_flags);
- AddStringSummary(vectors_category_sp,
- "",
- ConstString("vFloat"),
- vector_flags);
- AddStringSummary(vectors_category_sp,
- "",
- ConstString("vSInt8"),
- vector_flags);
- AddStringSummary(vectors_category_sp,
- "",
- ConstString("vSInt16"),
- vector_flags);
- AddStringSummary(vectors_category_sp,
- "",
- ConstString("vSInt32"),
- vector_flags);
- AddStringSummary(vectors_category_sp,
- "",
- ConstString("vUInt16"),
- vector_flags);
- AddStringSummary(vectors_category_sp,
- "",
- ConstString("vUInt8"),
- vector_flags);
- AddStringSummary(vectors_category_sp,
- "",
- ConstString("vUInt16"),
- vector_flags);
- AddStringSummary(vectors_category_sp,
- "",
- ConstString("vUInt32"),
- vector_flags);
- AddStringSummary(vectors_category_sp,
- "",
- ConstString("vBool32"),
- vector_flags);
-}
Modified: lldb/trunk/source/Core/Timer.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Timer.cpp?rev=173728&r1=173727&r2=173728&view=diff
==============================================================================
--- lldb/trunk/source/Core/Timer.cpp (original)
+++ lldb/trunk/source/Core/Timer.cpp Mon Jan 28 17:47:25 2013
@@ -25,7 +25,7 @@ uint32_t Timer::g_depth = 0;
uint32_t Timer::g_display_depth = 0;
FILE * Timer::g_file = NULL;
typedef std::vector<Timer *> TimerStack;
-typedef std::map<const char *, uint64_t> CategoryMap;
+typedef std::map<const char *, uint64_t> TimerCategoryMap;
static pthread_key_t g_key;
static Mutex &
@@ -35,10 +35,10 @@ GetCategoryMutex()
return g_category_mutex;
}
-static CategoryMap &
+static TimerCategoryMap &
GetCategoryMap()
{
- static CategoryMap g_category_map;
+ static TimerCategoryMap g_category_map;
return g_category_map;
}
@@ -153,7 +153,7 @@ Timer::~Timer()
// Keep total results for each category so we can dump results.
Mutex::Locker locker (GetCategoryMutex());
- CategoryMap &category_map = GetCategoryMap();
+ TimerCategoryMap &category_map = GetCategoryMap();
category_map[m_category] += timer_nsec_uint;
}
if (g_depth > 0)
@@ -214,7 +214,7 @@ Timer::SetDisplayDepth (uint32_t depth)
* - returns whether a person is less than another person
*/
static bool
-CategoryMapIteratorSortCriterion (const CategoryMap::const_iterator& lhs, const CategoryMap::const_iterator& rhs)
+CategoryMapIteratorSortCriterion (const TimerCategoryMap::const_iterator& lhs, const TimerCategoryMap::const_iterator& rhs)
{
return lhs->second > rhs->second;
}
@@ -224,7 +224,7 @@ void
Timer::ResetCategoryTimes ()
{
Mutex::Locker locker (GetCategoryMutex());
- CategoryMap &category_map = GetCategoryMap();
+ TimerCategoryMap &category_map = GetCategoryMap();
category_map.clear();
}
@@ -232,9 +232,9 @@ void
Timer::DumpCategoryTimes (Stream *s)
{
Mutex::Locker locker (GetCategoryMutex());
- CategoryMap &category_map = GetCategoryMap();
- std::vector<CategoryMap::const_iterator> sorted_iterators;
- CategoryMap::const_iterator pos, end = category_map.end();
+ TimerCategoryMap &category_map = GetCategoryMap();
+ std::vector<TimerCategoryMap::const_iterator> sorted_iterators;
+ TimerCategoryMap::const_iterator pos, end = category_map.end();
for (pos = category_map.begin(); pos != end; ++pos)
{
sorted_iterators.push_back (pos);
Modified: lldb/trunk/source/Core/ValueObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=173728&r1=173727&r2=173728&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObject.cpp (original)
+++ lldb/trunk/source/Core/ValueObject.cpp Mon Jan 28 17:47:25 2013
@@ -21,7 +21,6 @@
// Project includes
#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/DataVisualization.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
@@ -34,6 +33,8 @@
#include "lldb/Core/ValueObjectMemory.h"
#include "lldb/Core/ValueObjectSyntheticFilter.h"
+#include "lldb/DataFormatters/DataVisualization.h"
+
#include "lldb/Host/Endian.h"
#include "lldb/Interpreter/CommandInterpreter.h"
@@ -83,7 +84,6 @@ ValueObject::ValueObject (ValueObject &p
m_deref_valobj(NULL),
m_format (eFormatDefault),
m_last_format_mgr_revision(0),
- m_last_format_mgr_dynamic(parent.m_last_format_mgr_dynamic),
m_type_summary_sp(),
m_type_format_sp(),
m_synthetic_children_sp(),
@@ -129,7 +129,6 @@ ValueObject::ValueObject (ExecutionConte
m_deref_valobj(NULL),
m_format (eFormatDefault),
m_last_format_mgr_revision(0),
- m_last_format_mgr_dynamic(eNoDynamicValues),
m_type_summary_sp(),
m_type_format_sp(),
m_synthetic_children_sp(),
@@ -161,17 +160,11 @@ ValueObject::~ValueObject ()
bool
ValueObject::UpdateValueIfNeeded (bool update_format)
{
- return UpdateValueIfNeeded(m_last_format_mgr_dynamic, update_format);
-}
-
-bool
-ValueObject::UpdateValueIfNeeded (DynamicValueType use_dynamic, bool update_format)
-{
bool did_change_formats = false;
if (update_format)
- did_change_formats = UpdateFormatsIfNeeded(use_dynamic);
+ did_change_formats = UpdateFormatsIfNeeded();
// If this is a constant value, then our success is predicated on whether
// we have an error or not
@@ -238,7 +231,7 @@ ValueObject::UpdateValueIfNeeded (Dynami
}
bool
-ValueObject::UpdateFormatsIfNeeded(DynamicValueType use_dynamic)
+ValueObject::UpdateFormatsIfNeeded()
{
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
if (log)
@@ -250,17 +243,15 @@ ValueObject::UpdateFormatsIfNeeded(Dynam
bool any_change = false;
- if ( (m_last_format_mgr_revision != DataVisualization::GetCurrentRevision()) ||
- m_last_format_mgr_dynamic != use_dynamic)
+ if ( (m_last_format_mgr_revision != DataVisualization::GetCurrentRevision()))
{
SetValueFormat(DataVisualization::ValueFormats::GetFormat (*this, eNoDynamicValues));
- SetSummaryFormat(DataVisualization::GetSummaryFormat (*this, use_dynamic));
+ SetSummaryFormat(DataVisualization::GetSummaryFormat (*this, GetDynamicValueType()));
#ifndef LLDB_DISABLE_PYTHON
- SetSyntheticChildren(DataVisualization::GetSyntheticChildren (*this, use_dynamic));
+ SetSyntheticChildren(DataVisualization::GetSyntheticChildren (*this, GetDynamicValueType()));
#endif
m_last_format_mgr_revision = DataVisualization::GetCurrentRevision();
- m_last_format_mgr_dynamic = use_dynamic;
any_change = true;
}
@@ -2033,42 +2024,6 @@ ValueObject::GetSyntheticBitFieldChild (
}
ValueObjectSP
-ValueObject::GetSyntheticArrayRangeChild (uint32_t from, uint32_t to, bool can_create)
-{
- ValueObjectSP synthetic_child_sp;
- if (IsArrayType () || IsPointerType ())
- {
- char index_str[64];
- snprintf(index_str, sizeof(index_str), "[%i-%i]", from, to);
- ConstString index_const_str(index_str);
- // Check if we have already created a synthetic array member in this
- // valid object. If we have we will re-use it.
- synthetic_child_sp = GetSyntheticChild (index_const_str);
- if (!synthetic_child_sp)
- {
- ValueObjectSynthetic *synthetic_child;
-
- // 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(SyntheticChildren::Flags());
- view->AddRange(from,to);
- SyntheticChildrenSP view_sp(view);
- synthetic_child = new ValueObjectSynthetic(*this, view_sp);
-
- // Cache the value if we got one back...
- if (synthetic_child)
- {
- AddSyntheticChild(index_const_str, synthetic_child);
- synthetic_child_sp = synthetic_child->GetSP();
- synthetic_child_sp->SetName(ConstString(index_str));
- synthetic_child_sp->m_is_bitfield_for_scalar = true;
- }
- }
- }
- return synthetic_child_sp;
-}
-
-ValueObjectSP
ValueObject::GetSyntheticChildAtOffset(uint32_t offset, const ClangASTType& type, bool can_create)
{
@@ -2168,7 +2123,7 @@ ValueObject::CalculateSyntheticValue (bo
lldb::SyntheticChildrenSP current_synth_sp(m_synthetic_children_sp);
- if (!UpdateFormatsIfNeeded(m_last_format_mgr_dynamic) && m_synthetic_value)
+ if (!UpdateFormatsIfNeeded() && m_synthetic_value)
return;
if (m_synthetic_children_sp.get() == NULL)
@@ -2243,7 +2198,7 @@ ValueObject::GetSyntheticValue (bool use
bool
ValueObject::HasSyntheticValue()
{
- UpdateFormatsIfNeeded(m_last_format_mgr_dynamic);
+ UpdateFormatsIfNeeded();
if (m_synthetic_children_sp.get() == NULL)
return false;
@@ -3285,7 +3240,7 @@ DumpValueObject_Impl (Stream &s,
{
if (valobj)
{
- bool update_success = valobj->UpdateValueIfNeeded (options.m_use_dynamic, true);
+ bool update_success = valobj->UpdateValueIfNeeded (true);
const char *root_valobj_name =
options.m_root_valobj_name.empty() ?
Modified: lldb/trunk/source/Core/ValueObjectDynamicValue.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectDynamicValue.cpp?rev=173728&r1=173727&r2=173728&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObjectDynamicValue.cpp (original)
+++ lldb/trunk/source/Core/ValueObjectDynamicValue.cpp Mon Jan 28 17:47:25 2013
@@ -41,7 +41,6 @@ ValueObjectDynamicValue::ValueObjectDyna
m_dynamic_type_info(),
m_use_dynamic (use_dynamic)
{
- m_last_format_mgr_dynamic = use_dynamic;
SetName (parent.GetName());
}
Modified: lldb/trunk/source/Core/ValueObjectSyntheticFilter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectSyntheticFilter.cpp?rev=173728&r1=173727&r2=173728&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObjectSyntheticFilter.cpp (original)
+++ lldb/trunk/source/Core/ValueObjectSyntheticFilter.cpp Mon Jan 28 17:47:25 2013
@@ -15,8 +15,8 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/FormatClasses.h"
#include "lldb/Core/ValueObject.h"
+#include "lldb/DataFormatters/FormatClasses.h"
using namespace lldb_private;
@@ -39,7 +39,7 @@ public:
return lldb::ValueObjectSP();
}
- uint32_t
+ size_t
GetIndexOfChildWithName (const ConstString &name)
{
return UINT32_MAX;
@@ -95,6 +95,12 @@ ValueObjectSynthetic::GetTypeName()
return m_parent->GetTypeName();
}
+ConstString
+ValueObjectSynthetic::GetQualifiedTypeName()
+{
+ return m_parent->GetQualifiedTypeName();
+}
+
size_t
ValueObjectSynthetic::CalculateNumChildren()
{
@@ -104,6 +110,16 @@ ValueObjectSynthetic::CalculateNumChildr
return (m_synthetic_children_count = m_synth_filter_ap->CalculateNumChildren());
}
+lldb::ValueObjectSP
+ValueObjectSynthetic::GetDynamicValue (lldb::DynamicValueType valueType)
+{
+ if (!m_parent)
+ return lldb::ValueObjectSP();
+ if (m_parent->IsDynamic() && m_parent->GetDynamicValueType() == valueType)
+ return m_parent->GetSP();
+ return ValueObject::GetDynamicValue(valueType);
+}
+
bool
ValueObjectSynthetic::MightHaveChildren()
{
Copied: lldb/trunk/source/DataFormatters/CXXFormatterFunctions.cpp (from r173281, lldb/trunk/source/Core/CXXFormatterFunctions.cpp)
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/CXXFormatterFunctions.cpp?p2=lldb/trunk/source/DataFormatters/CXXFormatterFunctions.cpp&p1=lldb/trunk/source/Core/CXXFormatterFunctions.cpp&r1=173281&r2=173728&rev=173728&view=diff
==============================================================================
--- lldb/trunk/source/Core/CXXFormatterFunctions.cpp (original)
+++ lldb/trunk/source/DataFormatters/CXXFormatterFunctions.cpp Mon Jan 28 17:47:25 2013
@@ -9,7 +9,7 @@
#include "lldb/lldb-python.h"
-#include "lldb/Core/CXXFormatterFunctions.h"
+#include "lldb/DataFormatters/CXXFormatterFunctions.h"
// needed to get ConvertUTF16/32ToUTF8
#define CLANG_NEEDS_THESE_ONE_DAY
@@ -1092,7 +1092,7 @@ m_data_64(NULL)
}
}
-uint32_t
+size_t
lldb_private::formatters::NSArrayMSyntheticFrontEnd::CalculateNumChildren ()
{
if (m_data_32)
@@ -1103,7 +1103,7 @@ lldb_private::formatters::NSArrayMSynthe
}
lldb::ValueObjectSP
-lldb_private::formatters::NSArrayMSyntheticFrontEnd::GetChildAtIndex (uint32_t idx)
+lldb_private::formatters::NSArrayMSyntheticFrontEnd::GetChildAtIndex (size_t idx)
{
if (!m_data_32 && !m_data_64)
return lldb::ValueObjectSP();
@@ -1112,7 +1112,7 @@ lldb_private::formatters::NSArrayMSynthe
lldb::addr_t object_at_idx = (m_data_32 ? m_data_32->_data : m_data_64->_data);
object_at_idx += (idx * m_ptr_size);
StreamString idx_name;
- idx_name.Printf("[%d]",idx);
+ idx_name.Printf("[%zu]",idx);
lldb::ValueObjectSP retval_sp = ValueObject::CreateValueObjectFromAddress(idx_name.GetData(),
object_at_idx,
m_exe_ctx_ref,
@@ -1192,7 +1192,7 @@ ExtractIndexFromString (const char* item
return idx;
}
-uint32_t
+size_t
lldb_private::formatters::NSArrayMSyntheticFrontEnd::GetIndexOfChildWithName (const ConstString &name)
{
if (!m_data_32 && !m_data_64)
@@ -1230,7 +1230,7 @@ lldb_private::formatters::NSArrayISynthe
{
}
-uint32_t
+size_t
lldb_private::formatters::NSArrayISyntheticFrontEnd::GetIndexOfChildWithName (const ConstString &name)
{
const char* item_name = name.GetCString();
@@ -1240,7 +1240,7 @@ lldb_private::formatters::NSArrayISynthe
return idx;
}
-uint32_t
+size_t
lldb_private::formatters::NSArrayISyntheticFrontEnd::CalculateNumChildren ()
{
return m_items;
@@ -1286,7 +1286,7 @@ lldb_private::formatters::NSArrayISynthe
}
lldb::ValueObjectSP
-lldb_private::formatters::NSArrayISyntheticFrontEnd::GetChildAtIndex (uint32_t idx)
+lldb_private::formatters::NSArrayISyntheticFrontEnd::GetChildAtIndex (size_t idx)
{
if (idx >= CalculateNumChildren())
return lldb::ValueObjectSP();
@@ -1302,7 +1302,7 @@ lldb_private::formatters::NSArrayISynthe
StreamString expr;
expr.Printf("(id)%" PRIu64,object_at_idx);
StreamString idx_name;
- idx_name.Printf("[%d]",idx);
+ idx_name.Printf("[%zu]",idx);
lldb::ValueObjectSP retval_sp = ValueObject::CreateValueObjectFromExpression(idx_name.GetData(), expr.GetData(), m_exe_ctx_ref);
m_children.push_back(retval_sp);
return retval_sp;
@@ -1353,7 +1353,7 @@ lldb_private::formatters::NSArrayCodeRun
SyntheticChildrenFrontEnd(*valobj_sp.get())
{}
-uint32_t
+size_t
lldb_private::formatters::NSArrayCodeRunningSyntheticFrontEnd::CalculateNumChildren ()
{
uint64_t count = 0;
@@ -1363,10 +1363,10 @@ lldb_private::formatters::NSArrayCodeRun
}
lldb::ValueObjectSP
-lldb_private::formatters::NSArrayCodeRunningSyntheticFrontEnd::GetChildAtIndex (uint32_t idx)
+lldb_private::formatters::NSArrayCodeRunningSyntheticFrontEnd::GetChildAtIndex (size_t idx)
{
StreamString idx_name;
- idx_name.Printf("[%d]",idx);
+ idx_name.Printf("[%zu]",idx);
lldb::ValueObjectSP valobj_sp = CallSelectorOnObject(m_backend,"id","objectAtIndex:",idx);
if (valobj_sp)
valobj_sp->SetName(ConstString(idx_name.GetData()));
@@ -1385,7 +1385,7 @@ lldb_private::formatters::NSArrayCodeRun
return true;
}
-uint32_t
+size_t
lldb_private::formatters::NSArrayCodeRunningSyntheticFrontEnd::GetIndexOfChildWithName (const ConstString &name)
{
return 0;
@@ -1440,7 +1440,7 @@ lldb_private::formatters::NSDictionaryCo
SyntheticChildrenFrontEnd(*valobj_sp.get())
{}
-uint32_t
+size_t
lldb_private::formatters::NSDictionaryCodeRunningSyntheticFrontEnd::CalculateNumChildren ()
{
uint64_t count = 0;
@@ -1450,14 +1450,14 @@ lldb_private::formatters::NSDictionaryCo
}
lldb::ValueObjectSP
-lldb_private::formatters::NSDictionaryCodeRunningSyntheticFrontEnd::GetChildAtIndex (uint32_t idx)
+lldb_private::formatters::NSDictionaryCodeRunningSyntheticFrontEnd::GetChildAtIndex (size_t idx)
{
StreamString idx_name;
- idx_name.Printf("[%d]",idx);
+ idx_name.Printf("[%zu]",idx);
StreamString valobj_expr_path;
m_backend.GetExpressionPath(valobj_expr_path, false);
StreamString key_fetcher_expr;
- key_fetcher_expr.Printf("(id)[(NSArray*)[%s allKeys] objectAtIndex:%d]",valobj_expr_path.GetData(),idx);
+ key_fetcher_expr.Printf("(id)[(NSArray*)[%s allKeys] objectAtIndex:%zu]",valobj_expr_path.GetData(),idx);
StreamString value_fetcher_expr;
value_fetcher_expr.Printf("(id)[%s objectForKey:%s]",valobj_expr_path.GetData(),key_fetcher_expr.GetData());
StreamString object_fetcher_expr;
@@ -1482,7 +1482,7 @@ lldb_private::formatters::NSDictionaryCo
return true;
}
-uint32_t
+size_t
lldb_private::formatters::NSDictionaryCodeRunningSyntheticFrontEnd::GetIndexOfChildWithName (const ConstString &name)
{
return 0;
@@ -1510,7 +1510,7 @@ lldb_private::formatters::NSDictionaryIS
m_data_64 = NULL;
}
-uint32_t
+size_t
lldb_private::formatters::NSDictionaryISyntheticFrontEnd::GetIndexOfChildWithName (const ConstString &name)
{
const char* item_name = name.GetCString();
@@ -1520,7 +1520,7 @@ lldb_private::formatters::NSDictionaryIS
return idx;
}
-uint32_t
+size_t
lldb_private::formatters::NSDictionaryISyntheticFrontEnd::CalculateNumChildren ()
{
if (!m_data_32 && !m_data_64)
@@ -1581,7 +1581,7 @@ lldb_private::formatters::NSDictionaryIS
}
lldb::ValueObjectSP
-lldb_private::formatters::NSDictionaryISyntheticFrontEnd::GetChildAtIndex (uint32_t idx)
+lldb_private::formatters::NSDictionaryISyntheticFrontEnd::GetChildAtIndex (size_t idx)
{
uint32_t num_children = CalculateNumChildren();
@@ -1633,7 +1633,7 @@ lldb_private::formatters::NSDictionaryIS
StreamString expr;
expr.Printf("struct __lldb_autogen_nspair { id key; id value; } _lldb_valgen_item; _lldb_valgen_item.key = (id)%" PRIu64 " ; _lldb_valgen_item.value = (id)%" PRIu64 "; _lldb_valgen_item;",dict_item.key_ptr,dict_item.val_ptr);
StreamString idx_name;
- idx_name.Printf("[%d]",idx);
+ idx_name.Printf("[%zu]",idx);
dict_item.valobj_sp = ValueObject::CreateValueObjectFromExpression(idx_name.GetData(), expr.GetData(), m_exe_ctx_ref);
}
return dict_item.valobj_sp;
@@ -1658,7 +1658,7 @@ lldb_private::formatters::NSDictionaryMS
m_data_64 = NULL;
}
-uint32_t
+size_t
lldb_private::formatters::NSDictionaryMSyntheticFrontEnd::GetIndexOfChildWithName (const ConstString &name)
{
const char* item_name = name.GetCString();
@@ -1668,7 +1668,7 @@ lldb_private::formatters::NSDictionaryMS
return idx;
}
-uint32_t
+size_t
lldb_private::formatters::NSDictionaryMSyntheticFrontEnd::CalculateNumChildren ()
{
if (!m_data_32 && !m_data_64)
@@ -1728,7 +1728,7 @@ lldb_private::formatters::NSDictionaryMS
}
lldb::ValueObjectSP
-lldb_private::formatters::NSDictionaryMSyntheticFrontEnd::GetChildAtIndex (uint32_t idx)
+lldb_private::formatters::NSDictionaryMSyntheticFrontEnd::GetChildAtIndex (size_t idx)
{
lldb::addr_t m_keys_ptr = (m_data_32 ? m_data_32->_keys_addr : m_data_64->_keys_addr);
lldb::addr_t m_values_ptr = (m_data_32 ? m_data_32->_objs_addr : m_data_64->_objs_addr);
@@ -1783,7 +1783,7 @@ lldb_private::formatters::NSDictionaryMS
StreamString expr;
expr.Printf("struct __lldb_autogen_nspair { id key; id value; } _lldb_valgen_item; _lldb_valgen_item.key = (id)%" PRIu64 " ; _lldb_valgen_item.value = (id)%" PRIu64 "; _lldb_valgen_item;",dict_item.key_ptr,dict_item.val_ptr);
StreamString idx_name;
- idx_name.Printf("[%d]",idx);
+ idx_name.Printf("[%zu]",idx);
dict_item.valobj_sp = ValueObject::CreateValueObjectFromExpression(idx_name.GetData(), expr.GetData(), m_exe_ctx_ref);
}
return dict_item.valobj_sp;
Copied: lldb/trunk/source/DataFormatters/DataVisualization.cpp (from r173281, lldb/trunk/source/Core/DataVisualization.cpp)
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/DataVisualization.cpp?p2=lldb/trunk/source/DataFormatters/DataVisualization.cpp&p1=lldb/trunk/source/Core/DataVisualization.cpp&r1=173281&r2=173728&rev=173728&view=diff
==============================================================================
--- lldb/trunk/source/Core/DataVisualization.cpp (original)
+++ lldb/trunk/source/DataFormatters/DataVisualization.cpp Mon Jan 28 17:47:25 2013
@@ -9,7 +9,7 @@
#include "lldb/lldb-python.h"
-#include "lldb/Core/DataVisualization.h"
+#include "lldb/DataFormatters/DataVisualization.h"
// C Includes
// C++ Includes
@@ -80,20 +80,20 @@ DataVisualization::ValueFormats::LoopThr
GetFormatManager().GetValueNavigator().LoopThrough(callback, callback_baton);
}
-uint32_t
+size_t
DataVisualization::ValueFormats::GetCount ()
{
return GetFormatManager().GetValueNavigator().GetCount();
}
lldb::TypeNameSpecifierImplSP
-DataVisualization::ValueFormats::GetTypeNameSpecifierForFormatAtIndex (uint32_t index)
+DataVisualization::ValueFormats::GetTypeNameSpecifierForFormatAtIndex (size_t index)
{
return GetFormatManager().GetValueNavigator().GetTypeNameSpecifierAtIndex(index);
}
lldb::TypeFormatImplSP
-DataVisualization::ValueFormats::GetFormatAtIndex (uint32_t index)
+DataVisualization::ValueFormats::GetFormatAtIndex (size_t index)
{
return GetFormatManager().GetValueNavigator().GetAtIndex(index);
}
@@ -135,7 +135,7 @@ DataVisualization::GetFilterForType (lld
}
#ifndef LLDB_DISABLE_PYTHON
-lldb::TypeSyntheticImplSP
+lldb::ScriptedSyntheticChildrenSP
DataVisualization::GetSyntheticForType (lldb::TypeNameSpecifierImplSP type_sp)
{
return GetFormatManager().GetSyntheticForType(type_sp);
@@ -191,7 +191,7 @@ DataVisualization::Categories::Clear (co
void
DataVisualization::Categories::Enable (const ConstString& category,
- CategoryMap::Position pos)
+ TypeCategoryMap::Position pos)
{
if (GetFormatManager().GetCategory(category)->IsEnabled())
GetFormatManager().DisableCategory(category);
@@ -207,7 +207,7 @@ DataVisualization::Categories::Disable (
void
DataVisualization::Categories::Enable (const lldb::TypeCategoryImplSP& category,
- CategoryMap::Position pos)
+ TypeCategoryMap::Position pos)
{
if (category.get())
{
@@ -237,7 +237,7 @@ DataVisualization::Categories::GetCount
}
lldb::TypeCategoryImplSP
-DataVisualization::Categories::GetCategoryAtIndex (uint32_t index)
+DataVisualization::Categories::GetCategoryAtIndex (size_t index)
{
return GetFormatManager().GetCategoryAtIndex(index);
}
Added: lldb/trunk/source/DataFormatters/FormatCache.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/FormatCache.cpp?rev=173728&view=auto
==============================================================================
--- lldb/trunk/source/DataFormatters/FormatCache.cpp (added)
+++ lldb/trunk/source/DataFormatters/FormatCache.cpp Mon Jan 28 17:47:25 2013
@@ -0,0 +1,163 @@
+//===-- FormatCache.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
+
+// Other libraries and framework includes
+
+// Project includes
+#include "lldb/DataFormatters/FormatCache.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+FormatCache::Entry::Entry () :
+m_summary_cached(false),
+m_synthetic_cached(false),
+m_summary_sp(nullptr),
+m_synthetic_sp(nullptr)
+{}
+
+FormatCache::Entry::Entry (lldb::TypeSummaryImplSP summary_sp) : FormatCache::Entry()
+{
+ SetSummary (summary_sp);
+}
+
+FormatCache::Entry::Entry (lldb::SyntheticChildrenSP synthetic_sp) : FormatCache::Entry()
+{
+ SetSynthetic (synthetic_sp);
+}
+
+FormatCache::Entry::Entry (lldb::TypeSummaryImplSP summary_sp,lldb::SyntheticChildrenSP synthetic_sp) : FormatCache::Entry()
+{
+ SetSummary (summary_sp);
+ SetSynthetic (synthetic_sp);
+}
+
+bool
+FormatCache::Entry::IsSummaryCached ()
+{
+ return m_summary_cached;
+}
+
+bool
+FormatCache::Entry::IsSyntheticCached ()
+{
+ return m_synthetic_cached;
+}
+
+lldb::TypeSummaryImplSP
+FormatCache::Entry::GetSummary ()
+{
+ return m_summary_sp;
+}
+
+lldb::SyntheticChildrenSP
+FormatCache::Entry::GetSynthetic ()
+{
+ return m_synthetic_sp;
+}
+
+void
+FormatCache::Entry::SetSummary (lldb::TypeSummaryImplSP summary_sp)
+{
+ m_summary_cached = true;
+ m_summary_sp = summary_sp;
+}
+
+void
+FormatCache::Entry::SetSynthetic (lldb::SyntheticChildrenSP synthetic_sp)
+{
+ m_synthetic_cached = true;
+ m_synthetic_sp = synthetic_sp;
+}
+
+FormatCache::FormatCache () :
+m_map(),
+m_mutex (Mutex::eMutexTypeRecursive)
+#ifdef LLDB_CONFIGURATION_DEBUG
+,m_cache_hits(0),m_cache_misses(0)
+#endif
+{
+}
+
+FormatCache::Entry&
+FormatCache::GetEntry (const ConstString& type)
+{
+ auto i = m_map.find(type),
+ e = m_map.end();
+ if (i != e)
+ return i->second;
+ m_map[type] = FormatCache::Entry();
+ return m_map[type];
+}
+
+bool
+FormatCache::GetSummary (const ConstString& type,lldb::TypeSummaryImplSP& summary_sp)
+{
+ Mutex::Locker lock(m_mutex);
+ auto entry = GetEntry(type);
+ if (entry.IsSummaryCached())
+ {
+#ifdef LLDB_CONFIGURATION_DEBUG
+ m_cache_hits++;
+#endif
+ summary_sp = entry.GetSummary();
+ return true;
+ }
+#ifdef LLDB_CONFIGURATION_DEBUG
+ m_cache_misses++;
+#endif
+ summary_sp.reset();
+ return false;
+}
+
+bool
+FormatCache::GetSynthetic (const ConstString& type,lldb::SyntheticChildrenSP& synthetic_sp)
+{
+ Mutex::Locker lock(m_mutex);
+ auto entry = GetEntry(type);
+ if (entry.IsSyntheticCached())
+ {
+#ifdef LLDB_CONFIGURATION_DEBUG
+ m_cache_hits++;
+#endif
+ synthetic_sp = entry.GetSynthetic();
+ return true;
+ }
+#ifdef LLDB_CONFIGURATION_DEBUG
+ m_cache_misses++;
+#endif
+ synthetic_sp.reset();
+ return false;
+}
+
+void
+FormatCache::SetSummary (const ConstString& type,lldb::TypeSummaryImplSP& summary_sp)
+{
+ Mutex::Locker lock(m_mutex);
+ GetEntry(type).SetSummary(summary_sp);
+}
+
+void
+FormatCache::SetSynthetic (const ConstString& type,lldb::SyntheticChildrenSP& synthetic_sp)
+{
+ Mutex::Locker lock(m_mutex);
+ GetEntry(type).SetSynthetic(synthetic_sp);
+}
+
+void
+FormatCache::Clear ()
+{
+ Mutex::Locker lock(m_mutex);
+ m_map.clear();
+}
+
Copied: lldb/trunk/source/DataFormatters/FormatClasses.cpp (from r173281, lldb/trunk/source/Core/FormatClasses.cpp)
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/FormatClasses.cpp?p2=lldb/trunk/source/DataFormatters/FormatClasses.cpp&p1=lldb/trunk/source/Core/FormatClasses.cpp&r1=173281&r2=173728&rev=173728&view=diff
==============================================================================
--- lldb/trunk/source/Core/FormatClasses.cpp (original)
+++ lldb/trunk/source/DataFormatters/FormatClasses.cpp Mon Jan 28 17:47:25 2013
@@ -20,9 +20,9 @@
#include "lldb/lldb-enumerations.h"
#include "lldb/Core/Debugger.h"
-#include "lldb/Core/FormatClasses.h"
#include "lldb/Core/StreamString.h"
#include "lldb/Core/Timer.h"
+#include "lldb/DataFormatters/FormatClasses.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Symbol/ClangASTType.h"
#include "lldb/Target/StackFrame.h"
@@ -31,379 +31,3 @@
using namespace lldb;
using namespace lldb_private;
-TypeFormatImpl::TypeFormatImpl (lldb::Format f,
- const Flags& flags) :
- m_flags(flags),
- m_format (f)
-{
-}
-
-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();
-}
-
-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);
-}
-
-bool
-StringSummaryFormat::FormatObject(ValueObject *valobj,
- std::string& retval)
-{
- if (!valobj)
- {
- retval.assign("NULL ValueObject");
- return false;
- }
-
- StreamString s;
- ExecutionContext exe_ctx (valobj->GetExecutionContextRef());
- SymbolContext sc;
- StackFrame *frame = exe_ctx.GetFramePtr();
- if (frame)
- sc = frame->GetSymbolContext(lldb::eSymbolContextEverything);
-
- if (IsOneliner())
- {
- ValueObject* object;
-
- ValueObjectSP synth_valobj = valobj->GetSyntheticValue();
- if (synth_valobj)
- object = synth_valobj.get();
- else
- object = valobj;
-
- 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(", ");
- if (!HideNames())
- {
- s.PutCString(child_sp.get()->GetName().AsCString());
- s.PutCString(" = ");
- }
- child_sp.get()->DumpPrintableRepresentation(s,
- ValueObject::eValueObjectRepresentationStyleSummary,
- lldb::eFormatInvalid,
- ValueObject::ePrintableRepresentationSpecialCasesDisable);
- }
- }
-
- s.PutChar(')');
-
- retval.assign(s.GetString());
- return true;
- }
- else
- {
- retval.assign("error: oneliner for no children");
- return false;
- }
-
- }
- else
- {
- if (Debugger::FormatPrompt(m_format.c_str(), &sc, &exe_ctx, &sc.line_entry.range.GetBaseAddress(), s, NULL, valobj))
- {
- retval.assign(s.GetString());
- return true;
- }
- else
- {
- retval.assign("error: summary string parsing error");
- return false;
- }
- }
-}
-
-std::string
-StringSummaryFormat::GetDescription()
-{
- StreamString sstr;
-
- sstr.Printf ("`%s`%s%s%s%s%s%s%s", m_format.c_str(),
- Cascades() ? "" : " (not cascading)",
- !DoesPrintChildren() ? "" : " (show children)",
- !DoesPrintValue() ? " (hide value)" : "",
- IsOneliner() ? " (one-line printout)" : "",
- SkipsPointers() ? " (skip pointers)" : "",
- SkipsReferences() ? " (skip references)" : "",
- HideNames() ? " (hide member names)" : "");
- return sstr.GetString();
-}
-
-CXXFunctionSummaryFormat::CXXFunctionSummaryFormat (const TypeSummaryImpl::Flags& flags,
- Callback impl,
- const char* description) :
- TypeSummaryImpl(flags),
- m_impl(impl),
- m_description(description ? description : "")
-{
-}
-
-bool
-CXXFunctionSummaryFormat::FormatObject(ValueObject *valobj,
- std::string& dest)
-{
- dest.clear();
- StreamString stream;
- if (!m_impl || m_impl(*valobj,stream) == false)
- return false;
- dest.assign(stream.GetData());
- return true;
-}
-
-std::string
-CXXFunctionSummaryFormat::GetDescription()
-{
- StreamString sstr;
- sstr.Printf ("`%s (%p) `%s%s%s%s%s%s%s", m_description.c_str(),m_impl,
- Cascades() ? "" : " (not cascading)",
- !DoesPrintChildren() ? "" : " (show children)",
- !DoesPrintValue() ? " (hide value)" : "",
- IsOneliner() ? " (one-line printout)" : "",
- SkipsPointers() ? " (skip pointers)" : "",
- SkipsReferences() ? " (skip references)" : "",
- HideNames() ? " (hide member names)" : "");
- return sstr.GetString();
-}
-
-#ifndef LLDB_DISABLE_PYTHON
-
-
-ScriptSummaryFormat::ScriptSummaryFormat(const TypeSummaryImpl::Flags& flags,
- const char * function_name,
- const char * python_script) :
- TypeSummaryImpl(flags),
- m_function_name(),
- m_python_script(),
- m_script_function_sp()
-{
- if (function_name)
- m_function_name.assign(function_name);
- if (python_script)
- m_python_script.assign(python_script);
-}
-
-bool
-ScriptSummaryFormat::FormatObject(ValueObject *valobj,
- std::string& retval)
-{
- Timer scoped_timer (__PRETTY_FUNCTION__, __PRETTY_FUNCTION__);
-
- TargetSP target_sp(valobj->GetTargetSP());
-
- if (!target_sp)
- {
- retval.assign("error: no target");
- return false;
- }
-
- ScriptInterpreter *script_interpreter = target_sp->GetDebugger().GetCommandInterpreter().GetScriptInterpreter();
-
- if (!script_interpreter)
- {
- retval.assign("error: no ScriptInterpreter");
- return false;
- }
-
- return script_interpreter->GetScriptedSummary(m_function_name.c_str(),
- valobj->GetSP(),
- m_script_function_sp,
- retval);
-
-}
-
-std::string
-ScriptSummaryFormat::GetDescription()
-{
- StreamString sstr;
- sstr.Printf ("%s%s%s%s%s%s%s\n%s", Cascades() ? "" : " (not cascading)",
- !DoesPrintChildren() ? "" : " (show children)",
- !DoesPrintValue() ? " (hide value)" : "",
- IsOneliner() ? " (one-line printout)" : "",
- SkipsPointers() ? " (skip pointers)" : "",
- SkipsReferences() ? " (skip references)" : "",
- HideNames() ? " (hide member names)" : "",
- m_python_script.c_str());
- return sstr.GetString();
-
-}
-
-#endif // #ifndef LLDB_DISABLE_PYTHON
-
-std::string
-TypeFilterImpl::GetDescription()
-{
- StreamString sstr;
- sstr.Printf("%s%s%s {\n",
- Cascades() ? "" : " (not cascading)",
- SkipsPointers() ? " (skip pointers)" : "",
- SkipsReferences() ? " (skip references)" : "");
-
- for (int i = 0; i < GetCount(); i++)
- {
- sstr.Printf(" %s\n",
- GetExpressionPathAtIndex(i));
- }
-
- sstr.Printf("}");
- return sstr.GetString();
-}
-
-std::string
-CXXSyntheticChildren::GetDescription()
-{
- StreamString sstr;
- sstr.Printf("%s%s%s Generator at %p - %s\n",
- Cascades() ? "" : " (not cascading)",
- SkipsPointers() ? " (skip pointers)" : "",
- SkipsReferences() ? " (skip references)" : "",
- m_create_callback,
- m_description.c_str());
-
- return sstr.GetString();
-}
-
-std::string
-SyntheticArrayView::GetDescription()
-{
- StreamString sstr;
- sstr.Printf("%s%s%s {\n",
- Cascades() ? "" : " (not cascading)",
- SkipsPointers() ? " (skip pointers)" : "",
- SkipsReferences() ? " (skip references)" : "");
-
- SyntheticArrayRange* ptr = &m_head;
- while (ptr && ptr != m_tail)
- {
- if (ptr->GetLow() == ptr->GetHigh())
- sstr.Printf(" [%d]\n",
- ptr->GetLow());
- else
- sstr.Printf(" [%d-%d]\n",
- ptr->GetLow(),
- ptr->GetHigh());
- ptr = ptr->GetNext();
- }
-
- sstr.Printf("}");
- return sstr.GetString();
-}
-
-#ifndef LLDB_DISABLE_PYTHON
-
-TypeSyntheticImpl::FrontEnd::FrontEnd(std::string pclass, ValueObject &backend) :
- SyntheticChildrenFrontEnd(backend),
- m_python_class(pclass),
- m_wrapper_sp(),
- m_interpreter(NULL)
-{
- if (backend == LLDB_INVALID_UID)
- return;
-
- TargetSP target_sp = backend.GetTargetSP();
-
- if (!target_sp)
- return;
-
- m_interpreter = target_sp->GetDebugger().GetCommandInterpreter().GetScriptInterpreter();
-
- if (m_interpreter != NULL)
- m_wrapper_sp = m_interpreter->CreateSyntheticScriptedProvider(m_python_class.c_str(), backend.GetSP());
-}
-
-TypeSyntheticImpl::FrontEnd::~FrontEnd()
-{
-}
-
-lldb::ValueObjectSP
-TypeSyntheticImpl::FrontEnd::GetChildAtIndex (uint32_t idx)
-{
- if (!m_wrapper_sp || !m_interpreter)
- return lldb::ValueObjectSP();
-
- return m_interpreter->GetChildAtIndex(m_wrapper_sp, idx);
-}
-
-std::string
-TypeSyntheticImpl::GetDescription()
-{
- StreamString sstr;
- sstr.Printf("%s%s%s Python class %s",
- Cascades() ? "" : " (not cascading)",
- SkipsPointers() ? " (skip pointers)" : "",
- SkipsReferences() ? " (skip references)" : "",
- m_python_class.c_str());
-
- return sstr.GetString();
-}
-
-#endif // #ifndef LLDB_DISABLE_PYTHON
-
-int
-SyntheticArrayView::GetRealIndexForIndex(int i)
-{
- if (i >= GetCount())
- return -1;
-
- SyntheticArrayRange* ptr = &m_head;
-
- int residual = i;
-
- while(ptr && ptr != m_tail)
- {
- if (residual >= ptr->GetSelfCount())
- {
- residual -= ptr->GetSelfCount();
- ptr = ptr->GetNext();
- }
-
- return ptr->GetLow() + residual;
- }
-
- return -1;
-}
-
-uint32_t
-SyntheticArrayView::FrontEnd::GetIndexOfChildWithName (const ConstString &name_cs)
-{
- const char* name_cstr = name_cs.GetCString();
- if (*name_cstr != '[')
- return UINT32_MAX;
- std::string name(name_cstr+1);
- if (name[name.size()-1] != ']')
- return UINT32_MAX;
- name = name.erase(name.size()-1,1);
- int index = Args::StringToSInt32 (name.c_str(), -1);
- if (index < 0)
- return UINT32_MAX;
- return index;
-}
Copied: lldb/trunk/source/DataFormatters/FormatManager.cpp (from r173281, lldb/trunk/source/Core/FormatManager.cpp)
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/FormatManager.cpp?p2=lldb/trunk/source/DataFormatters/FormatManager.cpp&p1=lldb/trunk/source/Core/FormatManager.cpp&r1=173281&r2=173728&rev=173728&view=diff
==============================================================================
--- lldb/trunk/source/Core/FormatManager.cpp (original)
+++ lldb/trunk/source/DataFormatters/FormatManager.cpp Mon Jan 28 17:47:25 2013
@@ -9,15 +9,18 @@
#include "lldb/lldb-python.h"
-#include "lldb/Core/FormatManager.h"
+#include "lldb/DataFormatters/FormatManager.h"
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/CXXFormatterFunctions.h"
#include "lldb/Core/Debugger.h"
+#include "lldb/DataFormatters/CXXFormatterFunctions.h"
+#include "lldb/Interpreter/ScriptInterpreterPython.h"
+#include "lldb/Target/ExecutionContext.h"
+#include "lldb/Target/Platform.h"
using namespace lldb;
using namespace lldb_private;
@@ -151,8 +154,6 @@ FormatManager::GetFormatAsFormatChar (ll
}
return '\0';
}
-
-
const char *
FormatManager::GetFormatAsCString (Format format)
@@ -162,300 +163,6 @@ FormatManager::GetFormatAsCString (Forma
return NULL;
}
-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)),
- m_regex_filter_nav(new RegexFilterNavigator("regex-filter",clist)),
-#ifndef LLDB_DISABLE_PYTHON
- m_synth_nav(new SynthNavigator("synth",clist)),
- m_regex_synth_nav(new RegexSynthNavigator("regex-synth",clist)),
-#endif
- m_enabled(false),
- m_change_listener(clist),
- m_mutex(Mutex::eMutexTypeRecursive),
- m_name(name)
-{}
-
-bool
-TypeCategoryImpl::Get (ValueObject& valobj,
- lldb::TypeSummaryImplSP& entry,
- lldb::DynamicValueType use_dynamic,
- uint32_t* reason)
-{
- if (!IsEnabled())
- return false;
- if (GetSummaryNavigator()->Get(valobj, entry, use_dynamic, reason))
- return true;
- bool regex = GetRegexSummaryNavigator()->Get(valobj, entry, use_dynamic, reason);
- if (regex && reason)
- *reason |= lldb_private::eFormatterChoiceCriterionRegularExpressionSummary;
- return regex;
-}
-
-bool
-TypeCategoryImpl::Get(ValueObject& valobj,
- lldb::SyntheticChildrenSP& entry_sp,
- lldb::DynamicValueType use_dynamic,
- uint32_t* reason)
-{
- if (!IsEnabled())
- return false;
- 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
-
- if (!GetFilterNavigator()->Get(valobj, filter_sp, use_dynamic, &reason_filter))
- regex_filter = GetRegexFilterNavigator()->Get (valobj, filter_sp, use_dynamic, &reason_filter);
-
-#ifndef LLDB_DISABLE_PYTHON
- bool regex_synth = false;
- uint32_t reason_synth = 0;
- bool pick_synth = false;
- 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())
- return false;
- else if (!filter_sp.get() && synth.get())
- pick_synth = true;
-
- else if (filter_sp.get() && !synth.get())
- pick_synth = false;
-
- else /*if (filter_sp.get() && synth.get())*/
- {
- if (filter_sp->GetRevision() > synth->GetRevision())
- pick_synth = false;
- else
- pick_synth = true;
- }
- if (pick_synth)
- {
- if (regex_synth && reason)
- *reason |= lldb_private::eFormatterChoiceCriterionRegularExpressionFilter;
- entry_sp = synth;
- return true;
- }
- else
- {
- if (regex_filter && reason)
- *reason |= lldb_private::eFormatterChoiceCriterionRegularExpressionFilter;
- entry_sp = filter_sp;
- return true;
- }
-
-#else
- if (filter_sp)
- {
- entry_sp = filter_sp;
- return true;
- }
-#endif
-
- return false;
-
-}
-
-void
-TypeCategoryImpl::Clear (FormatCategoryItems items)
-{
- if ( (items & eFormatCategoryItemSummary) == eFormatCategoryItemSummary )
- m_summary_nav->Clear();
- if ( (items & eFormatCategoryItemRegexSummary) == eFormatCategoryItemRegexSummary )
- m_regex_summary_nav->Clear();
- if ( (items & eFormatCategoryItemFilter) == eFormatCategoryItemFilter )
- m_filter_nav->Clear();
- if ( (items & eFormatCategoryItemRegexFilter) == eFormatCategoryItemRegexFilter )
- m_regex_filter_nav->Clear();
-#ifndef LLDB_DISABLE_PYTHON
- if ( (items & eFormatCategoryItemSynth) == eFormatCategoryItemSynth )
- m_synth_nav->Clear();
- if ( (items & eFormatCategoryItemRegexSynth) == eFormatCategoryItemRegexSynth )
- m_regex_synth_nav->Clear();
-#endif
-}
-
-bool
-TypeCategoryImpl::Delete (ConstString name,
- FormatCategoryItems items)
-{
- bool success = false;
- if ( (items & eFormatCategoryItemSummary) == eFormatCategoryItemSummary )
- success = m_summary_nav->Delete(name) || success;
- if ( (items & eFormatCategoryItemRegexSummary) == eFormatCategoryItemRegexSummary )
- success = m_regex_summary_nav->Delete(name) || success;
- if ( (items & eFormatCategoryItemFilter) == eFormatCategoryItemFilter )
- success = m_filter_nav->Delete(name) || success;
- if ( (items & eFormatCategoryItemRegexFilter) == eFormatCategoryItemRegexFilter )
- success = m_regex_filter_nav->Delete(name) || success;
-#ifndef LLDB_DISABLE_PYTHON
- if ( (items & eFormatCategoryItemSynth) == eFormatCategoryItemSynth )
- success = m_synth_nav->Delete(name) || success;
- if ( (items & eFormatCategoryItemRegexSynth) == eFormatCategoryItemRegexSynth )
- success = m_regex_synth_nav->Delete(name) || success;
-#endif
- return success;
-}
-
-uint32_t
-TypeCategoryImpl::GetCount (FormatCategoryItems items)
-{
- uint32_t count = 0;
- if ( (items & eFormatCategoryItemSummary) == eFormatCategoryItemSummary )
- count += m_summary_nav->GetCount();
- if ( (items & eFormatCategoryItemRegexSummary) == eFormatCategoryItemRegexSummary )
- count += m_regex_summary_nav->GetCount();
- if ( (items & eFormatCategoryItemFilter) == eFormatCategoryItemFilter )
- count += m_filter_nav->GetCount();
- if ( (items & eFormatCategoryItemRegexFilter) == eFormatCategoryItemRegexFilter )
- count += m_regex_filter_nav->GetCount();
-#ifndef LLDB_DISABLE_PYTHON
- if ( (items & eFormatCategoryItemSynth) == eFormatCategoryItemSynth )
- count += m_synth_nav->GetCount();
- if ( (items & eFormatCategoryItemRegexSynth) == eFormatCategoryItemRegexSynth )
- count += m_regex_synth_nav->GetCount();
-#endif
- return count;
-}
-
-bool
-TypeCategoryImpl::AnyMatches(ConstString type_name,
- FormatCategoryItems items,
- bool only_enabled,
- const char** matching_category,
- FormatCategoryItems* matching_type)
-{
- if (!IsEnabled() && only_enabled)
- return false;
-
- lldb::TypeSummaryImplSP summary;
- TypeFilterImpl::SharedPointer filter;
-#ifndef LLDB_DISABLE_PYTHON
- TypeSyntheticImpl::SharedPointer synth;
-#endif
-
- if ( (items & eFormatCategoryItemSummary) == eFormatCategoryItemSummary )
- {
- if (m_summary_nav->Get(type_name, summary))
- {
- if (matching_category)
- *matching_category = m_name.GetCString();
- if (matching_type)
- *matching_type = eFormatCategoryItemSummary;
- return true;
- }
- }
- if ( (items & eFormatCategoryItemRegexSummary) == eFormatCategoryItemRegexSummary )
- {
- if (m_regex_summary_nav->Get(type_name, summary))
- {
- if (matching_category)
- *matching_category = m_name.GetCString();
- if (matching_type)
- *matching_type = eFormatCategoryItemRegexSummary;
- return true;
- }
- }
- if ( (items & eFormatCategoryItemFilter) == eFormatCategoryItemFilter )
- {
- if (m_filter_nav->Get(type_name, filter))
- {
- if (matching_category)
- *matching_category = m_name.GetCString();
- if (matching_type)
- *matching_type = eFormatCategoryItemFilter;
- return true;
- }
- }
- if ( (items & eFormatCategoryItemRegexFilter) == eFormatCategoryItemRegexFilter )
- {
- if (m_regex_filter_nav->Get(type_name, filter))
- {
- if (matching_category)
- *matching_category = m_name.GetCString();
- if (matching_type)
- *matching_type = eFormatCategoryItemRegexFilter;
- return true;
- }
- }
-#ifndef LLDB_DISABLE_PYTHON
- if ( (items & eFormatCategoryItemSynth) == eFormatCategoryItemSynth )
- {
- if (m_synth_nav->Get(type_name, synth))
- {
- if (matching_category)
- *matching_category = m_name.GetCString();
- if (matching_type)
- *matching_type = eFormatCategoryItemSynth;
- return true;
- }
- }
- if ( (items & eFormatCategoryItemRegexSynth) == eFormatCategoryItemRegexSynth )
- {
- if (m_regex_synth_nav->Get(type_name, synth))
- {
- if (matching_category)
- *matching_category = m_name.GetCString();
- if (matching_type)
- *matching_type = eFormatCategoryItemRegexSynth;
- return true;
- }
- }
-#endif
- return false;
-}
-
-bool
-CategoryMap::AnyMatches (ConstString type_name,
- TypeCategoryImpl::FormatCategoryItems items,
- bool only_enabled,
- const char** matching_category,
- TypeCategoryImpl::FormatCategoryItems* matching_type)
-{
- Mutex::Locker locker(m_map_mutex);
-
- MapIterator pos, end = m_map.end();
- for (pos = m_map.begin(); pos != end; pos++)
- {
- if (pos->second->AnyMatches(type_name,
- items,
- only_enabled,
- matching_category,
- matching_type))
- return true;
- }
- return false;
-}
-
-lldb::TypeSummaryImplSP
-CategoryMap::GetSummaryFormat (ValueObject& valobj,
- lldb::DynamicValueType use_dynamic)
-{
- Mutex::Locker locker(m_map_mutex);
-
- uint32_t reason_why;
- ActiveCategoriesIterator begin, end = m_active_categories.end();
-
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
-
- for (begin = m_active_categories.begin(); begin != end; begin++)
- {
- lldb::TypeCategoryImplSP category_sp = *begin;
- lldb::TypeSummaryImplSP current_format;
- if (log)
- log->Printf("[CategoryMap::GetSummaryFormat] Trying to use category %s\n", category_sp->GetName());
- if (!category_sp->Get(valobj, current_format, use_dynamic, &reason_why))
- continue;
- return current_format;
- }
- if (log)
- log->Printf("[CategoryMap::GetSummaryFormat] nothing found - returning empty SP\n");
- return lldb::TypeSummaryImplSP();
-}
-
lldb::TypeSummaryImplSP
FormatManager::GetSummaryForType (lldb::TypeNameSpecifierImplSP type_sp)
{
@@ -509,12 +216,12 @@ FormatManager::GetFilterForType (lldb::T
}
#ifndef LLDB_DISABLE_PYTHON
-lldb::TypeSyntheticImplSP
+lldb::ScriptedSyntheticChildrenSP
FormatManager::GetSyntheticForType (lldb::TypeNameSpecifierImplSP type_sp)
{
if (!type_sp)
- return lldb::TypeSyntheticImplSP();
- lldb::TypeSyntheticImplSP synth_chosen_sp;
+ return lldb::ScriptedSyntheticChildrenSP();
+ lldb::ScriptedSyntheticChildrenSP synth_chosen_sp;
uint32_t num_categories = m_categories_map.GetCount();
lldb::TypeCategoryImplSP category_sp;
uint32_t prio_category = UINT32_MAX;
@@ -525,7 +232,7 @@ FormatManager::GetSyntheticForType (lldb
category_sp = GetCategoryAtIndex(category_id);
if (category_sp->IsEnabled() == false)
continue;
- lldb::TypeSyntheticImplSP synth_current_sp((TypeSyntheticImpl*)category_sp->GetSyntheticForType(type_sp).get());
+ lldb::ScriptedSyntheticChildrenSP synth_current_sp((ScriptedSyntheticChildren*)category_sp->GetSyntheticForType(type_sp).get());
if (synth_current_sp && (synth_chosen_sp.get() == NULL || (prio_category > category_sp->GetEnabledPosition())))
{
prio_category = category_sp->GetEnabledPosition();
@@ -543,7 +250,7 @@ FormatManager::GetSyntheticChildrenForTy
if (!type_sp)
return lldb::SyntheticChildrenSP();
lldb::TypeFilterImplSP filter_sp = GetFilterForType(type_sp);
- lldb::TypeSyntheticImplSP synth_sp = GetSyntheticForType(type_sp);
+ lldb::ScriptedSyntheticChildrenSP synth_sp = GetSyntheticForType(type_sp);
if (filter_sp->GetRevision() > synth_sp->GetRevision())
return lldb::SyntheticChildrenSP(filter_sp.get());
else
@@ -551,88 +258,6 @@ FormatManager::GetSyntheticChildrenForTy
}
#endif
-#ifndef LLDB_DISABLE_PYTHON
-lldb::SyntheticChildrenSP
-CategoryMap::GetSyntheticChildren (ValueObject& valobj,
- lldb::DynamicValueType use_dynamic)
-{
- Mutex::Locker locker(m_map_mutex);
-
- uint32_t reason_why;
-
- ActiveCategoriesIterator begin, end = m_active_categories.end();
-
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
-
- for (begin = m_active_categories.begin(); begin != end; begin++)
- {
- lldb::TypeCategoryImplSP category_sp = *begin;
- lldb::SyntheticChildrenSP current_format;
- if (log)
- log->Printf("[CategoryMap::GetSyntheticChildren] Trying to use category %s\n", category_sp->GetName());
- if (!category_sp->Get(valobj, current_format, use_dynamic, &reason_why))
- continue;
- return current_format;
- }
- if (log)
- log->Printf("[CategoryMap::GetSyntheticChildren] nothing found - returning empty SP\n");
- return lldb::SyntheticChildrenSP();
-}
-#endif
-
-void
-CategoryMap::LoopThrough(CallbackType callback, void* param)
-{
- if (callback)
- {
- Mutex::Locker locker(m_map_mutex);
-
- // loop through enabled categories in respective order
- {
- ActiveCategoriesIterator begin, end = m_active_categories.end();
- for (begin = m_active_categories.begin(); begin != end; begin++)
- {
- lldb::TypeCategoryImplSP category = *begin;
- ConstString type = ConstString(category->GetName());
- if (!callback(param, category))
- break;
- }
- }
-
- // loop through disabled categories in just any order
- {
- MapIterator pos, end = m_map.end();
- for (pos = m_map.begin(); pos != end; pos++)
- {
- if (pos->second->IsEnabled())
- continue;
- KeyType type = pos->first;
- if (!callback(param, pos->second))
- break;
- }
- }
- }
-}
-
-TypeCategoryImplSP
-CategoryMap::GetAtIndex (uint32_t index)
-{
- Mutex::Locker 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)
@@ -686,7 +311,103 @@ FormatManager::GetValidTypeName (const C
return ::GetValidTypeName_Impl(type);
}
-FormatManager::FormatManager() :
+ConstString
+GetTypeForCache (ValueObject& valobj,
+ lldb::DynamicValueType use_dynamic)
+{
+ if (use_dynamic == lldb::eNoDynamicValues)
+ {
+ if (valobj.IsDynamic())
+ {
+ if (valobj.GetStaticValue())
+ return valobj.GetStaticValue()->GetQualifiedTypeName();
+ else
+ return ConstString();
+ }
+ else
+ return valobj.GetQualifiedTypeName();
+ }
+ if (valobj.IsDynamic())
+ return valobj.GetQualifiedTypeName();
+ if (valobj.GetDynamicValue(use_dynamic))
+ return valobj.GetDynamicValue(use_dynamic)->GetQualifiedTypeName();
+ return ConstString();
+}
+
+#define USE_CACHE 1
+lldb::TypeSummaryImplSP
+FormatManager::GetSummaryFormat (ValueObject& valobj,
+ lldb::DynamicValueType use_dynamic)
+{
+ TypeSummaryImplSP retval;
+#if USE_CACHE
+ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
+ ConstString valobj_type(GetTypeForCache(valobj, use_dynamic));
+ if (valobj_type)
+ {
+ if (log)
+ log->Printf("[FormatManager::GetSummaryFormat] Looking into cache for type %s", valobj_type.AsCString("<invalid>"));
+ if (m_format_cache.GetSummary(valobj_type,retval))
+ return retval;
+ if (log)
+ log->Printf("[FormatManager::GetSummaryFormat] Cache search failed. Going normal route");
+ }
+#endif
+ retval = m_categories_map.GetSummaryFormat(valobj, use_dynamic);
+#if USE_CACHE
+ if (valobj_type)
+ {
+ if (log)
+ log->Printf("[FormatManager::GetSummaryFormat] Caching %p for type %s",retval.get(),valobj_type.AsCString("<invalid>"));
+ m_format_cache.SetSummary(valobj_type,retval);
+ }
+#ifdef LLDB_CONFIGURATION_DEBUG
+ if (log)
+ log->Printf("[FormatManager::GetSummaryFormat] Cache hits: %llu - Cache Misses: %llu", m_format_cache.GetCacheHits(), m_format_cache.GetCacheMisses());
+#endif
+#endif
+ return retval;
+}
+
+#ifndef LLDB_DISABLE_PYTHON
+lldb::SyntheticChildrenSP
+FormatManager::GetSyntheticChildren (ValueObject& valobj,
+ lldb::DynamicValueType use_dynamic)
+{
+ SyntheticChildrenSP retval;
+#if USE_CACHE
+ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
+ ConstString valobj_type(GetTypeForCache(valobj, use_dynamic));
+ if (valobj_type)
+ {
+ if (log)
+ log->Printf("[FormatManager::GetSyntheticChildren] Looking into cache for type %s\n", valobj_type.AsCString("<invalid>"));
+ if (m_format_cache.GetSynthetic(valobj_type,retval))
+ return retval;
+ if (log)
+ log->Printf("[FormatManager::GetSyntheticChildren] Cache search failed. Going normal route\n");
+ }
+#endif
+ retval = m_categories_map.GetSyntheticChildren(valobj, use_dynamic);
+#if USE_CACHE
+ if (valobj_type)
+ {
+ if (log)
+ log->Printf("[FormatManager::GetSyntheticChildren] Caching %p for type %s\n",retval.get(),valobj_type.AsCString("<invalid>"));
+ m_format_cache.SetSynthetic(valobj_type,retval);
+ }
+#ifdef LLDB_CONFIGURATION_DEBUG
+ if (log)
+ log->Printf("[FormatManager::GetSyntheticChildren] Cache hits: %llu - Cache Misses: %llu", m_format_cache.GetCacheHits(), m_format_cache.GetCacheMisses());
+#endif
+#endif
+ return retval;
+}
+#endif
+#undef USE_CACHE
+
+FormatManager::FormatManager() :
+ m_format_cache(),
m_value_nav("format",this),
m_named_summaries_map(this),
m_last_revision(0),
@@ -702,21 +423,20 @@ FormatManager::FormatManager() :
m_vectortypes_category_name(ConstString("VectorTypes")),
m_appkit_category_name(ConstString("AppKit"))
{
-
LoadSystemFormatters();
LoadLibStdcppFormatters();
LoadLibcxxFormatters();
LoadObjCFormatters();
- EnableCategory(m_objc_category_name,CategoryMap::Last);
- EnableCategory(m_corefoundation_category_name,CategoryMap::Last);
- EnableCategory(m_appkit_category_name,CategoryMap::Last);
- EnableCategory(m_coreservices_category_name,CategoryMap::Last);
- EnableCategory(m_coregraphics_category_name,CategoryMap::Last);
- EnableCategory(m_gnu_cpp_category_name,CategoryMap::Last);
- EnableCategory(m_libcxx_category_name,CategoryMap::Last);
- EnableCategory(m_vectortypes_category_name,CategoryMap::Last);
- EnableCategory(m_system_category_name,CategoryMap::Last);
+ EnableCategory(m_objc_category_name,TypeCategoryMap::Last);
+ EnableCategory(m_corefoundation_category_name,TypeCategoryMap::Last);
+ EnableCategory(m_appkit_category_name,TypeCategoryMap::Last);
+ EnableCategory(m_coreservices_category_name,TypeCategoryMap::Last);
+ EnableCategory(m_coregraphics_category_name,TypeCategoryMap::Last);
+ EnableCategory(m_gnu_cpp_category_name,TypeCategoryMap::Last);
+ EnableCategory(m_libcxx_category_name,TypeCategoryMap::Last);
+ EnableCategory(m_vectortypes_category_name,TypeCategoryMap::Last);
+ EnableCategory(m_system_category_name,TypeCategoryMap::Last);
}
static void
@@ -769,7 +489,7 @@ static void AddCXXSynthetic (TypeCatego
CXXSyntheticChildren::CreateFrontEndCallback generator,
const char* description,
ConstString type_name,
- TypeSyntheticImpl::Flags flags)
+ ScriptedSyntheticChildren::Flags flags)
{
lldb::SyntheticChildrenSP synth_sp(new CXXSyntheticChildren(flags,description,generator));
category_sp->GetSyntheticNavigator()->Add(type_name,synth_sp);
@@ -822,13 +542,13 @@ FormatManager::LoadLibStdcppFormatters()
stl_synth_flags.SetCascades(true).SetSkipPointers(false).SetSkipReferences(false);
gnu_category_sp->GetRegexSyntheticNavigator()->Add(RegularExpressionSP(new RegularExpression("^std::vector<.+>(( )?&)?$")),
- SyntheticChildrenSP(new TypeSyntheticImpl(stl_synth_flags,
+ SyntheticChildrenSP(new ScriptedSyntheticChildren(stl_synth_flags,
"lldb.formatters.cpp.gnu_libstdcpp.StdVectorSynthProvider")));
gnu_category_sp->GetRegexSyntheticNavigator()->Add(RegularExpressionSP(new RegularExpression("^std::map<.+> >(( )?&)?$")),
- SyntheticChildrenSP(new TypeSyntheticImpl(stl_synth_flags,
+ SyntheticChildrenSP(new ScriptedSyntheticChildren(stl_synth_flags,
"lldb.formatters.cpp.gnu_libstdcpp.StdMapSynthProvider")));
gnu_category_sp->GetRegexSyntheticNavigator()->Add(RegularExpressionSP(new RegularExpression("^std::list<.+>(( )?&)?$")),
- SyntheticChildrenSP(new TypeSyntheticImpl(stl_synth_flags,
+ SyntheticChildrenSP(new ScriptedSyntheticChildren(stl_synth_flags,
"lldb.formatters.cpp.gnu_libstdcpp.StdListSynthProvider")));
stl_summary_flags.SetDontShowChildren(false);
@@ -879,22 +599,22 @@ FormatManager::LoadLibcxxFormatters()
stl_synth_flags.SetCascades(true).SetSkipPointers(false).SetSkipReferences(false);
libcxx_category_sp->GetRegexSyntheticNavigator()->Add(RegularExpressionSP(new RegularExpression("^std::__1::vector<.+>(( )?&)?$")),
- SyntheticChildrenSP(new TypeSyntheticImpl(stl_synth_flags,
+ SyntheticChildrenSP(new ScriptedSyntheticChildren(stl_synth_flags,
"lldb.formatters.cpp.libcxx.stdvector_SynthProvider")));
libcxx_category_sp->GetRegexSyntheticNavigator()->Add(RegularExpressionSP(new RegularExpression("^std::__1::list<.+>(( )?&)?$")),
- SyntheticChildrenSP(new TypeSyntheticImpl(stl_synth_flags,
+ SyntheticChildrenSP(new ScriptedSyntheticChildren(stl_synth_flags,
"lldb.formatters.cpp.libcxx.stdlist_SynthProvider")));
libcxx_category_sp->GetRegexSyntheticNavigator()->Add(RegularExpressionSP(new RegularExpression("^std::__1::map<.+> >(( )?&)?$")),
- SyntheticChildrenSP(new TypeSyntheticImpl(stl_synth_flags,
+ SyntheticChildrenSP(new ScriptedSyntheticChildren(stl_synth_flags,
"lldb.formatters.cpp.libcxx.stdmap_SynthProvider")));
libcxx_category_sp->GetRegexSyntheticNavigator()->Add(RegularExpressionSP(new RegularExpression("^(std::__1::)deque<.+>(( )?&)?$")),
- SyntheticChildrenSP(new TypeSyntheticImpl(stl_synth_flags,
+ SyntheticChildrenSP(new ScriptedSyntheticChildren(stl_synth_flags,
"lldb.formatters.cpp.libcxx.stddeque_SynthProvider")));
libcxx_category_sp->GetRegexSyntheticNavigator()->Add(RegularExpressionSP(new RegularExpression("^(std::__1::)shared_ptr<.+>(( )?&)?$")),
- SyntheticChildrenSP(new TypeSyntheticImpl(stl_synth_flags,
+ SyntheticChildrenSP(new ScriptedSyntheticChildren(stl_synth_flags,
"lldb.formatters.cpp.libcxx.stdsharedptr_SynthProvider")));
libcxx_category_sp->GetRegexSyntheticNavigator()->Add(RegularExpressionSP(new RegularExpression("^(std::__1::)weak_ptr<.+>(( )?&)?$")),
- SyntheticChildrenSP(new TypeSyntheticImpl(stl_synth_flags,
+ SyntheticChildrenSP(new ScriptedSyntheticChildren(stl_synth_flags,
"lldb.formatters.cpp.libcxx.stdsharedptr_SynthProvider")));
stl_summary_flags.SetDontShowChildren(false);stl_summary_flags.SetSkipPointers(true);
@@ -1141,18 +861,18 @@ FormatManager::LoadObjCFormatters()
appkit_flags.SetDontShowChildren(true);
- AddCXXSynthetic(appkit_category_sp, lldb_private::formatters::NSArraySyntheticFrontEndCreator, "NSArray synthetic children", ConstString("__NSArrayM"), TypeSyntheticImpl::Flags());
- AddCXXSynthetic(appkit_category_sp, lldb_private::formatters::NSArraySyntheticFrontEndCreator, "NSArray synthetic children", ConstString("__NSArrayI"), TypeSyntheticImpl::Flags());
- AddCXXSynthetic(appkit_category_sp, lldb_private::formatters::NSArraySyntheticFrontEndCreator, "NSArray synthetic children", ConstString("NSArray"), TypeSyntheticImpl::Flags());
- AddCXXSynthetic(appkit_category_sp, lldb_private::formatters::NSArraySyntheticFrontEndCreator, "NSArray synthetic children", ConstString("NSMutableArray"), TypeSyntheticImpl::Flags());
- AddCXXSynthetic(appkit_category_sp, lldb_private::formatters::NSArraySyntheticFrontEndCreator, "NSArray synthetic children", ConstString("__NSCFArray"), TypeSyntheticImpl::Flags());
-
- AddCXXSynthetic(appkit_category_sp, lldb_private::formatters::NSDictionarySyntheticFrontEndCreator, "NSDictionary synthetic children", ConstString("__NSDictionaryM"), TypeSyntheticImpl::Flags());
- AddCXXSynthetic(appkit_category_sp, lldb_private::formatters::NSDictionarySyntheticFrontEndCreator, "NSDictionary synthetic children", ConstString("__NSDictionaryI"), TypeSyntheticImpl::Flags());
- AddCXXSynthetic(appkit_category_sp, lldb_private::formatters::NSDictionarySyntheticFrontEndCreator, "NSDictionary synthetic children", ConstString("NSDictionary"), TypeSyntheticImpl::Flags());
- AddCXXSynthetic(appkit_category_sp, lldb_private::formatters::NSDictionarySyntheticFrontEndCreator, "NSDictionary synthetic children", ConstString("NSMutableDictionary"), TypeSyntheticImpl::Flags());
- AddCXXSynthetic(appkit_category_sp, lldb_private::formatters::NSDictionarySyntheticFrontEndCreator, "NSDictionary synthetic children", ConstString("CFDictionaryRef"), TypeSyntheticImpl::Flags());
- AddCXXSynthetic(appkit_category_sp, lldb_private::formatters::NSDictionarySyntheticFrontEndCreator, "NSDictionary synthetic children", ConstString("CFMutableDictionaryRef"), TypeSyntheticImpl::Flags());
+ AddCXXSynthetic(appkit_category_sp, lldb_private::formatters::NSArraySyntheticFrontEndCreator, "NSArray synthetic children", ConstString("__NSArrayM"), ScriptedSyntheticChildren::Flags());
+ AddCXXSynthetic(appkit_category_sp, lldb_private::formatters::NSArraySyntheticFrontEndCreator, "NSArray synthetic children", ConstString("__NSArrayI"), ScriptedSyntheticChildren::Flags());
+ AddCXXSynthetic(appkit_category_sp, lldb_private::formatters::NSArraySyntheticFrontEndCreator, "NSArray synthetic children", ConstString("NSArray"), ScriptedSyntheticChildren::Flags());
+ AddCXXSynthetic(appkit_category_sp, lldb_private::formatters::NSArraySyntheticFrontEndCreator, "NSArray synthetic children", ConstString("NSMutableArray"), ScriptedSyntheticChildren::Flags());
+ AddCXXSynthetic(appkit_category_sp, lldb_private::formatters::NSArraySyntheticFrontEndCreator, "NSArray synthetic children", ConstString("__NSCFArray"), ScriptedSyntheticChildren::Flags());
+
+ AddCXXSynthetic(appkit_category_sp, lldb_private::formatters::NSDictionarySyntheticFrontEndCreator, "NSDictionary synthetic children", ConstString("__NSDictionaryM"), ScriptedSyntheticChildren::Flags());
+ AddCXXSynthetic(appkit_category_sp, lldb_private::formatters::NSDictionarySyntheticFrontEndCreator, "NSDictionary synthetic children", ConstString("__NSDictionaryI"), ScriptedSyntheticChildren::Flags());
+ AddCXXSynthetic(appkit_category_sp, lldb_private::formatters::NSDictionarySyntheticFrontEndCreator, "NSDictionary synthetic children", ConstString("NSDictionary"), ScriptedSyntheticChildren::Flags());
+ AddCXXSynthetic(appkit_category_sp, lldb_private::formatters::NSDictionarySyntheticFrontEndCreator, "NSDictionary synthetic children", ConstString("NSMutableDictionary"), ScriptedSyntheticChildren::Flags());
+ AddCXXSynthetic(appkit_category_sp, lldb_private::formatters::NSDictionarySyntheticFrontEndCreator, "NSDictionary synthetic children", ConstString("CFDictionaryRef"), ScriptedSyntheticChildren::Flags());
+ AddCXXSynthetic(appkit_category_sp, lldb_private::formatters::NSDictionarySyntheticFrontEndCreator, "NSDictionary synthetic children", ConstString("CFMutableDictionaryRef"), ScriptedSyntheticChildren::Flags());
AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.CFBag.CFBag_SummaryProvider", ConstString("CFBagRef"), appkit_flags);
AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.CFBag.CFBag_SummaryProvider", ConstString("__CFBag"), appkit_flags);
@@ -1182,15 +902,14 @@ FormatManager::LoadObjCFormatters()
AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSDataSummaryProvider<true>, "NSData summary provider", ConstString("CFDataRef"), appkit_flags);
AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSDataSummaryProvider<true>, "NSData summary provider", ConstString("CFMutableDataRef"), appkit_flags);
- AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSException.NSException_SummaryProvider", ConstString("NSException"), appkit_flags);
-
AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSMachPort.NSMachPort_SummaryProvider", ConstString("NSMachPort"), appkit_flags);
AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSNotification.NSNotification_SummaryProvider", ConstString("NSNotification"), appkit_flags);
AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSNotification.NSNotification_SummaryProvider", ConstString("NSConcreteNotification"), appkit_flags);
AddStringSummary(appkit_category_sp, "domain: ${var._domain} - code: ${var._code}", ConstString("NSError"), appkit_flags);
-
+ AddStringSummary(appkit_category_sp,"name:${var.name%S} reason:${var.reason%S}",ConstString("NSException"),appkit_flags);
+
AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSNumberSummaryProvider, "NSNumber summary provider", ConstString("NSNumber"), appkit_flags);
AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSNumberSummaryProvider, "NSNumber summary provider", ConstString("__NSCFBoolean"), appkit_flags);
AddCXXSummary(appkit_category_sp, lldb_private::formatters::NSNumberSummaryProvider, "NSNumber summary provider", ConstString("__NSCFNumber"), appkit_flags);
@@ -1202,6 +921,7 @@ FormatManager::LoadObjCFormatters()
AddCXXSummary(appkit_category_sp, lldb_private::formatters::RuntimeSpecificDescriptionSummaryProvider, "NSTask summary provider", ConstString("NSTask"), appkit_flags);
AddCXXSummary(appkit_category_sp, lldb_private::formatters::RuntimeSpecificDescriptionSummaryProvider, "NSValue summary provider", ConstString("NSValue"), appkit_flags);
+
AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSSet.NSSet_SummaryProvider", ConstString("NSSet"), appkit_flags);
AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSSet.NSSet_SummaryProvider2", ConstString("CFSetRef"), appkit_flags);
AddScriptSummary(appkit_category_sp, "lldb.formatters.objc.NSSet.NSSet_SummaryProvider2", ConstString("CFMutableSetRef"), appkit_flags);
Added: lldb/trunk/source/DataFormatters/TypeCategory.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/TypeCategory.cpp?rev=173728&view=auto
==============================================================================
--- lldb/trunk/source/DataFormatters/TypeCategory.cpp (added)
+++ lldb/trunk/source/DataFormatters/TypeCategory.cpp Mon Jan 28 17:47:25 2013
@@ -0,0 +1,378 @@
+//===-- TypeCategory.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/DataFormatters/TypeCategory.h"
+
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+
+using namespace lldb;
+using namespace lldb_private;
+
+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)),
+m_regex_filter_nav(new RegexFilterNavigator("regex-filter",clist)),
+#ifndef LLDB_DISABLE_PYTHON
+m_synth_nav(new SynthNavigator("synth",clist)),
+m_regex_synth_nav(new RegexSynthNavigator("regex-synth",clist)),
+#endif
+m_enabled(false),
+m_change_listener(clist),
+m_mutex(Mutex::eMutexTypeRecursive),
+m_name(name)
+{}
+
+bool
+TypeCategoryImpl::Get (ValueObject& valobj,
+ lldb::TypeSummaryImplSP& entry,
+ lldb::DynamicValueType use_dynamic,
+ uint32_t* reason)
+{
+ if (!IsEnabled())
+ return false;
+ if (GetSummaryNavigator()->Get(valobj, entry, use_dynamic, reason))
+ return true;
+ bool regex = GetRegexSummaryNavigator()->Get(valobj, entry, use_dynamic, reason);
+ if (regex && reason)
+ *reason |= lldb_private::eFormatterChoiceCriterionRegularExpressionSummary;
+ return regex;
+}
+
+bool
+TypeCategoryImpl::Get(ValueObject& valobj,
+ lldb::SyntheticChildrenSP& entry_sp,
+ lldb::DynamicValueType use_dynamic,
+ uint32_t* reason)
+{
+ if (!IsEnabled())
+ return false;
+ 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
+
+ if (!GetFilterNavigator()->Get(valobj, filter_sp, use_dynamic, &reason_filter))
+ regex_filter = GetRegexFilterNavigator()->Get (valobj, filter_sp, use_dynamic, &reason_filter);
+
+#ifndef LLDB_DISABLE_PYTHON
+ bool regex_synth = false;
+ uint32_t reason_synth = 0;
+ bool pick_synth = false;
+ ScriptedSyntheticChildren::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())
+ return false;
+ else if (!filter_sp.get() && synth.get())
+ pick_synth = true;
+
+ else if (filter_sp.get() && !synth.get())
+ pick_synth = false;
+
+ else /*if (filter_sp.get() && synth.get())*/
+ {
+ if (filter_sp->GetRevision() > synth->GetRevision())
+ pick_synth = false;
+ else
+ pick_synth = true;
+ }
+ if (pick_synth)
+ {
+ if (regex_synth && reason)
+ *reason |= lldb_private::eFormatterChoiceCriterionRegularExpressionFilter;
+ entry_sp = synth;
+ return true;
+ }
+ else
+ {
+ if (regex_filter && reason)
+ *reason |= lldb_private::eFormatterChoiceCriterionRegularExpressionFilter;
+ entry_sp = filter_sp;
+ return true;
+ }
+
+#else
+ if (filter_sp)
+ {
+ entry_sp = filter_sp;
+ return true;
+ }
+#endif
+
+ return false;
+
+}
+
+void
+TypeCategoryImpl::Clear (FormatCategoryItems items)
+{
+ if ( (items & eFormatCategoryItemSummary) == eFormatCategoryItemSummary )
+ m_summary_nav->Clear();
+ if ( (items & eFormatCategoryItemRegexSummary) == eFormatCategoryItemRegexSummary )
+ m_regex_summary_nav->Clear();
+ if ( (items & eFormatCategoryItemFilter) == eFormatCategoryItemFilter )
+ m_filter_nav->Clear();
+ if ( (items & eFormatCategoryItemRegexFilter) == eFormatCategoryItemRegexFilter )
+ m_regex_filter_nav->Clear();
+#ifndef LLDB_DISABLE_PYTHON
+ if ( (items & eFormatCategoryItemSynth) == eFormatCategoryItemSynth )
+ m_synth_nav->Clear();
+ if ( (items & eFormatCategoryItemRegexSynth) == eFormatCategoryItemRegexSynth )
+ m_regex_synth_nav->Clear();
+#endif
+}
+
+bool
+TypeCategoryImpl::Delete (ConstString name,
+ FormatCategoryItems items)
+{
+ bool success = false;
+ if ( (items & eFormatCategoryItemSummary) == eFormatCategoryItemSummary )
+ success = m_summary_nav->Delete(name) || success;
+ if ( (items & eFormatCategoryItemRegexSummary) == eFormatCategoryItemRegexSummary )
+ success = m_regex_summary_nav->Delete(name) || success;
+ if ( (items & eFormatCategoryItemFilter) == eFormatCategoryItemFilter )
+ success = m_filter_nav->Delete(name) || success;
+ if ( (items & eFormatCategoryItemRegexFilter) == eFormatCategoryItemRegexFilter )
+ success = m_regex_filter_nav->Delete(name) || success;
+#ifndef LLDB_DISABLE_PYTHON
+ if ( (items & eFormatCategoryItemSynth) == eFormatCategoryItemSynth )
+ success = m_synth_nav->Delete(name) || success;
+ if ( (items & eFormatCategoryItemRegexSynth) == eFormatCategoryItemRegexSynth )
+ success = m_regex_synth_nav->Delete(name) || success;
+#endif
+ return success;
+}
+
+uint32_t
+TypeCategoryImpl::GetCount (FormatCategoryItems items)
+{
+ uint32_t count = 0;
+ if ( (items & eFormatCategoryItemSummary) == eFormatCategoryItemSummary )
+ count += m_summary_nav->GetCount();
+ if ( (items & eFormatCategoryItemRegexSummary) == eFormatCategoryItemRegexSummary )
+ count += m_regex_summary_nav->GetCount();
+ if ( (items & eFormatCategoryItemFilter) == eFormatCategoryItemFilter )
+ count += m_filter_nav->GetCount();
+ if ( (items & eFormatCategoryItemRegexFilter) == eFormatCategoryItemRegexFilter )
+ count += m_regex_filter_nav->GetCount();
+#ifndef LLDB_DISABLE_PYTHON
+ if ( (items & eFormatCategoryItemSynth) == eFormatCategoryItemSynth )
+ count += m_synth_nav->GetCount();
+ if ( (items & eFormatCategoryItemRegexSynth) == eFormatCategoryItemRegexSynth )
+ count += m_regex_synth_nav->GetCount();
+#endif
+ return count;
+}
+
+bool
+TypeCategoryImpl::AnyMatches(ConstString type_name,
+ FormatCategoryItems items,
+ bool only_enabled,
+ const char** matching_category,
+ FormatCategoryItems* matching_type)
+{
+ if (!IsEnabled() && only_enabled)
+ return false;
+
+ lldb::TypeSummaryImplSP summary;
+ TypeFilterImpl::SharedPointer filter;
+#ifndef LLDB_DISABLE_PYTHON
+ ScriptedSyntheticChildren::SharedPointer synth;
+#endif
+
+ if ( (items & eFormatCategoryItemSummary) == eFormatCategoryItemSummary )
+ {
+ if (m_summary_nav->Get(type_name, summary))
+ {
+ if (matching_category)
+ *matching_category = m_name.GetCString();
+ if (matching_type)
+ *matching_type = eFormatCategoryItemSummary;
+ return true;
+ }
+ }
+ if ( (items & eFormatCategoryItemRegexSummary) == eFormatCategoryItemRegexSummary )
+ {
+ if (m_regex_summary_nav->Get(type_name, summary))
+ {
+ if (matching_category)
+ *matching_category = m_name.GetCString();
+ if (matching_type)
+ *matching_type = eFormatCategoryItemRegexSummary;
+ return true;
+ }
+ }
+ if ( (items & eFormatCategoryItemFilter) == eFormatCategoryItemFilter )
+ {
+ if (m_filter_nav->Get(type_name, filter))
+ {
+ if (matching_category)
+ *matching_category = m_name.GetCString();
+ if (matching_type)
+ *matching_type = eFormatCategoryItemFilter;
+ return true;
+ }
+ }
+ if ( (items & eFormatCategoryItemRegexFilter) == eFormatCategoryItemRegexFilter )
+ {
+ if (m_regex_filter_nav->Get(type_name, filter))
+ {
+ if (matching_category)
+ *matching_category = m_name.GetCString();
+ if (matching_type)
+ *matching_type = eFormatCategoryItemRegexFilter;
+ return true;
+ }
+ }
+#ifndef LLDB_DISABLE_PYTHON
+ if ( (items & eFormatCategoryItemSynth) == eFormatCategoryItemSynth )
+ {
+ if (m_synth_nav->Get(type_name, synth))
+ {
+ if (matching_category)
+ *matching_category = m_name.GetCString();
+ if (matching_type)
+ *matching_type = eFormatCategoryItemSynth;
+ return true;
+ }
+ }
+ if ( (items & eFormatCategoryItemRegexSynth) == eFormatCategoryItemRegexSynth )
+ {
+ if (m_regex_synth_nav->Get(type_name, synth))
+ {
+ if (matching_category)
+ *matching_category = m_name.GetCString();
+ if (matching_type)
+ *matching_type = eFormatCategoryItemRegexSynth;
+ return true;
+ }
+ }
+#endif
+ return false;
+}
+
+TypeCategoryImpl::SummaryNavigator::MapValueType
+TypeCategoryImpl::GetSummaryForType (lldb::TypeNameSpecifierImplSP type_sp)
+{
+ SummaryNavigator::MapValueType retval;
+
+ if (type_sp)
+ {
+ if (type_sp->IsRegex())
+ m_regex_summary_nav->GetExact(ConstString(type_sp->GetName()),retval);
+ else
+ m_summary_nav->GetExact(ConstString(type_sp->GetName()),retval);
+ }
+
+ return retval;
+}
+
+TypeCategoryImpl::FilterNavigator::MapValueType
+TypeCategoryImpl::GetFilterForType (lldb::TypeNameSpecifierImplSP type_sp)
+{
+ FilterNavigator::MapValueType retval;
+
+ if (type_sp)
+ {
+ if (type_sp->IsRegex())
+ m_regex_filter_nav->GetExact(ConstString(type_sp->GetName()),retval);
+ else
+ m_filter_nav->GetExact(ConstString(type_sp->GetName()),retval);
+ }
+
+ return retval;
+}
+
+#ifndef LLDB_DISABLE_PYTHON
+TypeCategoryImpl::SynthNavigator::MapValueType
+TypeCategoryImpl::GetSyntheticForType (lldb::TypeNameSpecifierImplSP type_sp)
+{
+ SynthNavigator::MapValueType retval;
+
+ if (type_sp)
+ {
+ if (type_sp->IsRegex())
+ m_regex_synth_nav->GetExact(ConstString(type_sp->GetName()),retval);
+ else
+ m_synth_nav->GetExact(ConstString(type_sp->GetName()),retval);
+ }
+
+ return retval;
+}
+#endif
+
+lldb::TypeNameSpecifierImplSP
+TypeCategoryImpl::GetTypeNameSpecifierForSummaryAtIndex (size_t index)
+{
+ if (index < m_summary_nav->GetCount())
+ return m_summary_nav->GetTypeNameSpecifierAtIndex(index);
+ else
+ return m_regex_summary_nav->GetTypeNameSpecifierAtIndex(index-m_summary_nav->GetCount());
+}
+
+TypeCategoryImpl::SummaryNavigator::MapValueType
+TypeCategoryImpl::GetSummaryAtIndex (size_t index)
+{
+ if (index < m_summary_nav->GetCount())
+ return m_summary_nav->GetAtIndex(index);
+ else
+ return m_regex_summary_nav->GetAtIndex(index-m_summary_nav->GetCount());
+}
+
+TypeCategoryImpl::FilterNavigator::MapValueType
+TypeCategoryImpl::GetFilterAtIndex (size_t index)
+{
+ if (index < m_filter_nav->GetCount())
+ return m_filter_nav->GetAtIndex(index);
+ else
+ return m_regex_filter_nav->GetAtIndex(index-m_filter_nav->GetCount());
+}
+
+lldb::TypeNameSpecifierImplSP
+TypeCategoryImpl::GetTypeNameSpecifierForFilterAtIndex (size_t index)
+{
+ if (index < m_filter_nav->GetCount())
+ return m_filter_nav->GetTypeNameSpecifierAtIndex(index);
+ else
+ return m_regex_filter_nav->GetTypeNameSpecifierAtIndex(index-m_filter_nav->GetCount());
+}
+
+TypeCategoryImpl::SynthNavigator::MapValueType
+TypeCategoryImpl::GetSyntheticAtIndex (size_t index)
+{
+ if (index < m_synth_nav->GetCount())
+ return m_synth_nav->GetAtIndex(index);
+ else
+ return m_regex_synth_nav->GetAtIndex(index-m_synth_nav->GetCount());
+}
+
+lldb::TypeNameSpecifierImplSP
+TypeCategoryImpl::GetTypeNameSpecifierForSyntheticAtIndex (size_t index)
+{
+ if (index < m_synth_nav->GetCount())
+ return m_synth_nav->GetTypeNameSpecifierAtIndex(index);
+ else
+ return m_regex_synth_nav->GetTypeNameSpecifierAtIndex(index - m_synth_nav->GetCount());
+}
+
+void
+TypeCategoryImpl::Enable (bool value, uint32_t position)
+{
+ Mutex::Locker locker(m_mutex);
+ m_enabled = value;
+ m_enabled_position = position;
+ if (m_change_listener)
+ m_change_listener->Changed();
+}
Added: lldb/trunk/source/DataFormatters/TypeCategoryMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/TypeCategoryMap.cpp?rev=173728&view=auto
==============================================================================
--- lldb/trunk/source/DataFormatters/TypeCategoryMap.cpp (added)
+++ lldb/trunk/source/DataFormatters/TypeCategoryMap.cpp Mon Jan 28 17:47:25 2013
@@ -0,0 +1,283 @@
+//===-- TypeCategoryMap.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/DataFormatters/TypeCategoryMap.h"
+
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+
+using namespace lldb;
+using namespace lldb_private;
+
+TypeCategoryMap::TypeCategoryMap (IFormatChangeListener* lst) :
+m_map_mutex(Mutex::eMutexTypeRecursive),
+listener(lst),
+m_map(),
+m_active_categories()
+{
+ ConstString default_cs("default");
+ lldb::TypeCategoryImplSP default_sp = lldb::TypeCategoryImplSP(new TypeCategoryImpl(listener, default_cs));
+ Add(default_cs,default_sp);
+ Enable(default_cs,First);
+}
+
+void
+TypeCategoryMap::Add (KeyType name, const ValueSP& entry)
+{
+ Mutex::Locker locker(m_map_mutex);
+ m_map[name] = entry;
+ if (listener)
+ listener->Changed();
+}
+
+bool
+TypeCategoryMap::Delete (KeyType name)
+{
+ Mutex::Locker locker(m_map_mutex);
+ MapIterator iter = m_map.find(name);
+ if (iter == m_map.end())
+ return false;
+ m_map.erase(name);
+ Disable(name);
+ if (listener)
+ listener->Changed();
+ return true;
+}
+
+bool
+TypeCategoryMap::Enable (KeyType category_name, Position pos)
+{
+ Mutex::Locker locker(m_map_mutex);
+ ValueSP category;
+ if (!Get(category_name,category))
+ return false;
+ return Enable(category, pos);
+}
+
+bool
+TypeCategoryMap::Disable (KeyType category_name)
+{
+ Mutex::Locker locker(m_map_mutex);
+ ValueSP category;
+ if (!Get(category_name,category))
+ return false;
+ return Disable(category);
+}
+
+bool
+TypeCategoryMap::Enable (ValueSP category, Position pos)
+{
+ Mutex::Locker locker(m_map_mutex);
+ if (category.get())
+ {
+ Position pos_w = pos;
+ if (pos == First || m_active_categories.size() == 0)
+ m_active_categories.push_front(category);
+ else if (pos == Last || pos == m_active_categories.size())
+ m_active_categories.push_back(category);
+ else if (pos < m_active_categories.size())
+ {
+ ActiveCategoriesList::iterator iter = m_active_categories.begin();
+ while (pos_w)
+ {
+ pos_w--,iter++;
+ }
+ m_active_categories.insert(iter,category);
+ }
+ else
+ return false;
+ category->Enable(true,
+ pos);
+ return true;
+ }
+ return false;
+}
+
+bool
+TypeCategoryMap::Disable (ValueSP category)
+{
+ Mutex::Locker locker(m_map_mutex);
+ if (category.get())
+ {
+ m_active_categories.remove_if(delete_matching_categories(category));
+ category->Disable();
+ return true;
+ }
+ return false;
+}
+
+void
+TypeCategoryMap::Clear ()
+{
+ Mutex::Locker locker(m_map_mutex);
+ m_map.clear();
+ m_active_categories.clear();
+ if (listener)
+ listener->Changed();
+}
+
+bool
+TypeCategoryMap::Get (KeyType name, ValueSP& entry)
+{
+ Mutex::Locker locker(m_map_mutex);
+ MapIterator iter = m_map.find(name);
+ if (iter == m_map.end())
+ return false;
+ entry = iter->second;
+ return true;
+}
+
+bool
+TypeCategoryMap::Get (uint32_t pos, ValueSP& entry)
+{
+ Mutex::Locker locker(m_map_mutex);
+ MapIterator iter = m_map.begin();
+ MapIterator end = m_map.end();
+ while (pos > 0)
+ {
+ iter++;
+ pos--;
+ if (iter == end)
+ return false;
+ }
+ entry = iter->second;
+ return false;
+}
+
+bool
+TypeCategoryMap::AnyMatches (ConstString type_name,
+ TypeCategoryImpl::FormatCategoryItems items,
+ bool only_enabled,
+ const char** matching_category,
+ TypeCategoryImpl::FormatCategoryItems* matching_type)
+{
+ Mutex::Locker locker(m_map_mutex);
+
+ MapIterator pos, end = m_map.end();
+ for (pos = m_map.begin(); pos != end; pos++)
+ {
+ if (pos->second->AnyMatches(type_name,
+ items,
+ only_enabled,
+ matching_category,
+ matching_type))
+ return true;
+ }
+ return false;
+}
+
+lldb::TypeSummaryImplSP
+TypeCategoryMap::GetSummaryFormat (ValueObject& valobj,
+ lldb::DynamicValueType use_dynamic)
+{
+ Mutex::Locker locker(m_map_mutex);
+
+ uint32_t reason_why;
+ ActiveCategoriesIterator begin, end = m_active_categories.end();
+
+ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
+
+ for (begin = m_active_categories.begin(); begin != end; begin++)
+ {
+ lldb::TypeCategoryImplSP category_sp = *begin;
+ lldb::TypeSummaryImplSP current_format;
+ if (log)
+ log->Printf("[CategoryMap::GetSummaryFormat] Trying to use category %s\n", category_sp->GetName());
+ if (!category_sp->Get(valobj, current_format, use_dynamic, &reason_why))
+ continue;
+ return current_format;
+ }
+ if (log)
+ log->Printf("[CategoryMap::GetSummaryFormat] nothing found - returning empty SP\n");
+ return lldb::TypeSummaryImplSP();
+}
+
+#ifndef LLDB_DISABLE_PYTHON
+lldb::SyntheticChildrenSP
+TypeCategoryMap::GetSyntheticChildren (ValueObject& valobj,
+ lldb::DynamicValueType use_dynamic)
+{
+ Mutex::Locker locker(m_map_mutex);
+
+ uint32_t reason_why;
+
+ ActiveCategoriesIterator begin, end = m_active_categories.end();
+
+ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
+
+ for (begin = m_active_categories.begin(); begin != end; begin++)
+ {
+ lldb::TypeCategoryImplSP category_sp = *begin;
+ lldb::SyntheticChildrenSP current_format;
+ if (log)
+ log->Printf("[CategoryMap::GetSyntheticChildren] Trying to use category %s\n", category_sp->GetName());
+ if (!category_sp->Get(valobj, current_format, use_dynamic, &reason_why))
+ continue;
+ return current_format;
+ }
+ if (log)
+ log->Printf("[CategoryMap::GetSyntheticChildren] nothing found - returning empty SP\n");
+ return lldb::SyntheticChildrenSP();
+}
+#endif
+
+void
+TypeCategoryMap::LoopThrough(CallbackType callback, void* param)
+{
+ if (callback)
+ {
+ Mutex::Locker locker(m_map_mutex);
+
+ // loop through enabled categories in respective order
+ {
+ ActiveCategoriesIterator begin, end = m_active_categories.end();
+ for (begin = m_active_categories.begin(); begin != end; begin++)
+ {
+ lldb::TypeCategoryImplSP category = *begin;
+ ConstString type = ConstString(category->GetName());
+ if (!callback(param, category))
+ break;
+ }
+ }
+
+ // loop through disabled categories in just any order
+ {
+ MapIterator pos, end = m_map.end();
+ for (pos = m_map.begin(); pos != end; pos++)
+ {
+ if (pos->second->IsEnabled())
+ continue;
+ KeyType type = pos->first;
+ if (!callback(param, pos->second))
+ break;
+ }
+ }
+ }
+}
+
+TypeCategoryImplSP
+TypeCategoryMap::GetAtIndex (uint32_t index)
+{
+ Mutex::Locker 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();
+}
Added: lldb/trunk/source/DataFormatters/TypeFormat.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/TypeFormat.cpp?rev=173728&view=auto
==============================================================================
--- lldb/trunk/source/DataFormatters/TypeFormat.cpp (added)
+++ lldb/trunk/source/DataFormatters/TypeFormat.cpp Mon Jan 28 17:47:25 2013
@@ -0,0 +1,50 @@
+//===-- TypeFormat.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
+
+// 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/StreamString.h"
+#include "lldb/Core/Timer.h"
+#include "lldb/DataFormatters/TypeFormat.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;
+
+TypeFormatImpl::TypeFormatImpl (lldb::Format f,
+ const Flags& flags) :
+m_flags(flags),
+m_format (f)
+{
+}
+
+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();
+}
+
Added: lldb/trunk/source/DataFormatters/TypeSummary.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/TypeSummary.cpp?rev=173728&view=auto
==============================================================================
--- lldb/trunk/source/DataFormatters/TypeSummary.cpp (added)
+++ lldb/trunk/source/DataFormatters/TypeSummary.cpp Mon Jan 28 17:47:25 2013
@@ -0,0 +1,239 @@
+//===-- TypeSummary.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
+
+// 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/StreamString.h"
+#include "lldb/Core/Timer.h"
+#include "lldb/DataFormatters/TypeSummary.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;
+
+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);
+}
+
+bool
+StringSummaryFormat::FormatObject (ValueObject *valobj,
+ std::string& retval)
+{
+ if (!valobj)
+ {
+ retval.assign("NULL ValueObject");
+ return false;
+ }
+
+ StreamString s;
+ ExecutionContext exe_ctx (valobj->GetExecutionContextRef());
+ SymbolContext sc;
+ StackFrame *frame = exe_ctx.GetFramePtr();
+ if (frame)
+ sc = frame->GetSymbolContext(lldb::eSymbolContextEverything);
+
+ if (IsOneliner())
+ {
+ ValueObject* object;
+
+ ValueObjectSP synth_valobj = valobj->GetSyntheticValue();
+ if (synth_valobj)
+ object = synth_valobj.get();
+ else
+ object = valobj;
+
+ 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(", ");
+ if (!HideNames())
+ {
+ s.PutCString(child_sp.get()->GetName().AsCString());
+ s.PutCString(" = ");
+ }
+ child_sp.get()->DumpPrintableRepresentation(s,
+ ValueObject::eValueObjectRepresentationStyleSummary,
+ lldb::eFormatInvalid,
+ ValueObject::ePrintableRepresentationSpecialCasesDisable);
+ }
+ }
+
+ s.PutChar(')');
+
+ retval.assign(s.GetString());
+ return true;
+ }
+ else
+ {
+ retval.assign("error: oneliner for no children");
+ return false;
+ }
+
+ }
+ else
+ {
+ if (Debugger::FormatPrompt(m_format.c_str(), &sc, &exe_ctx, &sc.line_entry.range.GetBaseAddress(), s, NULL, valobj))
+ {
+ retval.assign(s.GetString());
+ return true;
+ }
+ else
+ {
+ retval.assign("error: summary string parsing error");
+ return false;
+ }
+ }
+}
+
+std::string
+StringSummaryFormat::GetDescription ()
+{
+ StreamString sstr;
+
+ sstr.Printf ("`%s`%s%s%s%s%s%s%s", m_format.c_str(),
+ Cascades() ? "" : " (not cascading)",
+ !DoesPrintChildren() ? "" : " (show children)",
+ !DoesPrintValue() ? " (hide value)" : "",
+ IsOneliner() ? " (one-line printout)" : "",
+ SkipsPointers() ? " (skip pointers)" : "",
+ SkipsReferences() ? " (skip references)" : "",
+ HideNames() ? " (hide member names)" : "");
+ return sstr.GetString();
+}
+
+CXXFunctionSummaryFormat::CXXFunctionSummaryFormat (const TypeSummaryImpl::Flags& flags,
+ Callback impl,
+ const char* description) :
+TypeSummaryImpl(flags),
+m_impl(impl),
+m_description(description ? description : "")
+{
+}
+
+bool
+CXXFunctionSummaryFormat::FormatObject (ValueObject *valobj,
+ std::string& dest)
+{
+ dest.clear();
+ StreamString stream;
+ if (!m_impl || m_impl(*valobj,stream) == false)
+ return false;
+ dest.assign(stream.GetData());
+ return true;
+}
+
+std::string
+CXXFunctionSummaryFormat::GetDescription ()
+{
+ StreamString sstr;
+ sstr.Printf ("`%s (%p) `%s%s%s%s%s%s%s", m_description.c_str(),m_impl,
+ Cascades() ? "" : " (not cascading)",
+ !DoesPrintChildren() ? "" : " (show children)",
+ !DoesPrintValue() ? " (hide value)" : "",
+ IsOneliner() ? " (one-line printout)" : "",
+ SkipsPointers() ? " (skip pointers)" : "",
+ SkipsReferences() ? " (skip references)" : "",
+ HideNames() ? " (hide member names)" : "");
+ return sstr.GetString();
+}
+
+#ifndef LLDB_DISABLE_PYTHON
+
+
+ScriptSummaryFormat::ScriptSummaryFormat (const TypeSummaryImpl::Flags& flags,
+ const char * function_name,
+ const char * python_script) :
+TypeSummaryImpl(flags),
+m_function_name(),
+m_python_script(),
+m_script_function_sp()
+{
+ if (function_name)
+ m_function_name.assign(function_name);
+ if (python_script)
+ m_python_script.assign(python_script);
+}
+
+bool
+ScriptSummaryFormat::FormatObject (ValueObject *valobj,
+ std::string& retval)
+{
+ Timer scoped_timer (__PRETTY_FUNCTION__, __PRETTY_FUNCTION__);
+
+ TargetSP target_sp(valobj->GetTargetSP());
+
+ if (!target_sp)
+ {
+ retval.assign("error: no target");
+ return false;
+ }
+
+ ScriptInterpreter *script_interpreter = target_sp->GetDebugger().GetCommandInterpreter().GetScriptInterpreter();
+
+ if (!script_interpreter)
+ {
+ retval.assign("error: no ScriptInterpreter");
+ return false;
+ }
+
+ return script_interpreter->GetScriptedSummary(m_function_name.c_str(),
+ valobj->GetSP(),
+ m_script_function_sp,
+ retval);
+
+}
+
+std::string
+ScriptSummaryFormat::GetDescription ()
+{
+ StreamString sstr;
+ sstr.Printf ("%s%s%s%s%s%s%s\n%s", Cascades() ? "" : " (not cascading)",
+ !DoesPrintChildren() ? "" : " (show children)",
+ !DoesPrintValue() ? " (hide value)" : "",
+ IsOneliner() ? " (one-line printout)" : "",
+ SkipsPointers() ? " (skip pointers)" : "",
+ SkipsReferences() ? " (skip references)" : "",
+ HideNames() ? " (hide member names)" : "",
+ m_python_script.c_str());
+ return sstr.GetString();
+
+}
+
+#endif // #ifndef LLDB_DISABLE_PYTHON
Added: lldb/trunk/source/DataFormatters/TypeSynthetic.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/TypeSynthetic.cpp?rev=173728&view=auto
==============================================================================
--- lldb/trunk/source/DataFormatters/TypeSynthetic.cpp (added)
+++ lldb/trunk/source/DataFormatters/TypeSynthetic.cpp Mon Jan 28 17:47:25 2013
@@ -0,0 +1,112 @@
+//===-- TypeSynthetic.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
+
+// 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/StreamString.h"
+#include "lldb/DataFormatters/TypeSynthetic.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;
+
+std::string
+TypeFilterImpl::GetDescription()
+{
+ StreamString sstr;
+ sstr.Printf("%s%s%s {\n",
+ Cascades() ? "" : " (not cascading)",
+ SkipsPointers() ? " (skip pointers)" : "",
+ SkipsReferences() ? " (skip references)" : "");
+
+ for (int i = 0; i < GetCount(); i++)
+ {
+ sstr.Printf(" %s\n",
+ GetExpressionPathAtIndex(i));
+ }
+
+ sstr.Printf("}");
+ return sstr.GetString();
+}
+
+std::string
+CXXSyntheticChildren::GetDescription()
+{
+ StreamString sstr;
+ sstr.Printf("%s%s%s Generator at %p - %s\n",
+ Cascades() ? "" : " (not cascading)",
+ SkipsPointers() ? " (skip pointers)" : "",
+ SkipsReferences() ? " (skip references)" : "",
+ m_create_callback,
+ m_description.c_str());
+
+ return sstr.GetString();
+}
+
+#ifndef LLDB_DISABLE_PYTHON
+
+ScriptedSyntheticChildren::FrontEnd::FrontEnd(std::string pclass, ValueObject &backend) :
+SyntheticChildrenFrontEnd(backend),
+m_python_class(pclass),
+m_wrapper_sp(),
+m_interpreter(NULL)
+{
+ if (backend == LLDB_INVALID_UID)
+ return;
+
+ TargetSP target_sp = backend.GetTargetSP();
+
+ if (!target_sp)
+ return;
+
+ m_interpreter = target_sp->GetDebugger().GetCommandInterpreter().GetScriptInterpreter();
+
+ if (m_interpreter != NULL)
+ m_wrapper_sp = m_interpreter->CreateSyntheticScriptedProvider(m_python_class.c_str(), backend.GetSP());
+}
+
+ScriptedSyntheticChildren::FrontEnd::~FrontEnd()
+{
+}
+
+lldb::ValueObjectSP
+ScriptedSyntheticChildren::FrontEnd::GetChildAtIndex (size_t idx)
+{
+ if (!m_wrapper_sp || !m_interpreter)
+ return lldb::ValueObjectSP();
+
+ return m_interpreter->GetChildAtIndex(m_wrapper_sp, idx);
+}
+
+std::string
+ScriptedSyntheticChildren::GetDescription()
+{
+ StreamString sstr;
+ sstr.Printf("%s%s%s Python class %s",
+ Cascades() ? "" : " (not cascading)",
+ SkipsPointers() ? " (skip pointers)" : "",
+ SkipsReferences() ? " (skip references)" : "",
+ m_python_class.c_str());
+
+ return sstr.GetString();
+}
+
+#endif // #ifndef LLDB_DISABLE_PYTHON
Modified: lldb/trunk/source/Interpreter/Args.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/Args.cpp?rev=173728&r1=173727&r2=173728&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/Args.cpp (original)
+++ lldb/trunk/source/Interpreter/Args.cpp Mon Jan 28 17:47:25 2013
@@ -16,10 +16,10 @@
// Other libraries and framework includes
// Project includes
#include "lldb/Interpreter/Args.h"
-#include "lldb/Core/FormatManager.h"
#include "lldb/Core/Stream.h"
#include "lldb/Core/StreamFile.h"
#include "lldb/Core/StreamString.h"
+#include "lldb/DataFormatters/FormatManager.h"
#include "lldb/Interpreter/Options.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Target/Process.h"
Modified: lldb/trunk/source/Interpreter/CommandObjectScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandObjectScript.cpp?rev=173728&r1=173727&r2=173728&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/CommandObjectScript.cpp (original)
+++ lldb/trunk/source/Interpreter/CommandObjectScript.cpp Mon Jan 28 17:47:25 2013
@@ -16,13 +16,14 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/DataVisualization.h"
#include "lldb/Core/Debugger.h"
-#include "lldb/Interpreter/Args.h"
+#include "lldb/DataFormatters/DataVisualization.h"
+
+#include "lldb/Interpreter/Args.h"
+#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Interpreter/ScriptInterpreter.h"
-#include "lldb/Interpreter/CommandInterpreter.h"
using namespace lldb;
using namespace lldb_private;
Modified: lldb/trunk/source/Interpreter/OptionGroupVariable.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionGroupVariable.cpp?rev=173728&r1=173727&r2=173728&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/OptionGroupVariable.cpp (original)
+++ lldb/trunk/source/Interpreter/OptionGroupVariable.cpp Mon Jan 28 17:47:25 2013
@@ -15,10 +15,10 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/DataVisualization.h"
#include "lldb/Core/Error.h"
-#include "lldb/Target/Target.h"
+#include "lldb/DataFormatters/DataVisualization.h"
#include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Target/Target.h"
#include "lldb/Utility/Utils.h"
using namespace lldb;
Modified: lldb/trunk/source/Interpreter/OptionValueArch.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionValueArch.cpp?rev=173728&r1=173727&r2=173728&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/OptionValueArch.cpp (original)
+++ lldb/trunk/source/Interpreter/OptionValueArch.cpp Mon Jan 28 17:47:25 2013
@@ -15,8 +15,8 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/FormatManager.h"
#include "lldb/Core/State.h"
+#include "lldb/DataFormatters/FormatManager.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Interpreter/CommandCompletions.h"
Modified: lldb/trunk/source/Interpreter/OptionValueDictionary.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionValueDictionary.cpp?rev=173728&r1=173727&r2=173728&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/OptionValueDictionary.cpp (original)
+++ lldb/trunk/source/Interpreter/OptionValueDictionary.cpp Mon Jan 28 17:47:25 2013
@@ -16,8 +16,8 @@
// Other libraries and framework includes
#include "llvm/ADT/StringRef.h"
// Project includes
-#include "lldb/Core/FormatManager.h"
#include "lldb/Core/State.h"
+#include "lldb/DataFormatters/FormatManager.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Interpreter/OptionValueString.h"
Modified: lldb/trunk/source/Interpreter/OptionValueFileSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionValueFileSpec.cpp?rev=173728&r1=173727&r2=173728&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/OptionValueFileSpec.cpp (original)
+++ lldb/trunk/source/Interpreter/OptionValueFileSpec.cpp Mon Jan 28 17:47:25 2013
@@ -15,8 +15,8 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/FormatManager.h"
#include "lldb/Core/State.h"
+#include "lldb/DataFormatters/FormatManager.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Interpreter/CommandCompletions.h"
Modified: lldb/trunk/source/Interpreter/OptionValueFormat.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionValueFormat.cpp?rev=173728&r1=173727&r2=173728&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/OptionValueFormat.cpp (original)
+++ lldb/trunk/source/Interpreter/OptionValueFormat.cpp Mon Jan 28 17:47:25 2013
@@ -15,8 +15,8 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/FormatManager.h"
#include "lldb/Core/Stream.h"
+#include "lldb/DataFormatters/FormatManager.h"
#include "lldb/Interpreter/Args.h"
using namespace lldb;
Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp?rev=173728&r1=173727&r2=173728&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp Mon Jan 28 17:47:25 2013
@@ -49,13 +49,26 @@ AppleObjCRuntimeV1::AppleObjCRuntimeV1(P
{
}
+// for V1 runtime we just try to return a class name as that is the minimum level of support
+// required for the data formatters to work
bool
AppleObjCRuntimeV1::GetDynamicTypeAndAddress (ValueObject &in_value,
lldb::DynamicValueType use_dynamic,
TypeAndOrName &class_type_or_name,
Address &address)
{
- return false;
+ class_type_or_name.Clear();
+ if (CouldHaveDynamicValue(in_value))
+ {
+ auto class_descriptor(GetClassDescriptor(in_value));
+ if (class_descriptor && class_descriptor->IsValid() && class_descriptor->GetClassName())
+ {
+ const addr_t object_ptr = in_value.GetPointerValue();
+ address.SetRawAddress(object_ptr);
+ class_type_or_name.SetName(class_descriptor->GetClassName());
+ }
+ }
+ return class_type_or_name.IsEmpty() == false;
}
//------------------------------------------------------------------
Modified: lldb/trunk/test/functionalities/data-formatter/rdar-12437442/TestRdar12437442.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/rdar-12437442/TestRdar12437442.py?rev=173728&r1=173727&r2=173728&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/data-formatter/rdar-12437442/TestRdar12437442.py (original)
+++ lldb/trunk/test/functionalities/data-formatter/rdar-12437442/TestRdar12437442.py Mon Jan 28 17:47:25 2013
@@ -69,6 +69,7 @@ class DataFormatterRdar12437442TestCase(
self.assertTrue(id_x.GetSummary() == '@"5 objects"', "array does not get correct summary")
self.runCmd("next")
+ self.runCmd("frame select 0")
id_x = self.dbg.GetSelectedTarget().GetProcess().GetSelectedThread().GetSelectedFrame().FindVariable("x")
id_x.SetPreferDynamicValue(lldb.eDynamicCanRunTarget)
More information about the lldb-commits
mailing list