Skip to content

Commit

Permalink
Add support for arm64ec (#587)
Browse files Browse the repository at this point in the history
The Rust Compiler has recently added support for ARM64EC
(rust-lang/rust#119199), so this change adds support for ARM64EC to
backtrace by using the same OS structures and functions as x64 NOT
AArch64: this is because an ARM64EC binary runs within an x64 process
(on an AArch64 machine), thus all the OS binaries it is interfacing
with expose the x64 API.
  • Loading branch information
dpaoliello authored Mar 8, 2024
1 parent 7fa4fee commit ef39a7d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
8 changes: 6 additions & 2 deletions src/backtrace/dbghelp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl Frame {
#[repr(C, align(16))] // required by `CONTEXT`, is a FIXME in winapi right now
struct MyContext(CONTEXT);

#[cfg(target_arch = "x86_64")]
#[cfg(any(target_arch = "x86_64", target_arch = "arm64ec"))]
impl MyContext {
#[inline(always)]
fn ip(&self) -> DWORD64 {
Expand Down Expand Up @@ -122,7 +122,11 @@ impl MyContext {
}
}

#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
#[cfg(any(
target_arch = "x86_64",
target_arch = "aarch64",
target_arch = "arm64ec"
))]
#[inline(always)]
pub unsafe fn trace(cb: &mut dyn FnMut(&super::Frame) -> bool) {
use core::ptr;
Expand Down
10 changes: 7 additions & 3 deletions src/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,11 @@ ffi! {
}
}

#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
#[cfg(any(
target_arch = "x86_64",
target_arch = "aarch64",
target_arch = "arm64ec"
))]
ffi! {
#[link(name = "kernel32")]
extern "system" {
Expand Down Expand Up @@ -606,7 +610,7 @@ ffi! {
}
}

#[cfg(target_arch = "x86_64")]
#[cfg(any(target_arch = "x86_64", target_arch = "arm64ec"))]
ffi! {
#[repr(C, align(8))]
pub struct CONTEXT {
Expand Down Expand Up @@ -674,7 +678,7 @@ ffi! {
}

#[repr(C)]
#[cfg(target_arch = "x86_64")]
#[cfg(any(target_arch = "x86_64", target_arch = "arm64ec"))]
#[derive(Copy, Clone)]
pub struct FLOATING_SAVE_AREA {
_Dummy: [u8; 512],
Expand Down

0 comments on commit ef39a7d

Please sign in to comment.