summaryrefslogtreecommitdiff
path: root/lldb/examples
diff options
context:
space:
mode:
authorUlrich Weigand <ulrich.weigand@de.ibm.com>2016-04-14 14:33:47 +0000
committerUlrich Weigand <ulrich.weigand@de.ibm.com>2016-04-14 14:33:47 +0000
commit2532525a9bd4542ee8a365be2c3df0945ebdaa40 (patch)
treea7022855eba72b735b8c83b9ef4b98616b41fd88 /lldb/examples
parentc99efe15bd8335410b3063f4491540700a079996 (diff)
Miscellaneous fixes for big-endian systems
This patch fixes a bunch of issues that show up on big-endian systems: - The gnu_libstdcpp.py script doesn't follow the way libstdc++ encodes bit vectors: it should identify the enclosing *word* and then access the appropriate bit within that word. Instead, the script simply operates on bytes. This gives the same result on little-endian systems, but not on big-endian. - lldb_private::formatters::WCharSummaryProvider always assumes wchar_t is UTF16, even though it could also be UTF8 or UTF32. This is mostly not an issue on little-endian systems, but immediately fails on BE. Fixed by checking the size of wchar_t like WCharStringSummaryProvider already does. - ClangASTContext::GetChildCompilerTypeAtIndex uses uint32_t to access the virtual base offset stored in the vtable, even though the size of this field matches the target pointer size according to the C++ ABI. Again, this is mostly not visible on LE, but fails on BE. - Process::ReadStringFromMemory uses strncmp to search for a terminator consisting of multiple zero bytes. This doesn't work since strncmp will stop already at the first zero byte. Use memcmp instead. Differential Revision: http://reviews.llvm.org/D18983
Diffstat (limited to 'lldb/examples')
-rw-r--r--lldb/examples/synthetic/gnu_libstdcpp.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/lldb/examples/synthetic/gnu_libstdcpp.py b/lldb/examples/synthetic/gnu_libstdcpp.py
index b6bf42235ac..fe60edce7e3 100644
--- a/lldb/examples/synthetic/gnu_libstdcpp.py
+++ b/lldb/examples/synthetic/gnu_libstdcpp.py
@@ -237,11 +237,12 @@ class StdVectorSynthProvider:
def get_child_at_index(self, index):
if index >= self.num_children():
return None
- byte_offset = index / 8
- bit_offset = index % 8
- element_size = self.start_p.GetType().GetPointeeType().GetByteSize()
- data = self.start_p.GetPointeeData(byte_offset / element_size)
- bit = data.GetUnsignedInt8(lldb.SBError(), byte_offset % element_size) & (1 << bit_offset)
+ element_type = self.start_p.GetType().GetPointeeType()
+ element_bits = 8 * element_type.GetByteSize()
+ element_offset = index / element_bits
+ bit_offset = index % element_bits
+ element = self.start_p.CreateChildAtOffset('['+str(index)+']',element_offset,element_type)
+ bit = element.GetValueAsUnsigned(0) & (1 << bit_offset)
if bit != 0:
value_expr = "(bool)true"
else: