Add separate GDB pretty-printer for empty structs

Use a class without children() method for printing empty structs.
Presence of this method makes GDB's variable objects interface act like
if the struct had children.
This commit is contained in:
gentoo90
2017-06-02 21:18:45 +03:00
parent c1f687b73f
commit b9f9c77103

View File

@@ -100,8 +100,10 @@ def rust_pretty_printer_lookup_function(gdb_val):
val = GdbValue(gdb_val) val = GdbValue(gdb_val)
type_kind = val.type.get_type_kind() type_kind = val.type.get_type_kind()
if (type_kind == rustpp.TYPE_KIND_REGULAR_STRUCT or if type_kind == rustpp.TYPE_KIND_EMPTY:
type_kind == rustpp.TYPE_KIND_EMPTY): return RustEmptyPrinter(val)
if type_kind == rustpp.TYPE_KIND_REGULAR_STRUCT:
return RustStructPrinter(val, return RustStructPrinter(val,
omit_first_field = False, omit_first_field = False,
omit_type_name = False, omit_type_name = False,
@@ -174,6 +176,14 @@ def rust_pretty_printer_lookup_function(gdb_val):
#=------------------------------------------------------------------------------ #=------------------------------------------------------------------------------
# Pretty Printer Classes # Pretty Printer Classes
#=------------------------------------------------------------------------------ #=------------------------------------------------------------------------------
class RustEmptyPrinter(object):
def __init__(self, val):
self.__val = val
def to_string(self):
return self.__val.type.get_unqualified_type_name()
class RustStructPrinter(object): class RustStructPrinter(object):
def __init__(self, val, omit_first_field, omit_type_name, is_tuple_like): def __init__(self, val, omit_first_field, omit_type_name, is_tuple_like):
self.__val = val self.__val = val