Skip to content

Commit

Permalink
fixup smoke.rs more
Browse files Browse the repository at this point in the history
  • Loading branch information
workingjubilee committed Jul 27, 2024
1 parent 5371553 commit c3ac2a5
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions tests/smoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use core::ffi::c_void;
use std::ptr;
use std::thread;

fn get_actual_fn_pointer(fp: usize) -> usize {
fn get_actual_fn_pointer(fp: *mut c_void) -> *mut c_void {
// On AIX, the function name references a function descriptor.
// A function descriptor consists of (See https://reviews.llvm.org/D62532)
// * The address of the entry point of the function.
Expand All @@ -16,17 +16,18 @@ fn get_actual_fn_pointer(fp: usize) -> usize {
// https://www.ibm.com/docs/en/aix/7.2?topic=program-understanding-programming-toc
if cfg!(target_os = "aix") {
unsafe {
let actual_fn_entry = *(fp as *const usize);
let actual_fn_entry = *(fp as *const *mut c_void);
actual_fn_entry
}
} else {
fp
fp as *mut c_void
}
}

#[test]
// FIXME: shouldn't ignore this test on i686-msvc, unsure why it's failing
#[cfg_attr(all(target_arch = "x86", target_env = "msvc"), ignore)]
#[inline(never)]
#[rustfmt::skip] // we care about line numbers here
fn smoke_test_frames() {
frame_1(line!());
Expand All @@ -43,10 +44,10 @@ fn smoke_test_frames() {
// Various platforms have various bits of weirdness about their
// backtraces. To find a good starting spot let's search through the
// frames
let target = get_actual_fn_pointer(frame_4 as usize);
let target = get_actual_fn_pointer(frame_4 as *mut c_void);
let offset = v
.iter()
.map(|frame| frame.symbol_address() as usize)
.map(|frame| frame.symbol_address())
.enumerate()
.filter_map(|(i, sym)| {
if sym >= target {
Expand All @@ -62,39 +63,39 @@ fn smoke_test_frames() {

assert_frame(
frames.next().unwrap(),
get_actual_fn_pointer(frame_4 as usize),
get_actual_fn_pointer(frame_4 as *mut c_void) as usize,
"frame_4",
"tests/smoke.rs",
start_line + 6,
9,
);
assert_frame(
frames.next().unwrap(),
get_actual_fn_pointer(frame_3 as usize),
get_actual_fn_pointer(frame_3 as *mut c_void) as usize,
"frame_3",
"tests/smoke.rs",
start_line + 3,
52,
);
assert_frame(
frames.next().unwrap(),
get_actual_fn_pointer(frame_2 as usize),
get_actual_fn_pointer(frame_2 as *mut c_void) as usize,
"frame_2",
"tests/smoke.rs",
start_line + 2,
52,
);
assert_frame(
frames.next().unwrap(),
get_actual_fn_pointer(frame_1 as usize),
get_actual_fn_pointer(frame_1 as *mut c_void) as usize,
"frame_1",
"tests/smoke.rs",
start_line + 1,
52,
);
assert_frame(
frames.next().unwrap(),
get_actual_fn_pointer(smoke_test_frames as usize),
get_actual_fn_pointer(smoke_test_frames as *mut c_void) as usize,
"smoke_test_frames",
"",
0,
Expand Down

0 comments on commit c3ac2a5

Please sign in to comment.