summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/guide/types/debuginfo.md8
-rw-r--r--rust/examples/dwarf/dwarf_import/src/helpers.rs13
2 files changed, 15 insertions, 6 deletions
diff --git a/docs/guide/types/debuginfo.md b/docs/guide/types/debuginfo.md
index 1a23d240..6f6ed085 100644
--- a/docs/guide/types/debuginfo.md
+++ b/docs/guide/types/debuginfo.md
@@ -14,7 +14,7 @@ DWARF supports information compiled in to ELF binaries, information from externa
## Applying Debug Info
-Debug Info is automatically applied by default if applicable.
+Debug Info is automatically applied by default if applicable.
![Import Debug Info >](../../img/import-debug-info.png "Import Debug Info"){ width="300" }
@@ -44,6 +44,10 @@ Our [DWARF Export plugin](https://github.com/Vector35/binaryninja-api/tree/dev/r
#### Special Note for `.dSYM` Files
-`.dSYM` packages are often provided as application bundles. Binary Ninja currently does not support extracting the actual `.dSYM` file out of the package for parsing, so you may need to provide a full path for Binary Ninja to correctly parse.
+Binary Ninja will automatically load `.dSYM` files given the following:
+- The `.dSYM` file is adjacent on the filesystem to the binary being analyzed
+- The `.dSYM` file is named `X.dSYM`, where `X` is the name of the binary being analyzed
+- `analysis.debugInfo.loadSiblingDebugFiles` is enabled
+When a `.dSYM` file is not automatically loaded, you will need to manually import the debug info contained in the `.dSYM`.
For example, you could have the file `hello.macho` that you would like to import debug info for. Thankfully, you also have `hello.dSYM`. So you open `hello.macho` with options, find the "External Debug Info File" and provide the `hello.dSYM` file. When the file opens, you notice that no information was imported and the log reads "No available/valid parsers for file." This is because `hello.dSYM` is a bundle. The actual path you needed to provide for the "External Debug Info File" setting would look something like `hello.dSYM/Contents/Resources/DWARF/hello`.
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<String> {
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?