[Lldb-commits] [lldb] r155555 - in /lldb/trunk/examples/synthetic: gnu_libstdcpp.py libcxx.py

Enrico Granata egranata at apple.com
Wed Apr 25 09:32:39 PDT 2012


Author: enrico
Date: Wed Apr 25 11:32:39 2012
New Revision: 155555

URL: http://llvm.org/viewvc/llvm-project?rev=155555&view=rev
Log:
Make the C++ formatters importable by having them use the right package to import and reference the Logger

Modified:
    lldb/trunk/examples/synthetic/gnu_libstdcpp.py
    lldb/trunk/examples/synthetic/libcxx.py

Modified: lldb/trunk/examples/synthetic/gnu_libstdcpp.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/synthetic/gnu_libstdcpp.py?rev=155555&r1=155554&r2=155555&view=diff
==============================================================================
--- lldb/trunk/examples/synthetic/gnu_libstdcpp.py (original)
+++ lldb/trunk/examples/synthetic/gnu_libstdcpp.py Wed Apr 25 11:32:39 2012
@@ -1,5 +1,5 @@
 import re
-import Logger
+import lldb.formatters.Logger
 
 # C++ STL formatters for LLDB
 # These formatters are based upon the version of the GNU libstdc++
@@ -10,28 +10,28 @@
 class StdListSynthProvider:
 
 	def __init__(self, valobj, dict):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		self.valobj = valobj
 		self.count = None
 		logger >> "Providing synthetic children for a map named " + str(valobj.GetName())
 
 	def next_node(self,node):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		return node.GetChildMemberWithName('_M_next')
 
 	def is_valid(self,node):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		return self.value(self.next_node(node)) != self.node_address
 
 	def value(self,node):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		return node.GetValueAsUnsigned()
 
 	# Floyd's cyle-finding algorithm
 	# try to detect if this list has a loop
 	def has_loop(self):
 		global _list_uses_loop_detector
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		if _list_uses_loop_detector == False:
 			logger >> "Asked not to use loop detection"
 			return False
@@ -49,7 +49,7 @@
 
 	def num_children(self):
 		global _list_capping_size
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		if self.count == None:
 			self.count = self.num_children_impl()
 			if self.count > _list_capping_size:
@@ -57,7 +57,7 @@
 		return self.count
 
 	def num_children_impl(self):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		global _list_capping_size
 		try:
 			next_val = self.next.GetValueAsUnsigned(0)
@@ -83,14 +83,14 @@
 			return 0;
 
 	def get_child_index(self,name):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		try:
 			return int(name.lstrip('[').rstrip(']'))
 		except:
 			return -1
 
 	def get_child_at_index(self,index):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		logger >> "Fetching child " + str(index)
 		if index < 0:
 			return None;
@@ -107,7 +107,7 @@
 			return None
 
 	def extract_type(self):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		list_type = self.valobj.GetType().GetUnqualifiedType()
 		if list_type.IsReferenceType():
 			list_type = list_type.GetDereferencedType()
@@ -118,7 +118,7 @@
 		return data_type
 
 	def update(self):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		# preemptively setting this to None - we might end up changing our mind later
 		self.count = None
 		try:
@@ -135,25 +135,25 @@
 class StdVectorSynthProvider:
 
 	def __init__(self, valobj, dict):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		self.count = None
 		self.valobj = valobj
 		logger >> "Providing synthetic children for a map named " + str(valobj.GetName())
 
 	def num_children(self):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		if self.count == None:
 			self.count = self.num_children_impl()
 		return self.count
 
 	def is_valid_pointer(ptr,process):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		error = lldb.SBError()
 		process.ReadMemory(ptr,1,error)
 		return False if error.Fail() else True
 
 	def num_children_impl(self):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		try:
 			start_val = self.start.GetValueAsUnsigned(0)
 			finish_val = self.finish.GetValueAsUnsigned(0)
@@ -188,14 +188,14 @@
 			return 0;
 
 	def get_child_index(self,name):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		try:
 			return int(name.lstrip('[').rstrip(']'))
 		except:
 			return -1
 
 	def get_child_at_index(self,index):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		logger >> "Retrieving child " + str(index)
 		if index < 0:
 			return None;
@@ -208,7 +208,7 @@
 			return None
 
 	def update(self):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		# preemptively setting this to None - we might end up changing our mind later
 		self.count = None
 		try:
@@ -230,7 +230,7 @@
 class StdMapSynthProvider:
 
 	def __init__(self, valobj, dict):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		self.valobj = valobj;
 		self.count = None
 		logger >> "Providing synthetic children for a map named " + str(valobj.GetName())
@@ -243,7 +243,7 @@
 	# to replace the longer versions of std::string with the shorter one in order to be able
 	# to find the type name
 	def fixup_class_name(self, class_name):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		if class_name == 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >':
 			return 'std::basic_string<char>',True
 		if class_name == 'basic_string<char, std::char_traits<char>, std::allocator<char> >':
@@ -255,7 +255,7 @@
 		return class_name,False
 
 	def update(self):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		# preemptively setting this to None - we might end up changing our mind later
 		self.count = None
 		try:
