From 9377836dfb2bf9c618b5d9436c9afa23b524dbab Mon Sep 17 00:00:00 2001 From: Kyle Huey Date: Mon, 17 Apr 2023 19:28:03 -0700 Subject: [PATCH 1/7] Bump addr2line to 0.20 and support packaged split DWARF. --- Cargo.toml | 2 +- src/symbolize/gimli.rs | 53 ++++++++++++++++++++++++++++++++++-- src/symbolize/gimli/elf.rs | 43 +++++++++++++++++++++++------ src/symbolize/gimli/stash.rs | 19 +++++++++++++ 4 files changed, 105 insertions(+), 12 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 477909111..7e48a0026 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,7 +37,7 @@ rustc-serialize = { version = "0.3", optional = true } # Optionally demangle C++ frames' symbols in backtraces. cpp_demangle = { default-features = false, version = "0.4.0", optional = true, features = ["alloc"] } -addr2line = { version = "0.19.0", default-features = false } +addr2line = { version = "0.20.0", default-features = false } miniz_oxide = { version = "0.6.0", default-features = false } [dependencies.object] diff --git a/src/symbolize/gimli.rs b/src/symbolize/gimli.rs index cd4cec58c..66ba26faf 100644 --- a/src/symbolize/gimli.rs +++ b/src/symbolize/gimli.rs @@ -105,6 +105,7 @@ impl Mapping { struct Context<'a> { dwarf: addr2line::Context>, object: Object<'a>, + package: Option>>, } impl<'data> Context<'data> { @@ -112,6 +113,7 @@ impl<'data> Context<'data> { stash: &'data Stash, object: Object<'data>, sup: Option>, + dwp: Option>, ) -> Option> { let mut sections = gimli::Dwarf::load(|id| -> Result<_, ()> { let data = object.section(stash, id.name()).unwrap_or(&[]); @@ -129,7 +131,52 @@ impl<'data> Context<'data> { } let dwarf = addr2line::Context::from_dwarf(sections).ok()?; - Some(Context { dwarf, object }) + let mut package = None; + if let Some(dwp) = dwp { + package = Some( + gimli::DwarfPackage::load( + |id| -> Result<_, gimli::Error> { + let data = dwp.section(stash, id.dwo_name().unwrap()).unwrap_or(&[]); + Ok(EndianSlice::new(data, Endian)) + }, + EndianSlice::new(&[], Endian), + ) + .ok()?, + ); + } + + Some(Context { + dwarf, + object, + package, + }) + } + + fn find_frames( + &'_ self, + probe: u64, + ) -> gimli::Result>> { + use addr2line::{LookupContinuation, LookupResult}; + use alloc::sync::Arc; + + let mut l = self.dwarf.find_frames(probe); + loop { + let (load, continuation) = match l { + LookupResult::Output(output) => break output, + LookupResult::Load { load, continuation } => (load, continuation), + }; + + let mut r: Option>> = None; + if let Some(dwp) = self.package.as_ref() { + if let Ok(Some(cu)) = dwp.find_cu(load.dwo_id, &load.parent) { + r = Some(Arc::new(cu)); + } + } + + // TODO: support unpacked split DWARF. + + l = continuation.resume(r); + } } } @@ -358,7 +405,7 @@ pub unsafe fn resolve(what: ResolveWhat<'_>, cb: &mut dyn FnMut(&super::Symbol)) None => return, }; let mut any_frames = false; - if let Ok(mut frames) = cx.dwarf.find_frames(addr as u64) { + if let Ok(mut frames) = cx.find_frames(addr as u64) { while let Ok(Some(frame)) = frames.next() { any_frames = true; let name = match frame.function { @@ -374,7 +421,7 @@ pub unsafe fn resolve(what: ResolveWhat<'_>, cb: &mut dyn FnMut(&super::Symbol)) } if !any_frames { if let Some((object_cx, object_addr)) = cx.object.search_object_map(addr as u64) { - if let Ok(mut frames) = object_cx.dwarf.find_frames(object_addr) { + if let Ok(mut frames) = object_cx.find_frames(object_addr) { while let Ok(Some(frame)) = frames.next() { any_frames = true; call(Symbol::Frame { diff --git a/src/symbolize/gimli/elf.rs b/src/symbolize/gimli/elf.rs index bc71ee2c9..c8b73616d 100644 --- a/src/symbolize/gimli/elf.rs +++ b/src/symbolize/gimli/elf.rs @@ -24,24 +24,26 @@ impl Mapping { // Try to locate an external debug file using the build ID. if let Some(path_debug) = object.build_id().and_then(locate_build_id) { - if let Some(mapping) = Mapping::new_debug(path_debug, None) { + if let Some(mapping) = Mapping::new_debug(path, path_debug, None) { return Some(Either::A(mapping)); } } // Try to locate an external debug file using the GNU debug link section. if let Some((path_debug, crc)) = object.gnu_debuglink_path(path) { - if let Some(mapping) = Mapping::new_debug(path_debug, Some(crc)) { + if let Some(mapping) = Mapping::new_debug(path, path_debug, Some(crc)) { return Some(Either::A(mapping)); } } - Context::new(stash, object, None).map(Either::B) + let dwp = Mapping::load_dwarf_package(path, stash); + + Context::new(stash, object, None, dwp).map(Either::B) }) } /// Load debuginfo from an external debug file. - fn new_debug(path: PathBuf, crc: Option) -> Option { + fn new_debug(original_path: &Path, path: PathBuf, crc: Option) -> Option { let map = super::mmap(&path)?; Mapping::mk(map, |map, stash| { let object = Object::parse(&map)?; @@ -51,20 +53,45 @@ impl Mapping { } // Try to locate a supplementary object file. + let mut sup = None; if let Some((path_sup, build_id_sup)) = object.gnu_debugaltlink_path(&path) { if let Some(map_sup) = super::mmap(&path_sup) { let map_sup = stash.set_mmap_aux(map_sup); - if let Some(sup) = Object::parse(map_sup) { - if sup.build_id() == Some(build_id_sup) { - return Context::new(stash, object, Some(sup)); + if let Some(sup_) = Object::parse(map_sup) { + if sup_.build_id() == Some(build_id_sup) { + sup = Some(sup_); } } } } - Context::new(stash, object, None) + let dwp = Mapping::load_dwarf_package(original_path, stash); + + Context::new(stash, object, sup, dwp) }) } + + /// Try to locate a DWARF package file. + fn load_dwarf_package<'data>(path: &Path, stash: &'data Stash) -> Option> { + let mut path_dwp = path.to_path_buf(); + let dwp_extension = path + .extension() + .map(|previous_extension| { + let mut previous_extension = previous_extension.to_os_string(); + previous_extension.push(".dwp"); + previous_extension + }) + .unwrap_or_else(|| "dwp".into()); + path_dwp.set_extension(dwp_extension); + if let Some(map_dwp) = super::mmap(&path_dwp) { + let map_dwp = stash.set_mmap_dwp(map_dwp); + if let Some(dwp_) = Object::parse(map_dwp) { + return Some(dwp_); + } + } + + None + } } struct ParsedSym { diff --git a/src/symbolize/gimli/stash.rs b/src/symbolize/gimli/stash.rs index 3adfc598a..dd1e04653 100644 --- a/src/symbolize/gimli/stash.rs +++ b/src/symbolize/gimli/stash.rs @@ -10,6 +10,7 @@ use core::cell::UnsafeCell; pub struct Stash { buffers: UnsafeCell>>, mmap_aux: UnsafeCell>, + mmap_dwp: UnsafeCell>, } impl Stash { @@ -17,6 +18,7 @@ impl Stash { Stash { buffers: UnsafeCell::new(Vec::new()), mmap_aux: UnsafeCell::new(None), + mmap_dwp: UnsafeCell::new(None), } } @@ -49,4 +51,21 @@ impl Stash { mmap_aux.as_ref().unwrap() } } + + /// Stores a `Mmap` for the lifetime of this `Stash`, returning a pointer + /// which is scoped to just this lifetime. + pub fn set_mmap_dwp(&self, map: Mmap) -> &[u8] { + // SAFETY: this is the only location for a mutable pointer to + // `mmap_dwp`, and this structure isn't threadsafe to shared across + // threads either. This also is careful to store at most one `mmap_dwp` + // since overwriting a previous one would invalidate the previous + // pointer. Given that though we can safely return a pointer to our + // interior-owned contents. + unsafe { + let mmap_dwp = &mut *self.mmap_dwp.get(); + assert!(mmap_dwp.is_none()); + *mmap_dwp = Some(map); + mmap_dwp.as_ref().unwrap() + } + } } From 35898f16b0db23207c6f2d4b63c652ac147533fe Mon Sep 17 00:00:00 2001 From: Kyle Huey Date: Mon, 17 Apr 2023 19:35:12 -0700 Subject: [PATCH 2/7] Bump addr2line version in as-if-std too. --- crates/as-if-std/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/as-if-std/Cargo.toml b/crates/as-if-std/Cargo.toml index c763227f2..655f47f90 100644 --- a/crates/as-if-std/Cargo.toml +++ b/crates/as-if-std/Cargo.toml @@ -15,7 +15,7 @@ bench = false cfg-if = "1.0" rustc-demangle = "0.1.4" libc = { version = "0.2.45", default-features = false } -addr2line = { version = "0.16.0", default-features = false, optional = true } +addr2line = { version = "0.20.0", default-features = false, optional = true } miniz_oxide = { version = "0.4.0", default-features = false } [dependencies.object] From 7536d435d12f6be9bd49d966228c5e8d3fedce9c Mon Sep 17 00:00:00 2001 From: Kyle Huey Date: Mon, 17 Apr 2023 19:43:01 -0700 Subject: [PATCH 3/7] Fix compilation on Mac and Windows. --- src/symbolize/gimli/coff.rs | 2 +- src/symbolize/gimli/macho.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/symbolize/gimli/coff.rs b/src/symbolize/gimli/coff.rs index 84d334207..754816be7 100644 --- a/src/symbolize/gimli/coff.rs +++ b/src/symbolize/gimli/coff.rs @@ -14,7 +14,7 @@ impl Mapping { pub fn new(path: &Path) -> Option { let map = super::mmap(path)?; Mapping::mk(map, |data, stash| { - Context::new(stash, Object::parse(data)?, None) + Context::new(stash, Object::parse(data)?, None, None) }) } } diff --git a/src/symbolize/gimli/macho.rs b/src/symbolize/gimli/macho.rs index adea97a09..5baa148ec 100644 --- a/src/symbolize/gimli/macho.rs +++ b/src/symbolize/gimli/macho.rs @@ -45,7 +45,7 @@ impl Mapping { let (macho, data) = find_header(data)?; let endian = macho.endian().ok()?; let obj = Object::parse(macho, endian, data)?; - Context::new(stash, obj, None) + Context::new(stash, obj, None, None) }) } @@ -82,7 +82,7 @@ impl Mapping { return None; } let obj = Object::parse(macho, endian, data)?; - Context::new(stash, obj, None) + Context::new(stash, obj, None, None) }); if let Some(candidate) = candidate { return Some(candidate); @@ -309,7 +309,7 @@ fn object_mapping(path: &[u8]) -> Option { let (macho, data) = find_header(data)?; let endian = macho.endian().ok()?; let obj = Object::parse(macho, endian, data)?; - Context::new(stash, obj, None) + Context::new(stash, obj, None, None) }) } From 6592a5178218f34502a2a89e2cd30cf10aead295 Mon Sep 17 00:00:00 2001 From: Kyle Huey Date: Wed, 19 Apr 2023 21:59:42 -0700 Subject: [PATCH 4/7] Support unpackaged split DWARF. --- src/symbolize/gimli.rs | 47 +++++++++++++++-------------- src/symbolize/gimli/coff.rs | 8 +++++ src/symbolize/gimli/elf.rs | 57 ++++++++++++++++++++++++++++++++++-- src/symbolize/gimli/macho.rs | 8 +++++ src/symbolize/gimli/stash.rs | 41 +++++++------------------- 5 files changed, 103 insertions(+), 58 deletions(-) diff --git a/src/symbolize/gimli.rs b/src/symbolize/gimli.rs index 66ba26faf..a48c6860d 100644 --- a/src/symbolize/gimli.rs +++ b/src/symbolize/gimli.rs @@ -58,7 +58,7 @@ struct Mapping { // 'static lifetime is a lie to hack around lack of support for self-referential structs. cx: Context<'static>, _map: Mmap, - _stash: Stash, + stash: Stash, } enum Either { @@ -97,7 +97,7 @@ impl Mapping { // only borrow `map` and `stash` and we're preserving them below. cx: unsafe { core::mem::transmute::, Context<'static>>(cx) }, _map: data, - _stash: stash, + stash: stash, }) } } @@ -136,7 +136,10 @@ impl<'data> Context<'data> { package = Some( gimli::DwarfPackage::load( |id| -> Result<_, gimli::Error> { - let data = dwp.section(stash, id.dwo_name().unwrap()).unwrap_or(&[]); + let data = id + .dwo_name() + .and_then(|name| dwp.section(stash, name)) + .unwrap_or(&[]); Ok(EndianSlice::new(data, Endian)) }, EndianSlice::new(&[], Endian), @@ -154,10 +157,10 @@ impl<'data> Context<'data> { fn find_frames( &'_ self, + stash: &'data Stash, probe: u64, ) -> gimli::Result>> { use addr2line::{LookupContinuation, LookupResult}; - use alloc::sync::Arc; let mut l = self.dwarf.find_frames(probe); loop { @@ -166,16 +169,7 @@ impl<'data> Context<'data> { LookupResult::Load { load, continuation } => (load, continuation), }; - let mut r: Option>> = None; - if let Some(dwp) = self.package.as_ref() { - if let Ok(Some(cu)) = dwp.find_cu(load.dwo_id, &load.parent) { - r = Some(Arc::new(cu)); - } - } - - // TODO: support unpacked split DWARF. - - l = continuation.resume(r); + l = continuation.resume(handle_split_dwarf(self.package.as_ref(), stash, load)); } } } @@ -189,7 +183,7 @@ fn mmap(path: &Path) -> Option { cfg_if::cfg_if! { if #[cfg(windows)] { mod coff; - use self::coff::Object; + use self::coff::{handle_split_dwarf, Object}; } else if #[cfg(any( target_os = "macos", target_os = "ios", @@ -197,10 +191,10 @@ cfg_if::cfg_if! { target_os = "watchos", ))] { mod macho; - use self::macho::Object; + use self::macho::{handle_split_dwarf, Object}; } else { mod elf; - use self::elf::Object; + use self::elf::{handle_split_dwarf, Object}; } } @@ -349,7 +343,7 @@ impl Cache { .next() } - fn mapping_for_lib<'a>(&'a mut self, lib: usize) -> Option<&'a mut Context<'a>> { + fn mapping_for_lib<'a>(&'a mut self, lib: usize) -> Option<(&'a mut Context<'a>, &'a Stash)> { let idx = self.mappings.iter().position(|(idx, _)| *idx == lib); // Invariant: after this conditional completes without early returning @@ -375,10 +369,15 @@ impl Cache { self.mappings.insert(0, (lib, mapping)); } - let cx: &'a mut Context<'static> = &mut self.mappings[0].1.cx; + let mapping = &mut self.mappings[0].1; + let cx: &'a mut Context<'static> = &mut mapping.cx; + let stash: &'a Stash = &mapping.stash; // don't leak the `'static` lifetime, make sure it's scoped to just // ourselves - Some(unsafe { mem::transmute::<&'a mut Context<'static>, &'a mut Context<'a>>(cx) }) + Some(( + unsafe { mem::transmute::<&'a mut Context<'static>, &'a mut Context<'a>>(cx) }, + stash, + )) } } @@ -400,12 +399,12 @@ pub unsafe fn resolve(what: ResolveWhat<'_>, cb: &mut dyn FnMut(&super::Symbol)) // Finally, get a cached mapping or create a new mapping for this file, and // evaluate the DWARF info to find the file/line/name for this address. - let cx = match cache.mapping_for_lib(lib) { - Some(cx) => cx, + let (cx, stash) = match cache.mapping_for_lib(lib) { + Some((cx, stash)) => (cx, stash), None => return, }; let mut any_frames = false; - if let Ok(mut frames) = cx.find_frames(addr as u64) { + if let Ok(mut frames) = cx.find_frames(stash, addr as u64) { while let Ok(Some(frame)) = frames.next() { any_frames = true; let name = match frame.function { @@ -421,7 +420,7 @@ pub unsafe fn resolve(what: ResolveWhat<'_>, cb: &mut dyn FnMut(&super::Symbol)) } if !any_frames { if let Some((object_cx, object_addr)) = cx.object.search_object_map(addr as u64) { - if let Ok(mut frames) = object_cx.find_frames(object_addr) { + if let Ok(mut frames) = object_cx.find_frames(stash, object_addr) { while let Ok(Some(frame)) = frames.next() { any_frames = true; call(Symbol::Frame { diff --git a/src/symbolize/gimli/coff.rs b/src/symbolize/gimli/coff.rs index 754816be7..dc039a800 100644 --- a/src/symbolize/gimli/coff.rs +++ b/src/symbolize/gimli/coff.rs @@ -106,3 +106,11 @@ impl<'a> Object<'a> { None } } + +pub(super) fn handle_split_dwarf<'data>( + package: Option<&gimli::DwarfPackage>>, + stash: &'data Stash, + load: addr2line::SplitDwarfLoad>, +) -> Option>>> { + None +} diff --git a/src/symbolize/gimli/elf.rs b/src/symbolize/gimli/elf.rs index c8b73616d..f1f215211 100644 --- a/src/symbolize/gimli/elf.rs +++ b/src/symbolize/gimli/elf.rs @@ -3,7 +3,8 @@ use super::mystd::fs; use super::mystd::os::unix::ffi::{OsStrExt, OsStringExt}; use super::mystd::path::{Path, PathBuf}; use super::Either; -use super::{Context, Mapping, Stash, Vec}; +use super::{gimli, Context, Endian, EndianSlice, Mapping, Stash, Vec}; +use alloc::sync::Arc; use core::convert::{TryFrom, TryInto}; use core::str; use object::elf::{ELFCOMPRESS_ZLIB, ELF_NOTE_GNU, NT_GNU_BUILD_ID, SHF_COMPRESSED}; @@ -56,7 +57,7 @@ impl Mapping { let mut sup = None; if let Some((path_sup, build_id_sup)) = object.gnu_debugaltlink_path(&path) { if let Some(map_sup) = super::mmap(&path_sup) { - let map_sup = stash.set_mmap_aux(map_sup); + let map_sup = stash.cache_mmap(map_sup); if let Some(sup_) = Object::parse(map_sup) { if sup_.build_id() == Some(build_id_sup) { sup = Some(sup_); @@ -84,7 +85,7 @@ impl Mapping { .unwrap_or_else(|| "dwp".into()); path_dwp.set_extension(dwp_extension); if let Some(map_dwp) = super::mmap(&path_dwp) { - let map_dwp = stash.set_mmap_dwp(map_dwp); + let map_dwp = stash.cache_mmap(map_dwp); if let Some(dwp_) = Object::parse(map_dwp) { return Some(dwp_); } @@ -448,3 +449,53 @@ fn locate_debugaltlink(path: &Path, filename: &[u8], build_id: &[u8]) -> Option< locate_build_id(build_id) } + +fn convert_path(r: &R) -> Result { + let bytes = r.to_slice()?; + Ok(PathBuf::from(OsStr::from_bytes(&bytes))) +} + +pub(super) fn handle_split_dwarf<'data>( + package: Option<&gimli::DwarfPackage>>, + stash: &'data Stash, + load: addr2line::SplitDwarfLoad>, +) -> Option>>> { + if let Some(dwp) = package.as_ref() { + if let Ok(Some(cu)) = dwp.find_cu(load.dwo_id, &load.parent) { + return Some(Arc::new(cu)); + } + } + + let mut path = PathBuf::new(); + if let Some(p) = load.comp_dir.as_ref() { + if let Ok(p) = convert_path(p) { + path.push(p); + } + } + + if let Some(p) = load.path.as_ref() { + if let Ok(p) = convert_path(p) { + path.push(p); + } + } + + if let Some(map_dwo) = super::mmap(&path) { + let map_dwo = stash.cache_mmap(map_dwo); + if let Some(dwo) = Object::parse(map_dwo) { + return gimli::Dwarf::load(|id| -> Result<_, ()> { + let data = id + .dwo_name() + .and_then(|name| dwo.section(stash, name)) + .unwrap_or(&[]); + Ok(EndianSlice::new(data, Endian)) + }) + .ok() + .map(|mut dwo_dwarf| { + dwo_dwarf.make_dwo(&load.parent); + Arc::new(dwo_dwarf) + }); + } + } + + None +} diff --git a/src/symbolize/gimli/macho.rs b/src/symbolize/gimli/macho.rs index 5baa148ec..95a2c75c1 100644 --- a/src/symbolize/gimli/macho.rs +++ b/src/symbolize/gimli/macho.rs @@ -322,3 +322,11 @@ fn split_archive_path(path: &[u8]) -> Option<(&[u8], &[u8])> { let (archive, rest) = path.split_at(index); Some((archive, &rest[1..])) } + +pub(super) fn handle_split_dwarf<'data>( + package: Option<&gimli::DwarfPackage>>, + stash: &'data Stash, + load: addr2line::SplitDwarfLoad>, +) -> Option>>> { + None +} diff --git a/src/symbolize/gimli/stash.rs b/src/symbolize/gimli/stash.rs index dd1e04653..792f9a6f8 100644 --- a/src/symbolize/gimli/stash.rs +++ b/src/symbolize/gimli/stash.rs @@ -9,16 +9,14 @@ use core::cell::UnsafeCell; /// A simple arena allocator for byte buffers. pub struct Stash { buffers: UnsafeCell>>, - mmap_aux: UnsafeCell>, - mmap_dwp: UnsafeCell>, + mmaps: UnsafeCell>, } impl Stash { pub fn new() -> Stash { Stash { buffers: UnsafeCell::new(Vec::new()), - mmap_aux: UnsafeCell::new(None), - mmap_dwp: UnsafeCell::new(None), + mmaps: UnsafeCell::new(Vec::new()), } } @@ -37,35 +35,16 @@ impl Stash { /// Stores a `Mmap` for the lifetime of this `Stash`, returning a pointer /// which is scoped to just this lifetime. - pub fn set_mmap_aux(&self, map: Mmap) -> &[u8] { + pub fn cache_mmap(&self, map: Mmap) -> &[u8] { // SAFETY: this is the only location for a mutable pointer to - // `mmap_aux`, and this structure isn't threadsafe to shared across - // threads either. This also is careful to store at most one `mmap_aux` - // since overwriting a previous one would invalidate the previous - // pointer. Given that though we can safely return a pointer to our - // interior-owned contents. + // `mmaps`, and this structure isn't threadsafe to shared across + // threads either. We also never remove elements from `self.mmaps`, + // so a reference to the data inside the map will live as long as + // `self` does. unsafe { - let mmap_aux = &mut *self.mmap_aux.get(); - assert!(mmap_aux.is_none()); - *mmap_aux = Some(map); - mmap_aux.as_ref().unwrap() - } - } - - /// Stores a `Mmap` for the lifetime of this `Stash`, returning a pointer - /// which is scoped to just this lifetime. - pub fn set_mmap_dwp(&self, map: Mmap) -> &[u8] { - // SAFETY: this is the only location for a mutable pointer to - // `mmap_dwp`, and this structure isn't threadsafe to shared across - // threads either. This also is careful to store at most one `mmap_dwp` - // since overwriting a previous one would invalidate the previous - // pointer. Given that though we can safely return a pointer to our - // interior-owned contents. - unsafe { - let mmap_dwp = &mut *self.mmap_dwp.get(); - assert!(mmap_dwp.is_none()); - *mmap_dwp = Some(map); - mmap_dwp.as_ref().unwrap() + let mmaps = &mut *self.mmaps.get(); + mmaps.push(map); + mmaps.last().unwrap() } } } From e55db1c0041ac81701de90730e9fb6430fd07574 Mon Sep 17 00:00:00 2001 From: Kyle Huey Date: Tue, 18 Apr 2023 08:44:49 -0700 Subject: [PATCH 5/7] Bump MSRV to 1.55. --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 24d814363..29fff2795 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -229,7 +229,7 @@ jobs: with: submodules: true - name: Install Rust - run: rustup update 1.42.0 && rustup default 1.42.0 + run: rustup update 1.55.0 && rustup default 1.55.0 - run: cargo build miri: From 7f72ec9e98889daae512819f3510b751cb2312f1 Mon Sep 17 00:00:00 2001 From: Kyle Huey Date: Wed, 19 Apr 2023 22:07:03 -0700 Subject: [PATCH 6/7] Fix Mac and Windows builds. --- src/symbolize/gimli/coff.rs | 9 +++++---- src/symbolize/gimli/macho.rs | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/symbolize/gimli/coff.rs b/src/symbolize/gimli/coff.rs index dc039a800..7b78ca297 100644 --- a/src/symbolize/gimli/coff.rs +++ b/src/symbolize/gimli/coff.rs @@ -1,4 +1,5 @@ -use super::{Context, Mapping, Path, Stash, Vec}; +use super::{gimli, Context, Endian, EndianSlice, Mapping, Path, Stash, Vec}; +use alloc::sync::Arc; use core::convert::TryFrom; use object::pe::{ImageDosHeader, ImageSymbol}; use object::read::pe::{ImageNtHeaders, ImageOptionalHeader, SectionTable}; @@ -108,9 +109,9 @@ impl<'a> Object<'a> { } pub(super) fn handle_split_dwarf<'data>( - package: Option<&gimli::DwarfPackage>>, - stash: &'data Stash, - load: addr2line::SplitDwarfLoad>, + _package: Option<&gimli::DwarfPackage>>, + _stash: &'data Stash, + _load: addr2line::SplitDwarfLoad>, ) -> Option>>> { None } diff --git a/src/symbolize/gimli/macho.rs b/src/symbolize/gimli/macho.rs index 95a2c75c1..74ed8091a 100644 --- a/src/symbolize/gimli/macho.rs +++ b/src/symbolize/gimli/macho.rs @@ -1,4 +1,5 @@ -use super::{Box, Context, Mapping, Path, Stash, Vec}; +use super::{gimli, Box, Context, Endian, EndianSlice, Mapping, Path, Stash, Vec}; +use alloc::sync::Arc; use core::convert::TryInto; use object::macho; use object::read::macho::{MachHeader, Nlist, Section, Segment as _}; @@ -324,9 +325,9 @@ fn split_archive_path(path: &[u8]) -> Option<(&[u8], &[u8])> { } pub(super) fn handle_split_dwarf<'data>( - package: Option<&gimli::DwarfPackage>>, - stash: &'data Stash, - load: addr2line::SplitDwarfLoad>, + _package: Option<&gimli::DwarfPackage>>, + _stash: &'data Stash, + _load: addr2line::SplitDwarfLoad>, ) -> Option>>> { None } From 57af7c299015ab8fa8e47bc6ac995e25d4d57e28 Mon Sep 17 00:00:00 2001 From: Kyle Huey Date: Wed, 17 May 2023 14:50:16 -0700 Subject: [PATCH 7/7] Address review comment. --- src/symbolize/gimli/elf.rs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/symbolize/gimli/elf.rs b/src/symbolize/gimli/elf.rs index f1f215211..b0eec0762 100644 --- a/src/symbolize/gimli/elf.rs +++ b/src/symbolize/gimli/elf.rs @@ -468,16 +468,10 @@ pub(super) fn handle_split_dwarf<'data>( let mut path = PathBuf::new(); if let Some(p) = load.comp_dir.as_ref() { - if let Ok(p) = convert_path(p) { - path.push(p); - } + path.push(convert_path(p).ok()?); } - if let Some(p) = load.path.as_ref() { - if let Ok(p) = convert_path(p) { - path.push(p); - } - } + path.push(convert_path(load.path.as_ref()?).ok()?); if let Some(map_dwo) = super::mmap(&path) { let map_dwo = stash.cache_mmap(map_dwo);