Commit 2ec77590 authored by Nagy Tibor's avatar Nagy Tibor

Use rustc-demangle in the stack traces

parent b4575711
Pipeline #2936 failed with stages
in 50 seconds
......@@ -179,6 +179,7 @@ dependencies = [
"linked_list_allocator 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
"raw-cpuid 4.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"redox_syscall 0.1.51",
"rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)",
"slab_allocator 0.3.1",
"spin 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)",
"x86 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
......
......@@ -22,6 +22,10 @@ version = "0.0.15"
default-features = false
features = ["elf32", "elf64"]
[dependencies.rustc-demangle]
version = "0.1.13"
default-features = false
[dependencies.x86]
version = "0.9.0"
default-features = false
......
use core::mem;
use core::{mem, str};
use goblin::elf::sym;
use rustc_demangle::demangle;
use paging::{ActivePageTable, VirtualAddress};
......@@ -76,54 +77,10 @@ pub unsafe fn symbol_trace(addr: usize) {
}
if end > start {
let sym_name = &elf.data[start .. end];
print!(" ");
if sym_name.starts_with(b"_ZN") {
// Skip _ZN
let mut i = 3;
let mut first = true;
while i < sym_name.len() {
// E is the end character
if sym_name[i] == b'E' {
break;
}
// Parse length string
let mut len = 0;
while i < sym_name.len() {
let b = sym_name[i];
if b >= b'0' && b <= b'9' {
i += 1;
len *= 10;
len += (b - b'0') as usize;
} else {
break;
}
}
// Print namespace seperator, if required
if first {
first = false;
} else {
print!("::");
}
// Print name string
let end = i + len;
while i < sym_name.len() && i < end {
print!("{}", sym_name[i] as char);
i += 1;
}
}
} else {
for &b in sym_name.iter() {
print!("{}", b as char);
}
let sym_slice = &elf.data[start .. end - 1];
if let Ok(sym_name) = str::from_utf8(sym_slice) {
println!(" {:#}", demangle(sym_name));
}
println!("");
}
}
}
......
......@@ -35,6 +35,7 @@ extern crate alloc;
extern crate bitflags;
extern crate goblin;
extern crate linked_list_allocator;
extern crate rustc_demangle;
extern crate spin;
#[cfg(feature = "slab")]
extern crate slab_allocator;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment