Rebasing fixes.

This commit is contained in:
Aaron Turon 2014-12-18 19:41:20 -08:00
parent f4c0c0ff42
commit a9e7669cdc
4 changed files with 22 additions and 14 deletions

View File

@ -94,7 +94,7 @@ static CALLBACKS: [atomic::AtomicUint, ..MAX_CALLBACKS] =
atomic::INIT_ATOMIC_UINT, atomic::INIT_ATOMIC_UINT];
static CALLBACK_CNT: atomic::AtomicUint = atomic::INIT_ATOMIC_UINT;
thread_local!(static PANICKING: Cell<bool> = Cell::new(false))
thread_local! { static PANICKING: Cell<bool> = Cell::new(false) }
/// Invoke a closure, capturing the cause of panic if one occurs.
///

View File

@ -40,8 +40,18 @@ pub fn demangle(writer: &mut Writer, s: &str) -> IoResult<()> {
// expecting, we just print it literally. Note that we must handle non-rust
// symbols because we could have any function in the backtrace.
let mut valid = true;
let mut inner = s;
if s.len() > 4 && s.starts_with("_ZN") && s.ends_with("E") {
let mut chars = s.slice(3, s.len() - 1).chars();
inner = s.slice(3, s.len() - 1);
// On Windows, dbghelp strips leading underscores, so we accept "ZN...E" form too.
} else if s.len() > 3 && s.starts_with("ZN") && s.ends_with("E") {
inner = s.slice(2, s.len() - 1);
} else {
valid = false;
}
if valid {
let mut chars = inner.chars();
while valid {
let mut i = 0;
for c in chars {
@ -58,32 +68,29 @@ pub fn demangle(writer: &mut Writer, s: &str) -> IoResult<()> {
valid = false;
}
}
} else {
valid = false;
}
// Alright, let's do this.
if !valid {
try!(writer.write_str(s));
} else {
let mut s = s.slice_from(3);
let mut first = true;
while s.len() > 1 {
while inner.len() > 0 {
if !first {
try!(writer.write_str("::"));
} else {
first = false;
}
let mut rest = s;
let mut rest = inner;
while rest.char_at(0).is_numeric() {
rest = rest.slice_from(1);
}
let i: uint = from_str(s.slice_to(s.len() - rest.len())).unwrap();
s = rest.slice_from(i);
let i: uint = from_str(inner.slice_to(inner.len() - rest.len())).unwrap();
inner = rest.slice_from(i);
rest = rest.slice_to(i);
while rest.len() > 0 {
if rest.starts_with("$") {
macro_rules! demangle(
macro_rules! demangle {
($($pat:expr => $demangled:expr),*) => ({
$(if rest.starts_with($pat) {
try!(writer.write_str($demangled));
@ -95,7 +102,8 @@ pub fn demangle(writer: &mut Writer, s: &str) -> IoResult<()> {
}
})
)
}
// see src/librustc/back/link.rs for these mappings
demangle! (
"$SP$" => "@",

View File

@ -23,7 +23,7 @@ struct ThreadInfo {
thread: Thread,
}
thread_local!(static THREAD_INFO: RefCell<Option<ThreadInfo>> = RefCell::new(None))
thread_local! { static THREAD_INFO: RefCell<Option<ThreadInfo>> = RefCell::new(None) }
impl ThreadInfo {
fn with<R>(f: |&mut ThreadInfo| -> R) -> R {

View File

@ -304,12 +304,12 @@ pub fn write(w: &mut Writer) -> IoResult<()> {
Err(..) => return Ok(()),
};
macro_rules! sym( ($e:expr, $t:ident) => (unsafe {
macro_rules! sym{ ($e:expr, $t:ident) => (unsafe {
match lib.symbol($e) {
Ok(f) => mem::transmute::<*mut u8, $t>(f),
Err(..) => return Ok(())
}
}) )
}) }
// Fetch the symbols necessary from dbghelp.dll
let SymFromAddr = sym!("SymFromAddr", SymFromAddrFn);