diff --git a/gdb/kakoune.py b/gdb/kakoune.py index 2192d52f..c64a343a 100644 --- a/gdb/kakoune.py +++ b/gdb/kakoune.py @@ -17,8 +17,8 @@ class ArrayIterator: self.index = self.index + 1 return ('[%d]' % index, (self.data + index).dereference()) -class MemoryView: - """Print a memoryview""" +class ArrayView: + """Print a ArrayView""" def __init__(self, val): self.val = val @@ -31,7 +31,7 @@ class MemoryView: def to_string(self): value_type = self.val.type.template_argument(0).unqualified().strip_typedefs() - return "memoryview<%s>" % (value_type) + return "ArrayView<%s>" % (value_type) class LineAndColumn: """Print a LineAndColumn""" @@ -55,7 +55,6 @@ class BufferIterator: else: return "buffer@(%s, %s)" % (self.val['m_coord']['line'], self.val['m_coord']['column']) -std_str = gdb.lookup_type("std::string") class String: """ Print a String""" @@ -63,8 +62,18 @@ class String: self.val = val def to_string(self): + std_str = gdb.lookup_type("std::string") return self.val.cast(std_str) +class StringView: + """ Print a StringView""" + + def __init__(self, val): + self.val = val + + def to_string(self): + return "\"%s\"" % (self.val['m_data'].string("utf-8", "ignore", self.val['m_length']['m_value'])) + class Option: """ Print a Option""" @@ -103,12 +112,14 @@ class LineCount: def build_pretty_printer(): pp = gdb.printing.RegexpCollectionPrettyPrinter("kakoune") - pp.add_printer('memoryview', '^Kakoune::memoryview<.*>$', MemoryView) + pp.add_printer('ArrayView', '^Kakoune::ArrayView<.*>$', ArrayView) pp.add_printer('LineAndColumn', '^Kakoune::LineAndColumn<.*>$', LineAndColumn) pp.add_printer('ByteCoord', '^Kakoune::ByteCoord$', LineAndColumn) pp.add_printer('CharCoord', '^Kakoune::CharCoord$', LineAndColumn) pp.add_printer('BufferIterator', '^Kakoune::BufferIterator$', BufferIterator) pp.add_printer('String', '^Kakoune::String$', String) + pp.add_printer('StringView', '^Kakoune::StringView$', StringView) + pp.add_printer('SharedString', '^Kakoune::SharedString$', StringView) pp.add_printer('Option', '^Kakoune::Option$', Option) pp.add_printer('LineCount', '^Kakoune::LineCount$', LineCount) pp.add_printer('CharCount', '^Kakoune::CharCount$', CharCount)