[Lldb-commits] [lldb] r137944 - in /lldb/trunk: include/lldb/Core/ source/Commands/ source/Core/ source/Interpreter/ test/functionalities/data-formatter/data-formatter-smart-array/ test/functionalities/data-formatter/rdar-9973865/
Enrico Granata
granata.enrico at gmail.com
Thu Aug 18 09:38:27 PDT 2011
Author: enrico
Date: Thu Aug 18 11:38:26 2011
New Revision: 137944
URL: http://llvm.org/viewvc/llvm-project?rev=137944&view=rev
Log:
Second round of code cleanups:
- reorganizing classes layout to have public part first
Typedefs that we want to keep private, but must be defined for some public code to work correctly are an exception
- avoiding methods in the form T foo() { code; } all on one-line
- moving method implementations from .h to .cpp whenever feasible
Templatized code is an exception and so are very small methods
- generally, adhering to coding conventions followed project-wide
Functional changes:
- fixed an issue where using ${var} in a summary for an aggregate, and then displaying a pointer-to-aggregate would lead to no summary being displayed
The issue was not a major one because all ${var} was meant to do in that context was display an error for invalid use of pointer
Accordingly fixed test cases and added a new test case
Added:
lldb/trunk/test/functionalities/data-formatter/rdar-9973865/
lldb/trunk/test/functionalities/data-formatter/rdar-9973865/Makefile
lldb/trunk/test/functionalities/data-formatter/rdar-9973865/Test-rdar-9973865.py
lldb/trunk/test/functionalities/data-formatter/rdar-9973865/main.cpp
Modified:
lldb/trunk/include/lldb/Core/FormatClasses.h
lldb/trunk/include/lldb/Core/FormatManager.h
lldb/trunk/include/lldb/Core/ValueObject.h
lldb/trunk/source/Commands/CommandObjectType.cpp
lldb/trunk/source/Core/Debugger.cpp
lldb/trunk/source/Core/FormatManager.cpp
lldb/trunk/source/Core/ValueObject.cpp
lldb/trunk/source/Interpreter/CommandObjectScript.cpp
lldb/trunk/test/functionalities/data-formatter/data-formatter-smart-array/TestDataFormatterSmartArray.py
Modified: lldb/trunk/include/lldb/Core/FormatClasses.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FormatClasses.h?rev=137944&r1=137943&r2=137944&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/FormatClasses.h (original)
+++ lldb/trunk/include/lldb/Core/FormatClasses.h Thu Aug 18 11:38:26 2011
@@ -57,7 +57,7 @@
}
typedef lldb::SharedPtr<ValueFormat>::Type SharedPointer;
- typedef bool(*ValueCallback)(void*, ConstString, const ValueFormat::SharedPointer&);
+ typedef bool(*ValueCallback)(void*, ConstString, const lldb::ValueFormatSP&);
~ValueFormat()
{
@@ -295,7 +295,10 @@
std::string
- GetPythonClassName() { return m_python_class; }
+ GetPythonClassName()
+ {
+ return m_python_class;
+ }
std::string
GetDescription();
@@ -453,8 +456,8 @@
GetDescription() = 0;
typedef lldb::SharedPtr<SummaryFormat>::Type SharedPointer;
- typedef bool(*SummaryCallback)(void*, ConstString, const SummaryFormat::SharedPointer&);
- typedef bool(*RegexSummaryCallback)(void*, lldb::RegularExpressionSP, const SummaryFormat::SharedPointer&);
+ typedef bool(*SummaryCallback)(void*, ConstString, const lldb::SummaryFormatSP&);
+ typedef bool(*RegexSummaryCallback)(void*, lldb::RegularExpressionSP, const lldb::SummaryFormatSP&);
};
Modified: lldb/trunk/include/lldb/Core/FormatManager.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FormatManager.h?rev=137944&r1=137943&r2=137944&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/FormatManager.h (original)
+++ lldb/trunk/include/lldb/Core/FormatManager.h Thu Aug 18 11:38:26 2011
@@ -69,13 +69,13 @@
{
public:
virtual void
- Changed() = 0;
+ Changed () = 0;
virtual
- ~IFormatChangeListener() {}
+ ~IFormatChangeListener () {}
virtual uint32_t
- GetCurrentRevision() = 0;
+ GetCurrentRevision () = 0;
};
@@ -85,9 +85,6 @@
template<typename KeyType, typename ValueType>
class FormatMap
{
- friend class FormatNavigator<KeyType, ValueType>;
- friend class FormatManager;
-
public:
typedef typename ValueType::SharedPointer ValueSP;
@@ -95,23 +92,6 @@
typedef typename MapType::iterator MapIterator;
typedef bool(*CallbackType)(void*, KeyType, const ValueSP&);
-private:
- MapType m_map;
- Mutex m_map_mutex;
- IFormatChangeListener* listener;
-
- MapType& map()
- {
- return m_map;
- }
-
- Mutex& mutex()
- {
- return m_map_mutex;
- }
-
-public:
-
FormatMap(IFormatChangeListener* lst = NULL) :
m_map(),
m_map_mutex(Mutex::eMutexTypeRecursive),
@@ -135,7 +115,7 @@
}
bool
- Delete(KeyType name)
+ Delete (KeyType name)
{
Mutex::Locker(m_map_mutex);
MapIterator iter = m_map.find(name);
@@ -148,7 +128,7 @@
}
void
- Clear()
+ Clear ()
{
Mutex::Locker(m_map_mutex);
m_map.clear();
@@ -169,7 +149,7 @@
}
void
- LoopThrough(CallbackType callback, void* param)
+ LoopThrough (CallbackType callback, void* param)
{
if (callback)
{
@@ -185,11 +165,31 @@
}
uint32_t
- GetCount()
+ GetCount ()
{
return m_map.size();
}
+private:
+ 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>
@@ -222,7 +222,7 @@
}
void
- Add(const MapKeyType &type, const MapValueType& entry)
+ Add (const MapKeyType &type, const MapValueType& entry)
{
m_format_map.Add(type,entry);
}
@@ -230,7 +230,7 @@
// using ConstString instead of MapKeyType is necessary here
// to make the partial template specializations below work
bool
- Delete(ConstString type)
+ Delete (ConstString type)
{
return m_format_map.Delete(type);
}
@@ -254,19 +254,19 @@
}
void
- Clear()
+ Clear ()
{
m_format_map.Clear();
}
void
- LoopThrough(CallbackType callback, void* param)
+ LoopThrough (CallbackType callback, void* param)
{
m_format_map.LoopThrough(callback,param);
}
uint32_t
- GetCount()
+ GetCount ()
{
return m_format_map.GetCount();
}
@@ -280,7 +280,7 @@
// using ConstString instead of MapKeyType is necessary here
// to make the partial template specializations below work
bool
- Get(ConstString type, MapValueType& entry)
+ Get (ConstString type, MapValueType& entry)
{
return m_format_map.Get(type, entry);
}
@@ -580,7 +580,7 @@
template<>
bool
-FormatNavigator<lldb::RegularExpressionSP, SummaryFormat>::Get(ConstString key, SummaryFormat::SharedPointer& value);
+FormatNavigator<lldb::RegularExpressionSP, SummaryFormat>::Get(ConstString key, lldb::SummaryFormatSP& value);
template<>
bool
@@ -624,47 +624,6 @@
typedef SynthNavigator::MapType SynthMap;
typedef RegexSynthNavigator::MapType RegexSynthMap;
- SummaryNavigator::SharedPointer m_summary_nav;
- RegexSummaryNavigator::SharedPointer m_regex_summary_nav;
- FilterNavigator::SharedPointer m_filter_nav;
- RegexFilterNavigator::SharedPointer m_regex_filter_nav;
- SynthNavigator::SharedPointer m_synth_nav;
- RegexSynthNavigator::SharedPointer m_regex_synth_nav;
-
- bool m_enabled;
-
- IFormatChangeListener* m_change_listener;
-
- Mutex m_mutex;
-
- std::string m_name;
-
- void
- Enable(bool value = true)
- {
- Mutex::Locker(m_mutex);
- m_enabled = value;
- if (m_change_listener)
- m_change_listener->Changed();
- }
-
- void
- Disable()
- {
- Enable(false);
- }
-
- friend class CategoryMap;
-
- friend class FormatNavigator<ConstString, SummaryFormat>;
- friend class FormatNavigator<lldb::RegularExpressionSP, SummaryFormat>;
-
- friend class FormatNavigator<ConstString, SyntheticFilter>;
- friend class FormatNavigator<lldb::RegularExpressionSP, SyntheticFilter>;
-
- friend class FormatNavigator<ConstString, SyntheticScriptProvider>;
- friend class FormatNavigator<lldb::RegularExpressionSP, SyntheticScriptProvider>;
-
public:
enum FormatCategoryItem
@@ -688,57 +647,46 @@
typedef RegexSynthNavigator::SharedPointer RegexSynthNavigatorSP;
FormatCategory(IFormatChangeListener* clist,
- std::string 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)),
- m_synth_nav(new SynthNavigator("synth",clist)),
- m_regex_synth_nav(new RegexSynthNavigator("regex-synth",clist)),
- m_enabled(false),
- m_change_listener(clist),
- m_mutex(Mutex::eMutexTypeRecursive),
- m_name(name)
- {}
+ std::string name);
SummaryNavigatorSP
- Summary()
+ GetSummaryNavigator ()
{
return SummaryNavigatorSP(m_summary_nav);
}
RegexSummaryNavigatorSP
- RegexSummary()
+ GetRegexSummaryNavigator ()
{
return RegexSummaryNavigatorSP(m_regex_summary_nav);
}
FilterNavigatorSP
- Filter()
+ GetFilterNavigator ()
{
return FilterNavigatorSP(m_filter_nav);
}
RegexFilterNavigatorSP
- RegexFilter()
+ GetRegexFilterNavigator ()
{
return RegexFilterNavigatorSP(m_regex_filter_nav);
}
SynthNavigatorSP
- Synth()
+ GetSyntheticNavigator ()
{
return SynthNavigatorSP(m_synth_nav);
}
RegexSynthNavigatorSP
- RegexSynth()
+ GetRegexSyntheticNavigator ()
{
return RegexSynthNavigatorSP(m_regex_synth_nav);
}
bool
- IsEnabled() const
+ IsEnabled () const
{
return m_enabled;
}
@@ -751,9 +699,9 @@
{
if (!IsEnabled())
return false;
- if (Summary()->Get(valobj, entry, use_dynamic, reason))
+ if (GetSummaryNavigator()->Get(valobj, entry, use_dynamic, reason))
return true;
- bool regex = RegexSummary()->Get(valobj, entry, use_dynamic, reason);
+ bool regex = GetRegexSummaryNavigator()->Get(valobj, entry, use_dynamic, reason);
if (regex && reason)
*reason |= lldb::eFormatterChoiceCriterionRegularExpressionSummary;
return regex;
@@ -763,76 +711,25 @@
Get(ValueObject& valobj,
lldb::SyntheticChildrenSP& entry,
lldb::DynamicValueType use_dynamic,
- uint32_t* reason = NULL)
- {
- if (!IsEnabled())
- return false;
- SyntheticFilter::SharedPointer filter;
- SyntheticScriptProvider::SharedPointer synth;
- bool regex_filter, regex_synth;
- uint32_t reason_filter;
- uint32_t reason_synth;
-
- bool pick_synth = false;
-
- // first find both Filter and Synth, and then check which is most recent
-
- if (!Filter()->Get(valobj, filter, use_dynamic, &reason_filter))
- regex_filter = RegexFilter()->Get(valobj, filter, use_dynamic, &reason_filter);
-
- if (!Synth()->Get(valobj, synth, use_dynamic, &reason_synth))
- regex_synth = RegexSynth()->Get(valobj, synth, use_dynamic, &reason_synth);
-
- if (!filter.get() && !synth.get())
- return false;
-
- else if (!filter.get() && synth.get())
- pick_synth = true;
-
- else if (filter.get() && !synth.get())
- pick_synth = false;
-
- else /*if (filter.get() && synth.get())*/
- {
- if (filter->m_my_revision > synth->m_my_revision)
- pick_synth = false;
- else
- pick_synth = true;
- }
-
- if (pick_synth)
- {
- if (regex_synth && reason)
- *reason |= lldb::eFormatterChoiceCriterionRegularExpressionFilter;
- entry = synth;
- return true;
- }
- else
- {
- if (regex_filter && reason)
- *reason |= lldb::eFormatterChoiceCriterionRegularExpressionFilter;
- entry = filter;
- return true;
- }
- }
+ uint32_t* reason = NULL);
- // just a shortcut for Summary()->Clear; RegexSummary()->Clear()
+ // just a shortcut for GetSummaryNavigator()->Clear; GetRegexSummaryNavigator()->Clear()
void
- ClearSummaries()
+ ClearSummaries ()
{
Clear(eSummary | eRegexSummary);
}
- // just a shortcut for (Summary()->Delete(name) || RegexSummary()->Delete(name))
+ // just a shortcut for (GetSummaryNavigator()->Delete(name) || GetRegexSummaryNavigator()->Delete(name))
bool
- DeleteSummaries(ConstString name)
+ DeleteSummaries (ConstString name)
{
return Delete(name, (eSummary | eRegexSummary));
}
void
- Clear(FormatCategoryItems items = ALL_ITEM_TYPES)
+ Clear (FormatCategoryItems items = ALL_ITEM_TYPES)
{
if ( (items & eSummary) == eSummary )
m_summary_nav->Clear();
@@ -869,7 +766,7 @@
}
uint32_t
- GetCount(FormatCategoryItems items = ALL_ITEM_TYPES)
+ GetCount (FormatCategoryItems items = ALL_ITEM_TYPES)
{
uint32_t count = 0;
if ( (items & eSummary) == eSummary )
@@ -888,7 +785,7 @@
}
std::string
- GetName()
+ GetName ()
{
return m_name;
}
@@ -898,127 +795,66 @@
FormatCategoryItems items = ALL_ITEM_TYPES,
bool only_enabled = true,
const char** matching_category = NULL,
- FormatCategoryItems* matching_type = NULL)
- {
- if (!IsEnabled() && only_enabled)
- return false;
-
- SummaryFormat::SharedPointer summary;
- SyntheticFilter::SharedPointer filter;
- SyntheticScriptProvider::SharedPointer synth;
-
- if ( (items & eSummary) == eSummary )
- {
- if (m_summary_nav->Get(type_name, summary))
- {
- if (matching_category)
- *matching_category = m_name.c_str();
- if (matching_type)
- *matching_type = eSummary;
- return true;
- }
- }
- if ( (items & eRegexSummary) == eRegexSummary )
- {
- if (m_regex_summary_nav->Get(type_name, summary))
- {
- if (matching_category)
- *matching_category = m_name.c_str();
- if (matching_type)
- *matching_type = eRegexSummary;
- return true;
- }
- }
- if ( (items & eFilter) == eFilter )
- {
- if (m_filter_nav->Get(type_name, filter))
- {
- if (matching_category)
- *matching_category = m_name.c_str();
- if (matching_type)
- *matching_type = eFilter;
- return true;
- }
- }
- if ( (items & eRegexFilter) == eRegexFilter )
- {
- if (m_regex_filter_nav->Get(type_name, filter))
- {
- if (matching_category)
- *matching_category = m_name.c_str();
- if (matching_type)
- *matching_type = eRegexFilter;
- return true;
- }
- }
- if ( (items & eSynth) == eSynth )
- {
- if (m_synth_nav->Get(type_name, synth))
- {
- if (matching_category)
- *matching_category = m_name.c_str();
- if (matching_type)
- *matching_type = eSynth;
- return true;
- }
- }
- if ( (items & eRegexSynth) == eRegexSynth )
- {
- if (m_regex_synth_nav->Get(type_name, synth))
- {
- if (matching_category)
- *matching_category = m_name.c_str();
- if (matching_type)
- *matching_type = eRegexSynth;
- return true;
- }
- }
- return false;
- }
+ FormatCategoryItems* matching_type = NULL);
typedef lldb::SharedPtr<FormatCategory>::Type SharedPointer;
-};
-
-class CategoryMap
-{
-private:
- typedef const char* KeyType;
- typedef FormatCategory ValueType;
- typedef ValueType::SharedPointer ValueSP;
- typedef std::list<FormatCategory::SharedPointer> ActiveCategoriesList;
- typedef ActiveCategoriesList::iterator ActiveCategoriesIterator;
- Mutex m_map_mutex;
- IFormatChangeListener* listener;
+private:
+ SummaryNavigator::SharedPointer m_summary_nav;
+ RegexSummaryNavigator::SharedPointer m_regex_summary_nav;
+ FilterNavigator::SharedPointer m_filter_nav;
+ RegexFilterNavigator::SharedPointer m_regex_filter_nav;
+ SynthNavigator::SharedPointer m_synth_nav;
+ RegexSynthNavigator::SharedPointer m_regex_synth_nav;
+ bool m_enabled;
- friend class FormatNavigator<KeyType, ValueType>;
- friend class FormatManager;
+ IFormatChangeListener* m_change_listener;
-public:
- typedef std::map<KeyType, ValueSP> MapType;
+ Mutex m_mutex;
-private:
- MapType m_map;
- ActiveCategoriesList m_active_categories;
+ std::string m_name;
- MapType& map()
+ void
+ Enable (bool value = true)
{
- return m_map;
+ Mutex::Locker(m_mutex);
+ m_enabled = value;
+ if (m_change_listener)
+ m_change_listener->Changed();
}
- ActiveCategoriesList& active_list()
+ void
+ Disable ()
{
- return m_active_categories;
+ Enable(false);
}
- Mutex& mutex()
- {
- return m_map_mutex;
- }
+ friend class CategoryMap;
-public:
+ friend class FormatNavigator<ConstString, SummaryFormat>;
+ friend class FormatNavigator<lldb::RegularExpressionSP, SummaryFormat>;
+
+ friend class FormatNavigator<ConstString, SyntheticFilter>;
+ friend class FormatNavigator<lldb::RegularExpressionSP, SyntheticFilter>;
+ friend class FormatNavigator<ConstString, SyntheticScriptProvider>;
+ friend class FormatNavigator<lldb::RegularExpressionSP, SyntheticScriptProvider>;
+
+
+};
+
+class CategoryMap
+{
+private:
+ typedef const char* KeyType;
+ typedef FormatCategory ValueType;
+ typedef ValueType::SharedPointer ValueSP;
+ typedef std::list<lldb::FormatCategorySP> ActiveCategoriesList;
+ typedef ActiveCategoriesList::iterator ActiveCategoriesIterator;
+
+public:
+ typedef std::map<KeyType, ValueSP> MapType;
typedef MapType::iterator MapIterator;
typedef bool(*CallbackType)(void*, KeyType, const ValueSP&);
@@ -1041,7 +877,7 @@
}
bool
- Delete(KeyType name)
+ Delete (KeyType name)
{
Mutex::Locker(m_map_mutex);
MapIterator iter = m_map.find(name);
@@ -1055,7 +891,7 @@
}
void
- EnableCategory(KeyType category_name)
+ EnableCategory (KeyType category_name)
{
Mutex::Locker(m_map_mutex);
ValueSP category;
@@ -1067,19 +903,19 @@
class delete_matching_categories
{
- FormatCategory::SharedPointer ptr;
+ lldb::FormatCategorySP ptr;
public:
- delete_matching_categories(FormatCategory::SharedPointer p) : ptr(p)
+ delete_matching_categories(lldb::FormatCategorySP p) : ptr(p)
{}
- bool operator()(const FormatCategory::SharedPointer& other)
+ bool operator()(const lldb::FormatCategorySP& other)
{
return ptr.get() == other.get();
}
};
void
- DisableCategory(KeyType category_name)
+ DisableCategory (KeyType category_name)
{
Mutex::Locker(m_map_mutex);
ValueSP category;
@@ -1090,7 +926,7 @@
}
void
- Clear()
+ Clear ()
{
Mutex::Locker(m_map_mutex);
m_map.clear();
@@ -1112,38 +948,7 @@
}
void
- LoopThrough(CallbackType callback, void* param)
- {
- if (callback)
- {
- Mutex::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++)
- {
- FormatCategory::SharedPointer category = *begin;
- const char* type = category->GetName().c_str();
- if (!callback(param, type, 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, type, pos->second))
- break;
- }
- }
- }
- }
+ LoopThrough (CallbackType callback, void* param);
bool
AnyMatches(ConstString type_name,
@@ -1168,7 +973,7 @@
}
uint32_t
- GetCount()
+ GetCount ()
{
return m_map.size();
}
@@ -1185,20 +990,10 @@
for (begin = m_active_categories.begin(); begin != end; begin++)
{
- FormatCategory::SharedPointer category = *begin;
+ lldb::FormatCategorySP category = *begin;
lldb::SummaryFormatSP current_format;
if (!category->Get(valobj, current_format, use_dynamic, &reason_why))
continue;
- /*if (reason_why == lldb::eFormatterChoiceCriterionDirectChoice)
- {
- entry = current_format;
- return true;
- }
- else if (first)
- {
- entry = current_format;
- first = false;
- }*/
entry = current_format;
return true;
}
@@ -1218,26 +1013,40 @@
for (begin = m_active_categories.begin(); begin != end; begin++)
{
- FormatCategory::SharedPointer category = *begin;
+ lldb::FormatCategorySP category = *begin;
lldb::SyntheticChildrenSP current_format;
if (!category->Get(valobj, current_format, use_dynamic, &reason_why))
continue;
- /*if (reason_why == lldb::eFormatterChoiceCriterionDirectChoice)
- {
- entry = current_format;
- return true;
- }
- else if (first)
- {
- entry = current_format;
- first = false;
- }*/
entry = current_format;
return true;
}
return false;
}
-
+
+private:
+ 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;
};
@@ -1249,46 +1058,46 @@
typedef ValueNavigator::MapType ValueMap;
typedef FormatMap<ConstString, SummaryFormat> NamedSummariesMap;
-
- ValueNavigator m_value_nav;
- NamedSummariesMap m_named_summaries_map;
- uint32_t m_last_revision;
- CategoryMap m_categories_map;
-
- const char* m_default_category_name;
- const char* m_system_category_name;
- const char* m_gnu_cpp_category_name;
-
typedef CategoryMap::MapType::iterator CategoryMapIterator;
-
- ConstString m_default_cs;
- ConstString m_system_cs;
- ConstString m_gnu_stdcpp_cs;
public:
- typedef bool (*CategoryCallback)(void*, const char*, const FormatCategory::SharedPointer&);
+ typedef bool (*CategoryCallback)(void*, const char*, const lldb::FormatCategorySP&);
- FormatManager();
+ FormatManager ();
+
+ CategoryMap&
+ Categories ()
+ {
+ return m_categories_map;
+ }
+
+ ValueNavigator&
+ Value ()
+ {
+ return m_value_nav;
+ }
+
+ NamedSummariesMap&
+ NamedSummary ()
+ {
+ return m_named_summaries_map;
+ }
- CategoryMap& Categories() { return m_categories_map; }
- ValueNavigator& Value() { return m_value_nav; }
- NamedSummariesMap& NamedSummary() { return m_named_summaries_map; }
-
void
- EnableCategory(const char* category_name)
+ EnableCategory (const char* category_name)
{
m_categories_map.EnableCategory(category_name);
}
void
- DisableCategory(const char* category_name)
+ DisableCategory (const char* category_name)
{
m_categories_map.DisableCategory(category_name);
}
void
- LoopThroughCategories(CategoryCallback callback, void* param)
+ LoopThroughCategories (CategoryCallback callback, void* param)
{
m_categories_map.LoopThrough(callback, param);
}
@@ -1296,17 +1105,17 @@
FormatCategory::SummaryNavigatorSP
Summary(const char* category_name = NULL)
{
- return Category(category_name)->Summary();
+ return Category(category_name)->GetSummaryNavigator();
}
FormatCategory::RegexSummaryNavigatorSP
- RegexSummary(const char* category_name = NULL)
+ RegexSummary (const char* category_name = NULL)
{
- return Category(category_name)->RegexSummary();
+ return Category(category_name)->GetRegexSummaryNavigator();
}
lldb::FormatCategorySP
- Category(const char* category_name = NULL)
+ Category (const char* category_name = NULL)
{
if (!category_name)
return Category(m_default_category_name);
@@ -1363,21 +1172,34 @@
GetSingleItemFormat(lldb::Format vector_format);
void
- Changed()
+ Changed ()
{
__sync_add_and_fetch(&m_last_revision, +1);
}
uint32_t
- GetCurrentRevision()
+ GetCurrentRevision ()
{
return m_last_revision;
}
- ~FormatManager()
+ ~FormatManager ()
{
}
+private:
+ ValueNavigator m_value_nav;
+ NamedSummariesMap m_named_summaries_map;
+ uint32_t m_last_revision;
+ CategoryMap m_categories_map;
+
+ const char* m_default_category_name;
+ const char* m_system_category_name;
+ const char* m_gnu_cpp_category_name;
+
+ ConstString m_default_cs;
+ ConstString m_system_cs;
+ ConstString m_gnu_stdcpp_cs;
};
class DataVisualization
@@ -1388,29 +1210,29 @@
static void
ForceUpdate();
+ static uint32_t
+ GetCurrentRevision ();
+
class ValueFormats
{
public:
static bool
- Get(ValueObject& valobj, lldb::DynamicValueType use_dynamic, ValueFormat::SharedPointer &entry);
+ Get (ValueObject& valobj, lldb::DynamicValueType use_dynamic, lldb::ValueFormatSP &entry);
static void
- Add(const ConstString &type, const ValueFormat::SharedPointer &entry);
+ Add (const ConstString &type, const lldb::ValueFormatSP &entry);
static bool
- Delete(const ConstString &type);
+ Delete (const ConstString &type);
static void
- Clear();
+ Clear ();
static void
- LoopThrough(ValueFormat::ValueCallback callback, void* callback_baton);
-
- static uint32_t
- GetCurrentRevision();
+ LoopThrough (ValueFormat::ValueCallback callback, void* callback_baton);
static uint32_t
- GetCount();
+ GetCount ();
};
static bool
@@ -1433,25 +1255,22 @@
{
public:
static bool
- Get(const ConstString &type, lldb::SummaryFormatSP &entry);
+ Get (const ConstString &type, lldb::SummaryFormatSP &entry);
static void
- Add(const ConstString &type, const lldb::SummaryFormatSP &entry);
+ Add (const ConstString &type, const lldb::SummaryFormatSP &entry);
static bool
- Delete(const ConstString &type);
+ Delete (const ConstString &type);
static void
- Clear();
+ Clear ();
static void
- LoopThrough(SummaryFormat::SummaryCallback callback, void* callback_baton);
+ LoopThrough (SummaryFormat::SummaryCallback callback, void* callback_baton);
static uint32_t
- GetCurrentRevision();
-
- static uint32_t
- GetCount();
+ GetCount ();
};
class Categories
@@ -1459,34 +1278,31 @@
public:
static bool
- Get(const ConstString &category, lldb::FormatCategorySP &entry);
+ Get (const ConstString &category, lldb::FormatCategorySP &entry);
static void
- Add(const ConstString &category);
+ Add (const ConstString &category);
static bool
- Delete(const ConstString &category);
+ Delete (const ConstString &category);
static void
- Clear();
+ Clear ();
static void
- Clear(ConstString &category);
+ Clear (ConstString &category);
static void
- Enable(ConstString& category);
+ Enable (ConstString& category);
static void
- Disable(ConstString& category);
+ Disable (ConstString& category);
static void
- LoopThrough(FormatManager::CategoryCallback callback, void* callback_baton);
-
- static uint32_t
- GetCurrentRevision();
+ LoopThrough (FormatManager::CategoryCallback callback, void* callback_baton);
static uint32_t
- GetCount();
+ GetCount ();
};
};
Modified: lldb/trunk/include/lldb/Core/ValueObject.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObject.h?rev=137944&r1=137943&r2=137944&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObject.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObject.h Thu Aug 18 11:38:26 2011
@@ -660,7 +660,8 @@
bool
DumpPrintableRepresentation(Stream& s,
ValueObjectRepresentationStyle val_obj_display = eDisplaySummary,
- lldb::Format custom_format = lldb::eFormatInvalid);
+ lldb::Format custom_format = lldb::eFormatInvalid,
+ bool only_special = false);
bool
GetValueIsValid () const;
Modified: lldb/trunk/source/Commands/CommandObjectType.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectType.cpp?rev=137944&r1=137943&r2=137944&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectType.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectType.cpp Thu Aug 18 11:38:26 2011
@@ -195,7 +195,8 @@
// now I have a valid format, let's add it to every type
- for (size_t i = 0; i < argc; i++) {
+ for (size_t i = 0; i < argc; i++)
+ {
const char* typeA = command.GetArgumentAtIndex(i);
ConstString typeCS(typeA);
if (typeCS)
@@ -325,7 +326,7 @@
// CommandObjectTypeFormatList
//-------------------------------------------------------------------------
-bool CommandObjectTypeFormatList_LoopCallback(void* pt2self, ConstString type, const ValueFormat::SharedPointer& entry);
+bool CommandObjectTypeFormatList_LoopCallback(void* pt2self, ConstString type, const lldb::ValueFormatSP& entry);
class CommandObjectTypeFormatList;
@@ -368,7 +369,8 @@
CommandObjectTypeFormatList_LoopCallbackParam *param;
- if (argc == 1) {
+ if (argc == 1)
+ {
RegularExpression* regex = new RegularExpression(command.GetArgumentAtIndex(0));
regex->Compile(command.GetArgumentAtIndex(0));
param = new CommandObjectTypeFormatList_LoopCallbackParam(this,&result,regex);
@@ -385,7 +387,7 @@
bool
LoopCallback (ConstString type,
- const ValueFormat::SharedPointer& entry,
+ const lldb::ValueFormatSP& entry,
RegularExpression* regex,
CommandReturnObject *result)
{
@@ -400,7 +402,7 @@
return true;
}
- friend bool CommandObjectTypeFormatList_LoopCallback(void* pt2self, ConstString type, const ValueFormat::SharedPointer& entry);
+ friend bool CommandObjectTypeFormatList_LoopCallback(void* pt2self, ConstString type, const lldb::ValueFormatSP& entry);
};
@@ -408,7 +410,7 @@
CommandObjectTypeFormatList_LoopCallback (
void* pt2self,
ConstString type,
- const ValueFormat::SharedPointer& entry)
+ const lldb::ValueFormatSP& entry)
{
CommandObjectTypeFormatList_LoopCallbackParam* param = (CommandObjectTypeFormatList_LoopCallbackParam*)pt2self;
return param->self->LoopCallback(type, entry, param->regex, param->result);
@@ -788,7 +790,8 @@
m_options.m_name,
m_options.m_category);
- for (size_t i = 0; i < argc; i++) {
+ for (size_t i = 0; i < argc; i++)
+ {
const char* typeA = command.GetArgumentAtIndex(i);
if (typeA && *typeA)
options->m_target_types << typeA;
@@ -872,7 +875,7 @@
Error error;
- SummaryFormat::SharedPointer entry(new StringSummaryFormat(m_options.m_cascade,
+ lldb::SummaryFormatSP entry(new StringSummaryFormat(m_options.m_cascade,
m_options.m_skip_pointers,
m_options.m_skip_references,
m_options.m_no_children,
@@ -889,7 +892,8 @@
// now I have a valid format, let's add it to every type
- for (size_t i = 0; i < argc; i++) {
+ for (size_t i = 0; i < argc; i++)
+ {
const char* typeA = command.GetArgumentAtIndex(i);
if (!typeA || typeA[0] == '\0')
{
@@ -1049,8 +1053,8 @@
return false;
}
- category->RegexSummary()->Delete(type_name);
- category->RegexSummary()->Add(typeRX, entry);
+ category->GetRegexSummaryNavigator()->Delete(type_name);
+ category->GetRegexSummaryNavigator()->Add(typeRX, entry);
return true;
}
@@ -1062,7 +1066,7 @@
}
else
{
- category->Summary()->Add(type_name, entry);
+ category->GetSummaryNavigator()->Add(type_name, entry);
return true;
}
}
@@ -1163,7 +1167,7 @@
static bool
PerCategoryCallback(void* param,
const char* cate_name,
- const FormatCategory::SharedPointer& cate)
+ const lldb::FormatCategorySP& cate)
{
ConstString *name = (ConstString*)param;
cate->Delete(*name, FormatCategory::eSummary | FormatCategory::eRegexSummary);
@@ -1319,10 +1323,10 @@
static bool
PerCategoryCallback(void* param,
const char* cate_name,
- const FormatCategory::SharedPointer& cate)
+ const lldb::FormatCategorySP& cate)
{
- cate->Summary()->Clear();
- cate->RegexSummary()->Clear();
+ cate->GetSummaryNavigator()->Clear();
+ cate->GetRegexSummaryNavigator()->Clear();
return true;
}
@@ -1491,7 +1495,8 @@
m_options.m_category_regex.empty() ? NULL :
new RegularExpression(m_options.m_category_regex.c_str());
- if (argc == 1) {
+ if (argc == 1)
+ {
RegularExpression* regex = new RegularExpression(command.GetArgumentAtIndex(0));
regex->Compile(command.GetArgumentAtIndex(0));
param = new CommandObjectTypeSummaryList_LoopCallbackParam(this,&result,regex,cate_regex);
@@ -1504,7 +1509,8 @@
if (DataVisualization::NamedSummaryFormats::GetCount() > 0)
{
result.GetOutputStream().Printf("Named summaries:\n");
- if (argc == 1) {
+ if (argc == 1)
+ {
RegularExpression* regex = new RegularExpression(command.GetArgumentAtIndex(0));
regex->Compile(command.GetArgumentAtIndex(0));
param = new CommandObjectTypeSummaryList_LoopCallbackParam(this,&result,regex);
@@ -1527,7 +1533,7 @@
static bool
PerCategoryCallback(void* param_vp,
const char* cate_name,
- const FormatCategory::SharedPointer& cate)
+ const lldb::FormatCategorySP& cate)
{
CommandObjectTypeSummaryList_LoopCallbackParam* param =
@@ -1546,12 +1552,12 @@
cate_name,
(cate->IsEnabled() ? "enabled" : "disabled"));
- cate->Summary()->LoopThrough(CommandObjectTypeSummaryList_LoopCallback, param_vp);
+ cate->GetSummaryNavigator()->LoopThrough(CommandObjectTypeSummaryList_LoopCallback, param_vp);
- if (cate->RegexSummary()->GetCount() > 0)
+ if (cate->GetRegexSummaryNavigator()->GetCount() > 0)
{
result->GetOutputStream().Printf("Regex-based summaries (slower):\n");
- cate->RegexSummary()->LoopThrough(CommandObjectTypeRXSummaryList_LoopCallback, param_vp);
+ cate->GetRegexSummaryNavigator()->LoopThrough(CommandObjectTypeRXSummaryList_LoopCallback, param_vp);
}
return true;
}
@@ -1559,7 +1565,7 @@
bool
LoopCallback (const char* type,
- const SummaryFormat::SharedPointer& entry,
+ const lldb::SummaryFormatSP& entry,
RegularExpression* regex,
CommandReturnObject *result)
{
@@ -1568,15 +1574,15 @@
return true;
}
- friend bool CommandObjectTypeSummaryList_LoopCallback(void* pt2self, ConstString type, const SummaryFormat::SharedPointer& entry);
- friend bool CommandObjectTypeRXSummaryList_LoopCallback(void* pt2self, lldb::RegularExpressionSP regex, const SummaryFormat::SharedPointer& entry);
+ friend bool CommandObjectTypeSummaryList_LoopCallback(void* pt2self, ConstString type, const lldb::SummaryFormatSP& entry);
+ friend bool CommandObjectTypeRXSummaryList_LoopCallback(void* pt2self, lldb::RegularExpressionSP regex, const lldb::SummaryFormatSP& entry);
};
bool
CommandObjectTypeSummaryList_LoopCallback (
void* pt2self,
ConstString type,
- const SummaryFormat::SharedPointer& entry)
+ const lldb::SummaryFormatSP& entry)
{
CommandObjectTypeSummaryList_LoopCallbackParam* param = (CommandObjectTypeSummaryList_LoopCallbackParam*)pt2self;
return param->self->LoopCallback(type.AsCString(), entry, param->regex, param->result);
@@ -1586,7 +1592,7 @@
CommandObjectTypeRXSummaryList_LoopCallback (
void* pt2self,
lldb::RegularExpressionSP regex,
- const SummaryFormat::SharedPointer& entry)
+ const lldb::SummaryFormatSP& entry)
{
CommandObjectTypeSummaryList_LoopCallbackParam* param = (CommandObjectTypeSummaryList_LoopCallbackParam*)pt2self;
return param->self->LoopCallback(regex->GetText(), entry, param->regex, param->result);
@@ -1819,7 +1825,7 @@
static bool
PerCategoryCallback(void* param_vp,
const char* cate_name,
- const FormatCategory::SharedPointer& cate)
+ const lldb::FormatCategorySP& cate)
{
CommandObjectTypeCategoryList_CallbackParam* param =
(CommandObjectTypeCategoryList_CallbackParam*)param_vp;
@@ -2000,7 +2006,8 @@
m_options.m_category_regex.empty() ? NULL :
new RegularExpression(m_options.m_category_regex.c_str());
- if (argc == 1) {
+ if (argc == 1)
+ {
RegularExpression* regex = new RegularExpression(command.GetArgumentAtIndex(0));
regex->Compile(command.GetArgumentAtIndex(0));
param = new CommandObjectTypeFilterList_LoopCallbackParam(this,&result,regex,cate_regex);
@@ -2022,7 +2029,7 @@
static bool
PerCategoryCallback(void* param_vp,
const char* cate_name,
- const FormatCategory::SharedPointer& cate)
+ const lldb::FormatCategorySP& cate)
{
CommandObjectTypeFilterList_LoopCallbackParam* param =
@@ -2041,12 +2048,12 @@
cate_name,
(cate->IsEnabled() ? "enabled" : "disabled"));
- cate->Filter()->LoopThrough(CommandObjectTypeFilterList_LoopCallback, param_vp);
+ cate->GetFilterNavigator()->LoopThrough(CommandObjectTypeFilterList_LoopCallback, param_vp);
- if (cate->RegexFilter()->GetCount() > 0)
+ if (cate->GetRegexFilterNavigator()->GetCount() > 0)
{
result->GetOutputStream().Printf("Regex-based filters (slower):\n");
- cate->RegexFilter()->LoopThrough(CommandObjectTypeFilterRXList_LoopCallback, param_vp);
+ cate->GetRegexFilterNavigator()->LoopThrough(CommandObjectTypeFilterRXList_LoopCallback, param_vp);
}
return true;
@@ -2208,7 +2215,8 @@
m_options.m_category_regex.empty() ? NULL :
new RegularExpression(m_options.m_category_regex.c_str());
- if (argc == 1) {
+ if (argc == 1)
+ {
RegularExpression* regex = new RegularExpression(command.GetArgumentAtIndex(0));
regex->Compile(command.GetArgumentAtIndex(0));
param = new CommandObjectTypeSynthList_LoopCallbackParam(this,&result,regex,cate_regex);
@@ -2230,7 +2238,7 @@
static bool
PerCategoryCallback(void* param_vp,
const char* cate_name,
- const FormatCategory::SharedPointer& cate)
+ const lldb::FormatCategorySP& cate)
{
CommandObjectTypeSynthList_LoopCallbackParam* param =
@@ -2249,12 +2257,12 @@
cate_name,
(cate->IsEnabled() ? "enabled" : "disabled"));
- cate->Synth()->LoopThrough(CommandObjectTypeSynthList_LoopCallback, param_vp);
+ cate->GetSyntheticNavigator()->LoopThrough(CommandObjectTypeSynthList_LoopCallback, param_vp);
- if (cate->RegexSynth()->GetCount() > 0)
+ if (cate->GetRegexSyntheticNavigator()->GetCount() > 0)
{
result->GetOutputStream().Printf("Regex-based synthetic providers (slower):\n");
- cate->RegexSynth()->LoopThrough(CommandObjectTypeSynthRXList_LoopCallback, param_vp);
+ cate->GetRegexSyntheticNavigator()->LoopThrough(CommandObjectTypeSynthRXList_LoopCallback, param_vp);
}
return true;
@@ -2377,7 +2385,7 @@
static bool
PerCategoryCallback(void* param,
const char* cate_name,
- const FormatCategory::SharedPointer& cate)
+ const lldb::FormatCategorySP& cate)
{
ConstString *name = (ConstString*)param;
return cate->Delete(*name, FormatCategory::eFilter | FormatCategory::eRegexFilter);
@@ -2438,8 +2446,8 @@
lldb::FormatCategorySP category;
DataVisualization::Categories::Get(ConstString(m_options.m_category.c_str()), category);
- bool delete_category = category->Filter()->Delete(typeCS);
- delete_category = category->RegexFilter()->Delete(typeCS) || delete_category;
+ bool delete_category = category->GetFilterNavigator()->Delete(typeCS);
+ delete_category = category->GetRegexFilterNavigator()->Delete(typeCS) || delete_category;
if (delete_category)
{
@@ -2540,7 +2548,7 @@
static bool
PerCategoryCallback(void* param,
const char* cate_name,
- const FormatCategory::SharedPointer& cate)
+ const lldb::FormatCategorySP& cate)
{
ConstString* name = (ConstString*)param;
return cate->Delete(*name, FormatCategory::eSynth | FormatCategory::eRegexSynth);
@@ -2601,8 +2609,8 @@
lldb::FormatCategorySP category;
DataVisualization::Categories::Get(ConstString(m_options.m_category.c_str()), category);
- bool delete_category = category->Synth()->Delete(typeCS);
- delete_category = category->RegexSynth()->Delete(typeCS) || delete_category;
+ bool delete_category = category->GetSyntheticNavigator()->Delete(typeCS);
+ delete_category = category->GetRegexSyntheticNavigator()->Delete(typeCS) || delete_category;
if (delete_category)
{
@@ -2699,7 +2707,7 @@
static bool
PerCategoryCallback(void* param,
const char* cate_name,
- const FormatCategory::SharedPointer& cate)
+ const lldb::FormatCategorySP& cate)
{
cate->Clear(FormatCategory::eFilter | FormatCategory::eRegexFilter);
return true;
@@ -2737,8 +2745,8 @@
}
else
DataVisualization::Categories::Get(ConstString(NULL), category);
- category->Filter()->Clear();
- category->RegexFilter()->Clear();
+ category->GetFilterNavigator()->Clear();
+ category->GetRegexFilterNavigator()->Clear();
}
result.SetStatus(eReturnStatusSuccessFinishResult);
@@ -2826,7 +2834,7 @@
static bool
PerCategoryCallback(void* param,
const char* cate_name,
- const FormatCategory::SharedPointer& cate)
+ const lldb::FormatCategorySP& cate)
{
cate->Clear(FormatCategory::eSynth | FormatCategory::eRegexSynth);
return true;
@@ -2864,8 +2872,8 @@
}
else
DataVisualization::Categories::Get(ConstString(NULL), category);
- category->Synth()->Clear();
- category->RegexSynth()->Clear();
+ category->GetSyntheticNavigator()->Clear();
+ category->GetRegexSyntheticNavigator()->Clear();
}
result.SetStatus(eReturnStatusSuccessFinishResult);
@@ -3018,7 +3026,8 @@
Error error;
- for (size_t i = 0; i < options->m_target_types.GetSize(); i++) {
+ for (size_t i = 0; i < options->m_target_types.GetSize(); i++)
+ {
const char *type_name = options->m_target_types.GetStringAtIndex(i);
ConstString typeCS(type_name);
if (typeCS)
@@ -3084,7 +3093,8 @@
const size_t argc = command.GetArgumentCount();
- for (size_t i = 0; i < argc; i++) {
+ for (size_t i = 0; i < argc; i++)
+ {
const char* typeA = command.GetArgumentAtIndex(i);
if (typeA && *typeA)
options->m_target_types << typeA;
@@ -3135,7 +3145,8 @@
Error error;
- for (size_t i = 0; i < argc; i++) {
+ for (size_t i = 0; i < argc; i++)
+ {
const char* typeA = command.GetArgumentAtIndex(i);
ConstString typeCS(typeA);
if (typeCS)
@@ -3210,14 +3221,14 @@
return false;
}
- category->RegexSynth()->Delete(type_name);
- category->RegexSynth()->Add(typeRX, entry);
+ category->GetRegexSyntheticNavigator()->Delete(type_name);
+ category->GetRegexSyntheticNavigator()->Add(typeRX, entry);
return true;
}
else
{
- category->Synth()->Add(type_name, entry);
+ category->GetSyntheticNavigator()->Add(type_name, entry);
return true;
}
}
@@ -3387,14 +3398,14 @@
return false;
}
- category->RegexFilter()->Delete(type_name);
- category->RegexFilter()->Add(typeRX, entry);
+ category->GetRegexFilterNavigator()->Delete(type_name);
+ category->GetRegexFilterNavigator()->Add(typeRX, entry);
return true;
}
else
{
- category->Filter()->Add(type_name, entry);
+ category->GetFilterNavigator()->Add(type_name, entry);
return true;
}
}
@@ -3466,7 +3477,8 @@
Error error;
- for (size_t i = 0; i < argc; i++) {
+ for (size_t i = 0; i < argc; i++)
+ {
const char* typeA = command.GetArgumentAtIndex(i);
ConstString typeCS(typeA);
if (typeCS)
Modified: lldb/trunk/source/Core/Debugger.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=137944&r1=137943&r2=137944&view=diff
==============================================================================
--- lldb/trunk/source/Core/Debugger.cpp (original)
+++ lldb/trunk/source/Core/Debugger.cpp Thu Aug 18 11:38:26 2011
@@ -1055,16 +1055,20 @@
int64_t index_higher = -1;
bool is_array_range = false;
const char* first_unparsed;
+ bool was_plain_var = false;
+ bool was_var_format = false;
if (!valobj) break;
// simplest case ${var}, just print valobj's value
if (::strncmp (var_name_begin, "var}", strlen("var}")) == 0)
{
+ was_plain_var = true;
target = valobj;
val_obj_display = ValueObject::eDisplayValue;
}
else if (::strncmp(var_name_begin,"var%",strlen("var%")) == 0)
{
+ was_var_format = true;
// this is a variable with some custom format applied to it
const char* percent_position;
target = valobj;
@@ -1151,19 +1155,38 @@
do_deref_pointer = false;
}
+ // TODO use flags for these
bool is_array = ClangASTContext::IsArrayType(target->GetClangType());
bool is_pointer = ClangASTContext::IsPointerType(target->GetClangType());
+ bool is_aggregate = ClangASTContext::IsAggregateType(target->GetClangType());
if ((is_array || is_pointer) && (!is_array_range) && val_obj_display == ValueObject::eDisplayValue) // this should be wrong, but there are some exceptions
{
+ StreamString str_temp;
if (log)
log->Printf("I am into array || pointer && !range");
// try to use the special cases
- var_success = target->DumpPrintableRepresentation(s,val_obj_display, custom_format);
- if (!var_success)
- s << "<invalid, please use [] operator>";
+ var_success = target->DumpPrintableRepresentation(str_temp,
+ val_obj_display,
+ custom_format);
if (log)
log->Printf("special cases did%s match", var_success ? "" : "n't");
+ if (!var_success)
+ {
+ s << "<invalid usage of pointer value as object>";
+ var_success = true;
+ }
+ else
+ s << str_temp.GetData();
+ break;
+ }
+
+ // if directly trying to print ${var} using its value, and this is an aggregate, display a nice
+ // error message about it (and avoid recursion in DumpPrintableRepresentation)
+ if (is_aggregate && ((was_var_format && val_obj_display == ValueObject::eDisplayValue) || was_plain_var))
+ {
+ s << "<invalid use of aggregate type>";
+ var_success = true;
break;
}
Modified: lldb/trunk/source/Core/FormatManager.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/FormatManager.cpp?rev=137944&r1=137943&r2=137944&view=diff
==============================================================================
--- lldb/trunk/source/Core/FormatManager.cpp (original)
+++ lldb/trunk/source/Core/FormatManager.cpp Thu Aug 18 11:38:26 2011
@@ -156,7 +156,7 @@
template<>
bool
-FormatNavigator<lldb::RegularExpressionSP, SummaryFormat>::Get(ConstString key, SummaryFormat::SharedPointer& value)
+FormatNavigator<lldb::RegularExpressionSP, SummaryFormat>::Get(ConstString key, lldb::SummaryFormatSP& value)
{
Mutex::Locker(m_format_map.mutex());
MapIterator pos, end = m_format_map.map().end();
@@ -268,6 +268,194 @@
return false;
}
+FormatCategory::FormatCategory(IFormatChangeListener* clist,
+ std::string 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)),
+ m_synth_nav(new SynthNavigator("synth",clist)),
+ m_regex_synth_nav(new RegexSynthNavigator("regex-synth",clist)),
+ m_enabled(false),
+ m_change_listener(clist),
+ m_mutex(Mutex::eMutexTypeRecursive),
+ m_name(name)
+{}
+
+bool
+FormatCategory::Get(ValueObject& valobj,
+ lldb::SyntheticChildrenSP& entry,
+ lldb::DynamicValueType use_dynamic,
+ uint32_t* reason)
+{
+ if (!IsEnabled())
+ return false;
+ SyntheticFilter::SharedPointer filter;
+ SyntheticScriptProvider::SharedPointer synth;
+ bool regex_filter, regex_synth;
+ uint32_t reason_filter;
+ uint32_t reason_synth;
+
+ bool pick_synth = false;
+
+ // first find both Filter and Synth, and then check which is most recent
+
+ if (!GetFilterNavigator()->Get(valobj, filter, use_dynamic, &reason_filter))
+ regex_filter = GetRegexFilterNavigator()->Get(valobj, filter, use_dynamic, &reason_filter);
+
+ if (!GetSyntheticNavigator()->Get(valobj, synth, use_dynamic, &reason_synth))
+ regex_synth = GetRegexSyntheticNavigator()->Get(valobj, synth, use_dynamic, &reason_synth);
+
+ if (!filter.get() && !synth.get())
+ return false;
+
+ else if (!filter.get() && synth.get())
+ pick_synth = true;
+
+ else if (filter.get() && !synth.get())
+ pick_synth = false;
+
+ else /*if (filter.get() && synth.get())*/
+ {
+ if (filter->m_my_revision > synth->m_my_revision)
+ pick_synth = false;
+ else
+ pick_synth = true;
+ }
+
+ if (pick_synth)
+ {
+ if (regex_synth && reason)
+ *reason |= lldb::eFormatterChoiceCriterionRegularExpressionFilter;
+ entry = synth;
+ return true;
+ }
+ else
+ {
+ if (regex_filter && reason)
+ *reason |= lldb::eFormatterChoiceCriterionRegularExpressionFilter;
+ entry = filter;
+ return true;
+ }
+}
+
+bool
+FormatCategory::AnyMatches(ConstString type_name,
+ FormatCategoryItems items,
+ bool only_enabled,
+ const char** matching_category,
+ FormatCategoryItems* matching_type)
+{
+ if (!IsEnabled() && only_enabled)
+ return false;
+
+ lldb::SummaryFormatSP summary;
+ SyntheticFilter::SharedPointer filter;
+ SyntheticScriptProvider::SharedPointer synth;
+
+ if ( (items & eSummary) == eSummary )
+ {
+ if (m_summary_nav->Get(type_name, summary))
+ {
+ if (matching_category)
+ *matching_category = m_name.c_str();
+ if (matching_type)
+ *matching_type = eSummary;
+ return true;
+ }
+ }
+ if ( (items & eRegexSummary) == eRegexSummary )
+ {
+ if (m_regex_summary_nav->Get(type_name, summary))
+ {
+ if (matching_category)
+ *matching_category = m_name.c_str();
+ if (matching_type)
+ *matching_type = eRegexSummary;
+ return true;
+ }
+ }
+ if ( (items & eFilter) == eFilter )
+ {
+ if (m_filter_nav->Get(type_name, filter))
+ {
+ if (matching_category)
+ *matching_category = m_name.c_str();
+ if (matching_type)
+ *matching_type = eFilter;
+ return true;
+ }
+ }
+ if ( (items & eRegexFilter) == eRegexFilter )
+ {
+ if (m_regex_filter_nav->Get(type_name, filter))
+ {
+ if (matching_category)
+ *matching_category = m_name.c_str();
+ if (matching_type)
+ *matching_type = eRegexFilter;
+ return true;
+ }
+ }
+ if ( (items & eSynth) == eSynth )
+ {
+ if (m_synth_nav->Get(type_name, synth))
+ {
+ if (matching_category)
+ *matching_category = m_name.c_str();
+ if (matching_type)
+ *matching_type = eSynth;
+ return true;
+ }
+ }
+ if ( (items & eRegexSynth) == eRegexSynth )
+ {
+ if (m_regex_synth_nav->Get(type_name, synth))
+ {
+ if (matching_category)
+ *matching_category = m_name.c_str();
+ if (matching_type)
+ *matching_type = eRegexSynth;
+ return true;
+ }
+ }
+ return false;
+}
+
+void
+CategoryMap::LoopThrough(CallbackType callback, void* param)
+{
+ if (callback)
+ {
+ Mutex::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::FormatCategorySP category = *begin;
+ const char* type = category->GetName().c_str();
+ if (!callback(param, type, 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, type, pos->second))
+ break;
+ }
+ }
+ }
+}
+
lldb::Format
FormatManager::GetSingleItemFormat(lldb::Format vector_format)
{
@@ -316,7 +504,7 @@
// add some default stuff
// most formats, summaries, ... actually belong to the users' lldbinit file rather than here
- SummaryFormat::SharedPointer string_format(new StringSummaryFormat(false,
+ lldb::SummaryFormatSP string_format(new StringSummaryFormat(false,
true,
false,
true,
@@ -325,7 +513,7 @@
"${var%s}"));
- SummaryFormat::SharedPointer string_array_format(new StringSummaryFormat(false,
+ lldb::SummaryFormatSP string_array_format(new StringSummaryFormat(false,
true,
false,
false,
@@ -336,9 +524,9 @@
lldb::RegularExpressionSP any_size_char_arr(new RegularExpression("char \\[[0-9]+\\]"));
- Category(m_system_category_name)->Summary()->Add(ConstString("char *"), string_format);
- Category(m_system_category_name)->Summary()->Add(ConstString("const char *"), string_format);
- Category(m_system_category_name)->RegexSummary()->Add(any_size_char_arr, string_array_format);
+ Category(m_system_category_name)->GetSummaryNavigator()->Add(ConstString("char *"), string_format);
+ Category(m_system_category_name)->GetSummaryNavigator()->Add(ConstString("const char *"), string_format);
+ Category(m_system_category_name)->GetRegexSummaryNavigator()->Add(any_size_char_arr, string_array_format);
Category(m_default_category_name); // this call is there to force LLDB into creating an empty "default" category
@@ -356,24 +544,24 @@
true,
false,
"${var._M_dataplus._M_p}"));
- Category(m_gnu_cpp_category_name)->Summary()->Add(ConstString("std::string"),
+ Category(m_gnu_cpp_category_name)->GetSummaryNavigator()->Add(ConstString("std::string"),
std_string_summary_sp);
- Category(m_gnu_cpp_category_name)->Summary()->Add(ConstString("std::basic_string<char>"),
+ Category(m_gnu_cpp_category_name)->GetSummaryNavigator()->Add(ConstString("std::basic_string<char>"),
std_string_summary_sp);
- Category(m_gnu_cpp_category_name)->Summary()->Add(ConstString("std::basic_string<char,std::char_traits<char>,std::allocator<char> >"),
+ Category(m_gnu_cpp_category_name)->GetSummaryNavigator()->Add(ConstString("std::basic_string<char,std::char_traits<char>,std::allocator<char> >"),
std_string_summary_sp);
- Category(m_gnu_cpp_category_name)->RegexSynth()->Add(RegularExpressionSP(new RegularExpression("std::vector<")),
+ Category(m_gnu_cpp_category_name)->GetRegexSyntheticNavigator()->Add(RegularExpressionSP(new RegularExpression("std::vector<")),
SyntheticChildrenSP(new SyntheticScriptProvider(true,
false,
false,
"StdVectorSynthProvider")));
- Category(m_gnu_cpp_category_name)->RegexSynth()->Add(RegularExpressionSP(new RegularExpression("std::map<")),
+ Category(m_gnu_cpp_category_name)->GetRegexSyntheticNavigator()->Add(RegularExpressionSP(new RegularExpression("std::map<")),
SyntheticChildrenSP(new SyntheticScriptProvider(true,
false,
false,
"StdMapSynthProvider")));
- Category(m_gnu_cpp_category_name)->RegexSynth()->Add(RegularExpressionSP(new RegularExpression("std::list<")),
+ Category(m_gnu_cpp_category_name)->GetRegexSyntheticNavigator()->Add(RegularExpressionSP(new RegularExpression("std::list<")),
SyntheticChildrenSP(new SyntheticScriptProvider(true,
false,
false,
@@ -388,7 +576,8 @@
static FormatManager&
-GetFormatManager() {
+GetFormatManager()
+{
static FormatManager g_format_manager;
return g_format_manager;
}
@@ -399,14 +588,20 @@
GetFormatManager().Changed();
}
+uint32_t
+DataVisualization::GetCurrentRevision ()
+{
+ return GetFormatManager().GetCurrentRevision();
+}
+
bool
-DataVisualization::ValueFormats::Get(ValueObject& valobj, lldb::DynamicValueType use_dynamic, ValueFormat::SharedPointer &entry)
+DataVisualization::ValueFormats::Get(ValueObject& valobj, lldb::DynamicValueType use_dynamic, lldb::ValueFormatSP &entry)
{
return GetFormatManager().Value().Get(valobj,entry, use_dynamic);
}
void
-DataVisualization::ValueFormats::Add(const ConstString &type, const ValueFormat::SharedPointer &entry)
+DataVisualization::ValueFormats::Add(const ConstString &type, const lldb::ValueFormatSP &entry)
{
GetFormatManager().Value().Add(type,entry);
}
@@ -430,12 +625,6 @@
}
uint32_t
-DataVisualization::ValueFormats::GetCurrentRevision()
-{
- return GetFormatManager().GetCurrentRevision();
-}
-
-uint32_t
DataVisualization::ValueFormats::GetCount()
{
return GetFormatManager().Value().GetCount();
@@ -528,25 +717,19 @@
}
uint32_t
-DataVisualization::Categories::GetCurrentRevision()
-{
- return GetFormatManager().GetCurrentRevision();
-}
-
-uint32_t
DataVisualization::Categories::GetCount()
{
return GetFormatManager().Categories().GetCount();
}
bool
-DataVisualization::NamedSummaryFormats::Get(const ConstString &type, SummaryFormat::SharedPointer &entry)
+DataVisualization::NamedSummaryFormats::Get(const ConstString &type, lldb::SummaryFormatSP &entry)
{
return GetFormatManager().NamedSummary().Get(type,entry);
}
void
-DataVisualization::NamedSummaryFormats::Add(const ConstString &type, const SummaryFormat::SharedPointer &entry)
+DataVisualization::NamedSummaryFormats::Add(const ConstString &type, const lldb::SummaryFormatSP &entry)
{
GetFormatManager().NamedSummary().Add(type,entry);
}
@@ -570,12 +753,6 @@
}
uint32_t
-DataVisualization::NamedSummaryFormats::GetCurrentRevision()
-{
- return GetFormatManager().GetCurrentRevision();
-}
-
-uint32_t
DataVisualization::NamedSummaryFormats::GetCount()
{
return GetFormatManager().NamedSummary().GetCount();
Modified: lldb/trunk/source/Core/ValueObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=137944&r1=137943&r2=137944&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObject.cpp (original)
+++ lldb/trunk/source/Core/ValueObject.cpp Thu Aug 18 11:38:26 2011
@@ -224,13 +224,13 @@
log->Printf("checking for FormatManager revisions. VO named %s is at revision %d, while the format manager is at revision %d",
GetName().GetCString(),
m_last_format_mgr_revision,
- DataVisualization::ValueFormats::GetCurrentRevision());
+ DataVisualization::GetCurrentRevision());
if (HasCustomSummaryFormat() && m_update_point.GetModID() != m_user_id_of_forced_summary)
{
ClearCustomSummaryFormat();
m_summary_str.clear();
}
- if ( (m_last_format_mgr_revision != DataVisualization::ValueFormats::GetCurrentRevision()) ||
+ if ( (m_last_format_mgr_revision != DataVisualization::GetCurrentRevision()) ||
m_last_format_mgr_dynamic != use_dynamic)
{
if (m_last_summary_format.get())
@@ -246,7 +246,7 @@
DataVisualization::GetSummaryFormat(*this, use_dynamic, m_last_summary_format);
DataVisualization::GetSyntheticChildren(*this, use_dynamic, m_last_synthetic_filter);
- m_last_format_mgr_revision = DataVisualization::ValueFormats::GetCurrentRevision();
+ m_last_format_mgr_revision = DataVisualization::GetCurrentRevision();
m_last_format_mgr_dynamic = use_dynamic;
ClearUserVisibleData();
@@ -1029,7 +1029,8 @@
bool
ValueObject::DumpPrintableRepresentation(Stream& s,
ValueObjectRepresentationStyle val_obj_display,
- lldb::Format custom_format)
+ lldb::Format custom_format,
+ bool only_special)
{
clang_type_t elem_or_pointee_type;
@@ -1147,6 +1148,10 @@
(custom_format == lldb::eFormatDefault)) // use the [] operator
return false;
}
+
+ if (only_special)
+ return false;
+
bool var_success = GetPrintableRepresentation(s, val_obj_display, custom_format);
if (custom_format != eFormatInvalid)
SetFormat(eFormatDefault);
@@ -1727,7 +1732,8 @@
{
const bool is_deref_of_parent = IsDereferenceOfParent ();
- if (is_deref_of_parent && epformat == eDereferencePointers) {
+ if (is_deref_of_parent && epformat == eDereferencePointers)
+ {
// this is the original format of GetExpressionPath() producing code like *(a_ptr).memberName, which is entirely
// fine, until you put this into StackFrame::GetValueForVariableExpressionPath() which prefers to see a_ptr->memberName.
// the eHonorPointers mode is meant to produce strings in this latter format
@@ -1789,7 +1795,8 @@
}
}
- if (is_deref_of_parent && epformat == eDereferencePointers) {
+ if (is_deref_of_parent && epformat == eDereferencePointers)
+ {
s.PutChar(')');
}
}
Modified: lldb/trunk/source/Interpreter/CommandObjectScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandObjectScript.cpp?rev=137944&r1=137943&r2=137944&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/CommandObjectScript.cpp (original)
+++ lldb/trunk/source/Interpreter/CommandObjectScript.cpp Thu Aug 18 11:38:26 2011
@@ -59,7 +59,8 @@
DataVisualization::ForceUpdate(); // script might change Python code we use for formatting.. make sure we keep up to date with it
- if (command == NULL || command[0] == '\0') {
+ if (command == NULL || command[0] == '\0')
+ {
script_interpreter->ExecuteInterpreterLoop ();
result.SetStatus (eReturnStatusSuccessFinishNoResult);
return result.Succeeded();
Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-smart-array/TestDataFormatterSmartArray.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-smart-array/TestDataFormatterSmartArray.py?rev=137944&r1=137943&r2=137944&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/data-formatter/data-formatter-smart-array/TestDataFormatterSmartArray.py (original)
+++ lldb/trunk/test/functionalities/data-formatter/data-formatter-smart-array/TestDataFormatterSmartArray.py Thu Aug 18 11:38:26 2011
@@ -57,7 +57,7 @@
self.runCmd("type summary add -f \"${var%V}\" SomeData")
self.expect("frame variable data",
- substrs = ['no printable representation'])
+ substrs = ['invalid use of aggregate type'])
# ${var%s}
self.runCmd("type summary add -f \"ptr = ${var%s}\" \"char *\"")
@@ -169,12 +169,10 @@
self.runCmd("type summary add -f \"arr = ${var%x}\" \"int [5]\"")
self.expect("frame variable intarr",
- substrs = ['intarr = {',
- '[0] = 1'])
+ substrs = ['<invalid usage of pointer value as object>'])
self.expect("frame variable other.intarr",
- substrs = ['intarr = {',
- '[0] = 9'])
+ substrs = ['<invalid usage of pointer value as object>'])
self.runCmd("type summary add -f \"arr = ${var[]%x}\" \"int [5]\"")
Added: lldb/trunk/test/functionalities/data-formatter/rdar-9973865/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/rdar-9973865/Makefile?rev=137944&view=auto
==============================================================================
--- lldb/trunk/test/functionalities/data-formatter/rdar-9973865/Makefile (added)
+++ lldb/trunk/test/functionalities/data-formatter/rdar-9973865/Makefile Thu Aug 18 11:38:26 2011
@@ -0,0 +1,5 @@
+LEVEL = ../../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules
Added: lldb/trunk/test/functionalities/data-formatter/rdar-9973865/Test-rdar-9973865.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/rdar-9973865/Test-rdar-9973865.py?rev=137944&view=auto
==============================================================================
--- lldb/trunk/test/functionalities/data-formatter/rdar-9973865/Test-rdar-9973865.py (added)
+++ lldb/trunk/test/functionalities/data-formatter/rdar-9973865/Test-rdar-9973865.py Thu Aug 18 11:38:26 2011
@@ -0,0 +1,76 @@
+"""
+Test lldb data formatter subsystem.
+"""
+
+import os, time
+import unittest2
+import lldb
+from lldbtest import *
+
+class DataFormatterTestCase(TestBase):
+
+ # test for rdar://problem/9973865 (If you use "${var}" in the summary string for an aggregate type, the summary doesn't print for a pointer to that type)
+ mydir = os.path.join("functionalities", "data-formatter", "rdar-9973865")
+
+ @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
+ def test_with_dsym_and_run_command(self):
+ """Test data formatter commands."""
+ self.buildDsym()
+ self.data_formatter_commands()
+
+ def test_with_dwarf_and_run_command(self):
+ """Test data formatter commands."""
+ self.buildDwarf()
+ self.data_formatter_commands()
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break at.
+ self.line = line_number('main.cpp', '// Set break point at this line.')
+
+ def data_formatter_commands(self):
+ """Test that that file and class static variables display correctly."""
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+ self.expect("breakpoint set -f main.cpp -l %d" % self.line,
+ BREAKPOINT_CREATED,
+ startstr = "Breakpoint created: 1: file ='main.cpp', line = %d, locations = 1" %
+ self.line)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # This is the function to remove the custom formats in order to have a
+ # clean slate for the next test case.
+ def cleanup():
+ self.runCmd('type summary clear', check=False)
+
+ # Execute the cleanup function during test case tear down.
+ self.addTearDownHook(cleanup)
+
+ self.runCmd("type summary add -f \"SUMMARY SUCCESS ${var}\" Summarize")
+
+ self.expect('frame variable mine_ptr',
+ substrs = ['SUMMARY SUCCESS <invalid usage of pointer value as object>'])
+
+ self.expect('frame variable *mine_ptr',
+ substrs = ['SUMMARY SUCCESS <invalid use of aggregate type>'])
+
+ self.runCmd("type summary add -f \"SUMMARY SUCCESS ${var.first}\" Summarize")
+
+ self.expect('frame variable mine_ptr',
+ substrs = ['SUMMARY SUCCESS 10'])
+
+ self.expect('frame variable *mine_ptr',
+ substrs = ['SUMMARY SUCCESS 10'])
+
+if __name__ == '__main__':
+ import atexit
+ lldb.SBDebugger.Initialize()
+ atexit.register(lambda: lldb.SBDebugger.Terminate())
+ unittest2.main()
Added: lldb/trunk/test/functionalities/data-formatter/rdar-9973865/main.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/rdar-9973865/main.cpp?rev=137944&view=auto
==============================================================================
--- lldb/trunk/test/functionalities/data-formatter/rdar-9973865/main.cpp (added)
+++ lldb/trunk/test/functionalities/data-formatter/rdar-9973865/main.cpp Thu Aug 18 11:38:26 2011
@@ -0,0 +1,30 @@
+//===-- main.cpp ------------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdio.h>
+struct Summarize
+{
+ int first;
+ int second;
+};
+
+typedef Summarize summarize_t;
+typedef summarize_t *summarize_ptr_t;
+
+summarize_t global_mine = {30, 40};
+
+int
+main()
+{
+ summarize_t mine = {10, 20};
+ summarize_ptr_t mine_ptr = &mine;
+ printf ("Summarize: first: %d second: %d and address: 0x%p\n", mine.first, mine.second, mine_ptr); // Set break point at this line.
+ printf ("Global summarize: first: %d second: %d.\n", global_mine.first, global_mine.second);
+ return 0;
+}
More information about the lldb-commits
mailing list