Skip to content

Commit ff678ea

Browse files
committedFeb 27, 2015
std: Fixed backtrace warnings and tests for non-Linux platforms.
- Fixed a couple of dead code warnings in std::sys::backtrace. - Made `backtrace-debuginfo` test a no-op on non-Linux platforms. - `backtrace-debuginfo` is no longer tested on pretty-rpass.
1 parent 587f10a commit ff678ea

File tree

2 files changed

+28
-5
lines changed

2 files changed

+28
-5
lines changed
 

‎src/libstd/sys/unix/backtrace.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ pub fn write(w: &mut Writer) -> IoResult<()> {
224224

225225
#[cfg(any(target_os = "macos", target_os = "ios"))]
226226
fn print(w: &mut Writer, idx: int, addr: *mut libc::c_void,
227-
symaddr: *mut libc::c_void) -> IoResult<()> {
227+
_symaddr: *mut libc::c_void) -> IoResult<()> {
228228
use intrinsics;
229229
#[repr(C)]
230230
struct Dl_info {
@@ -450,6 +450,7 @@ fn output(w: &mut Writer, idx: int, addr: *mut libc::c_void,
450450
w.write_all(&['\n' as u8])
451451
}
452452

453+
#[allow(dead_code)]
453454
fn output_fileline(w: &mut Writer, file: &[u8], line: libc::c_int,
454455
more: bool) -> IoResult<()> {
455456
let file = str::from_utf8(file).ok().unwrap_or("<unknown>");

‎src/test/run-pass/backtrace-debuginfo.rs

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// except according to those terms.
1010

1111
// compile-flags:-g
12+
// ignore-pretty as this critically relies on line numbers
1213

1314
use std::old_io::stderr;
1415
use std::env;
@@ -19,14 +20,35 @@ macro_rules! pos {
1920
() => ((file!(), line!()))
2021
}
2122

23+
#[cfg(all(unix,
24+
not(target_os = "macos"),
25+
not(target_os = "ios"),
26+
not(target_os = "android"),
27+
not(all(target_os = "linux", target_arch = "arm"))))]
28+
macro_rules! dump_and_die {
29+
($($pos:expr),*) => ({
30+
// FIXME(#18285): we cannot include the current position because
31+
// the macro span takes over the last frame's file/line.
32+
dump_filelines(&[$($pos),*]);
33+
panic!();
34+
})
35+
}
36+
37+
// this does not work on Windows, Android, OSX or iOS
38+
#[cfg(any(not(unix),
39+
target_os = "macos",
40+
target_os = "ios",
41+
target_os = "android",
42+
all(target_os = "linux", target_arch = "arm")))]
43+
macro_rules! dump_and_die {
44+
($($pos:expr),*) => ({ let _ = [$($pos),*]; })
45+
}
46+
2247
// we can't use a function as it will alter the backtrace
2348
macro_rules! check {
2449
($counter:expr; $($pos:expr),*) => ({
2550
if *$counter == 0 {
26-
// FIXME(#18285): we cannot include the current position because
27-
// the macro span takes over the last frame's file/line.
28-
dump_filelines(&[$($pos),*]);
29-
panic!();
51+
dump_and_die!($($pos),*)
3052
} else {
3153
*$counter -= 1;
3254
}

0 commit comments

Comments
 (0)
Please sign in to comment.