Skip to content

Commit

Permalink
Add separate GDB pretty-printer for empty structs
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
gentoo90 committed Jun 2, 2017
1 parent c1f687b commit b9f9c77
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/etc/gdb_rust_pretty_printing.py
Expand Up @@ -100,8 +100,10 @@ def rust_pretty_printer_lookup_function(gdb_val):
val = GdbValue(gdb_val)
type_kind = val.type.get_type_kind()

if (type_kind == rustpp.TYPE_KIND_REGULAR_STRUCT or
type_kind == rustpp.TYPE_KIND_EMPTY):
if type_kind == rustpp.TYPE_KIND_EMPTY:
return RustEmptyPrinter(val)

if type_kind == rustpp.TYPE_KIND_REGULAR_STRUCT:
return RustStructPrinter(val,
omit_first_field = False,
omit_type_name = False,
Expand Down Expand Up @@ -174,6 +176,14 @@ def rust_pretty_printer_lookup_function(gdb_val):
#=------------------------------------------------------------------------------
# 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):
def __init__(self, val, omit_first_field, omit_type_name, is_tuple_like):
self.__val = val
Expand Down

0 comments on commit b9f9c77

Please sign in to comment.