summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorJosh Ferrell <josh@vector35.com>2025-08-21 12:20:21 -0400
committerJosh Ferrell <josh@vector35.com>2025-08-21 12:20:45 -0400
commiteb09898c0ea423328d929dec4d1730030f99abe4 (patch)
treeef188a4d24a171142e65441b2a46bb3b1a92a835 /plugins
parent55b35dfbcf181797ef91c9b8d5a22638a1dfb0c6 (diff)
Add support for automatically loading PDB/DWARF info from sibling files in projects
Diffstat (limited to 'plugins')
-rw-r--r--plugins/dwarf/dwarf_import/src/helpers.rs25
-rw-r--r--plugins/pdb-ng/src/lib.rs35
2 files changed, 55 insertions, 5 deletions
diff --git a/plugins/dwarf/dwarf_import/src/helpers.rs b/plugins/dwarf/dwarf_import/src/helpers.rs
index fdf4e038..0ab9ab95 100644
--- a/plugins/dwarf/dwarf_import/src/helpers.rs
+++ b/plugins/dwarf/dwarf_import/src/helpers.rs
@@ -577,10 +577,35 @@ pub(crate) fn find_sibling_debug_file(view: &BinaryView) -> Option<String> {
let debug_file = PathBuf::from(format!("{}.debug", full_file_path));
let dsym_folder = PathBuf::from(format!("{}.dSYM", full_file_path));
+
+ // Find sibling debug file
if debug_file.exists() && debug_file.is_file() {
return Some(debug_file.to_string_lossy().to_string());
}
+ // Find sibling debug file in project
+ if let Some(debug_file_name) = debug_file.file_name() {
+ if let Some(project_file) = view.file().project_file() {
+ let project_file_folder_id = project_file.folder().map(|x| x.id());
+ for file in project_file.project().files().iter() {
+ if !file.exists_on_disk() {
+ // If the file doesn't exist, don't consider it
+ // TODO: if we're connected to a remote project, offer to download the file
+ continue;
+ }
+
+ let file_folder_id = file.folder().map(|x| x.id());
+ if *file.name() == *debug_file_name && file_folder_id == project_file_folder_id {
+ if let Some(path_on_disk) = file.path_on_disk() {
+ return path_on_disk.to_str().map(|x| x.to_string());
+ }
+ }
+ }
+ }
+ }
+
+ // Look for dSYM
+ // TODO: look for dSYM in project
if dsym_folder.exists() && dsym_folder.is_dir() {
let filename = Path::new(&full_file_path)
.file_name()
diff --git a/plugins/pdb-ng/src/lib.rs b/plugins/pdb-ng/src/lib.rs
index cad1ada0..9a0e0724 100644
--- a/plugins/pdb-ng/src/lib.rs
+++ b/plugins/pdb-ng/src/lib.rs
@@ -614,11 +614,7 @@ impl CustomDebugInfoParser for PDBParser {
potential_path.pop();
potential_path.push(&info.file_name);
if potential_path.exists() {
- match fs::read(
- potential_path
- .to_str()
- .expect("Potential path is a real string"),
- ) {
+ match fs::read(potential_path) {
Ok(conts) => match self
.load_from_file(&conts, debug_info, view, &progress, true, false)
{
@@ -631,6 +627,35 @@ impl CustomDebugInfoParser for PDBParser {
}
}
+ // Try in the same folder in the project
+ if let Some(project_file) = view.file().project_file() {
+ let project_file_folder_id = project_file.folder().map(|x| x.id());
+ for file in project_file.project().files().iter() {
+ let file_folder_id = file.folder().map(|x| x.id());
+ if file.name() == info.file_name && file_folder_id == project_file_folder_id {
+ if !file.exists_on_disk() {
+ // If the file doesn't exist, don't consider it
+ // TODO: if we're connected to a remote project, offer to download the file
+ continue;
+ }
+
+ if let Some(path_on_disk) = file.path_on_disk() {
+ match fs::read(path_on_disk) {
+ Ok(conts) => match self.load_from_file(
+ &conts, debug_info, view, &progress, true, false,
+ ) {
+ Ok(_) => return true,
+ Err(e) if e.to_string() == "Cancelled" => return false,
+ Err(e) => debug!("Skipping, {}", e.to_string()),
+ },
+ Err(e) if e.to_string() == "Cancelled" => return false,
+ Err(e) => debug!("Could not read pdb: {}", e.to_string()),
+ }
+ }
+ }
+ }
+ }
+
// Check the local symbol store
if let Ok(local_store_path) = active_local_cache(Some(view)) {
match search_sym_store(view, local_store_path.clone(), &info) {