summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSterling Augustine <saugustine@google.com>2019-10-01 22:42:37 +0000
committerSterling Augustine <saugustine@google.com>2019-10-01 22:42:37 +0000
commit9b36c1cf278b44d3ac039e60dca93df793d280cd (patch)
tree5fcf3e8c804cdf8658efd38d0f7586b710389653
parent0da163a2cf2e3d90a8f01a3dc748875906d896b9 (diff)
downloadbcm5719-llvm-9b36c1cf278b44d3ac039e60dca93df793d280cd.tar.gz
bcm5719-llvm-9b36c1cf278b44d3ac039e60dca93df793d280cd.zip
Determine endianness at a time when it doesn't inadvertantly clear gdb's wrap_buffer via gdb.execute.
Summary: I haven't managed a small reproduction for this bug, it involves complicated and deeply nested data structures with a wide variety of pretty printers. But in general, we shouldn't be combining gdb's command line interface (via gdb.execute) with pretty-printers. Subscribers: christof, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D68306 llvm-svn: 373402
-rw-r--r--libcxx/utils/gdb/libcxx/printers.py18
1 files changed, 11 insertions, 7 deletions
diff --git a/libcxx/utils/gdb/libcxx/printers.py b/libcxx/utils/gdb/libcxx/printers.py
index dc2f2e97aec..ff45bde6172 100644
--- a/libcxx/utils/gdb/libcxx/printers.py
+++ b/libcxx/utils/gdb/libcxx/printers.py
@@ -27,6 +27,7 @@ _void_pointer_type = gdb.lookup_type("void").pointer()
_long_int_type = gdb.lookup_type("unsigned long long")
+_libcpp_big_endian = False
def addr_as_long(addr):
return int(addr.cast(_long_int_type))
@@ -195,19 +196,14 @@ class StdStringPrinter(object):
field = short_field.type.fields()[1].type.fields()[0]
libcpp_abi_alternate_string_layout = field.name and "__padding" in field.name
- # Strictly, this only tells us the current mode, not how libcxx was
- # compiled.
- libcpp_big_endian = "big endian" in gdb.execute("show endian",
- to_string=True)
-
# This logical structure closely follows the original code (which is clearer
# in C++). Keep them parallel to make them easier to compare.
if libcpp_abi_alternate_string_layout:
- if libcpp_big_endian:
+ if _libcpp_big_endian:
return short_size >> 1
else:
return short_size
- elif libcpp_big_endian:
+ elif _libcpp_big_endian:
return short_size
else:
return short_size >> 1
@@ -969,6 +965,14 @@ _libcxx_printer_name = "libcxx_pretty_printer"
# certain pathological cases. Limit our pretty printers to the progspace.
def _register_libcxx_printers(event):
progspace = event.new_objfile.progspace
+ # It would be ideal to get the endianness at print time, but
+ # gdb.execute clears gdb's internal wrap buffer, removing any values
+ # already generated as part of a larger data structure, and there is
+ # no python api to get the endianness. Mixed-endianness debugging
+ # rare enough that this workaround should be adequate.
+ _libcpp_big_endian = "big endian" in gdb.execute("show endian",
+ to_string=True)
+
if not getattr(progspace, _libcxx_printer_name, False):
print("Loading libc++ pretty-printers.")
gdb.printing.register_pretty_printer(
OpenPOWER on IntegriCloud