Skip to content

Commit

Permalink
debuginfo: Fix LLDB pretty printer for enum variants with zero fields.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelwoerister committed Nov 26, 2014
1 parent 7608d06 commit 67ba096
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/etc/lldb_rust_formatters.py
Expand Up @@ -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}"
Expand All @@ -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:
Expand All @@ -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
Expand Down

5 comments on commit 67ba096

@bors
Copy link
Contributor

@bors bors commented on 67ba096 Nov 26, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from alexcrichton
at michaelwoerister@67ba096

@bors
Copy link
Contributor

@bors bors commented on 67ba096 Nov 26, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging michaelwoerister/rust/lldb-scripts = 67ba096 into auto

@bors
Copy link
Contributor

@bors bors commented on 67ba096 Nov 26, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

michaelwoerister/rust/lldb-scripts = 67ba096 merged ok, testing candidate = 6faff24

@bors
Copy link
Contributor

@bors bors commented on 67ba096 Nov 26, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on 67ba096 Nov 26, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = 6faff24

Please sign in to comment.