From 4ad1c1085d314dda37b843a8167fe477ac2bd38c Mon Sep 17 00:00:00 2001 From: Hanna Kruppe Date: Sun, 19 Jan 2025 15:55:52 +0100 Subject: [PATCH] Support reading zstd compressed DWARF --- samply-symbols/src/dwarf.rs | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/samply-symbols/src/dwarf.rs b/samply-symbols/src/dwarf.rs index 4f011a8b..820aa476 100644 --- a/samply-symbols/src/dwarf.rs +++ b/samply-symbols/src/dwarf.rs @@ -97,24 +97,11 @@ where size: file_range.uncompressed_size, _phantom: PhantomData, }), - CompressionFormat::Zlib => { - let compressed_bytes = data - .read_bytes_at(file_range.offset, file_range.compressed_size) - .ok()?; - - let mut decompressed = Vec::with_capacity(file_range.uncompressed_size as usize); - let mut decompress = flate2::Decompress::new(true); - decompress - .decompress_vec( - compressed_bytes, - &mut decompressed, - flate2::FlushDecompress::Finish, - ) - .ok()?; - - Some(SingleSectionData::Owned(decompressed)) + _ => { + let compressed = file_range.data(data).ok()?; + let decompressed = compressed.decompress().ok()?; + Some(SingleSectionData::Owned(decompressed.into_owned())) } - _ => None, } }