diff options
| author | gentoo90 <gentoo90@gmail.com> | 2017-06-02 21:18:45 +0300 |
|---|---|---|
| committer | gentoo90 <gentoo90@gmail.com> | 2017-06-02 21:29:24 +0300 |
| commit | b9f9c7710320ed1973ece7973d5918a09767a7e7 (patch) | |
| tree | c7fd54762c10b4490268bd7ffcd6faff5d7ba0ad | |
| parent | c1f687b73fc76808d8f4555d6f77b7f64e554fa9 (diff) | |
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.
| -rwxr-xr-x | src/etc/gdb_rust_pretty_printing.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/etc/gdb_rust_pretty_printing.py b/src/etc/gdb_rust_pretty_printing.py index d2bc7dd53df..aab15d9ed1e 100755 --- a/src/etc/gdb_rust_pretty_printing.py +++ b/src/etc/gdb_rust_pretty_printing.py @@ -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, @@ -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 |
