forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds bootstrap rules to support installing rust-demangler. When compiling with `-Z instrument-coverage`, the coverage reports are generated by `llvm-cov`. `llvm-cov` includes a built-in demangler for C++, and an option to supply an alternate demangler. For Rust, we have `rust-demangler`, currently used in `rustc` coverage tests. Fuchsia's toolchain for Rust is built via `./x.py install`. Fuchsia is adding support for Rust coverage, and we need to include the `rust-demangler` in the installed `bin` directory. Configured rust-demangler as an in-tree extended tool. Added tests to support `./x.py test rust-demangler`. Install with extended tools by default only if `profiler = true`.
- Loading branch information
Showing
12 changed files
with
328 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# rust-demangler | ||
|
||
Demangles rustc mangled names. | ||
|
||
This tool uses the [rustc-demangle](https://crates.io/crates/rustc-demangle) | ||
crate to convert an input buffer of newline-separated mangled names into their | ||
demangled translations. | ||
|
||
This tool takes a list of mangled names (one per line) on standard input, and | ||
prints a corresponding list of demangled names. The tool is designed to support | ||
programs that can leverage a third-party demangler, such as `llvm-cov`, via the | ||
`-Xdemangler=<path-to-demangler>` option. | ||
|
||
To use `rust-demangler` with `llvm-cov` for example, add the `-Xdemangler=...` | ||
option: | ||
|
||
```shell | ||
$ TARGET="${PWD}/build/x86_64-unknown-linux-gnu" | ||
$ "${TARGET}"/llvm/bin/llvm-cov show \ | ||
--Xdemangler=path/to/rust-demangler \ | ||
--instr-profile=main.profdata ./main --show-line-counts-or-regions | ||
``` | ||
|
||
## License | ||
|
||
Rust-demangler is distributed under the terms of both the MIT license and the | ||
Apache License (Version 2.0). | ||
|
||
See [LICENSE-APACHE](/LICENSE-APACHE) and [LICENSE-MIT](/LICENSE-MIT) for details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
use regex::Regex; | ||
use rustc_demangle::demangle; | ||
|
||
const REPLACE_COLONS: &str = "::"; | ||
|
||
pub fn create_disambiguator_re() -> Regex { | ||
Regex::new(r"\[[a-f0-9]{5,16}\]::").unwrap() | ||
} | ||
|
||
pub fn demangle_lines(buffer: &str, strip_crate_disambiguators: Option<Regex>) -> Vec<String> { | ||
let lines = buffer.lines(); | ||
let mut demangled_lines = Vec::new(); | ||
for mangled in lines { | ||
let mut demangled = demangle(mangled).to_string(); | ||
if let Some(re) = &strip_crate_disambiguators { | ||
demangled = re.replace_all(&demangled, REPLACE_COLONS).to_string(); | ||
} | ||
demangled_lines.push(demangled); | ||
} | ||
demangled_lines.push("".to_string()); | ||
demangled_lines | ||
} |
Oops, something went wrong.