From dd23fef4f7f7b306828bd5471af2b5bc457846ef Mon Sep 17 00:00:00 2001 From: Benjamin Moir Date: Wed, 3 Jan 2024 03:33:07 +1000 Subject: [PATCH] Support some more MetroWerkz DWARF extensions (#22) * Support FT_MW_int128 * Support OP_MW_FPREG * Support AT_MW_mangled on local variables * cargo fmt --------- Co-authored-by: Luke Street --- src/util/dwarf.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/util/dwarf.rs b/src/util/dwarf.rs index a63356d..0f31215 100644 --- a/src/util/dwarf.rs +++ b/src/util/dwarf.rs @@ -86,6 +86,7 @@ pub enum FundType { LongLong = 0x8008, SignedLongLong = 0x8108, UnsignedLongLong = 0x8208, + Int128 = 0xa510, Vec2x32Float = 0xac00, } @@ -108,6 +109,7 @@ impl FundType { | FundType::SignedLongLong | FundType::UnsignedLongLong | FundType::Vec2x32Float => 8, + FundType::Int128 => 16, FundType::Void => 0, FundType::ExtPrecFloat | FundType::Complex @@ -145,6 +147,7 @@ impl FundType { FundType::LongLong => "long long", FundType::SignedLongLong => "signed long long", FundType::UnsignedLongLong => "unsigned long long", + FundType::Int128 => "__int128", FundType::Vec2x32Float => "__vec2x32float__", }) } @@ -670,6 +673,7 @@ pub struct SubroutineParameter { #[derive(Debug, Clone)] pub struct SubroutineVariable { pub name: Option, + pub mangled_name: Option, pub kind: Type, pub location: Option, } @@ -1478,7 +1482,9 @@ pub const fn register_name(reg: u32) -> &'static str { pub fn process_variable_location(block: &[u8], e: Endian) -> Result { if block.len() == 5 - && (block[0] == LocationOp::Register as u8 || block[0] == LocationOp::BaseRegister as u8) + && (block[0] == LocationOp::Register as u8 + || block[0] == LocationOp::BaseRegister as u8 + || block[0] == LocationOp::MwFpReg as u8) { Ok(register_name(u32::from_bytes(*array_ref!(block, 1, 4), e)).to_string()) } else if block.len() == 5 && block[0] == LocationOp::Address as u8 { @@ -2143,6 +2149,7 @@ fn process_subroutine_parameter_tag(info: &DwarfInfo, tag: &Tag) -> Result Result { ensure!(tag.kind == TagKind::LocalVariable, "{:?} is not a LocalVariable tag", tag.kind); + let mut mangled_name = None; let mut name = None; let mut kind = None; let mut location = None; @@ -2150,6 +2157,7 @@ fn process_local_variable_tag(info: &DwarfInfo, tag: &Tag) -> Result {} (AttributeKind::Name, AttributeValue::String(s)) => name = Some(s.clone()), + (AttributeKind::MwMangled, AttributeValue::String(s)) => mangled_name = Some(s.clone()), ( AttributeKind::FundType | AttributeKind::ModFundType @@ -2188,7 +2196,7 @@ fn process_local_variable_tag(info: &DwarfInfo, tag: &Tag) -> Result Result {