From d3dfe7a02c9c3ce13dd0dea2c4d3e7492712cf6d Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Sat, 8 Feb 2025 15:44:45 +0100 Subject: [PATCH 1/3] Use dl_iterate_phdr on Haiku An implementation or dl_iterate_phdr was added to Haiku a little over a year after Haiku support got added to backtrace-rs. --- src/symbolize/gimli.rs | 4 +-- src/symbolize/gimli/libs_haiku.rs | 50 ------------------------------- 2 files changed, 1 insertion(+), 53 deletions(-) delete mode 100644 src/symbolize/gimli/libs_haiku.rs diff --git a/src/symbolize/gimli.rs b/src/symbolize/gimli.rs index 31b83b51..ec56dcd4 100644 --- a/src/symbolize/gimli.rs +++ b/src/symbolize/gimli.rs @@ -223,6 +223,7 @@ cfg_if::cfg_if! { target_os = "linux", target_os = "fuchsia", target_os = "freebsd", + target_os = "haiku", target_os = "hurd", target_os = "openbsd", target_os = "netbsd", @@ -238,9 +239,6 @@ cfg_if::cfg_if! { } else if #[cfg(target_env = "libnx")] { mod libs_libnx; use libs_libnx::native_libraries; - } else if #[cfg(target_os = "haiku")] { - mod libs_haiku; - use libs_haiku::native_libraries; } else if #[cfg(target_os = "aix")] { mod libs_aix; use libs_aix::native_libraries; diff --git a/src/symbolize/gimli/libs_haiku.rs b/src/symbolize/gimli/libs_haiku.rs deleted file mode 100644 index ddfd6b47..00000000 --- a/src/symbolize/gimli/libs_haiku.rs +++ /dev/null @@ -1,50 +0,0 @@ -// Haiku implements the image_info struct and the get_next_image_info() -// functions to iterate through the loaded executable images. The -// image_info struct contains a pointer to the start of the .text -// section within the virtual address space, as well as the size of -// that section. All the read-only segments of the ELF-binary are in -// that part of the address space. - -use super::mystd::ffi::OsStr; -use super::mystd::os::unix::prelude::*; -use super::{Library, LibrarySegment}; -use alloc::borrow::ToOwned; -use alloc::vec::Vec; -use core::ffi::CStr; -use core::mem::MaybeUninit; - -pub(super) fn native_libraries() -> Vec { - let mut libraries: Vec = Vec::new(); - - unsafe { - let mut info = MaybeUninit::::zeroed(); - let mut cookie: i32 = 0; - // Load the first image to get a valid info struct - let mut status = - libc::get_next_image_info(libc::B_CURRENT_TEAM, &mut cookie, info.as_mut_ptr()); - if status != libc::B_OK { - return libraries; - } - let mut info = info.assume_init(); - - while status == libc::B_OK { - let mut segments = Vec::new(); - segments.push(LibrarySegment { - stated_virtual_memory_address: 0, - len: info.text_size as usize, - }); - - let bytes = CStr::from_ptr(info.name.as_ptr()).to_bytes(); - let name = OsStr::from_bytes(bytes).to_owned(); - libraries.push(Library { - name: name, - segments: segments, - bias: info.text as usize, - }); - - status = libc::get_next_image_info(libc::B_CURRENT_TEAM, &mut cookie, &mut info); - } - } - - libraries -} From f3be30150886b95e3747d6993293935aa45b6a82 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Sat, 8 Feb 2025 17:05:32 +0100 Subject: [PATCH 2/3] Disable test that doesn't work on Haiku Haiku's dynamic linker (/system/runtime_loader) doesn't support getting directly invoked rather than going through PT_INTERP. --- tests/current-exe-mismatch.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/current-exe-mismatch.rs b/tests/current-exe-mismatch.rs index d99c574a..a1f7a31c 100644 --- a/tests/current-exe-mismatch.rs +++ b/tests/current-exe-mismatch.rs @@ -12,10 +12,11 @@ use std::process::Command; mod common; fn main() { - if cfg!(target_os = "netbsd") { - // NetBSD doesn't support this silliness, so because this is an fn main test, - // just pass it on there. If we used ui-test or something we'd use + if cfg!(target_os = "netbsd") || cfg!(target_os = "haiku") { + // NetBSD and Haiku don't support this silliness, so because this is an fn main + // test just pass it on there. If we used ui-test or something we'd use //@ ignore-netbsd + //@ ignore-haiku return; } From a57a35353463972c4c52bcc1f8d33208df250b56 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Sat, 8 Feb 2025 17:10:31 +0100 Subject: [PATCH 3/3] Update apt package list before installing libc6-dbg Repos often delete package versions soon after a new version is available. If the package list still references an old version, apt will error when trying to install the package. --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4330d2f8..a9685b56 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -57,7 +57,7 @@ jobs: # Starting with Ubuntu 22.04 libc6-dbg is needed. - name: Install libc debug info - run: sudo apt-get install -y libc6-dbg + run: sudo apt-get update && sudo apt-get install -y libc6-dbg shell: bash if: contains(matrix.os, 'ubuntu-24.04')