[Lldb-commits] [lldb] r232678 - Cleanup to simplify the formatter for std::map of libstdc++.

Siva Chandra sivachandra at google.com
Wed Mar 18 15:01:45 PDT 2015


Author: sivachandra
Date: Wed Mar 18 17:01:45 2015
New Revision: 232678

URL: http://llvm.org/viewvc/llvm-project?rev=232678&view=rev
Log:
Cleanup to simplify the formatter for std::map of libstdc++.

Summary:
GCC does not emit some DWARF required for the simplified formatter
to work. A workaround for it has been incorporated in the formatter.
The corresponding test TestDataFormatterStdMap has also been enabled
for GCC.

Test Plan: dotest.py -C <clang|gcc> -p TestDataFormatterStdMap

Reviewers: clayborg, vharron, granata.enrico

Subscribers: lldb-commits

Differential Revision: http://reviews.llvm.org/D8424

Modified:
    lldb/trunk/examples/synthetic/gnu_libstdcpp.py
    lldb/trunk/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/TestDataFormatterStdMap.py

Modified: lldb/trunk/examples/synthetic/gnu_libstdcpp.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/synthetic/gnu_libstdcpp.py?rev=232678&r1=232677&r2=232678&view=diff
==============================================================================
--- lldb/trunk/examples/synthetic/gnu_libstdcpp.py (original)
+++ lldb/trunk/examples/synthetic/gnu_libstdcpp.py Wed Mar 18 17:01:45 2015
@@ -325,39 +325,17 @@ class StdMapSynthProvider:
 			if map_type.IsReferenceType():
 				logger >> "Dereferencing type"
 				map_type = map_type.GetDereferencedType()
-			
-			map_arg_0 = str(map_type.GetTemplateArgumentType(0).GetName())
-			map_arg_1 = str(map_type.GetTemplateArgumentType(1).GetName())
-			
-			logger >> "map has args " + str(map_arg_0) + " and " + str(map_arg_1)
-			
-			map_arg_0,fixed_0 = self.fixup_class_name(map_arg_0)
-			map_arg_1,fixed_1 = self.fixup_class_name(map_arg_1)
-			
-			logger >> "arg_0 has become: " + str(map_arg_0) + " (fixed: " + str(fixed_0) + ")"
-			logger >> "arg_1 has become: " + str(map_arg_1) + " (fixed: " + str(fixed_1) + ")"
-			
-			# HACK: this is related to the above issue with the typename for std::string
-			# being shortened by clang - the changes to typename display and searching to honor
-			# namespaces make it so that we go looking for std::pair<const std::basic_string<char>, ...>
-			# but when we find a type for this, we then compare it against the fully-qualified
-			# std::pair<const std::basic_string<char, std::char_traits... and of course fail
-			# the way to bypass this problem is to avoid using the std:: prefix in this specific case
-			if fixed_0 or fixed_1:
-				map_arg_type = "pair<const " + map_arg_0 + ", " + map_arg_1
-			else:
-				map_arg_type = "std::pair<const " + map_arg_0 + ", " + map_arg_1
-			
-			if map_arg_1[-1] == '>':
-				map_arg_type = map_arg_type + " >"
-			else:
-				map_arg_type = map_arg_type + ">"
-			
-			logger >> "final contents datatype is: " + str(map_arg_type)
-			
-			self.data_type = self.valobj.GetTarget().FindFirstType(map_arg_type)
-			
-			logger >> "and the SBType is: " + str(self.data_type)
+
+			# Get the type of std::pair<key, value>. It is the first template
+			# argument type of the 4th template argument to std::map.
+			allocator_type = map_type.GetTemplateArgumentType(3)
+			self.data_type = allocator_type.GetTemplateArgumentType(0)
+			if not self.data_type:
+				# GCC does not emit DW_TAG_template_type_parameter for
+				# std::allocator<...>. For such a case, get the type of
+				# std::pair from a member of std::map.
+				rep_type = self.valobj.GetChildMemberWithName('_M_t').GetType()
+				self.data_type = rep_type.GetTypedefedType().GetTemplateArgumentType(1)
 			
 			# from libstdc++ implementation of _M_root for rbtree
 			self.Mroot = self.Mheader.GetChildMemberWithName('_M_parent')

Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/TestDataFormatterStdMap.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/TestDataFormatterStdMap.py?rev=232678&r1=232677&r2=232678&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/TestDataFormatterStdMap.py (original)
+++ lldb/trunk/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/TestDataFormatterStdMap.py Wed Mar 18 17:01:45 2015
@@ -19,8 +19,6 @@ class StdMapDataFormatterTestCase(TestBa
         self.buildDsym()
         self.data_formatter_commands()
 
-    @skipIfGcc # llvm.org/pr15036: When built with GCC, this test causes lldb to crash with
-               # assert DeclCXX.h:554 queried property of class with no definition
     @expectedFailureIcc   # llvm.org/pr15301: LLDB prints incorrect size of
                           # libstdc++ containers
     @skipIfFreeBSD





More information about the lldb-commits mailing list