Skip to content

Commit

Permalink
Add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
loewenheim committed Feb 11, 2025
1 parent e1884a2 commit a6de0a8
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 0 deletions.
22 changes: 22 additions & 0 deletions symbolic-symcache/tests/test_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,3 +351,25 @@ fn test_trailing_marker() -> Result<(), Error> {

Ok(())
}

/// Tests that addresses between functions are unmapped. See
/// <https://github.com/getsentry/symbolic/pull/897>.
#[test]
fn test_lookup_between_functions() {
let buffer = ByteView::open(fixture(
"macos/3CD3E3CC-281E-3AF3-84EB-CDE6D56F0559.dSYM/Contents/Resources/DWARF/CrashLibiOS",
))
.unwrap();
let object = Object::parse(&buffer).unwrap();

let mut buffer = Vec::new();
let mut converter = SymCacheConverter::new();
converter.process_object(&object).unwrap();
converter.serialize(&mut Cursor::new(&mut buffer)).unwrap();
let symcache = SymCache::parse(&buffer).unwrap();
// This address is exactly at the end of the function "-[CRLCrashNXPage desc]",
// which starts at 0x8b0c and has size 0x2c. The next function,
// "-[CRLCrashStackGuard category]", starts at 0x8b3c.
let symbols = symcache.lookup(0x8b38).collect::<Vec<_>>();
assert!(symbols.is_empty());
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleIdentifier</key>
<string>com.apple.xcode.dsym.CrashLibiOS</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>dSYM</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>DBGOriginalUUID</key>
<string>73F2DB01-F4C5-371A-9FC2-7A48430A26F7</string>
</dict>
</plist>
Binary file not shown.

0 comments on commit a6de0a8

Please sign in to comment.