From 3d3670bc65a07f1d4dcaca8d0965d3f0ba040101 Mon Sep 17 00:00:00 2001 From: Kelvin Ly Date: Sun, 4 Jan 2015 23:35:29 -0500 Subject: [PATCH] Added fix to LLDB formatter --- src/etc/gdb_rust_pretty_printing.py | 8 ++++---- src/etc/lldb_rust_formatters.py | 24 ++++++++++++------------ 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/etc/gdb_rust_pretty_printing.py b/src/etc/gdb_rust_pretty_printing.py index 3abef3dda83a..6e9aa6e80ce8 100755 --- a/src/etc/gdb_rust_pretty_printing.py +++ b/src/etc/gdb_rust_pretty_printing.py @@ -62,10 +62,10 @@ def rust_pretty_printer_lookup_function(val): assert first_variant_name.startswith("RUST$ENCODED$ENUM$") # This is a space-optimized enum last_separator_index = first_variant_name.rfind("$") - start_index = len("RUST$ENCODED$ENUM") - disr_field_indices = first_variant_name[start_index + 1 : - last_separator_index] - disr_field_indices = [int(index) for index in disr_field_indices.split("$")] + start_index = len("RUST$ENCODED$ENUM$") + disr_field_indices = first_variant_name[start_index : + last_separator_index].split("$") + disr_field_indices = [int(index) for index in disr_field_indices] sole_variant_val = val[enum_members[0]] discriminant = sole_variant_val diff --git a/src/etc/lldb_rust_formatters.py b/src/etc/lldb_rust_formatters.py index f4f1a5121d19..b9bb3ec4fe91 100644 --- a/src/etc/lldb_rust_formatters.py +++ b/src/etc/lldb_rust_formatters.py @@ -79,11 +79,11 @@ def print_struct_val_starting_from(field_start_index, val, internal_dict): has_field_names = type_has_field_names(t) if has_field_names: - template = "%(type_name)s {\n%(body)s\n}" - separator = ", \n" + template = "%(type_name)s {\n%(body)s\n}" + separator = ", \n" else: - template = "%(type_name)s(%(body)s)" - separator = ", " + template = "%(type_name)s(%(body)s)" + separator = ", " if type_name.startswith("("): # this is a tuple, so don't print the type name @@ -125,20 +125,20 @@ def print_enum_val(val, internal_dict): if last_separator_index == -1: return "" % first_variant_name - second_last_separator_index = first_variant_name.rfind("$", 0, last_separator_index) - if second_last_separator_index == -1: - return "" % first_variant_name + start_index = len("RUST$ENCODED$ENUM$") - # Extract index of the discriminator field + # Extract indices of the discriminator field try: - disr_field_index = first_variant_name[second_last_separator_index + 1 : - last_separator_index] - disr_field_index = int(disr_field_index) + disr_field_indices = first_variant_name[start_index : + last_separator_index].split("$") + disr_field_indices = [int(index) for index in dis_field_indices] except: return "" % first_variant_name # Read the discriminant - disr_val = val.GetChildAtIndex(0).GetChildAtIndex(disr_field_index) + disr_val = val.GetChildAtIndex(0) + for index in disr_field_indices: + disr_val = disr_val.GetChildAtIndex(disr_field_index) # If the discriminant field is a fat pointer we have to consider the # first word as the true discriminant