wallace created this revision.
wallace added a reviewer: labath.
wallace requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
As suggested by @labath in https://reviews.llvm.org/D114403, we should
make the formatter more resilient to corrupted data. The Libcxx version
explicitly checks for engaged = 1, so we can do that as well for safety.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D114450
Files:
lldb/examples/synthetic/gnu_libstdcpp.py
Index: lldb/examples/synthetic/gnu_libstdcpp.py
===================================================================
--- lldb/examples/synthetic/gnu_libstdcpp.py
+++ lldb/examples/synthetic/gnu_libstdcpp.py
@@ -1,5 +1,4 @@
from __future__ import division
-import re
import lldb.formatters.Logger
# C++ STL formatters for LLDB
@@ -22,14 +21,14 @@
try:
self.payload = self.valobj.GetChildMemberWithName('_M_payload')
self.value = self.payload.GetChildMemberWithName('_M_payload')
- self.count =
self.payload.GetChildMemberWithName('_M_engaged').GetValueAsUnsigned(0)
+ self.has_value =
self.payload.GetChildMemberWithName('_M_engaged').GetValueAsUnsigned(0) == 1
except:
- self.count = 0
+ self.has_value = 0
return False
def num_children(self):
- return self.count
+ return 1 if self.has_value else 0
def get_child_index(self, name):
return 0
Index: lldb/examples/synthetic/gnu_libstdcpp.py
===================================================================
--- lldb/examples/synthetic/gnu_libstdcpp.py
+++ lldb/examples/synthetic/gnu_libstdcpp.py
@@ -1,5 +1,4 @@
from __future__ import division
-import re
import lldb.formatters.Logger
# C++ STL formatters for LLDB
@@ -22,14 +21,14 @@
try:
self.payload = self.valobj.GetChildMemberWithName('_M_payload')
self.value = self.payload.GetChildMemberWithName('_M_payload')
- self.count = self.payload.GetChildMemberWithName('_M_engaged').GetValueAsUnsigned(0)
+ self.has_value = self.payload.GetChildMemberWithName('_M_engaged').GetValueAsUnsigned(0) == 1
except:
- self.count = 0
+ self.has_value = 0
return False
def num_children(self):
- return self.count
+ return 1 if self.has_value else 0
def get_child_index(self, name):
return 0
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits