
12 changed files with 125 additions and 17 deletions
@ -1,2 +1,3 @@
|
||||
/.name |
||||
/workspace.xml |
||||
/xtextAutoBuilderState.xml |
||||
|
@ -0,0 +1,21 @@
|
||||
<component name="libraryTable"> |
||||
<library name="Cargo <rustfilt>"> |
||||
<CLASSES> |
||||
<root url="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/regex-0.1.80" /> |
||||
<root url="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/regex-syntax-0.3.9" /> |
||||
<root url="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-demangle-0.1.3" /> |
||||
<root url="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/winapi-build-0.1.1" /> |
||||
<root url="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/thread-id-2.0.0" /> |
||||
<root url="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/winapi-0.2.8" /> |
||||
<root url="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/thread_local-0.2.7" /> |
||||
<root url="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.18" /> |
||||
<root url="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/aho-corasick-0.5.3" /> |
||||
<root url="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/lazy_static-0.2.2" /> |
||||
<root url="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/kernel32-sys-0.2.2" /> |
||||
<root url="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/memchr-0.1.11" /> |
||||
<root url="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/utf8-ranges-0.1.3" /> |
||||
</CLASSES> |
||||
<JAVADOC /> |
||||
<SOURCES /> |
||||
</library> |
||||
</component> |
@ -0,0 +1,13 @@
|
||||
<component name="libraryTable"> |
||||
<library name="Rust <rustfilt>"> |
||||
<CLASSES> |
||||
<root url="file://$USER_HOME$/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd" /> |
||||
<root url="file://$USER_HOME$/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore" /> |
||||
<root url="file://$USER_HOME$/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcollections" /> |
||||
<root url="file://$USER_HOME$/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/liballoc" /> |
||||
<root url="file://$USER_HOME$/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/librustc_unicode" /> |
||||
</CLASSES> |
||||
<JAVADOC /> |
||||
<SOURCES /> |
||||
</library> |
||||
</component> |
@ -1,4 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<project version="4"> |
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_3" assert-keyword="false" jdk-15="false" /> |
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_3" /> |
||||
<component name="RustProjectSettings"> |
||||
<option name="toolchainHomeDirectory" value="$USER_HOME$/.cargo/bin" /> |
||||
</component> |
||||
</project> |
@ -1,6 +1,8 @@
|
||||
compilers=/usr/local/bin/rustc |
||||
compileFilename=example.rs |
||||
supportsBinary=false |
||||
compilerType=rust |
||||
demangler=rust/target/release/rustfilt |
||||
stubRe=\bmain\b |
||||
stubText=pub fn main() {/*stub provided by Compiler Explorer*/} |
||||
binaryHideFuncRe=^(_.*|call_gmon_start|(de)?register_tm_clones|frame_dummy|.*@plt.*)$ |
||||
|
@ -0,0 +1 @@
|
||||
compilers=/home/mgodbolt/.cargo/bin/rustc |
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<module type="RUST_MODULE" version="4"> |
||||
<component name="NewModuleRootManager" inherit-compiler-output="true"> |
||||
<exclude-output /> |
||||
<content url="file://$MODULE_DIR$"> |
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> |
||||
<sourceFolder url="file://$MODULE_DIR$/examples" isTestSource="false" /> |
||||
<sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="true" /> |
||||
<sourceFolder url="file://$MODULE_DIR$/benches" isTestSource="true" /> |
||||
<excludeFolder url="file://$MODULE_DIR$/target" /> |
||||
</content> |
||||
<orderEntry type="sourceFolder" forTests="false" /> |
||||
<orderEntry type="library" name="Rust <rustfilt>" level="project" /> |
||||
<orderEntry type="library" name="Cargo <rustfilt>" level="project" /> |
||||
</component> |
||||
</module> |
@ -1,25 +1,58 @@
|
||||
#[macro_use] extern crate lazy_static; |
||||
extern crate rustc_demangle; |
||||
extern crate regex; |
||||
|
||||
use std::io; |
||||
use std::io::prelude::*; |
||||
use regex::Regex; |
||||
use regex::Captures; |
||||
use rustc_demangle::demangle; |
||||
|
||||
extern crate rustc_demangle; |
||||
extern crate regex; |
||||
fn demangle_line(line: &str) -> String { |
||||
lazy_static! { |
||||
static ref RE: Regex = Regex::new(r"[_a-zA-Z$][_a-zA-Z$0-9.]*").unwrap(); |
||||
} |
||||
|
||||
RE.replace_all(line, |caps: &Captures| { |
||||
format!("{:#}", demangle(caps.at(0).unwrap())) |
||||
}) |
||||
} |
||||
|
||||
#[cfg(test)] |
||||
mod tests { |
||||
#[test] |
||||
fn passes_text() { |
||||
assert_eq!( |
||||
::demangle_line("mo fo\tboom hello "), |
||||
"mo fo\tboom hello "); |
||||
} |
||||
|
||||
#[test] |
||||
fn demangles() { |
||||
assert_eq!( |
||||
::demangle_line("_ZN7example4main17h0db00b8b32acffd5E:"), |
||||
"example::main:"); |
||||
} |
||||
|
||||
#[test] |
||||
fn handles_mid_demangling() { |
||||
assert_eq!( |
||||
::demangle_line(" lea rax, [rip + _ZN55_$LT$$RF$$u27$a$u20$T$u20$as$u20$core..fmt..Display$GT$3fmt17h510ed05e72307174E]"), |
||||
" lea rax, [rip + <&\'a T as core::fmt::Display>::fmt]"); |
||||
} |
||||
|
||||
#[test] |
||||
fn handles_call_plt() { |
||||
assert_eq!( |
||||
::demangle_line(" call _ZN3std2io5stdio6_print17he48522be5b0a80d9E@PLT"), |
||||
" call std::io::stdio::_print@PLT"); |
||||
} |
||||
} |
||||
|
||||
fn main() { |
||||
let stdin = io::stdin(); |
||||
let token = Regex::new(r"[_a-zA-Z$][_a-zA-Z$0-9]*").unwrap(); |
||||
|
||||
for line in stdin.lock().lines() { |
||||
println!("{}", |
||||
line.unwrap() |
||||
.split_whitespace() |
||||
.map(|x| demangle(x).to_string()) |
||||
.collect::<Vec<String>>() |
||||
.join(" ")); |
||||
// println!("{}", token.replace(line.unwrap(), |caps: &Captures| {
|
||||
// demangle(caps.at(0).unwrap()).to_string()
|
||||
// }));
|
||||
println!("{}", demangle_line(&line.unwrap())); |
||||
} |
||||
} |
||||
} |
||||
|
Loading…
Reference in new issue