Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to thiserror 2 and zerocopy 0.8. #443

Merged
merged 1 commit into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 38 additions & 18 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion samply-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 4 additions & 4 deletions samply-symbols/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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]
Expand Down
23 changes: 9 additions & 14 deletions samply-symbols/src/breakpad/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -145,8 +144,7 @@ impl BreakpadIndex {
)
.ok_or(BreakpadSymindexParseError::CouldntReadSymbolAddressListBytes)?;
let symbol_address_list =
Ref::<&[u8], [U32<LittleEndian>]>::new_slice_unaligned(symbol_address_list_bytes)
.unwrap();
Ref::<&[u8], [U32<LittleEndian>]>::from_bytes(symbol_address_list_bytes).unwrap();
let symbol_entry_list_bytes_len = header
.symbol_count
.get()
Expand All @@ -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<BreakpadFileLine> = file_list
.into_slice()
.iter()
.map(|entry| BreakpadFileLine {
index: entry.index.get(),
Expand All @@ -173,7 +170,6 @@ impl BreakpadIndex {
})
.collect();
let inline_origins: Vec<BreakpadInlineOriginLine> = inline_origin_list
.into_slice()
.iter()
.map(|entry| BreakpadInlineOriginLine {
index: entry.index.get(),
Expand All @@ -183,7 +179,6 @@ impl BreakpadIndex {
.collect();
let symbol_addresses: Vec<u32> = symbol_address_list.iter().map(|a| a.get()).collect();
let symbol_offsets: Vec<BreakpadSymbolType> = symbol_entry_list
.into_slice()
.iter()
.map(|entry| {
if entry.kind.get() == SYMBOL_ENTRY_KIND_PUBLIC {
Expand Down Expand Up @@ -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
Expand All @@ -399,7 +394,7 @@ struct BreakpadSymindexFileHeader {
symbol_entries_offset: U32<LittleEndian>,
}

#[derive(FromZeroes, FromBytes, AsBytes, Unaligned)]
#[derive(FromBytes, KnownLayout, Immutable, IntoBytes, Unaligned)]
#[repr(C)]
struct FileOrInlineOriginEntry {
pub index: U32<LittleEndian>,
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion samply-symbols/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub enum Error {
#[error("Unmatched breakpad_id: Expected {0}, but received {1:?}")]
UnmatchedDebugIdOptional(DebugId, Option<DebugId>),

#[error("Unmatched CodeId: Expected {0}, but received {}", .1.as_ref().map_or("<none>".into(), ToString::to_string))]
#[error("Unmatched CodeId: Expected {0}, but received {recvd}", recvd=.1.as_ref().map_or("<none>".into(), ToString::to_string))]
UnmatchedCodeId(CodeId, Option<CodeId>),

#[error("The Breakpad sym file was malformed, causing a parsing error: {0}")]
Expand Down
2 changes: 1 addition & 1 deletion samply/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion wholesym/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading