From 67ba096cc30ec0f5fac8deec23d5557012e33d27 Mon Sep 17 00:00:00 2001 From: Michael Woerister Date: Wed, 26 Nov 2014 17:42:32 +0100 Subject: [PATCH] debuginfo: Fix LLDB pretty printer for enum variants with zero fields. --- src/etc/lldb_rust_formatters.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/etc/lldb_rust_formatters.py b/src/etc/lldb_rust_formatters.py index 642235ed4e38..7924d63c8e0d 100644 --- a/src/etc/lldb_rust_formatters.py +++ b/src/etc/lldb_rust_formatters.py @@ -69,8 +69,14 @@ def print_struct_val_starting_from(field_start_index, val, internal_dict): assert val.GetType().GetTypeClass() == lldb.eTypeClassStruct t = val.GetType() - has_field_names = type_has_field_names(t) type_name = extract_type_name(t.GetName()) + num_children = val.num_children + + if (num_children - field_start_index) == 0: + # The only field of this struct is the enum discriminant + return type_name + + has_field_names = type_has_field_names(t) if has_field_names: template = "%(type_name)s {\n%(body)s\n}" @@ -83,8 +89,6 @@ def print_struct_val_starting_from(field_start_index, val, internal_dict): # this is a tuple, so don't print the type name type_name = "" - num_children = val.num_children - def render_child(child_index): this = "" if has_field_names: @@ -105,7 +109,6 @@ def print_enum_val(val, internal_dict): assert val.GetType().GetTypeClass() == lldb.eTypeClassUnion - if val.num_children == 1: # This is either an enum with just one variant, or it is an Option-like enum # where the discriminant is encoded in a non-nullable pointer field. We find