Skip to content

Commit

Permalink
std: Fixed backtrace warnings and tests for non-Linux platforms.
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
lifthrasiir committed Feb 27, 2015
1 parent 587f10a commit ff678ea
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/libstd/sys/unix/backtrace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ pub fn write(w: &mut Writer) -> IoResult<()> {

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

#[allow(dead_code)]
fn output_fileline(w: &mut Writer, file: &[u8], line: libc::c_int,
more: bool) -> IoResult<()> {
let file = str::from_utf8(file).ok().unwrap_or("<unknown>");
Expand Down
30 changes: 26 additions & 4 deletions src/test/run-pass/backtrace-debuginfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// except according to those terms.

// compile-flags:-g
// ignore-pretty as this critically relies on line numbers

use std::old_io::stderr;
use std::env;
Expand All @@ -19,14 +20,35 @@ macro_rules! pos {
() => ((file!(), line!()))
}

#[cfg(all(unix,
not(target_os = "macos"),
not(target_os = "ios"),
not(target_os = "android"),
not(all(target_os = "linux", target_arch = "arm"))))]
macro_rules! dump_and_die {
($($pos:expr),*) => ({
// FIXME(#18285): we cannot include the current position because
// the macro span takes over the last frame's file/line.
dump_filelines(&[$($pos),*]);
panic!();
})
}

// this does not work on Windows, Android, OSX or iOS
#[cfg(any(not(unix),
target_os = "macos",
target_os = "ios",
target_os = "android",
all(target_os = "linux", target_arch = "arm")))]
macro_rules! dump_and_die {
($($pos:expr),*) => ({ let _ = [$($pos),*]; })
}

// we can't use a function as it will alter the backtrace
macro_rules! check {
($counter:expr; $($pos:expr),*) => ({
if *$counter == 0 {
// FIXME(#18285): we cannot include the current position because
// the macro span takes over the last frame's file/line.
dump_filelines(&[$($pos),*]);
panic!();
dump_and_die!($($pos),*)
} else {
*$counter -= 1;
}
Expand Down

0 comments on commit ff678ea

Please sign in to comment.