From bf8ecfead9fcbe669c5e5c0a531037701c53d52d Mon Sep 17 00:00:00 2001 From: Josh Ferrell Date: Tue, 5 Nov 2024 17:12:11 -0500 Subject: Fix .dSYM sibling file load logic and update .dSYM docs --- rust/examples/dwarf/dwarf_import/src/helpers.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'rust/examples') diff --git a/rust/examples/dwarf/dwarf_import/src/helpers.rs b/rust/examples/dwarf/dwarf_import/src/helpers.rs index 691c5751..6aba99d4 100644 --- a/rust/examples/dwarf/dwarf_import/src/helpers.rs +++ b/rust/examples/dwarf/dwarf_import/src/helpers.rs @@ -12,7 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -use std::path::PathBuf; +use std::ffi::OsStr; +use std::path::{Path, PathBuf}; use std::{ collections::HashMap, ops::Deref, @@ -553,15 +554,19 @@ pub(crate) fn find_sibling_debug_file(view: &BinaryView) -> Option { return None; } - let filename = view.file().filename().to_string(); + let full_file_path = view.file().filename().to_string(); - let debug_file = PathBuf::from(format!("{}.debug", filename)); - let dsym_folder = PathBuf::from(format!("{}.dSYM/", filename)); + let debug_file = PathBuf::from(format!("{}.debug", full_file_path)); + let dsym_folder = PathBuf::from(format!("{}.dSYM", full_file_path)); if debug_file.exists() && debug_file.is_file() { return Some(debug_file.to_string_lossy().to_string()); } if dsym_folder.exists() && dsym_folder.is_dir() { + let filename = Path::new(&full_file_path) + .file_name() + .unwrap_or(OsStr::new("")); + let dsym_file = dsym_folder .join("Contents/Resources/DWARF/") .join(filename); // TODO: should this just pull any file out? Can there be multiple files? -- cgit v1.3.1