Skip to content

Commit 92e8a03

Browse files
committed
Big cleanup
1 parent 4be0888 commit 92e8a03

File tree

3 files changed

+29
-27
lines changed

3 files changed

+29
-27
lines changed

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ mod symbolize;
8383
pub use crate::types::BytesOrWideString;
8484
mod types;
8585

86+
#[cfg(feature = "std")]
8687
pub use crate::symbolize::clear_symbol_cache;
8788

8889
cfg_if::cfg_if! {

src/symbolize/gimli.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ pub unsafe fn clear_symbol_cache() {
351351
with_cache(|cache| cache.clear());
352352
}
353353

354-
fn with_mapping_for_path<F>(path: PathBuf, f: F)
354+
unsafe fn with_mapping_for_path<F>(path: PathBuf, f: F)
355355
where
356356
F: FnMut(&Context<'_>),
357357
{

src/symbolize/mod.rs

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -436,24 +436,11 @@ cfg_if::cfg_if! {
436436

437437
mod dladdr;
438438

439-
/// Each resolve() implementation allocates and caches several megabytes worth of symbols,
440-
/// clear_symbol_cache tries to reclaim that cached memory.
441-
/// Note: for now, only the Gimli implementation is able to clear its cache.
442-
#[cfg(feature = "std")]
443-
pub fn clear_symbol_cache() {
444-
let _guard = crate::lock::lock();
445-
unsafe {
446-
clear_imp()
447-
}
448-
}
449-
450439
cfg_if::cfg_if! {
451440
if #[cfg(all(windows, target_env = "msvc", feature = "dbghelp"))] {
452441
mod dbghelp;
453442
use self::dbghelp::resolve as resolve_imp;
454443
use self::dbghelp::Symbol as SymbolImp;
455-
unsafe fn noop_clear_symbol_cache() {}
456-
use noop_clear_symbol_cache as clear_imp;
457444
} else if #[cfg(all(
458445
feature = "std",
459446
feature = "gimli-symbolize",
@@ -466,7 +453,6 @@ cfg_if::cfg_if! {
466453
mod gimli;
467454
use self::gimli::resolve as resolve_imp;
468455
use self::gimli::Symbol as SymbolImp;
469-
use self::gimli::clear_symbol_cache as clear_imp;
470456
// Note that we only enable coresymbolication on iOS when debug assertions
471457
// are enabled because it's helpful in debug mode but it looks like apps get
472458
// rejected from the app store if they use this API, see #92 for more info
@@ -476,34 +462,49 @@ cfg_if::cfg_if! {
476462
mod coresymbolication;
477463
use self::coresymbolication::resolve as resolve_imp;
478464
use self::coresymbolication::Symbol as SymbolImp;
479-
480-
unsafe fn noop_clear_symbol_cache() {}
481-
use noop_clear_symbol_cache as clear_imp;
482465
} else if #[cfg(all(feature = "libbacktrace",
483466
any(unix, all(windows, not(target_vendor = "uwp"), target_env = "gnu")),
484467
not(target_os = "fuchsia"),
485468
not(target_os = "emscripten")))] {
486469
mod libbacktrace;
487470
use self::libbacktrace::resolve as resolve_imp;
488471
use self::libbacktrace::Symbol as SymbolImp;
489-
490-
unsafe fn noop_clear_symbol_cache() {}
491-
use noop_clear_symbol_cache as clear_imp;
492472
} else if #[cfg(all(unix,
493473
not(target_os = "emscripten"),
494474
feature = "dladdr"))] {
495475
mod dladdr_resolve;
496476
use self::dladdr_resolve::resolve as resolve_imp;
497477
use self::dladdr_resolve::Symbol as SymbolImp;
498-
499-
unsafe fn noop_clear_symbol_cache() {}
500-
use noop_clear_symbol_cache as clear_imp;
501478
} else {
502479
mod noop;
503480
use self::noop::resolve as resolve_imp;
504481
use self::noop::Symbol as SymbolImp;
505-
506-
unsafe fn noop_clear_symbol_cache() {}
507-
use noop_clear_symbol_cache as clear_imp;
508482
}
509483
}
484+
485+
cfg_if::cfg_if! {
486+
if #[cfg(all(
487+
feature = "std",
488+
feature = "gimli-symbolize",
489+
any(
490+
target_os = "linux",
491+
target_os = "macos",
492+
windows,
493+
),
494+
))] {
495+
/// clear_symbol_cache tries to reclaim that cached memory.
496+
/// Note: for now, only the Gimli implementation is able to clear its cache.
497+
pub fn clear_symbol_cache() {
498+
let _guard = crate::lock::lock();
499+
unsafe {
500+
self::gimli::clear_symbol_cache();
501+
}
502+
}
503+
} else if #[cfg(feature = "std")] {
504+
/// clear_symbol_cache tries to reclaim that cached memory.
505+
/// Note: for now, only the Gimli implementation is able to clear its cache.
506+
pub fn clear_symbol_cache() {
507+
// noop
508+
}
509+
}
510+
}

0 commit comments

Comments
 (0)