Skip to content

Commit

Permalink
Add GNU/Hurd support (#567)
Browse files Browse the repository at this point in the history
  • Loading branch information
sthibaul committed Oct 6, 2023
1 parent 9532971 commit 11e0a4b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
2 changes: 2 additions & 0 deletions src/symbolize/gimli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ cfg_if::cfg_if! {
target_os = "freebsd",
target_os = "fuchsia",
target_os = "haiku",
target_os = "hurd",
target_os = "ios",
target_os = "linux",
target_os = "macos",
Expand Down Expand Up @@ -231,6 +232,7 @@ cfg_if::cfg_if! {
target_os = "linux",
target_os = "fuchsia",
target_os = "freebsd",
target_os = "hurd",
target_os = "openbsd",
target_os = "netbsd",
all(target_os = "android", feature = "dl_iterate_phdr"),
Expand Down
2 changes: 1 addition & 1 deletion src/symbolize/gimli/elf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ const DEBUG_PATH: &[u8] = b"/usr/lib/debug";

fn debug_path_exists() -> bool {
cfg_if::cfg_if! {
if #[cfg(any(target_os = "freebsd", target_os = "linux"))] {
if #[cfg(any(target_os = "freebsd", target_os = "hurd", target_os = "linux"))] {
use core::sync::atomic::{AtomicU8, Ordering};
static DEBUG_PATH_EXISTS: AtomicU8 = AtomicU8::new(0);

Expand Down
20 changes: 12 additions & 8 deletions src/symbolize/gimli/libs_dl_iterate_phdr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,18 @@ pub(super) fn native_libraries() -> Vec<Library> {
}

fn infer_current_exe(base_addr: usize) -> OsString {
if let Ok(entries) = super::parse_running_mmaps::parse_maps() {
let opt_path = entries
.iter()
.find(|e| e.ip_matches(base_addr) && e.pathname().len() > 0)
.map(|e| e.pathname())
.cloned();
if let Some(path) = opt_path {
return path;
cfg_if::cfg_if! {
if #[cfg(not(target_os = "hurd"))] {
if let Ok(entries) = super::parse_running_mmaps::parse_maps() {
let opt_path = entries
.iter()
.find(|e| e.ip_matches(base_addr) && e.pathname().len() > 0)
.map(|e| e.pathname())
.cloned();
if let Some(path) = opt_path {
return path;
}
}
}
}
env::current_exe().map(|e| e.into()).unwrap_or_default()
Expand Down

0 comments on commit 11e0a4b

Please sign in to comment.