Prevent repeated registration of frames on Linux.
This commit calls `__register_frame` once for the entire frame table on Linux. On macOS, it still manually walks the frame table and registers each frame with `__register_frame`.
This commit is contained in:
@@ -99,6 +99,9 @@ impl UnwindRegistry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn register_frames(&mut self) {
|
unsafe fn register_frames(&mut self) {
|
||||||
|
cfg_if::cfg_if! {
|
||||||
|
if #[cfg(target_os = "macos")] {
|
||||||
|
// On macOS, `__register_frame` takes a pointer to a single FDE
|
||||||
let start = self.frame_table.as_ptr();
|
let start = self.frame_table.as_ptr();
|
||||||
let end = start.add(self.frame_table.len());
|
let end = start.add(self.frame_table.len());
|
||||||
let mut current = start;
|
let mut current = start;
|
||||||
@@ -116,6 +119,13 @@ impl UnwindRegistry {
|
|||||||
// Move to the next table entry (+4 because the length itself is not inclusive)
|
// Move to the next table entry (+4 because the length itself is not inclusive)
|
||||||
current = current.add(len + 4);
|
current = current.add(len + 4);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// On other platforms, `__register_frame` will walk the FDEs until an entry of length 0
|
||||||
|
let ptr = self.frame_table.as_ptr();
|
||||||
|
__register_frame(ptr);
|
||||||
|
self.registrations.push(ptr as usize);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user