lldb: Fix pretty printer for nullable-opt enums with fat pointers.
This commit is contained in:
parent
3a325c666d
commit
886ff4f3c3
2 changed files with 16 additions and 2 deletions
|
|
@ -138,9 +138,14 @@ def print_enum_val(val, internal_dict):
|
|||
return "<invalid enum encoding: %s>" % first_variant_name
|
||||
|
||||
# Read the discriminant
|
||||
disr_val = val.GetChildAtIndex(0).GetChildAtIndex(disr_field_index).GetValueAsUnsigned()
|
||||
disr_val = val.GetChildAtIndex(0).GetChildAtIndex(disr_field_index)
|
||||
|
||||
if disr_val == 0:
|
||||
# If the discriminant field is a fat pointer we have to consider the
|
||||
# first word as the true discriminant
|
||||
if disr_val.GetType().GetTypeClass() == lldb.eTypeClassStruct:
|
||||
disr_val = disr_val.GetChildAtIndex(0)
|
||||
|
||||
if disr_val.GetValueAsUnsigned() == 0:
|
||||
# Null case: Print the name of the null-variant
|
||||
null_variant_name = first_variant_name[last_separator_index + 1:]
|
||||
return null_variant_name
|
||||
|
|
|
|||
|
|
@ -61,6 +61,12 @@
|
|||
// lldb-command:print void_droid
|
||||
// lldb-check:[...]$5 = Void
|
||||
|
||||
// lldb-command:print some_str
|
||||
// lldb-check:[...]$6 = Some(&str { data_ptr: [...], length: 3 })
|
||||
|
||||
// lldb-command:print none_str
|
||||
// lldb-check:[...]$7 = None
|
||||
|
||||
|
||||
// If a struct has exactly two variants, one of them is empty, and the other one
|
||||
// contains a non-nullable pointer, then this value is used as the discriminator.
|
||||
|
|
@ -96,6 +102,9 @@ struct NamedFieldsRepr<'a> {
|
|||
|
||||
fn main() {
|
||||
|
||||
let some_str: Option<&'static str> = Some("abc");
|
||||
let none_str: Option<&'static str> = None;
|
||||
|
||||
let some: Option<&u32> = Some(unsafe { std::mem::transmute(0x12345678u) });
|
||||
let none: Option<&u32> = None;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue