summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lldb/include/lldb/Core/FormatManager.h160
-rw-r--r--lldb/include/lldb/Core/ValueObject.h2
-rw-r--r--lldb/include/lldb/Interpreter/ScriptInterpreter.h2
-rw-r--r--lldb/source/Commands/CommandObjectType.cpp2
-rw-r--r--lldb/source/Commands/CommandObjectType.h4
-rw-r--r--lldb/source/Core/FormatManager.cpp125
-rw-r--r--lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h4
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp6
-rw-r--r--lldb/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py28
9 files changed, 165 insertions, 168 deletions
diff --git a/lldb/include/lldb/Core/FormatManager.h b/lldb/include/lldb/Core/FormatManager.h
index 1f37c5915f8..c04cfdba756 100644
--- a/lldb/include/lldb/Core/FormatManager.h
+++ b/lldb/include/lldb/Core/FormatManager.h
@@ -79,6 +79,35 @@ public:
};
+// 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 ( ::strstr(type_cstr, "class ") == type_cstr)
+ strip_len = 6;
+ if ( ::strstr(type_cstr, "enum ") == type_cstr)
+ strip_len = 5;
+ if ( ::strstr(type_cstr, "struct ") == type_cstr)
+ strip_len = 7;
+ if ( ::strstr(type_cstr, "union ") == type_cstr)
+ strip_len = 6;
+
+ if (strip_len == 0)
+ return type;
+
+ return ConstString(type_cstr + strip_len);
+}
+
template<typename KeyType, typename ValueType>
class FormatNavigator;
@@ -170,7 +199,7 @@ public:
return m_map.size();
}
-private:
+protected:
MapType m_map;
Mutex m_map_mutex;
IFormatChangeListener* listener;
@@ -195,20 +224,19 @@ private:
template<typename KeyType, typename ValueType>
class FormatNavigator
{
-private:
+protected:
typedef FormatMap<KeyType,ValueType> BackEndType;
- BackEndType m_format_map;
-
- std::string m_name;
-
+ template<typename, typename>
+ struct Types { };
+
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;
-
+
typedef typename lldb::SharedPtr<FormatNavigator<KeyType, ValueType> >::Type SharedPointer;
friend class FormatCategory;
@@ -224,15 +252,13 @@ public:
void
Add (const MapKeyType &type, const MapValueType& entry)
{
- m_format_map.Add(type,entry);
+ Add_Impl(type, entry, Types<KeyType,ValueType>());
}
- // using ConstString instead of MapKeyType is necessary here
- // to make the partial template specializations below work
bool
Delete (ConstString type)
{
- return m_format_map.Delete(type);
+ return Delete_Impl(type, Types<KeyType, ValueType>());
}
bool
@@ -270,19 +296,88 @@ public:
{
return m_format_map.GetCount();
}
+
+protected:
-private:
+ BackEndType m_format_map;
+
+ std::string m_name;
DISALLOW_COPY_AND_ASSIGN(FormatNavigator);
ConstString m_id_cs;
-
- // using ConstString instead of MapKeyType is necessary here
- // to make the partial template specializations below work
+
+ template<typename K, typename V>
+ void
+ Add_Impl (const MapKeyType &type, const MapValueType& entry, Types<K,V>)
+ {
+ m_format_map.Add(type,entry);
+ }
+
+ template<typename V>
+ void Add_Impl (const ConstString &type, const MapValueType& entry, Types<ConstString,V>)
+ {
+ m_format_map.Add(GetValidTypeName_Impl(type), entry);
+ }
+
+ template<typename K, typename V>
+ bool
+ Delete_Impl (ConstString type, Types<K,V>)
+ {
+ return m_format_map.Delete(type);
+ }
+
+ template<typename V>
+ bool
+ Delete_Impl (ConstString type, Types<lldb::RegularExpressionSP,V>)
+ {
+ 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;
+ }
+
+ template<typename K, typename V>
+ bool
+ Get_Impl (ConstString type, MapValueType& entry, Types<K,V>)
+ {
+ return m_format_map.Get(type, entry);
+ }
+
+ template<typename V>
+ bool
+ Get_Impl (ConstString key, MapValueType& value, Types<lldb::RegularExpressionSP,V>)
+ {
+ 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.AsCString()))
+ {
+ value = pos->second;
+ return true;
+ }
+ }
+ return false;
+ }
+
bool
Get (ConstString type, MapValueType& entry)
{
- return m_format_map.Get(type, entry);
+ return Get_Impl(type, entry, Types<KeyType,ValueType>());
}
bool Get_ObjC(ValueObject& valobj,
@@ -577,30 +672,6 @@ private:
return false;
}
};
-
-template<>
-bool
-FormatNavigator<lldb::RegularExpressionSP, SummaryFormat>::Get(ConstString key, lldb::SummaryFormatSP& value);
-
-template<>
-bool
-FormatNavigator<lldb::RegularExpressionSP, SummaryFormat>::Delete(ConstString type);
-
-template<>
-bool
-FormatNavigator<lldb::RegularExpressionSP, SyntheticFilter>::Get(ConstString key, SyntheticFilter::SharedPointer& value);
-
-template<>
-bool
-FormatNavigator<lldb::RegularExpressionSP, SyntheticFilter>::Delete(ConstString type);
-
-template<>
-bool
-FormatNavigator<lldb::RegularExpressionSP, SyntheticScriptProvider>::Get(ConstString key, SyntheticFilter::SharedPointer& value);
-
-template<>
-bool
-FormatNavigator<lldb::RegularExpressionSP, SyntheticScriptProvider>::Delete(ConstString type);
class CategoryMap;
@@ -633,7 +704,7 @@ public:
eFilter = 0x0002,
eRegexFilter = 0x1002,
eSynth = 0x0004,
- eRegexSynth = 0x1004,
+ eRegexSynth = 0x1004
};
typedef uint16_t FormatCategoryItems;
@@ -1166,6 +1237,13 @@ public:
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
diff --git a/lldb/include/lldb/Core/ValueObject.h b/lldb/include/lldb/Core/ValueObject.h
index cc8f2ab5c5c..25532ab456b 100644
--- a/lldb/include/lldb/Core/ValueObject.h
+++ b/lldb/include/lldb/Core/ValueObject.h
@@ -79,7 +79,7 @@ public:
eDisplaySummary,
eDisplayLanguageSpecific,
eDisplayLocation,
- eDisplayChildrenCount,
+ eDisplayChildrenCount
};
enum ExpressionPathScanEndReason
diff --git a/lldb/include/lldb/Interpreter/ScriptInterpreter.h b/lldb/include/lldb/Interpreter/ScriptInterpreter.h
index 4d494f732c9..21becb6f297 100644
--- a/lldb/include/lldb/Interpreter/ScriptInterpreter.h
+++ b/lldb/include/lldb/Interpreter/ScriptInterpreter.h
@@ -66,7 +66,7 @@ public:
eFloat,
eDouble,
eChar,
- eCharStrOrNone,
+ eCharStrOrNone
} ReturnType;
diff --git a/lldb/source/Commands/CommandObjectType.cpp b/lldb/source/Commands/CommandObjectType.cpp
index d3b7163b53c..abc613b511e 100644
--- a/lldb/source/Commands/CommandObjectType.cpp
+++ b/lldb/source/Commands/CommandObjectType.cpp
@@ -3366,7 +3366,7 @@ private:
enum FilterFormatType
{
eRegularFilter,
- eRegexFilter,
+ eRegexFilter
};
bool
diff --git a/lldb/source/Commands/CommandObjectType.h b/lldb/source/Commands/CommandObjectType.h
index cb86f8e3e11..b38e0ff9d11 100644
--- a/lldb/source/Commands/CommandObjectType.h
+++ b/lldb/source/Commands/CommandObjectType.h
@@ -187,7 +187,7 @@ public:
{
eRegularSummary,
eRegexSummary,
- eNamedSummary,
+ eNamedSummary
};
CommandObjectTypeSummaryAdd (CommandInterpreter &interpreter);
@@ -330,7 +330,7 @@ public:
enum SynthFormatType
{
eRegularSynth,
- eRegexSynth,
+ eRegexSynth
};
CommandObjectTypeSynthAdd (CommandInterpreter &interpreter);
diff --git a/lldb/source/Core/FormatManager.cpp b/lldb/source/Core/FormatManager.cpp
index 13df1bbbb8c..cc69ff1b8fd 100644
--- a/lldb/source/Core/FormatManager.cpp
+++ b/lldb/source/Core/FormatManager.cpp
@@ -154,120 +154,6 @@ FormatManager::GetFormatAsCString (Format format)
return NULL;
}
-template<>
-bool
-FormatNavigator<lldb::RegularExpressionSP, SummaryFormat>::Get(ConstString key, lldb::SummaryFormatSP& value)
-{
- Mutex::Locker(m_format_map.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.AsCString()))
- {
- value = pos->second;
- return true;
- }
- }
- return false;
-}
-
-template<>
-bool
-FormatNavigator<lldb::RegularExpressionSP, SummaryFormat>::Delete(ConstString type)
-{
- Mutex::Locker(m_format_map.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;
-}
-
-template<>
-bool
-FormatNavigator<lldb::RegularExpressionSP, SyntheticFilter>::Get(ConstString key, SyntheticFilter::SharedPointer& value)
-{
- Mutex::Locker(m_format_map.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.AsCString()))
- {
- value = pos->second;
- return true;
- }
- }
- return false;
-}
-
-template<>
-bool
-FormatNavigator<lldb::RegularExpressionSP, SyntheticFilter>::Delete(ConstString type)
-{
- Mutex::Locker(m_format_map.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;
-}
-
-template<>
-bool
-FormatNavigator<lldb::RegularExpressionSP, SyntheticScriptProvider>::Get(ConstString key, SyntheticFilter::SharedPointer& value)
-{
- Mutex::Locker(m_format_map.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.AsCString()))
- {
- value = pos->second;
- return true;
- }
- }
- return false;
-}
-
-template<>
-bool
-FormatNavigator<lldb::RegularExpressionSP, SyntheticScriptProvider>::Delete(ConstString type)
-{
- Mutex::Locker(m_format_map.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;
-}
-
FormatCategory::FormatCategory(IFormatChangeListener* clist,
std::string name) :
m_summary_nav(new SummaryNavigator("summary",clist)),
@@ -486,6 +372,12 @@ FormatManager::GetSingleItemFormat(lldb::Format vector_format)
}
}
+ConstString
+FormatManager::GetValidTypeName (const ConstString& type)
+{
+ return ::GetValidTypeName_Impl(type);
+}
+
FormatManager::FormatManager() :
m_value_nav("format",this),
m_named_summaries_map(this),
@@ -574,7 +466,6 @@ FormatManager::FormatManager() :
}
-
static FormatManager&
GetFormatManager()
{
@@ -603,7 +494,7 @@ DataVisualization::ValueFormats::Get(ValueObject& valobj, lldb::DynamicValueType
void
DataVisualization::ValueFormats::Add(const ConstString &type, const lldb::ValueFormatSP &entry)
{
- GetFormatManager().Value().Add(type,entry);
+ GetFormatManager().Value().Add(FormatManager::GetValidTypeName(type),entry);
}
bool
@@ -731,7 +622,7 @@ DataVisualization::NamedSummaryFormats::Get(const ConstString &type, lldb::Summa
void
DataVisualization::NamedSummaryFormats::Add(const ConstString &type, const lldb::SummaryFormatSP &entry)
{
- GetFormatManager().NamedSummary().Add(type,entry);
+ GetFormatManager().NamedSummary().Add(FormatManager::GetValidTypeName(type),entry);
}
bool
diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h b/lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h
index 502a59432f6..db1e02f605f 100644
--- a/lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h
+++ b/lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h
@@ -62,12 +62,12 @@ public:
KDP_WRITEMEM64,
KDP_BREAKPOINT_SET64,
KDP_BREAKPOINT_REMOVE64,
- KDP_KERNELVERSION,
+ KDP_KERNELVERSION
} CommandType;
enum
{
- KDP_FEATURE_BP = (1u << 0),
+ KDP_FEATURE_BP = (1u << 0)
};
typedef enum
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp
index dcf4da37039..46a0a8fb0cc 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp
@@ -98,7 +98,7 @@ enum
fpu_fiseg = fpu_cs,
fpu_fioff = fpu_ip,
fpu_foseg = fpu_ds,
- fpu_fooff = fpu_dp,
+ fpu_fooff = fpu_dp
};
enum gcc_dwarf_regnums
@@ -143,7 +143,7 @@ enum gcc_dwarf_regnums
gcc_dwarf_fpu_stmm4,
gcc_dwarf_fpu_stmm5,
gcc_dwarf_fpu_stmm6,
- gcc_dwarf_fpu_stmm7,
+ gcc_dwarf_fpu_stmm7
};
@@ -205,7 +205,7 @@ enum gdb_regnums
gdb_fpu_xmm13 = 53,
gdb_fpu_xmm14 = 54,
gdb_fpu_xmm15 = 55,
- gdb_fpu_mxcsr = 56,
+ gdb_fpu_mxcsr = 56
};
RegisterContextDarwin_x86_64::RegisterContextDarwin_x86_64 (Thread &thread, uint32_t concrete_frame_idx) :
diff --git a/lldb/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py b/lldb/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py
index 97aae5c8e1c..0cc04f9ea86 100644
--- a/lldb/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py
+++ b/lldb/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py
@@ -202,6 +202,34 @@ class DataFormatterTestCase(TestBase):
self.expect("frame variable the_coolest_guy",
substrs = ['(i_am_cooler) the_coolest_guy = goofy'])
+ # check that unwanted type specifiers are removed
+ self.runCmd("type summary delete i_am_cool")
+ self.runCmd("type summary add -f \"goofy\" \"class i_am_cool\"")
+ self.expect("frame variable the_coolest_guy",
+ substrs = ['(i_am_cooler) the_coolest_guy = goofy'])
+
+ self.runCmd("type summary delete i_am_cool")
+ self.runCmd("type summary add -f \"goofy\" \"enum i_am_cool\"")
+ self.expect("frame variable the_coolest_guy",
+ substrs = ['(i_am_cooler) the_coolest_guy = goofy'])
+
+ self.runCmd("type summary delete i_am_cool")
+ self.runCmd("type summary add -f \"goofy\" \"struct i_am_cool\"")
+ self.expect("frame variable the_coolest_guy",
+ substrs = ['(i_am_cooler) the_coolest_guy = goofy'])
+
+ self.runCmd("type summary delete i_am_cool")
+ self.runCmd("type summary add -f \"goofy\" \"union i_am_cool\"")
+ self.expect("frame variable the_coolest_guy",
+ substrs = ['(i_am_cooler) the_coolest_guy = goofy'])
+
+ # but that not *every* specifier is removed
+ self.runCmd("type summary delete i_am_cool")
+ self.runCmd("type summary add -f \"goofy\" \"wrong i_am_cool\"")
+ self.expect("frame variable the_coolest_guy", matching=False,
+ substrs = ['(i_am_cooler) the_coolest_guy = goofy'])
+
+
if __name__ == '__main__':
import atexit
lldb.SBDebugger.Initialize()
OpenPOWER on IntegriCloud