@@ -313,7 +313,7 @@
 
 	def num_children(self):
 		global _map_capping_size
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		if self.count == None:
 			self.count = self.num_children_impl()
 			if self.count > _map_capping_size:
@@ -321,7 +321,7 @@
 		return self.count
 
 	def num_children_impl(self):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		try:
 			root_ptr_val = self.node_ptr_value(self.Mroot)
 			if root_ptr_val == 0:
@@ -333,14 +333,14 @@
 			return 0;
 
 	def get_child_index(self,name):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		try:
 			return int(name.lstrip('[').rstrip(']'))
 		except:
 			return -1
 
 	def get_child_at_index(self,index):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		logger >> "Being asked to fetch child[" + str(index) + "]"
 		if index < 0:
 			return None
@@ -362,24 +362,24 @@
 
 	# utility functions
 	def node_ptr_value(self,node):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		return node.GetValueAsUnsigned(0)
 
 	def right(self,node):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		return node.GetChildMemberWithName("_M_right");
 
 	def left(self,node):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		return node.GetChildMemberWithName("_M_left");
 
 	def parent(self,node):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		return node.GetChildMemberWithName("_M_parent");
 
 	# from libstdc++ implementation of iterator for rbtree
 	def increment_node(self,node):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		max_steps = self.num_children()
 		if self.node_ptr_value(self.right(node)) != 0:
 			x = self.right(node);

Modified: lldb/trunk/examples/synthetic/libcxx.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/synthetic/libcxx.py?rev=155555&r1=155554&r2=155555&view=diff
==============================================================================
--- lldb/trunk/examples/synthetic/libcxx.py (original)
+++ lldb/trunk/examples/synthetic/libcxx.py Wed Apr 25 11:32:39 2012
@@ -1,5 +1,5 @@
 import lldb
-import Logger
+import lldb.formatters.Logger
 
 # libcxx STL formatters for LLDB
 # These formatters are based upon the implementation of libc++ that
@@ -28,7 +28,7 @@
 # no external significance - we access them by index since this saves a name lookup that would add
 # no information for readers of the code, but when possible try to use meaningful variable names
 def stdstring_SummaryProvider(valobj,dict):
-	logger = Logger.Logger()
+	logger = lldb.formatters.Logger.lldb.formatters.Logger()
 	r = valobj.GetChildAtIndex(0)
 	B = r.GetChildAtIndex(0)
 	first = B.GetChildAtIndex(0)
@@ -57,11 +57,11 @@
 class stdvector_SynthProvider:
 
 	def __init__(self, valobj, dict):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		self.valobj = valobj;
 
 	def num_children(self):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		try:
 			start_val = self.start.GetValueAsUnsigned(0)
 			finish_val = self.finish.GetValueAsUnsigned(0)
@@ -89,14 +89,14 @@
 			return 0;
 
 	def get_child_index(self,name):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		try:
 			return int(name.lstrip('[').rstrip(']'))
 		except:
 			return -1
 
 	def get_child_at_index(self,index):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		logger >> "Retrieving child " + str(index)
 		if index < 0:
 			return None;
@@ -109,7 +109,7 @@
 			return None
 
 	def update(self):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		try:
 			self.start = self.valobj.GetChildMemberWithName('__begin_')
 			self.finish = self.valobj.GetChildMemberWithName('__end_')
@@ -129,27 +129,27 @@
 class stdlist_entry:
 
 	def __init__(self,entry):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		self.entry = entry
 
 	def _next_impl(self):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		return stdlist_entry(self.entry.GetChildMemberWithName('__next_'))
 
 	def _prev_impl(self):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		return stdlist_entry(self.entry.GetChildMemberWithName('__prev_'))
 
 	def _value_impl(self):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		return self.entry.GetValueAsUnsigned(0)
 
 	def _isnull_impl(self):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		return self._value_impl() == 0
 
 	def _sbvalue_impl(self):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		return self.entry
 
 	next = property(_next_impl,None)
@@ -160,21 +160,21 @@
 class stdlist_iterator:
 
 	def increment_node(self,node):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		if node.is_null:
 			return None
 		return node.next
 
 	def __init__(self,node):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		self.node = stdlist_entry(node) # we convert the SBValue to an internal node object on entry
 
 	def value(self):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		return self.node.sbvalue # and return the SBValue back on exit
 
 	def next(self):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		node = self.increment_node(self.node)
 		if node != None and node.sbvalue.IsValid() and not(node.is_null):
 			self.node = node
@@ -183,7 +183,7 @@
 			return None
 
 	def advance(self,N):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		if N < 0:
 			return None
 		if N == 0:
@@ -198,22 +198,22 @@
 
 class stdlist_SynthProvider:
 	def __init__(self, valobj, dict):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		self.valobj = valobj
 
 	def next_node(self,node):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		return node.GetChildMemberWithName('__next_')
 
 	def value(self,node):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		return node.GetValueAsUnsigned()
 
 	# Floyd's cyle-finding algorithm
 	# try to detect if this list has a loop
 	def has_loop(self):
 		global _list_uses_loop_detector
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		if _list_uses_loop_detector == False:
 			logger >> "Asked not to use loop detection"
 			return False
@@ -231,7 +231,7 @@
 
 	def num_children(self):
 		global _list_capping_size
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		if self.count == None:
 			self.count = self.num_children_impl()
 			if self.count > _list_capping_size:
@@ -240,7 +240,7 @@
 
 	def num_children_impl(self):
 		global _list_capping_size
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		try:
 			next_val = self.head.GetValueAsUnsigned(0)
 			prev_val = self.tail.GetValueAsUnsigned(0)
@@ -265,14 +265,14 @@
 			return 0;
 
 	def get_child_index(self,name):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		try:
 			return int(name.lstrip('[').rstrip(']'))
 		except:
 			return -1
 
 	def get_child_at_index(self,index):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		logger >> "Fetching child " + str(index)
 		if index < 0:
 			return None;
@@ -290,7 +290,7 @@
 			return None
 
 	def extract_type(self):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		list_type = self.valobj.GetType().GetUnqualifiedType()
 		if list_type.IsReferenceType():
 			list_type = list_type.GetDereferencedType()
@@ -301,7 +301,7 @@
 		return data_type
 
 	def update(self):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		self.count = None
 		try:
 			impl = self.valobj.GetChildMemberWithName('__end_')
@@ -321,31 +321,31 @@
 # a tree node - this class makes the syntax in the actual iterator nicer to read and maintain
 class stdmap_iterator_node:
 	def _left_impl(self):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		return stdmap_iterator_node(self.node.GetChildMemberWithName("__left_"))
 
 	def _right_impl(self):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		return stdmap_iterator_node(self.node.GetChildMemberWithName("__right_"))
 
 	def _parent_impl(self):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		return stdmap_iterator_node(self.node.GetChildMemberWithName("__parent_"))
 
 	def _value_impl(self):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		return self.node.GetValueAsUnsigned(0)
 
 	def _sbvalue_impl(self):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		return self.node
 
 	def _null_impl(self):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		return self.value == 0
 
 	def __init__(self,node):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		self.node = node
 
 	left = property(_left_impl,None)
@@ -359,7 +359,7 @@
 class stdmap_iterator:
 
 	def tree_min(self,x):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		steps = 0
 		if x.is_null:
 			return None
@@ -372,7 +372,7 @@
 		return x
 
 	def tree_max(self,x):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		if x.is_null:
 			return None
 		while (not x.right.is_null):
@@ -380,13 +380,13 @@
 		return x
 
 	def tree_is_left_child(self,x):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		if x.is_null:
 			return None
 		return True if x.value == x.parent.left.value else False
 
 	def increment_node(self,node):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		if node.is_null:
 			return None
 		if not node.right.is_null:
@@ -401,16 +401,16 @@
 		return node.parent
 
 	def __init__(self,node,max_count=0):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		self.node = stdmap_iterator_node(node) # we convert the SBValue to an internal node object on entry
 		self.max_count = max_count
 
 	def value(self):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		return self.node.sbvalue # and return the SBValue back on exit
 
 	def next(self):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		node = self.increment_node(self.node)
 		if node != None and node.sbvalue.IsValid() and not(node.is_null):
 			self.node = node
@@ -419,7 +419,7 @@
 			return None
 
 	def advance(self,N):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		if N < 0:
 			return None
 		if N == 0:
@@ -435,12 +435,12 @@
 class stdmap_SynthProvider:
 
 	def __init__(self, valobj, dict):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		self.valobj = valobj;
 		self.pointer_size = self.valobj.GetProcess().GetAddressByteSize()
 
 	def update(self):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		self.count = None
 		try:
 			# we will set this to True if we find out that discovering a node in the map takes more steps than the overall size of the RB tree
@@ -458,7 +458,7 @@
 
 	def num_children(self):
 		global _map_capping_size
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		if self.count == None:
 			self.count = self.num_children_impl()
 			if self.count > _map_capping_size:
@@ -466,14 +466,14 @@
 		return self.count
 
 	def num_children_impl(self):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		try:
 			return self.valobj.GetChildMemberWithName('__tree_').GetChildMemberWithName('__pair3_').GetChildMemberWithName('__first_').GetValueAsUnsigned()
 		except:
 			return 0;
 
 	def get_data_type(self):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		if self.data_type == None or self.data_size == None:
 			if self.num_children() == 0:
 				return False
@@ -491,7 +491,7 @@
 			return True
 
 	def get_value_offset(self,node):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		if self.skip_size == None:
 			node_type = node.GetType()
 			fields_count = node_type.GetNumberOfFields()
@@ -503,14 +503,14 @@
 		return (self.skip_size != None)
 
 	def get_child_index(self,name):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		try:
 			return int(name.lstrip('[').rstrip(']'))
 		except:
 			return -1
 
 	def get_child_at_index(self,index):
-		logger = Logger.Logger()
+		logger = lldb.formatters.Logger.lldb.formatters.Logger()
 		logger >> "Retrieving child " + str(index)
 		if index < 0:
 			return None





More information about the lldb-commits mailing list