2019-03-18 23:42:08 +08:00
|
|
|
from __future__ import division
|
2012-04-26 00:32:39 +08:00
|
|
|
import lldb.formatters.Logger
|
2011-08-18 03:07:52 +08:00
|
|
|
|
|
|
|
# C++ STL formatters for LLDB
|
2021-11-24 01:32:30 +08:00
|
|
|
# As there are many versions of the libcstd++, you are encouraged to look at the STL
|
|
|
|
# implementation for your platform before relying on these formatters to do the right
|
|
|
|
# thing for your setup
|
2011-08-18 03:07:52 +08:00
|
|
|
|
2021-11-24 06:11:42 +08:00
|
|
|
def ForwardListSummaryProvider(valobj, dict):
|
|
|
|
list_capping_size = valobj.GetTarget().GetMaximumNumberOfChildrenToDisplay()
|
|
|
|
text = "size=" + str(valobj.GetNumChildren())
|
|
|
|
if valobj.GetNumChildren() > list_capping_size:
|
|
|
|
return "(capped) " + text
|
|
|
|
else:
|
|
|
|
return text
|
|
|
|
|
2021-11-23 05:46:49 +08:00
|
|
|
def StdOptionalSummaryProvider(valobj, dict):
|
|
|
|
has_value = valobj.GetNumChildren() > 0
|
|
|
|
# We add wrapping spaces for consistency with the libcxx formatter
|
|
|
|
return " Has Value=" + ("true" if has_value else "false") + " "
|
|
|
|
|
|
|
|
|
|
|
|
class StdOptionalSynthProvider:
|
|
|
|
def __init__(self, valobj, dict):
|
|
|
|
self.valobj = valobj
|
|
|
|
|
|
|
|
def update(self):
|
|
|
|
try:
|
|
|
|
self.payload = self.valobj.GetChildMemberWithName('_M_payload')
|
|
|
|
self.value = self.payload.GetChildMemberWithName('_M_payload')
|
2021-11-24 01:16:59 +08:00
|
|
|
self.has_value = self.payload.GetChildMemberWithName('_M_engaged').GetValueAsUnsigned(0) != 0
|
2021-11-23 05:46:49 +08:00
|
|
|
except:
|
2021-11-24 01:16:59 +08:00
|
|
|
self.has_value = False
|
2021-11-23 05:46:49 +08:00
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|
def num_children(self):
|
2021-11-24 01:16:59 +08:00
|
|
|
return 1 if self.has_value else 0
|
2021-11-23 05:46:49 +08:00
|
|
|
|
|
|
|
def get_child_index(self, name):
|
|
|
|
return 0
|
|
|
|
|
|
|
|
def get_child_at_index(self, index):
|
2021-11-23 08:33:11 +08:00
|
|
|
# some versions of libstdcpp have an additional _M_value child with the actual value
|
|
|
|
possible_value = self.value.GetChildMemberWithName('_M_value')
|
|
|
|
if possible_value.IsValid():
|
|
|
|
return possible_value.Clone('Value')
|
2021-11-23 05:46:49 +08:00
|
|
|
return self.value.Clone('Value')
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2021-11-23 04:54:28 +08:00
|
|
|
"""
|
|
|
|
This formatter can be applied to all
|
|
|
|
unordered map-like structures (unordered_map, unordered_multimap, unordered_set, unordered_multiset)
|
|
|
|
"""
|
|
|
|
class StdUnorderedMapSynthProvider:
|
|
|
|
def __init__(self, valobj, dict):
|
|
|
|
self.valobj = valobj
|
|
|
|
self.count = None
|
|
|
|
self.kind = self.get_object_kind(valobj)
|
|
|
|
|
|
|
|
def get_object_kind(self, valobj):
|
|
|
|
type_name = valobj.GetTypeName()
|
|
|
|
return "set" if "set" in type_name else "map"
|
|
|
|
|
|
|
|
def extract_type(self):
|
|
|
|
type = self.valobj.GetType()
|
|
|
|
# type of std::pair<key, value> is the first template
|
2021-11-23 05:46:49 +08:00
|
|
|
# argument type of the 4th template argument to std::map and
|
|
|
|
# 3rd template argument for std::set. That's why
|
2021-11-23 04:54:28 +08:00
|
|
|
# we need to know kind of the object
|
|
|
|
template_arg_num = 4 if self.kind == "map" else 3
|
|
|
|
allocator_type = type.GetTemplateArgumentType(template_arg_num)
|
|
|
|
data_type = allocator_type.GetTemplateArgumentType(0)
|
|
|
|
return data_type
|
|
|
|
|
2021-11-23 05:46:49 +08:00
|
|
|
def update(self):
|
2021-11-23 04:54:28 +08:00
|
|
|
# preemptively setting this to None - we might end up changing our mind
|
|
|
|
# later
|
|
|
|
self.count = None
|
|
|
|
try:
|
|
|
|
self.head = self.valobj.GetChildMemberWithName('_M_h')
|
|
|
|
self.before_begin = self.head.GetChildMemberWithName('_M_before_begin')
|
|
|
|
self.next = self.before_begin.GetChildMemberWithName('_M_nxt')
|
|
|
|
self.data_type = self.extract_type()
|
|
|
|
self.skip_size = self.next.GetType().GetByteSize()
|
|
|
|
self.data_size = self.data_type.GetByteSize()
|
2021-11-24 01:32:30 +08:00
|
|
|
if (not self.data_type.IsValid()) or (not self.next.IsValid()):
|
|
|
|
self.count = 0
|
2021-11-23 04:54:28 +08:00
|
|
|
except:
|
2021-11-24 01:32:30 +08:00
|
|
|
self.count = 0
|
2021-11-23 04:54:28 +08:00
|
|
|
return False
|
|
|
|
|
|
|
|
def get_child_index(self, name):
|
|
|
|
try:
|
|
|
|
return int(name.lstrip('[').rstrip(']'))
|
|
|
|
except:
|
|
|
|
return -1
|
|
|
|
|
|
|
|
def get_child_at_index(self, index):
|
|
|
|
logger = lldb.formatters.Logger.Logger()
|
|
|
|
logger >> "Being asked to fetch child[" + str(index) + "]"
|
|
|
|
if index < 0:
|
|
|
|
return None
|
|
|
|
if index >= self.num_children():
|
|
|
|
return None
|
|
|
|
try:
|
|
|
|
offset = index
|
2021-11-23 05:46:49 +08:00
|
|
|
current = self.next
|
2021-11-23 04:54:28 +08:00
|
|
|
while offset > 0:
|
|
|
|
current = current.GetChildMemberWithName('_M_nxt')
|
|
|
|
offset = offset - 1
|
|
|
|
return current.CreateChildAtOffset( '[' + str(index) + ']', self.skip_size, self.data_type)
|
2021-11-23 05:46:49 +08:00
|
|
|
|
2021-11-23 04:54:28 +08:00
|
|
|
except:
|
|
|
|
logger >> "Cannot get child"
|
|
|
|
return None
|
|
|
|
|
|
|
|
def num_children(self):
|
|
|
|
if self.count is None:
|
|
|
|
self.count = self.num_children_impl()
|
|
|
|
return self.count
|
|
|
|
|
|
|
|
def num_children_impl(self):
|
|
|
|
logger = lldb.formatters.Logger.Logger()
|
|
|
|
try:
|
|
|
|
count = self.head.GetChildMemberWithName('_M_element_count').GetValueAsUnsigned(0)
|
|
|
|
return count
|
|
|
|
except:
|
|
|
|
logger >> "Could not determine the size"
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
2021-11-10 13:22:14 +08:00
|
|
|
class AbstractListSynthProvider:
|
|
|
|
def __init__(self, valobj, dict, has_prev):
|
|
|
|
'''
|
|
|
|
:param valobj: The value object of the list
|
|
|
|
:param dict: A dict with metadata provided by LLDB
|
|
|
|
:param has_prev: Whether the list supports a 'prev' pointer besides a 'next' one
|
|
|
|
'''
|
2012-04-26 01:53:41 +08:00
|
|
|
logger = lldb.formatters.Logger.Logger()
|
2011-08-18 03:07:52 +08:00
|
|
|
self.valobj = valobj
|
2012-04-10 08:11:03 +08:00
|
|
|
self.count = None
|
2021-11-10 13:22:14 +08:00
|
|
|
self.has_prev = has_prev
|
2021-11-24 06:11:42 +08:00
|
|
|
self.list_capping_size = self.valobj.GetTarget().GetMaximumNumberOfChildrenToDisplay()
|
2015-10-22 08:23:38 +08:00
|
|
|
logger >> "Providing synthetic children for a list named " + \
|
|
|
|
str(valobj.GetName())
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-03-09 11:09:58 +08:00
|
|
|
def next_node(self, node):
|
2012-04-26 01:53:41 +08:00
|
|
|
logger = lldb.formatters.Logger.Logger()
|
2012-03-09 11:09:58 +08:00
|
|
|
return node.GetChildMemberWithName('_M_next')
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-03-09 11:09:58 +08:00
|
|
|
def is_valid(self, node):
|
2012-04-26 01:53:41 +08:00
|
|
|
logger = lldb.formatters.Logger.Logger()
|
2021-11-10 13:22:14 +08:00
|
|
|
valid = self.value(self.next_node(node)) != self.get_end_of_list_address()
|
2015-10-27 00:51:36 +08:00
|
|
|
if valid:
|
|
|
|
logger >> "%s is valid" % str(self.valobj.GetName())
|
|
|
|
else:
|
|
|
|
logger >> "synthetic value is not valid"
|
|
|
|
return valid
|
2021-11-23 05:46:49 +08:00
|
|
|
|
2012-03-09 11:09:58 +08:00
|
|
|
def value(self, node):
|
2012-04-26 01:53:41 +08:00
|
|
|
logger = lldb.formatters.Logger.Logger()
|
2015-10-27 00:51:36 +08:00
|
|
|
value = node.GetValueAsUnsigned()
|
|
|
|
logger >> "synthetic value for {}: {}".format(
|
|
|
|
str(self.valobj.GetName()), value)
|
|
|
|
return value
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2015-09-22 13:07:56 +08:00
|
|
|
# Floyd's cycle-finding algorithm
|
2012-03-09 11:09:58 +08:00
|
|
|
# try to detect if this list has a loop
|
|
|
|
def has_loop(self):
|
Part 1 of a series of fixes meant to improve reliability and increase ease of bug fixing for data formatter issues.
We are introducing a new Logger class on the Python side. This has the same purpose, but is unrelated, to the C++ logging facility
The Pythonic logging can be enabled by using the following scripting commands:
(lldb) script Logger._lldb_formatters_debug_level = {0,1,2,...}
0 = no logging
1 = do log
2 = flush after logging each line - slower but safer
3 or more = each time a Logger is constructed, log the function that has created it
more log levels may be added, each one being more log-active than the previous
by default, the log output will come out on your screen, to direct it to a file:
(lldb) script Logger._lldb_formatters_debug_filename = 'filename'
that will make the output go to the file - set to None to disable the file output and get screen logging back
Logging has been enabled for the C++ STL formatters and for Cocoa class NSData - more logging will follow
synthetic children providers for classes list and map (both libstdcpp and libcxx) now have internal capping for safety reasons
this will fix crashers where a malformed list or map would not ever meet our termination conditions
to set the cap to a different value:
(lldb) script {gnu_libstdcpp|libcxx}.{map|list}_capping_size = new_cap (by default, it is 255)
you can optionally disable the loop detection algorithm for lists
(lldb) script {gnu_libstdcpp|libcxx}.list_uses_loop_detector = False
llvm-svn: 153676
2012-03-30 03:29:45 +08:00
|
|
|
global _list_uses_loop_detector
|
2012-04-26 01:53:41 +08:00
|
|
|
logger = lldb.formatters.Logger.Logger()
|
Part 1 of a series of fixes meant to improve reliability and increase ease of bug fixing for data formatter issues.
We are introducing a new Logger class on the Python side. This has the same purpose, but is unrelated, to the C++ logging facility
The Pythonic logging can be enabled by using the following scripting commands:
(lldb) script Logger._lldb_formatters_debug_level = {0,1,2,...}
0 = no logging
1 = do log
2 = flush after logging each line - slower but safer
3 or more = each time a Logger is constructed, log the function that has created it
more log levels may be added, each one being more log-active than the previous
by default, the log output will come out on your screen, to direct it to a file:
(lldb) script Logger._lldb_formatters_debug_filename = 'filename'
that will make the output go to the file - set to None to disable the file output and get screen logging back
Logging has been enabled for the C++ STL formatters and for Cocoa class NSData - more logging will follow
synthetic children providers for classes list and map (both libstdcpp and libcxx) now have internal capping for safety reasons
this will fix crashers where a malformed list or map would not ever meet our termination conditions
to set the cap to a different value:
(lldb) script {gnu_libstdcpp|libcxx}.{map|list}_capping_size = new_cap (by default, it is 255)
you can optionally disable the loop detection algorithm for lists
(lldb) script {gnu_libstdcpp|libcxx}.list_uses_loop_detector = False
llvm-svn: 153676
2012-03-30 03:29:45 +08:00
|
|
|
if not _list_uses_loop_detector:
|
|
|
|
logger >> "Asked not to use loop detection"
|
|
|
|
return False
|
2012-03-09 11:09:58 +08:00
|
|
|
slow = self.next
|
|
|
|
fast1 = self.next
|
|
|
|
fast2 = self.next
|
|
|
|
while self.is_valid(slow):
|
|
|
|
slow_value = self.value(slow)
|
|
|
|
fast1 = self.next_node(fast2)
|
|
|
|
fast2 = self.next_node(fast1)
|
|
|
|
if self.value(fast1) == slow_value or self.value(
|
|
|
|
fast2) == slow_value:
|
|
|
|
return True
|
|
|
|
slow = self.next_node(slow)
|
|
|
|
return False
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2011-08-18 03:07:52 +08:00
|
|
|
def num_children(self):
|
2012-04-26 01:53:41 +08:00
|
|
|
logger = lldb.formatters.Logger.Logger()
|
2015-10-22 08:23:38 +08:00
|
|
|
if self.count is None:
|
2015-10-27 00:51:36 +08:00
|
|
|
# libstdc++ 6.0.21 added dedicated count field.
|
|
|
|
count_child = self.node.GetChildMemberWithName('_M_data')
|
|
|
|
if count_child and count_child.IsValid():
|
|
|
|
self.count = count_child.GetValueAsUnsigned(0)
|
|
|
|
if self.count is None:
|
|
|
|
self.count = self.num_children_impl()
|
2012-03-09 11:09:58 +08:00
|
|
|
return self.count
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-03-09 11:09:58 +08:00
|
|
|
def num_children_impl(self):
|
2012-04-26 01:53:41 +08:00
|
|
|
logger = lldb.formatters.Logger.Logger()
|
2011-08-23 00:10:25 +08:00
|
|
|
try:
|
|
|
|
# After a std::list has been initialized, both next and prev will
|
|
|
|
# be non-NULL
|
2021-11-10 13:22:14 +08:00
|
|
|
next_val = self.next.GetValueAsUnsigned(0)
|
2021-11-23 05:46:49 +08:00
|
|
|
if next_val == 0:
|
2011-08-23 00:10:25 +08:00
|
|
|
return 0
|
2012-03-09 11:09:58 +08:00
|
|
|
if self.has_loop():
|
|
|
|
return 0
|
2021-11-10 13:22:14 +08:00
|
|
|
if self.has_prev:
|
|
|
|
prev_val = self.prev.GetValueAsUnsigned(0)
|
|
|
|
if prev_val == 0:
|
|
|
|
return 0
|
|
|
|
if next_val == self.node_address:
|
|
|
|
return 0
|
|
|
|
if next_val == prev_val:
|
2021-11-23 05:46:49 +08:00
|
|
|
return 1
|
2021-11-10 13:22:14 +08:00
|
|
|
size = 1
|
2011-08-23 00:10:25 +08:00
|
|
|
current = self.next
|
|
|
|
while current.GetChildMemberWithName(
|
2021-11-10 13:22:14 +08:00
|
|
|
'_M_next').GetValueAsUnsigned(0) != self.get_end_of_list_address():
|
2011-08-23 00:10:25 +08:00
|
|
|
current = current.GetChildMemberWithName('_M_next')
|
2021-11-24 01:32:30 +08:00
|
|
|
if not current.IsValid():
|
|
|
|
break
|
|
|
|
size = size + 1
|
2021-11-24 06:11:42 +08:00
|
|
|
if size >= self.list_capping_size:
|
|
|
|
break
|
2021-11-24 01:32:30 +08:00
|
|
|
|
2021-11-23 05:46:49 +08:00
|
|
|
return size
|
2011-08-23 00:10:25 +08:00
|
|
|
except:
|
2021-11-10 13:22:14 +08:00
|
|
|
logger >> "Error determining the size"
|
2011-08-23 00:10:25 +08:00
|
|
|
return 0
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2011-08-18 03:07:52 +08:00
|
|
|
def get_child_index(self, name):
|
2012-04-26 01:53:41 +08:00
|
|
|
logger = lldb.formatters.Logger.Logger()
|
2011-08-23 00:10:25 +08:00
|
|
|
try:
|
|
|
|
return int(name.lstrip('[').rstrip(']'))
|
|
|
|
except:
|
|
|
|
return -1
|
2021-11-23 05:46:49 +08:00
|
|
|
|
2011-08-18 03:07:52 +08:00
|
|
|
def get_child_at_index(self, index):
|
2012-04-26 01:53:41 +08:00
|
|
|
logger = lldb.formatters.Logger.Logger()
|
2012-03-31 00:07:08 +08:00
|
|
|
logger >> "Fetching child " + str(index)
|
2011-08-23 00:10:25 +08:00
|
|
|
if index < 0:
|
|
|
|
return None
|
2011-08-18 03:07:52 +08:00
|
|
|
if index >= self.num_children():
|
|
|
|
return None
|
2011-08-23 00:10:25 +08:00
|
|
|
try:
|
|
|
|
offset = index
|
|
|
|
current = self.next
|
|
|
|
while offset > 0:
|
|
|
|
current = current.GetChildMemberWithName('_M_next')
|
|
|
|
offset = offset - 1
|
2021-11-10 13:22:14 +08:00
|
|
|
# C++ lists store the data of a node after its pointers. In the case of a forward list, there's just one pointer (next), and
|
|
|
|
# in the case of a double-linked list, there's an additional pointer (prev).
|
2011-08-23 00:10:25 +08:00
|
|
|
return current.CreateChildAtOffset(
|
|
|
|
'[' + str(index) + ']',
|
2021-11-10 13:22:14 +08:00
|
|
|
(2 if self.has_prev else 1) * current.GetType().GetByteSize(),
|
2011-08-23 00:10:25 +08:00
|
|
|
self.data_type)
|
|
|
|
except:
|
2011-08-23 00:38:44 +08:00
|
|
|
return None
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-02-04 02:11:52 +08:00
|
|
|
def extract_type(self):
|
2012-04-26 01:53:41 +08:00
|
|
|
logger = lldb.formatters.Logger.Logger()
|
2012-02-04 02:11:52 +08:00
|
|
|
list_type = self.valobj.GetType().GetUnqualifiedType()
|
2012-03-27 10:35:13 +08:00
|
|
|
if list_type.IsReferenceType():
|
|
|
|
list_type = list_type.GetDereferencedType()
|
2012-02-04 02:11:52 +08:00
|
|
|
if list_type.GetNumberOfTemplateArguments() > 0:
|
2021-11-24 01:32:30 +08:00
|
|
|
return list_type.GetTemplateArgumentType(0)
|
|
|
|
return lldb.SBType()
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2011-08-18 03:07:52 +08:00
|
|
|
def update(self):
|
2012-04-26 01:53:41 +08:00
|
|
|
logger = lldb.formatters.Logger.Logger()
|
2012-03-31 08:15:24 +08:00
|
|
|
# preemptively setting this to None - we might end up changing our mind
|
|
|
|
# later
|
|
|
|
self.count = None
|
2011-08-23 00:10:25 +08:00
|
|
|
try:
|
2021-11-10 13:22:14 +08:00
|
|
|
self.impl = self.valobj.GetChildMemberWithName('_M_impl')
|
2012-02-04 02:11:52 +08:00
|
|
|
self.data_type = self.extract_type()
|
2021-11-24 01:32:30 +08:00
|
|
|
if (not self.data_type.IsValid()) or (not self.impl.IsValid()):
|
|
|
|
self.count = 0
|
|
|
|
elif not self.updateNodes():
|
|
|
|
self.count = 0
|
|
|
|
else:
|
|
|
|
self.data_size = self.data_type.GetByteSize()
|
2011-08-23 00:10:25 +08:00
|
|
|
except:
|
2021-11-24 01:32:30 +08:00
|
|
|
self.count = 0
|
[lldb] Fix gnu_libstdcpp's update methods
The variable.rst documentation says:
```
If it returns a value, and that value is True, LLDB will be allowed to cache the children and the children count it previously obtained, and will not return to the provider class to ask. If nothing, None, or anything other than True is returned, LLDB will discard the cached information and ask. Regardless, whenever necessary LLDB will call update.
```
However, several update methods in gnu_libstdcpp.py were returning True,
which made lldb unaware of any changes in the corresponding objects.
This problem was visible by lldb-vscode in the following way:
- If a breakpoint is hit and there's a vector with the contents {1, 2},
it'll be displayed correctly.
- Then the user steps and the next stop contains the vector modified.
The program changed it to {1, 2, 3}
- frame var then displays {1, 2} incorrectly, due to the caching caused
by the update method
It's worth mentioning that none of libcxx.py'd update methods return True. Same for LibCxxVector.cpp, which returns false.
Added a very simple test that fails without this fix.
Differential Revision: https://reviews.llvm.org/D103209
2021-05-27 05:30:48 +08:00
|
|
|
return False
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2021-11-10 13:22:14 +08:00
|
|
|
'''
|
|
|
|
Method is used to extract the list pointers into the variables (e.g self.node, self.next, and optionally to self.prev)
|
2021-11-24 01:32:30 +08:00
|
|
|
and is mandatory to be overriden in each AbstractListSynthProvider subclass.
|
|
|
|
This should return True or False depending on wheter it found valid data.
|
2021-11-10 13:22:14 +08:00
|
|
|
'''
|
|
|
|
def updateNodes(self):
|
|
|
|
raise NotImplementedError
|
|
|
|
|
2012-10-24 05:54:53 +08:00
|
|
|
def has_children(self):
|
|
|
|
return True
|
2021-11-23 05:46:49 +08:00
|
|
|
|
2021-11-10 13:22:14 +08:00
|
|
|
'''
|
|
|
|
Method is used to identify if a node traversal has reached its end
|
|
|
|
and is mandatory to be overriden in each AbstractListSynthProvider subclass
|
|
|
|
'''
|
|
|
|
def get_end_of_list_address(self):
|
|
|
|
raise NotImplementedError
|
|
|
|
|
|
|
|
|
|
|
|
class StdForwardListSynthProvider(AbstractListSynthProvider):
|
|
|
|
|
|
|
|
def __init__(self, valobj, dict):
|
|
|
|
has_prev = False
|
|
|
|
super().__init__(valobj, dict, has_prev)
|
|
|
|
|
|
|
|
def updateNodes(self):
|
|
|
|
self.node = self.impl.GetChildMemberWithName('_M_head')
|
|
|
|
self.next = self.node.GetChildMemberWithName('_M_next')
|
2021-11-24 01:32:30 +08:00
|
|
|
if (not self.node.IsValid()) or (not self.next.IsValid()):
|
|
|
|
return False
|
|
|
|
return True
|
2021-11-10 13:22:14 +08:00
|
|
|
|
|
|
|
def get_end_of_list_address(self):
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
|
|
class StdListSynthProvider(AbstractListSynthProvider):
|
|
|
|
|
|
|
|
def __init__(self, valobj, dict):
|
|
|
|
has_prev = True
|
|
|
|
super().__init__(valobj, dict, has_prev)
|
|
|
|
|
|
|
|
def updateNodes(self):
|
|
|
|
self.node_address = self.valobj.AddressOf().GetValueAsUnsigned(0)
|
|
|
|
self.node = self.impl.GetChildMemberWithName('_M_node')
|
|
|
|
self.prev = self.node.GetChildMemberWithName('_M_prev')
|
|
|
|
self.next = self.node.GetChildMemberWithName('_M_next')
|
2021-11-24 01:32:30 +08:00
|
|
|
if self.node_address == 0 or (not self.node.IsValid()) or (not self.next.IsValid()) or (not self.prev.IsValid()):
|
|
|
|
return False
|
|
|
|
return True
|
2021-11-10 13:22:14 +08:00
|
|
|
|
|
|
|
def get_end_of_list_address(self):
|
|
|
|
return self.node_address
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-10-24 05:54:53 +08:00
|
|
|
|
2011-08-18 03:07:52 +08:00
|
|
|
class StdVectorSynthProvider:
|
|
|
|
|
2015-03-18 05:23:17 +08:00
|
|
|
class StdVectorImplementation(object):
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2015-03-18 05:23:17 +08:00
|
|
|
def __init__(self, valobj):
|
|
|
|
self.valobj = valobj
|
|
|
|
self.count = None
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2015-03-18 05:23:17 +08:00
|
|
|
def num_children(self):
|
2015-10-20 01:35:02 +08:00
|
|
|
if self.count is None:
|
|
|
|
self.count = self.num_children_impl()
|
|
|
|
return self.count
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2015-10-20 01:35:02 +08:00
|
|
|
def num_children_impl(self):
|
2015-03-18 05:23:17 +08:00
|
|
|
try:
|
|
|
|
start_val = self.start.GetValueAsUnsigned(0)
|
|
|
|
finish_val = self.finish.GetValueAsUnsigned(0)
|
|
|
|
end_val = self.end.GetValueAsUnsigned(0)
|
|
|
|
# Before a vector has been constructed, it will contain bad values
|
|
|
|
# so we really need to be careful about the length we return since
|
2015-09-22 13:07:56 +08:00
|
|
|
# uninitialized data can cause us to return a huge number. We need
|
2015-03-18 05:23:17 +08:00
|
|
|
# to also check for any of the start, finish or end of storage values
|
|
|
|
# being zero (NULL). If any are, then this vector has not been
|
|
|
|
# initialized yet and we should return zero
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2015-03-18 05:23:17 +08:00
|
|
|
# Make sure nothing is NULL
|
|
|
|
if start_val == 0 or finish_val == 0 or end_val == 0:
|
|
|
|
return 0
|
|
|
|
# Make sure start is less than finish
|
|
|
|
if start_val >= finish_val:
|
|
|
|
return 0
|
|
|
|
# Make sure finish is less than or equal to end of storage
|
|
|
|
if finish_val > end_val:
|
|
|
|
return 0
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2015-03-18 05:23:17 +08:00
|
|
|
# if we have a struct (or other data type that the compiler pads to native word size)
|
|
|
|
# this check might fail, unless the sizeof() we get is itself incremented to take the
|
|
|
|
# padding bytes into account - on current clang it looks like
|
|
|
|
# this is the case
|
|
|
|
num_children = (finish_val - start_val)
|
|
|
|
if (num_children % self.data_size) != 0:
|
|
|
|
return 0
|
|
|
|
else:
|
2019-03-18 23:42:08 +08:00
|
|
|
num_children = num_children // self.data_size
|
2015-03-18 05:23:17 +08:00
|
|
|
return num_children
|
|
|
|
except:
|
|
|
|
return 0
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2015-03-18 05:23:17 +08:00
|
|
|
def get_child_at_index(self, index):
|
|
|
|
logger = lldb.formatters.Logger.Logger()
|
|
|
|
logger >> "Retrieving child " + str(index)
|
|
|
|
if index < 0:
|
|
|
|
return None
|
|
|
|
if index >= self.num_children():
|
|
|
|
return None
|
|
|
|
try:
|
|
|
|
offset = index * self.data_size
|
|
|
|
return self.start.CreateChildAtOffset(
|
|
|
|
'[' + str(index) + ']', offset, self.data_type)
|
|
|
|
except:
|
|
|
|
return None
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2015-03-18 05:23:17 +08:00
|
|
|
def update(self):
|
|
|
|
# preemptively setting this to None - we might end up changing our
|
|
|
|
# mind later
|
|
|
|
self.count = None
|
|
|
|
try:
|
|
|
|
impl = self.valobj.GetChildMemberWithName('_M_impl')
|
|
|
|
self.start = impl.GetChildMemberWithName('_M_start')
|
|
|
|
self.finish = impl.GetChildMemberWithName('_M_finish')
|
|
|
|
self.end = impl.GetChildMemberWithName('_M_end_of_storage')
|
|
|
|
self.data_type = self.start.GetType().GetPointeeType()
|
|
|
|
self.data_size = self.data_type.GetByteSize()
|
|
|
|
# if any of these objects is invalid, it means there is no
|
|
|
|
# point in trying to fetch anything
|
|
|
|
if self.start.IsValid() and self.finish.IsValid(
|
|
|
|
) and self.end.IsValid() and self.data_type.IsValid():
|
|
|
|
self.count = None
|
|
|
|
else:
|
|
|
|
self.count = 0
|
|
|
|
except:
|
2021-11-24 01:32:30 +08:00
|
|
|
self.count = 0
|
2021-11-23 05:46:49 +08:00
|
|
|
return False
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2015-03-18 05:23:17 +08:00
|
|
|
class StdVBoolImplementation(object):
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2015-03-18 05:23:17 +08:00
|
|
|
def __init__(self, valobj, bool_type):
|
|
|
|
self.valobj = valobj
|
|
|
|
self.bool_type = bool_type
|
|
|
|
self.valid = False
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2015-03-18 05:23:17 +08:00
|
|
|
def num_children(self):
|
|
|
|
if self.valid:
|
|
|
|
start = self.start_p.GetValueAsUnsigned(0)
|
|
|
|
finish = self.finish_p.GetValueAsUnsigned(0)
|
|
|
|
offset = self.offset.GetValueAsUnsigned(0)
|
|
|
|
if finish >= start:
|
|
|
|
return (finish - start) * 8 + offset
|
|
|
|
return 0
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2015-03-18 05:23:17 +08:00
|
|
|
def get_child_at_index(self, index):
|
|
|
|
if index >= self.num_children():
|
|
|
|
return None
|
2016-04-14 22:33:47 +08:00
|
|
|
element_type = self.start_p.GetType().GetPointeeType()
|
|
|
|
element_bits = 8 * element_type.GetByteSize()
|
2019-03-18 23:42:08 +08:00
|
|
|
element_offset = (index // element_bits) * \
|
2016-04-15 02:31:12 +08:00
|
|
|
element_type.GetByteSize()
|
2016-04-14 22:33:47 +08:00
|
|
|
bit_offset = index % element_bits
|
|
|
|
element = self.start_p.CreateChildAtOffset(
|
|
|
|
'[' + str(index) + ']', element_offset, element_type)
|
|
|
|
bit = element.GetValueAsUnsigned(0) & (1 << bit_offset)
|
2015-03-18 05:23:17 +08:00
|
|
|
if bit != 0:
|
|
|
|
value_expr = "(bool)true"
|
|
|
|
else:
|
|
|
|
value_expr = "(bool)false"
|
|
|
|
return self.valobj.CreateValueFromExpression(
|
|
|
|
"[%d]" % index, value_expr)
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2015-03-18 05:23:17 +08:00
|
|
|
def update(self):
|
|
|
|
try:
|
|
|
|
m_impl = self.valobj.GetChildMemberWithName('_M_impl')
|
|
|
|
self.m_start = m_impl.GetChildMemberWithName('_M_start')
|
|
|
|
self.m_finish = m_impl.GetChildMemberWithName('_M_finish')
|
|
|
|
self.start_p = self.m_start.GetChildMemberWithName('_M_p')
|
|
|
|
self.finish_p = self.m_finish.GetChildMemberWithName('_M_p')
|
|
|
|
self.offset = self.m_finish.GetChildMemberWithName('_M_offset')
|
2021-11-24 01:32:30 +08:00
|
|
|
if self.offset.IsValid() and self.start_p.IsValid() and self.finish_p.IsValid():
|
|
|
|
self.valid = True
|
|
|
|
else:
|
|
|
|
self.valid = False
|
2015-03-18 05:23:17 +08:00
|
|
|
except:
|
|
|
|
self.valid = False
|
[lldb] Fix gnu_libstdcpp's update methods
The variable.rst documentation says:
```
If it returns a value, and that value is True, LLDB will be allowed to cache the children and the children count it previously obtained, and will not return to the provider class to ask. If nothing, None, or anything other than True is returned, LLDB will discard the cached information and ask. Regardless, whenever necessary LLDB will call update.
```
However, several update methods in gnu_libstdcpp.py were returning True,
which made lldb unaware of any changes in the corresponding objects.
This problem was visible by lldb-vscode in the following way:
- If a breakpoint is hit and there's a vector with the contents {1, 2},
it'll be displayed correctly.
- Then the user steps and the next stop contains the vector modified.
The program changed it to {1, 2, 3}
- frame var then displays {1, 2} incorrectly, due to the caching caused
by the update method
It's worth mentioning that none of libcxx.py'd update methods return True. Same for LibCxxVector.cpp, which returns false.
Added a very simple test that fails without this fix.
Differential Revision: https://reviews.llvm.org/D103209
2021-05-27 05:30:48 +08:00
|
|
|
return False
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2011-08-18 03:07:52 +08:00
|
|
|
def __init__(self, valobj, dict):
|
2012-04-26 01:53:41 +08:00
|
|
|
logger = lldb.formatters.Logger.Logger()
|
2015-03-18 05:23:17 +08:00
|
|
|
first_template_arg_type = valobj.GetType().GetTemplateArgumentType(0)
|
|
|
|
if str(first_template_arg_type.GetName()) == "bool":
|
|
|
|
self.impl = self.StdVBoolImplementation(
|
|
|
|
valobj, first_template_arg_type)
|
|
|
|
else:
|
|
|
|
self.impl = self.StdVectorImplementation(valobj)
|
2015-03-17 07:02:03 +08:00
|
|
|
logger >> "Providing synthetic children for a vector named " + \
|
|
|
|
str(valobj.GetName())
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2011-08-18 03:07:52 +08:00
|
|
|
def num_children(self):
|
2015-03-18 05:23:17 +08:00
|
|
|
return self.impl.num_children()
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2011-08-18 03:07:52 +08:00
|
|
|
def get_child_index(self, name):
|
2011-08-23 00:10:25 +08:00
|
|
|
try:
|
|
|
|
return int(name.lstrip('[').rstrip(']'))
|
|
|
|
except:
|
|
|
|
return -1
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2015-03-18 05:23:17 +08:00
|
|
|
def get_child_at_index(self, index):
|
|
|
|
return self.impl.get_child_at_index(index)
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2011-08-18 03:07:52 +08:00
|
|
|
def update(self):
|
2015-03-18 05:23:17 +08:00
|
|
|
return self.impl.update()
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-10-24 05:54:53 +08:00
|
|
|
def has_children(self):
|
2012-12-11 03:55:53 +08:00
|
|
|
return True
|
2011-08-18 03:07:52 +08:00
|
|
|
|
2021-10-28 02:54:19 +08:00
|
|
|
"""
|
2021-10-31 03:53:19 +08:00
|
|
|
This formatter can be applied to all
|
|
|
|
map-like structures (map, multimap, set, multiset)
|
2021-10-28 02:54:19 +08:00
|
|
|
"""
|
2021-10-31 03:53:19 +08:00
|
|
|
class StdMapLikeSynthProvider:
|
2011-08-18 03:07:52 +08:00
|
|
|
|
|
|
|
def __init__(self, valobj, dict):
|
2012-04-26 01:53:41 +08:00
|
|
|
logger = lldb.formatters.Logger.Logger()
|
2011-08-18 03:07:52 +08:00
|
|
|
self.valobj = valobj
|
2012-04-10 08:11:03 +08:00
|
|
|
self.count = None
|
2021-10-31 05:48:26 +08:00
|
|
|
self.kind = self.get_object_kind(valobj)
|
2021-10-28 02:54:19 +08:00
|
|
|
logger >> "Providing synthetic children for a " + self.kind + " named " + \
|
Part 1 of a series of fixes meant to improve reliability and increase ease of bug fixing for data formatter issues.
We are introducing a new Logger class on the Python side. This has the same purpose, but is unrelated, to the C++ logging facility
The Pythonic logging can be enabled by using the following scripting commands:
(lldb) script Logger._lldb_formatters_debug_level = {0,1,2,...}
0 = no logging
1 = do log
2 = flush after logging each line - slower but safer
3 or more = each time a Logger is constructed, log the function that has created it
more log levels may be added, each one being more log-active than the previous
by default, the log output will come out on your screen, to direct it to a file:
(lldb) script Logger._lldb_formatters_debug_filename = 'filename'
that will make the output go to the file - set to None to disable the file output and get screen logging back
Logging has been enabled for the C++ STL formatters and for Cocoa class NSData - more logging will follow
synthetic children providers for classes list and map (both libstdcpp and libcxx) now have internal capping for safety reasons
this will fix crashers where a malformed list or map would not ever meet our termination conditions
to set the cap to a different value:
(lldb) script {gnu_libstdcpp|libcxx}.{map|list}_capping_size = new_cap (by default, it is 255)
you can optionally disable the loop detection algorithm for lists
(lldb) script {gnu_libstdcpp|libcxx}.list_uses_loop_detector = False
llvm-svn: 153676
2012-03-30 03:29:45 +08:00
|
|
|
str(valobj.GetName())
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2021-10-31 05:48:26 +08:00
|
|
|
def get_object_kind(self, valobj):
|
|
|
|
type_name = valobj.GetTypeName()
|
|
|
|
for kind in ["multiset", "multimap", "set", "map"]:
|
|
|
|
if kind in type_name:
|
|
|
|
return kind
|
|
|
|
return type_name
|
|
|
|
|
2012-02-04 02:11:52 +08:00
|
|
|
# we need this function as a temporary workaround for rdar://problem/10801549
|
|
|
|
# which prevents us from extracting the std::pair<K,V> SBType out of the template
|
2021-10-28 02:54:19 +08:00
|
|
|
# arguments for _Rep_Type _M_t in the object itself - because we have to make up the
|
2012-02-04 02:11:52 +08:00
|
|
|
# typename and then find it, we may hit the situation were std::string has multiple
|
|
|
|
# names but only one is actually referenced in the debug information. hence, we need
|
|
|
|
# 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):
|
2012-04-26 01:53:41 +08:00
|
|
|
logger = lldb.formatters.Logger.Logger()
|
2012-02-04 02:11:52 +08:00
|
|
|
if class_name == 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >':
|
2012-03-27 10:35:13 +08:00
|
|
|
return 'std::basic_string<char>', True
|
2012-02-04 02:11:52 +08:00
|
|
|
if class_name == 'basic_string<char, std::char_traits<char>, std::allocator<char> >':
|
2012-03-27 10:35:13 +08:00
|
|
|
return 'std::basic_string<char>', True
|
|
|
|
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> >':
|
|
|
|
return 'std::basic_string<char>', True
|
|
|
|
return class_name, False
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2011-08-18 03:07:52 +08:00
|
|
|
def update(self):
|
2012-04-26 01:53:41 +08:00
|
|
|
logger = lldb.formatters.Logger.Logger()
|
2012-03-31 08:15:24 +08:00
|
|
|
# preemptively setting this to None - we might end up changing our mind
|
|
|
|
# later
|
|
|
|
self.count = None
|
2011-08-23 00:10:25 +08:00
|
|
|
try:
|
2021-10-28 02:54:19 +08:00
|
|
|
# we will set this to True if we find out that discovering a node in the object takes more steps than the overall size of the RB tree
|
Part 1 of a series of fixes meant to improve reliability and increase ease of bug fixing for data formatter issues.
We are introducing a new Logger class on the Python side. This has the same purpose, but is unrelated, to the C++ logging facility
The Pythonic logging can be enabled by using the following scripting commands:
(lldb) script Logger._lldb_formatters_debug_level = {0,1,2,...}
0 = no logging
1 = do log
2 = flush after logging each line - slower but safer
3 or more = each time a Logger is constructed, log the function that has created it
more log levels may be added, each one being more log-active than the previous
by default, the log output will come out on your screen, to direct it to a file:
(lldb) script Logger._lldb_formatters_debug_filename = 'filename'
that will make the output go to the file - set to None to disable the file output and get screen logging back
Logging has been enabled for the C++ STL formatters and for Cocoa class NSData - more logging will follow
synthetic children providers for classes list and map (both libstdcpp and libcxx) now have internal capping for safety reasons
this will fix crashers where a malformed list or map would not ever meet our termination conditions
to set the cap to a different value:
(lldb) script {gnu_libstdcpp|libcxx}.{map|list}_capping_size = new_cap (by default, it is 255)
you can optionally disable the loop detection algorithm for lists
(lldb) script {gnu_libstdcpp|libcxx}.list_uses_loop_detector = False
llvm-svn: 153676
2012-03-30 03:29:45 +08:00
|
|
|
# if this gets set to True, then we will merrily return None for
|
|
|
|
# any child from that moment on
|
|
|
|
self.garbage = False
|
2011-08-23 00:10:25 +08:00
|
|
|
self.Mt = self.valobj.GetChildMemberWithName('_M_t')
|
|
|
|
self.Mimpl = self.Mt.GetChildMemberWithName('_M_impl')
|
|
|
|
self.Mheader = self.Mimpl.GetChildMemberWithName('_M_header')
|
2021-11-24 01:32:30 +08:00
|
|
|
if not self.Mheader.IsValid():
|
|
|
|
self.count = 0
|
|
|
|
else:
|
|
|
|
map_type = self.valobj.GetType()
|
|
|
|
if map_type.IsReferenceType():
|
|
|
|
logger >> "Dereferencing type"
|
|
|
|
map_type = map_type.GetDereferencedType()
|
|
|
|
|
|
|
|
# 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')
|
|
|
|
self.data_size = self.data_type.GetByteSize()
|
|
|
|
self.skip_size = self.Mheader.GetType().GetByteSize()
|
2011-08-23 00:10:25 +08:00
|
|
|
except:
|
2021-11-24 01:32:30 +08:00
|
|
|
self.count = 0
|
[lldb] Fix gnu_libstdcpp's update methods
The variable.rst documentation says:
```
If it returns a value, and that value is True, LLDB will be allowed to cache the children and the children count it previously obtained, and will not return to the provider class to ask. If nothing, None, or anything other than True is returned, LLDB will discard the cached information and ask. Regardless, whenever necessary LLDB will call update.
```
However, several update methods in gnu_libstdcpp.py were returning True,
which made lldb unaware of any changes in the corresponding objects.
This problem was visible by lldb-vscode in the following way:
- If a breakpoint is hit and there's a vector with the contents {1, 2},
it'll be displayed correctly.
- Then the user steps and the next stop contains the vector modified.
The program changed it to {1, 2, 3}
- frame var then displays {1, 2} incorrectly, due to the caching caused
by the update method
It's worth mentioning that none of libcxx.py'd update methods return True. Same for LibCxxVector.cpp, which returns false.
Added a very simple test that fails without this fix.
Differential Revision: https://reviews.llvm.org/D103209
2021-05-27 05:30:48 +08:00
|
|
|
return False
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2011-08-18 03:07:52 +08:00
|
|
|
def num_children(self):
|
2012-04-26 01:53:41 +08:00
|
|
|
logger = lldb.formatters.Logger.Logger()
|
Part 1 of a series of fixes meant to improve reliability and increase ease of bug fixing for data formatter issues.
We are introducing a new Logger class on the Python side. This has the same purpose, but is unrelated, to the C++ logging facility
The Pythonic logging can be enabled by using the following scripting commands:
(lldb) script Logger._lldb_formatters_debug_level = {0,1,2,...}
0 = no logging
1 = do log
2 = flush after logging each line - slower but safer
3 or more = each time a Logger is constructed, log the function that has created it
more log levels may be added, each one being more log-active than the previous
by default, the log output will come out on your screen, to direct it to a file:
(lldb) script Logger._lldb_formatters_debug_filename = 'filename'
that will make the output go to the file - set to None to disable the file output and get screen logging back
Logging has been enabled for the C++ STL formatters and for Cocoa class NSData - more logging will follow
synthetic children providers for classes list and map (both libstdcpp and libcxx) now have internal capping for safety reasons
this will fix crashers where a malformed list or map would not ever meet our termination conditions
to set the cap to a different value:
(lldb) script {gnu_libstdcpp|libcxx}.{map|list}_capping_size = new_cap (by default, it is 255)
you can optionally disable the loop detection algorithm for lists
(lldb) script {gnu_libstdcpp|libcxx}.list_uses_loop_detector = False
llvm-svn: 153676
2012-03-30 03:29:45 +08:00
|
|
|
if self.count is None:
|
|
|
|
self.count = self.num_children_impl()
|
|
|
|
return self.count
|
2016-09-07 04:57:50 +08:00
|
|
|
|
Part 1 of a series of fixes meant to improve reliability and increase ease of bug fixing for data formatter issues.
We are introducing a new Logger class on the Python side. This has the same purpose, but is unrelated, to the C++ logging facility
The Pythonic logging can be enabled by using the following scripting commands:
(lldb) script Logger._lldb_formatters_debug_level = {0,1,2,...}
0 = no logging
1 = do log
2 = flush after logging each line - slower but safer
3 or more = each time a Logger is constructed, log the function that has created it
more log levels may be added, each one being more log-active than the previous
by default, the log output will come out on your screen, to direct it to a file:
(lldb) script Logger._lldb_formatters_debug_filename = 'filename'
that will make the output go to the file - set to None to disable the file output and get screen logging back
Logging has been enabled for the C++ STL formatters and for Cocoa class NSData - more logging will follow
synthetic children providers for classes list and map (both libstdcpp and libcxx) now have internal capping for safety reasons
this will fix crashers where a malformed list or map would not ever meet our termination conditions
to set the cap to a different value:
(lldb) script {gnu_libstdcpp|libcxx}.{map|list}_capping_size = new_cap (by default, it is 255)
you can optionally disable the loop detection algorithm for lists
(lldb) script {gnu_libstdcpp|libcxx}.list_uses_loop_detector = False
llvm-svn: 153676
2012-03-30 03:29:45 +08:00
|
|
|
def num_children_impl(self):
|
2012-04-26 01:53:41 +08:00
|
|
|
logger = lldb.formatters.Logger.Logger()
|
2011-08-23 00:10:25 +08:00
|
|
|
try:
|
|
|
|
root_ptr_val = self.node_ptr_value(self.Mroot)
|
|
|
|
if root_ptr_val == 0:
|
|
|
|
return 0
|
Part 1 of a series of fixes meant to improve reliability and increase ease of bug fixing for data formatter issues.
We are introducing a new Logger class on the Python side. This has the same purpose, but is unrelated, to the C++ logging facility
The Pythonic logging can be enabled by using the following scripting commands:
(lldb) script Logger._lldb_formatters_debug_level = {0,1,2,...}
0 = no logging
1 = do log
2 = flush after logging each line - slower but safer
3 or more = each time a Logger is constructed, log the function that has created it
more log levels may be added, each one being more log-active than the previous
by default, the log output will come out on your screen, to direct it to a file:
(lldb) script Logger._lldb_formatters_debug_filename = 'filename'
that will make the output go to the file - set to None to disable the file output and get screen logging back
Logging has been enabled for the C++ STL formatters and for Cocoa class NSData - more logging will follow
synthetic children providers for classes list and map (both libstdcpp and libcxx) now have internal capping for safety reasons
this will fix crashers where a malformed list or map would not ever meet our termination conditions
to set the cap to a different value:
(lldb) script {gnu_libstdcpp|libcxx}.{map|list}_capping_size = new_cap (by default, it is 255)
you can optionally disable the loop detection algorithm for lists
(lldb) script {gnu_libstdcpp|libcxx}.list_uses_loop_detector = False
llvm-svn: 153676
2012-03-30 03:29:45 +08:00
|
|
|
count = self.Mimpl.GetChildMemberWithName(
|
|
|
|
'_M_node_count').GetValueAsUnsigned(0)
|
|
|
|
logger >> "I have " + str(count) + " children available"
|
|
|
|
return count
|
2011-08-23 00:10:25 +08:00
|
|
|
except:
|
2011-08-18 03:07:52 +08:00
|
|
|
return 0
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2011-08-18 03:07:52 +08:00
|
|
|
def get_child_index(self, name):
|
2012-04-26 01:53:41 +08:00
|
|
|
logger = lldb.formatters.Logger.Logger()
|
2011-08-23 00:10:25 +08:00
|
|
|
try:
|
|
|
|
return int(name.lstrip('[').rstrip(']'))
|
|
|
|
except:
|
|
|
|
return -1
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2011-08-18 03:07:52 +08:00
|
|
|
def get_child_at_index(self, index):
|
2012-04-26 01:53:41 +08:00
|
|
|
logger = lldb.formatters.Logger.Logger()
|
Part 1 of a series of fixes meant to improve reliability and increase ease of bug fixing for data formatter issues.
We are introducing a new Logger class on the Python side. This has the same purpose, but is unrelated, to the C++ logging facility
The Pythonic logging can be enabled by using the following scripting commands:
(lldb) script Logger._lldb_formatters_debug_level = {0,1,2,...}
0 = no logging
1 = do log
2 = flush after logging each line - slower but safer
3 or more = each time a Logger is constructed, log the function that has created it
more log levels may be added, each one being more log-active than the previous
by default, the log output will come out on your screen, to direct it to a file:
(lldb) script Logger._lldb_formatters_debug_filename = 'filename'
that will make the output go to the file - set to None to disable the file output and get screen logging back
Logging has been enabled for the C++ STL formatters and for Cocoa class NSData - more logging will follow
synthetic children providers for classes list and map (both libstdcpp and libcxx) now have internal capping for safety reasons
this will fix crashers where a malformed list or map would not ever meet our termination conditions
to set the cap to a different value:
(lldb) script {gnu_libstdcpp|libcxx}.{map|list}_capping_size = new_cap (by default, it is 255)
you can optionally disable the loop detection algorithm for lists
(lldb) script {gnu_libstdcpp|libcxx}.list_uses_loop_detector = False
llvm-svn: 153676
2012-03-30 03:29:45 +08:00
|
|
|
logger >> "Being asked to fetch child[" + str(index) + "]"
|
2011-08-23 00:10:25 +08:00
|
|
|
if index < 0:
|
|
|
|
return None
|
2011-08-18 03:07:52 +08:00
|
|
|
if index >= self.num_children():
|
|
|
|
return None
|
Part 1 of a series of fixes meant to improve reliability and increase ease of bug fixing for data formatter issues.
We are introducing a new Logger class on the Python side. This has the same purpose, but is unrelated, to the C++ logging facility
The Pythonic logging can be enabled by using the following scripting commands:
(lldb) script Logger._lldb_formatters_debug_level = {0,1,2,...}
0 = no logging
1 = do log
2 = flush after logging each line - slower but safer
3 or more = each time a Logger is constructed, log the function that has created it
more log levels may be added, each one being more log-active than the previous
by default, the log output will come out on your screen, to direct it to a file:
(lldb) script Logger._lldb_formatters_debug_filename = 'filename'
that will make the output go to the file - set to None to disable the file output and get screen logging back
Logging has been enabled for the C++ STL formatters and for Cocoa class NSData - more logging will follow
synthetic children providers for classes list and map (both libstdcpp and libcxx) now have internal capping for safety reasons
this will fix crashers where a malformed list or map would not ever meet our termination conditions
to set the cap to a different value:
(lldb) script {gnu_libstdcpp|libcxx}.{map|list}_capping_size = new_cap (by default, it is 255)
you can optionally disable the loop detection algorithm for lists
(lldb) script {gnu_libstdcpp|libcxx}.list_uses_loop_detector = False
llvm-svn: 153676
2012-03-30 03:29:45 +08:00
|
|
|
if self.garbage:
|
|
|
|
logger >> "Returning None since we are a garbage tree"
|
|
|
|
return None
|
2011-08-23 00:10:25 +08:00
|
|
|
try:
|
|
|
|
offset = index
|
|
|
|
current = self.left(self.Mheader)
|
|
|
|
while offset > 0:
|
|
|
|
current = self.increment_node(current)
|
|
|
|
offset = offset - 1
|
|
|
|
# skip all the base stuff and get at the data
|
|
|
|
return current.CreateChildAtOffset(
|
|
|
|
'[' + str(index) + ']', self.skip_size, self.data_type)
|
|
|
|
except:
|
|
|
|
return None
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2011-08-18 03:07:52 +08:00
|
|
|
# utility functions
|
|
|
|
def node_ptr_value(self, node):
|
2012-04-26 01:53:41 +08:00
|
|
|
logger = lldb.formatters.Logger.Logger()
|
2011-08-18 03:07:52 +08:00
|
|
|
return node.GetValueAsUnsigned(0)
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2011-08-18 03:07:52 +08:00
|
|
|
def right(self, node):
|
2012-04-26 01:53:41 +08:00
|
|
|
logger = lldb.formatters.Logger.Logger()
|
2011-08-18 03:07:52 +08:00
|
|
|
return node.GetChildMemberWithName("_M_right")
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2011-08-18 03:07:52 +08:00
|
|
|
def left(self, node):
|
2012-04-26 01:53:41 +08:00
|
|
|
logger = lldb.formatters.Logger.Logger()
|
2011-08-18 03:07:52 +08:00
|
|
|
return node.GetChildMemberWithName("_M_left")
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2011-08-18 03:07:52 +08:00
|
|
|
def parent(self, node):
|
2012-04-26 01:53:41 +08:00
|
|
|
logger = lldb.formatters.Logger.Logger()
|
2011-08-18 03:07:52 +08:00
|
|
|
return node.GetChildMemberWithName("_M_parent")
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2011-08-18 03:07:52 +08:00
|
|
|
# from libstdc++ implementation of iterator for rbtree
|
|
|
|
def increment_node(self, node):
|
2012-04-26 01:53:41 +08:00
|
|
|
logger = lldb.formatters.Logger.Logger()
|
Part 1 of a series of fixes meant to improve reliability and increase ease of bug fixing for data formatter issues.
We are introducing a new Logger class on the Python side. This has the same purpose, but is unrelated, to the C++ logging facility
The Pythonic logging can be enabled by using the following scripting commands:
(lldb) script Logger._lldb_formatters_debug_level = {0,1,2,...}
0 = no logging
1 = do log
2 = flush after logging each line - slower but safer
3 or more = each time a Logger is constructed, log the function that has created it
more log levels may be added, each one being more log-active than the previous
by default, the log output will come out on your screen, to direct it to a file:
(lldb) script Logger._lldb_formatters_debug_filename = 'filename'
that will make the output go to the file - set to None to disable the file output and get screen logging back
Logging has been enabled for the C++ STL formatters and for Cocoa class NSData - more logging will follow
synthetic children providers for classes list and map (both libstdcpp and libcxx) now have internal capping for safety reasons
this will fix crashers where a malformed list or map would not ever meet our termination conditions
to set the cap to a different value:
(lldb) script {gnu_libstdcpp|libcxx}.{map|list}_capping_size = new_cap (by default, it is 255)
you can optionally disable the loop detection algorithm for lists
(lldb) script {gnu_libstdcpp|libcxx}.list_uses_loop_detector = False
llvm-svn: 153676
2012-03-30 03:29:45 +08:00
|
|
|
max_steps = self.num_children()
|
2011-08-18 03:07:52 +08:00
|
|
|
if self.node_ptr_value(self.right(node)) != 0:
|
|
|
|
x = self.right(node)
|
Part 1 of a series of fixes meant to improve reliability and increase ease of bug fixing for data formatter issues.
We are introducing a new Logger class on the Python side. This has the same purpose, but is unrelated, to the C++ logging facility
The Pythonic logging can be enabled by using the following scripting commands:
(lldb) script Logger._lldb_formatters_debug_level = {0,1,2,...}
0 = no logging
1 = do log
2 = flush after logging each line - slower but safer
3 or more = each time a Logger is constructed, log the function that has created it
more log levels may be added, each one being more log-active than the previous
by default, the log output will come out on your screen, to direct it to a file:
(lldb) script Logger._lldb_formatters_debug_filename = 'filename'
that will make the output go to the file - set to None to disable the file output and get screen logging back
Logging has been enabled for the C++ STL formatters and for Cocoa class NSData - more logging will follow
synthetic children providers for classes list and map (both libstdcpp and libcxx) now have internal capping for safety reasons
this will fix crashers where a malformed list or map would not ever meet our termination conditions
to set the cap to a different value:
(lldb) script {gnu_libstdcpp|libcxx}.{map|list}_capping_size = new_cap (by default, it is 255)
you can optionally disable the loop detection algorithm for lists
(lldb) script {gnu_libstdcpp|libcxx}.list_uses_loop_detector = False
llvm-svn: 153676
2012-03-30 03:29:45 +08:00
|
|
|
max_steps -= 1
|
2011-08-18 03:07:52 +08:00
|
|
|
while self.node_ptr_value(self.left(x)) != 0:
|
|
|
|
x = self.left(x)
|
Part 1 of a series of fixes meant to improve reliability and increase ease of bug fixing for data formatter issues.
We are introducing a new Logger class on the Python side. This has the same purpose, but is unrelated, to the C++ logging facility
The Pythonic logging can be enabled by using the following scripting commands:
(lldb) script Logger._lldb_formatters_debug_level = {0,1,2,...}
0 = no logging
1 = do log
2 = flush after logging each line - slower but safer
3 or more = each time a Logger is constructed, log the function that has created it
more log levels may be added, each one being more log-active than the previous
by default, the log output will come out on your screen, to direct it to a file:
(lldb) script Logger._lldb_formatters_debug_filename = 'filename'
that will make the output go to the file - set to None to disable the file output and get screen logging back
Logging has been enabled for the C++ STL formatters and for Cocoa class NSData - more logging will follow
synthetic children providers for classes list and map (both libstdcpp and libcxx) now have internal capping for safety reasons
this will fix crashers where a malformed list or map would not ever meet our termination conditions
to set the cap to a different value:
(lldb) script {gnu_libstdcpp|libcxx}.{map|list}_capping_size = new_cap (by default, it is 255)
you can optionally disable the loop detection algorithm for lists
(lldb) script {gnu_libstdcpp|libcxx}.list_uses_loop_detector = False
llvm-svn: 153676
2012-03-30 03:29:45 +08:00
|
|
|
max_steps -= 1
|
|
|
|
logger >> str(max_steps) + " more to go before giving up"
|
|
|
|
if max_steps <= 0:
|
|
|
|
self.garbage = True
|
|
|
|
return None
|
2011-08-18 03:07:52 +08:00
|
|
|
return x
|
|
|
|
else:
|
|
|
|
x = node
|
|
|
|
y = self.parent(x)
|
Part 1 of a series of fixes meant to improve reliability and increase ease of bug fixing for data formatter issues.
We are introducing a new Logger class on the Python side. This has the same purpose, but is unrelated, to the C++ logging facility
The Pythonic logging can be enabled by using the following scripting commands:
(lldb) script Logger._lldb_formatters_debug_level = {0,1,2,...}
0 = no logging
1 = do log
2 = flush after logging each line - slower but safer
3 or more = each time a Logger is constructed, log the function that has created it
more log levels may be added, each one being more log-active than the previous
by default, the log output will come out on your screen, to direct it to a file:
(lldb) script Logger._lldb_formatters_debug_filename = 'filename'
that will make the output go to the file - set to None to disable the file output and get screen logging back
Logging has been enabled for the C++ STL formatters and for Cocoa class NSData - more logging will follow
synthetic children providers for classes list and map (both libstdcpp and libcxx) now have internal capping for safety reasons
this will fix crashers where a malformed list or map would not ever meet our termination conditions
to set the cap to a different value:
(lldb) script {gnu_libstdcpp|libcxx}.{map|list}_capping_size = new_cap (by default, it is 255)
you can optionally disable the loop detection algorithm for lists
(lldb) script {gnu_libstdcpp|libcxx}.list_uses_loop_detector = False
llvm-svn: 153676
2012-03-30 03:29:45 +08:00
|
|
|
max_steps -= 1
|
2011-08-18 03:07:52 +08:00
|
|
|
while(self.node_ptr_value(x) == self.node_ptr_value(self.right(y))):
|
|
|
|
x = y
|
|
|
|
y = self.parent(y)
|
Part 1 of a series of fixes meant to improve reliability and increase ease of bug fixing for data formatter issues.
We are introducing a new Logger class on the Python side. This has the same purpose, but is unrelated, to the C++ logging facility
The Pythonic logging can be enabled by using the following scripting commands:
(lldb) script Logger._lldb_formatters_debug_level = {0,1,2,...}
0 = no logging
1 = do log
2 = flush after logging each line - slower but safer
3 or more = each time a Logger is constructed, log the function that has created it
more log levels may be added, each one being more log-active than the previous
by default, the log output will come out on your screen, to direct it to a file:
(lldb) script Logger._lldb_formatters_debug_filename = 'filename'
that will make the output go to the file - set to None to disable the file output and get screen logging back
Logging has been enabled for the C++ STL formatters and for Cocoa class NSData - more logging will follow
synthetic children providers for classes list and map (both libstdcpp and libcxx) now have internal capping for safety reasons
this will fix crashers where a malformed list or map would not ever meet our termination conditions
to set the cap to a different value:
(lldb) script {gnu_libstdcpp|libcxx}.{map|list}_capping_size = new_cap (by default, it is 255)
you can optionally disable the loop detection algorithm for lists
(lldb) script {gnu_libstdcpp|libcxx}.list_uses_loop_detector = False
llvm-svn: 153676
2012-03-30 03:29:45 +08:00
|
|
|
max_steps -= 1
|
|
|
|
logger >> str(max_steps) + " more to go before giving up"
|
|
|
|
if max_steps <= 0:
|
|
|
|
self.garbage = True
|
|
|
|
return None
|
2011-08-18 03:07:52 +08:00
|
|
|
if self.node_ptr_value(self.right(x)) != self.node_ptr_value(y):
|
|
|
|
x = y
|
|
|
|
return x
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-10-24 05:54:53 +08:00
|
|
|
def has_children(self):
|
2012-12-11 03:55:53 +08:00
|
|
|
return True
|
Part 1 of a series of fixes meant to improve reliability and increase ease of bug fixing for data formatter issues.
We are introducing a new Logger class on the Python side. This has the same purpose, but is unrelated, to the C++ logging facility
The Pythonic logging can be enabled by using the following scripting commands:
(lldb) script Logger._lldb_formatters_debug_level = {0,1,2,...}
0 = no logging
1 = do log
2 = flush after logging each line - slower but safer
3 or more = each time a Logger is constructed, log the function that has created it
more log levels may be added, each one being more log-active than the previous
by default, the log output will come out on your screen, to direct it to a file:
(lldb) script Logger._lldb_formatters_debug_filename = 'filename'
that will make the output go to the file - set to None to disable the file output and get screen logging back
Logging has been enabled for the C++ STL formatters and for Cocoa class NSData - more logging will follow
synthetic children providers for classes list and map (both libstdcpp and libcxx) now have internal capping for safety reasons
this will fix crashers where a malformed list or map would not ever meet our termination conditions
to set the cap to a different value:
(lldb) script {gnu_libstdcpp|libcxx}.{map|list}_capping_size = new_cap (by default, it is 255)
you can optionally disable the loop detection algorithm for lists
(lldb) script {gnu_libstdcpp|libcxx}.list_uses_loop_detector = False
llvm-svn: 153676
2012-03-30 03:29:45 +08:00
|
|
|
|
|
|
|
_list_uses_loop_detector = True
|