Skip to content

Commit b9f9c77

Browse files
committed
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.
1 parent c1f687b commit b9f9c77

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/etc/gdb_rust_pretty_printing.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,10 @@ def rust_pretty_printer_lookup_function(gdb_val):
100100
val = GdbValue(gdb_val)
101101
type_kind = val.type.get_type_kind()
102102

103-
if (type_kind == rustpp.TYPE_KIND_REGULAR_STRUCT or
104-
type_kind == rustpp.TYPE_KIND_EMPTY):
103+
if type_kind == rustpp.TYPE_KIND_EMPTY:
104+
return RustEmptyPrinter(val)
105+
106+
if type_kind == rustpp.TYPE_KIND_REGULAR_STRUCT:
105107
return RustStructPrinter(val,
106108
omit_first_field = False,
107109
omit_type_name = False,
@@ -174,6 +176,14 @@ def rust_pretty_printer_lookup_function(gdb_val):
174176
#=------------------------------------------------------------------------------
175177
# Pretty Printer Classes
176178
#=------------------------------------------------------------------------------
179+
class RustEmptyPrinter(object):
180+
def __init__(self, val):
181+
self.__val = val
182+
183+
def to_string(self):
184+
return self.__val.type.get_unqualified_type_name()
185+
186+
177187
class RustStructPrinter(object):
178188
def __init__(self, val, omit_first_field, omit_type_name, is_tuple_like):
179189
self.__val = val

0 commit comments

Comments
 (0)