diff --git a/src/btf/enum.rs b/src/btf/enum.rs index d0eb2e5..840cae1 100644 --- a/src/btf/enum.rs +++ b/src/btf/enum.rs @@ -32,7 +32,7 @@ pub struct NamedValue { /// The name of the value pub name: String, - /// The signed value + /// The integer value pub value: IntegerValue, } @@ -50,6 +50,9 @@ struct Data { /// A list of enum values named_value_list: NamedValueList, + + /// True if the enum is signed + signed: bool, } impl Data { @@ -96,6 +99,7 @@ impl Data { name, size: type_header.size_or_type() as usize, named_value_list, + signed, }) } } @@ -103,7 +107,8 @@ impl Data { define_type!(Enum, Data, name: Option, size: usize, - named_value_list: NamedValueList + named_value_list: NamedValueList, + signed: bool ); #[cfg(test)] @@ -151,6 +156,7 @@ mod tests { let type_header = Header::new(&mut reader, &file_header).unwrap(); let r#enum = Enum::new(&mut reader, &file_header, type_header).unwrap(); assert_eq!(*r#enum.size(), 4); + assert!(!*r#enum.signed()); assert!(!r#enum.header().kind_flag()); assert_eq!(r#enum.name().as_deref(), Some("State")); @@ -207,6 +213,7 @@ mod tests { let type_header = Header::new(&mut reader, &file_header).unwrap(); let r#enum = Enum::new(&mut reader, &file_header, type_header).unwrap(); assert_eq!(*r#enum.size(), 4); + assert!(*r#enum.signed()); assert!(r#enum.header().kind_flag()); assert_eq!(r#enum.name().as_deref(), Some("State")); diff --git a/src/btf/enum64.rs b/src/btf/enum64.rs index fdf2e19..dcd37f9 100644 --- a/src/btf/enum64.rs +++ b/src/btf/enum64.rs @@ -32,7 +32,7 @@ pub struct NamedValue { /// The name of the value pub name: String, - /// The signed value + /// The integer value pub value: IntegerValue, } @@ -50,6 +50,9 @@ struct Data { /// A list of enum values named_value_list: NamedValueList, + + /// True if the enum is signed + signed: bool, } impl Data { @@ -96,6 +99,7 @@ impl Data { name, size: type_header.size_or_type() as usize, named_value_list, + signed, }) } } @@ -103,7 +107,8 @@ impl Data { define_type!(Enum64, Data, name: Option, size: usize, - named_value_list: NamedValueList + named_value_list: NamedValueList, + signed: bool ); #[cfg(test)] @@ -151,6 +156,7 @@ mod tests { let type_header = Header::new(&mut reader, &file_header).unwrap(); let enum64 = Enum64::new(&mut reader, &file_header, type_header).unwrap(); assert_eq!(*enum64.size(), 8); + assert!(!*enum64.signed()); assert!(!enum64.header().kind_flag()); assert_eq!(enum64.name().as_deref(), Some("State")); @@ -207,6 +213,7 @@ mod tests { let type_header = Header::new(&mut reader, &file_header).unwrap(); let enum64 = Enum64::new(&mut reader, &file_header, type_header).unwrap(); assert_eq!(*enum64.size(), 8); + assert!(*enum64.signed()); assert!(enum64.header().kind_flag()); assert_eq!(enum64.name().as_deref(), Some("State")); diff --git a/src/btf/type_information.rs b/src/btf/type_information.rs index 05b1f4a..a4481b3 100644 --- a/src/btf/type_information.rs +++ b/src/btf/type_information.rs @@ -817,6 +817,7 @@ mod tests { name: String::from("Enum32Value1"), value: IntegerValue32::Unsigned(0), }], + false, )), ); @@ -834,6 +835,7 @@ mod tests { name: String::from("Enum64Value1"), value: IntegerValue64::Unsigned(0), }], + false, )), );