Add GDB pretty-printer for OsString

This commit is contained in:
gentoo90
2017-06-02 16:18:00 +03:00
parent c7ef85ca0e
commit c1f687b73f
3 changed files with 37 additions and 2 deletions

View File

@@ -125,6 +125,9 @@ def rust_pretty_printer_lookup_function(gdb_val):
if type_kind == rustpp.TYPE_KIND_STD_STRING:
return RustStdStringPrinter(val)
if type_kind == rustpp.TYPE_KIND_OS_STRING:
return RustOsStringPrinter(val)
if type_kind == rustpp.TYPE_KIND_TUPLE:
return RustStructPrinter(val,
omit_first_field = False,
@@ -269,6 +272,21 @@ class RustStdStringPrinter(object):
length=length)
class RustOsStringPrinter(object):
def __init__(self, val):
self.__val = val
def to_string(self):
buf = self.__val.get_child_at_index(0)
vec = buf.get_child_at_index(0)
if vec.type.get_unqualified_type_name() == "Wtf8Buf":
vec = vec.get_child_at_index(0)
(length, data_ptr, cap) = rustpp.extract_length_ptr_and_cap_from_std_vec(
vec)
return '"%s"' % data_ptr.get_wrapped_value().string(length=length)
class RustCStyleVariantPrinter(object):
def __init__(self, val):
assert val.type.get_dwarf_type_kind() == rustpp.DWARF_TYPE_CODE_ENUM