Skip to content
Snippets Groups Projects
Commit 2ec77590 authored by Nagy Tibor's avatar Nagy Tibor
Browse files

Use rustc-demangle in the stack traces

parent b4575711
No related branches found
No related tags found
1 merge request!100Use rustc-demangle in the stack traces
...@@ -179,6 +179,7 @@ dependencies = [ ...@@ -179,6 +179,7 @@ dependencies = [
"linked_list_allocator 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", "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)", "raw-cpuid 4.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"redox_syscall 0.1.51", "redox_syscall 0.1.51",
"rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)",
"slab_allocator 0.3.1", "slab_allocator 0.3.1",
"spin 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "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)", "x86 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
......
...@@ -22,6 +22,10 @@ version = "0.0.15" ...@@ -22,6 +22,10 @@ version = "0.0.15"
default-features = false default-features = false
features = ["elf32", "elf64"] features = ["elf32", "elf64"]
[dependencies.rustc-demangle]
version = "0.1.13"
default-features = false
[dependencies.x86] [dependencies.x86]
version = "0.9.0" version = "0.9.0"
default-features = false default-features = false
......
use core::mem; use core::{mem, str};
use goblin::elf::sym; use goblin::elf::sym;
use rustc_demangle::demangle;
use paging::{ActivePageTable, VirtualAddress}; use paging::{ActivePageTable, VirtualAddress};
...@@ -76,54 +77,10 @@ pub unsafe fn symbol_trace(addr: usize) { ...@@ -76,54 +77,10 @@ pub unsafe fn symbol_trace(addr: usize) {
} }
if end > start { if end > start {
let sym_name = &elf.data[start .. end]; let sym_slice = &elf.data[start .. end - 1];
if let Ok(sym_name) = str::from_utf8(sym_slice) {
print!(" "); println!(" {:#}", demangle(sym_name));
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);
}
} }
println!("");
} }
} }
} }
......
...@@ -35,6 +35,7 @@ extern crate alloc; ...@@ -35,6 +35,7 @@ extern crate alloc;
extern crate bitflags; extern crate bitflags;
extern crate goblin; extern crate goblin;
extern crate linked_list_allocator; extern crate linked_list_allocator;
extern crate rustc_demangle;
extern crate spin; extern crate spin;
#[cfg(feature = "slab")] #[cfg(feature = "slab")]
extern crate slab_allocator; extern crate slab_allocator;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment