From ac428267466f8aa4c2e975c703422e0bb73fa7a5 Mon Sep 17 00:00:00 2001 From: Markus Stange Date: Fri, 6 Dec 2024 15:33:34 -0500 Subject: [PATCH] Update to thiserror 2 and zerocopy 0.8. --- Cargo.lock | 56 +++++++++++++++++++--------- samply-api/Cargo.toml | 2 +- samply-symbols/Cargo.toml | 8 ++-- samply-symbols/src/breakpad/index.rs | 23 +++++------- samply-symbols/src/error.rs | 2 +- samply/Cargo.toml | 2 +- wholesym/Cargo.toml | 2 +- 7 files changed, 55 insertions(+), 40 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d25e128d..1b4c4232 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -27,7 +27,7 @@ dependencies = [ "cfg-if", "once_cell", "version_check", - "zerocopy", + "zerocopy 0.7.35", ] [[package]] @@ -705,9 +705,9 @@ dependencies = [ [[package]] name = "framehop" -version = "0.13.1" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf36f12e45e344d8ee069ea1d73657a1ff47967f49beb1bfaf562ecc091aab42" +checksum = "59bdf491caf8284489b65c99366d0f88393709b8214e4ccff2f55d9892da7713" dependencies = [ "arrayvec", "cfg-if", @@ -1408,13 +1408,13 @@ dependencies = [ [[package]] name = "macho-unwind-info" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b6086acc74bc23f56b60e88bb082d505e23849d68d6c0f12bb6a7ad5c60e03e" +checksum = "bb4bdc8b0ce69932332cf76d24af69c3a155242af95c226b2ab6c2e371ed1149" dependencies = [ - "thiserror 1.0.69", - "zerocopy", - "zerocopy-derive", + "thiserror 2.0.4", + "zerocopy 0.8.13", + "zerocopy-derive 0.8.13", ] [[package]] @@ -1665,8 +1665,8 @@ dependencies = [ "arrayvec", "bitflags", "thiserror 1.0.69", - "zerocopy", - "zerocopy-derive", + "zerocopy 0.7.35", + "zerocopy-derive 0.7.35", ] [[package]] @@ -1727,7 +1727,7 @@ version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" dependencies = [ - "zerocopy", + "zerocopy 0.7.35", ] [[package]] @@ -2217,7 +2217,7 @@ dependencies = [ "shlex", "sysctl", "tempfile", - "thiserror 1.0.69", + "thiserror 2.0.4", "tokio", "tokio-util", "uname", @@ -2240,7 +2240,7 @@ dependencies = [ "serde", "serde_derive", "serde_json", - "thiserror 1.0.69", + "thiserror 2.0.4", "yaxpeax-arch", "yaxpeax-arm", "yaxpeax-x86", @@ -2285,12 +2285,12 @@ dependencies = [ "rustc-demangle", "scala-native-demangle", "srcsrv", - "thiserror 1.0.69", + "thiserror 2.0.4", "uuid", "yoke", "yoke-derive", - "zerocopy", - "zerocopy-derive", + "zerocopy 0.8.13", + "zerocopy-derive 0.8.13", ] [[package]] @@ -2966,7 +2966,7 @@ dependencies = [ "samply-symbols", "scopeguard", "symsrv", - "thiserror 1.0.69", + "thiserror 2.0.4", "tokio", "uuid", "yoke", @@ -3406,7 +3406,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" dependencies = [ "byteorder", - "zerocopy-derive", + "zerocopy-derive 0.7.35", +] + +[[package]] +name = "zerocopy" +version = "0.8.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67914ab451f3bfd2e69e5e9d2ef3858484e7074d63f204fd166ec391b54de21d" +dependencies = [ + "zerocopy-derive 0.8.13", ] [[package]] @@ -3420,6 +3429,17 @@ dependencies = [ "syn", ] +[[package]] +name = "zerocopy-derive" +version = "0.8.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7988d73a4303ca289df03316bc490e934accf371af6bc745393cf3c2c5c4f25d" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "zerofrom" version = "0.1.5" diff --git a/samply-api/Cargo.toml b/samply-api/Cargo.toml index d68778a4..b1a6d8f5 100644 --- a/samply-api/Cargo.toml +++ b/samply-api/Cargo.toml @@ -15,7 +15,7 @@ send_futures = ["samply-symbols/send_futures"] [dependencies] samply-symbols = { version = "0.23.0", path = "../samply-symbols" } -thiserror = "1" +thiserror = "2" serde = "1.0.204" serde_derive = "1.0.188" serde_json = "1" diff --git a/samply-symbols/Cargo.toml b/samply-symbols/Cargo.toml index 7717c3dd..56bf68ef 100644 --- a/samply-symbols/Cargo.toml +++ b/samply-symbols/Cargo.toml @@ -34,7 +34,7 @@ version = "0.36" #pdb-addr2line = { path = "../../pdb-addr2line" } pdb-addr2line = "0.11.0" uuid = "1.10.0" -thiserror = "1" +thiserror = "2" cpp_demangle = "0.4.0" msvc-demangler = "0.10.1" rustc-demangle = "0.1.24" @@ -47,14 +47,14 @@ elsa = "1.4.0" memchr = { version = "2.7", default-features = false } srcsrv = "0.2.2" lzma-rs = "0.3" -macho-unwind-info = "0.4.0" +macho-unwind-info = "0.5.0" debugid = "0.8.0" flate2 = "1" yoke = "0.7" yoke-derive = "0.7" nom = "7.1.1" -zerocopy = "0.7" -zerocopy-derive = "0.7" +zerocopy = "0.8" +zerocopy-derive = "0.8" linux-perf-data = "0.10.0" [dev-dependencies] diff --git a/samply-symbols/src/breakpad/index.rs b/samply-symbols/src/breakpad/index.rs index f26ffe0c..f073d9d9 100644 --- a/samply-symbols/src/breakpad/index.rs +++ b/samply-symbols/src/breakpad/index.rs @@ -11,7 +11,7 @@ use nom::error::{Error, ErrorKind, ParseError}; use nom::multi::separated_list1; use nom::sequence::{terminated, tuple}; use nom::{Err, IResult}; -use zerocopy::{AsBytes, LittleEndian, Ref, U32, U64}; +use zerocopy::{IntoBytes, LittleEndian, Ref, U32, U64}; use zerocopy_derive::*; use crate::CodeId; @@ -41,7 +41,7 @@ impl BreakpadIndex { let header_bytes = data .get(..HEADER_SIZE as usize) .ok_or(BreakpadSymindexParseError::FileTooSmallForHeader)?; - let header = Ref::<&[u8], BreakpadSymindexFileHeader>::new_unaligned(header_bytes).unwrap(); + let header = Ref::<&[u8], BreakpadSymindexFileHeader>::from_bytes(header_bytes).unwrap(); if &header.magic != b"SYMINDEX" { return Err(BreakpadSymindexParseError::WrongMagicBytes); } @@ -108,7 +108,7 @@ impl BreakpadIndex { .get(header.file_entries_offset.get() as usize..file_list_end_offset as usize) .ok_or(BreakpadSymindexParseError::CouldntReadFileListBytes)?; let file_list = - Ref::<&[u8], [FileOrInlineOriginEntry]>::new_slice_unaligned(file_list_bytes).unwrap(); + Ref::<&[u8], [FileOrInlineOriginEntry]>::from_bytes(file_list_bytes).unwrap(); let inline_origin_list_bytes_len = header .inline_origin_count .get() @@ -126,8 +126,7 @@ impl BreakpadIndex { ) .ok_or(BreakpadSymindexParseError::CouldntReadInlineOriginListBytes)?; let inline_origin_list = - Ref::<&[u8], [FileOrInlineOriginEntry]>::new_slice_unaligned(inline_origin_list_bytes) - .unwrap(); + Ref::<&[u8], [FileOrInlineOriginEntry]>::from_bytes(inline_origin_list_bytes).unwrap(); let symbol_address_list_bytes_len = header .symbol_count .get() @@ -145,8 +144,7 @@ impl BreakpadIndex { ) .ok_or(BreakpadSymindexParseError::CouldntReadSymbolAddressListBytes)?; let symbol_address_list = - Ref::<&[u8], [U32]>::new_slice_unaligned(symbol_address_list_bytes) - .unwrap(); + Ref::<&[u8], [U32]>::from_bytes(symbol_address_list_bytes).unwrap(); let symbol_entry_list_bytes_len = header .symbol_count .get() @@ -161,10 +159,9 @@ impl BreakpadIndex { .get(header.symbol_entries_offset.get() as usize..symbol_entry_list_end_offset as usize) .ok_or(BreakpadSymindexParseError::CouldntReadSymbolEntryListBytes)?; let symbol_entry_list = - Ref::<&[u8], [SymbolEntry]>::new_slice_unaligned(symbol_entry_list_bytes).unwrap(); + Ref::<&[u8], [SymbolEntry]>::from_bytes(symbol_entry_list_bytes).unwrap(); let files: Vec = file_list - .into_slice() .iter() .map(|entry| BreakpadFileLine { index: entry.index.get(), @@ -173,7 +170,6 @@ impl BreakpadIndex { }) .collect(); let inline_origins: Vec = inline_origin_list - .into_slice() .iter() .map(|entry| BreakpadInlineOriginLine { index: entry.index.get(), @@ -183,7 +179,6 @@ impl BreakpadIndex { .collect(); let symbol_addresses: Vec = symbol_address_list.iter().map(|a| a.get()).collect(); let symbol_offsets: Vec = symbol_entry_list - .into_slice() .iter() .map(|entry| { if entry.kind.get() == SYMBOL_ENTRY_KIND_PUBLIC { @@ -372,7 +367,7 @@ pub enum BreakpadSymindexParseError { CouldntReadSymbolEntryListBytes, } -#[derive(FromZeroes, FromBytes, AsBytes, Unaligned)] +#[derive(FromBytes, KnownLayout, Immutable, IntoBytes, Unaligned)] #[repr(C)] struct BreakpadSymindexFileHeader { /// Always b"SYMINDEX", at 0 @@ -399,7 +394,7 @@ struct BreakpadSymindexFileHeader { symbol_entries_offset: U32, } -#[derive(FromZeroes, FromBytes, AsBytes, Unaligned)] +#[derive(FromBytes, KnownLayout, Immutable, IntoBytes, Unaligned)] #[repr(C)] struct FileOrInlineOriginEntry { pub index: U32, @@ -410,7 +405,7 @@ struct FileOrInlineOriginEntry { const SYMBOL_ENTRY_KIND_PUBLIC: u32 = 0; const SYMBOL_ENTRY_KIND_FUNC: u32 = 1; -#[derive(FromZeroes, FromBytes, AsBytes, Unaligned)] +#[derive(FromBytes, KnownLayout, Immutable, IntoBytes, Unaligned)] #[repr(C)] struct SymbolEntry { /// Uses `SYMBOL_ENTRY_KIND_*` constants (0 for PUBLIC, 1 for FUNC) diff --git a/samply-symbols/src/error.rs b/samply-symbols/src/error.rs index 00bf6c58..832a8905 100644 --- a/samply-symbols/src/error.rs +++ b/samply-symbols/src/error.rs @@ -19,7 +19,7 @@ pub enum Error { #[error("Unmatched breakpad_id: Expected {0}, but received {1:?}")] UnmatchedDebugIdOptional(DebugId, Option), - #[error("Unmatched CodeId: Expected {0}, but received {}", .1.as_ref().map_or("".into(), ToString::to_string))] + #[error("Unmatched CodeId: Expected {0}, but received {recvd}", recvd=.1.as_ref().map_or("".into(), ToString::to_string))] UnmatchedCodeId(CodeId, Option), #[error("The Breakpad sym file was malformed, causing a parsing error: {0}")] diff --git a/samply/Cargo.toml b/samply/Cargo.toml index 5af02101..8f90e946 100644 --- a/samply/Cargo.toml +++ b/samply/Cargo.toml @@ -29,7 +29,7 @@ debugid = "0.8.0" memchr = "2.7.2" memmap2 = "0.9.4" serde_json = "1" -thiserror = "1" +thiserror = "2" tempfile = "3.13" uuid = { version = "1.10.0", features = ["v4"] } percent-encoding = "2.1.0" diff --git a/wholesym/Cargo.toml b/wholesym/Cargo.toml index 7fef331a..622f4e94 100644 --- a/wholesym/Cargo.toml +++ b/wholesym/Cargo.toml @@ -38,7 +38,7 @@ memmap2 = "0.9.4" tokio = { version = "1.38", features = ["fs"] } futures-util = "0.3.30" fs4 = "0.12" -thiserror = "1" +thiserror = "2" async-compression = { version = "0.4", default-features = false, features = [ "tokio", "futures-io",