Skip to content

Commit 6463d67

Browse files
committed
Use built-in mach_uuid() function instead of our own
The implementation is even basically the same!
1 parent 2288c8c commit 6463d67

File tree

2 files changed

+6
-21
lines changed

2 files changed

+6
-21
lines changed

Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ cpp_demangle = { default-features = false, version = "0.2.3", optional = true }
3333
addr2line = { version = "0.9.0", optional = true, default-features = false, features = ['std', 'std-object'] }
3434
findshlibs = { version = "0.5.0", optional = true }
3535
memmap = { version = "0.7.0", optional = true }
36-
goblin = { version = "0.0.22", optional = true, default-features = false }
3736

3837
[target.'cfg(windows)'.dependencies]
3938
winapi = { version = "0.3.3", optional = true }
@@ -93,7 +92,7 @@ kernel32 = []
9392
libbacktrace = ["backtrace-sys"]
9493
dladdr = []
9594
coresymbolication = []
96-
gimli-symbolize = ["addr2line", "findshlibs", "memmap", "goblin"]
95+
gimli-symbolize = ["addr2line", "findshlibs", "memmap"]
9796

9897
#=======================================
9998
# Methods of serialization

src/symbolize/gimli.rs

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use crate::symbolize::ResolveWhat;
1111
use crate::types::BytesOrWideString;
1212
use crate::SymbolName;
1313
use addr2line::gimli;
14-
use addr2line::object::{self, Object};
14+
use addr2line::object::{self, Object, Uuid};
1515
use core::cell::RefCell;
1616
use core::convert::TryFrom;
1717
use core::mem;
@@ -71,7 +71,7 @@ impl Mapping {
7171
// header of the file we're reading, specified at `path`.
7272
let map = mmap(path)?;
7373
let object = object::MachOFile::parse(&map).ok()?;
74-
let uuid = get_uuid(&object)?;
74+
let uuid = object.mach_uuid()?;
7575

7676
// Next we need to look for a `*.dSYM` file. For now we just probe the
7777
// containing directory and look around for something that matches
@@ -100,34 +100,20 @@ impl Mapping {
100100
// symbolication purposes.
101101
return Some(mk!(Mapping { map, object }));
102102

103-
fn load_dsym(dir: &Path, uuid: &[u8]) -> Option<Mapping> {
103+
fn load_dsym(dir: &Path, uuid: &Uuid) -> Option<Mapping> {
104104
for entry in dir.read_dir().ok()? {
105105
let entry = entry.ok()?;
106106
let map = mmap(&entry.path())?;
107107
let object = object::MachOFile::parse(&map).ok()?;
108-
let entry_uuid = get_uuid(&object)?;
109-
if &entry_uuid[..] != uuid {
108+
let entry_uuid = object.mach_uuid()?;
109+
if entry_uuid != *uuid {
110110
continue;
111111
}
112112
return Some(mk!(Mapping { map, object }));
113113
}
114114

115115
None
116116
}
117-
118-
fn get_uuid(object: &object::MachOFile) -> Option<[u8; 16]> {
119-
use goblin::mach::load_command::CommandVariant;
120-
121-
object
122-
.macho()
123-
.load_commands
124-
.iter()
125-
.filter_map(|cmd| match cmd.command {
126-
CommandVariant::Uuid(u) => Some(u.uuid),
127-
_ => None,
128-
})
129-
.next()
130-
}
131117
}
132118

133119
// Ensure the 'static lifetimes don't leak.

0 commit comments

Comments
 (0)