File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -6,3 +6,8 @@ The output format is mostly arbitrary, so it's OK to change the output as long
66as any affected tests are also re-blessed. However, the output should be
77consistent across different executions on different platforms, so avoid
88printing any information that is platform-specific or non-deterministic.
9+
10+ ## Demangle mode
11+
12+ When run as ` coverage-dump --demangle ` , this tool instead functions as a
13+ command-line demangler that can be invoked by ` llvm-cov ` .
Original file line number Diff line number Diff line change @@ -7,6 +7,13 @@ fn main() -> anyhow::Result<()> {
77
88 let args = std:: env:: args ( ) . collect :: < Vec < _ > > ( ) ;
99
10+ // The coverage-dump tool already needs `rustc_demangle` in order to read
11+ // coverage metadata, so it's very easy to also have a separate mode that
12+ // turns it into a command-line demangler for use by coverage-run tests.
13+ if & args[ 1 ..] == & [ "--demangle" ] {
14+ return demangle ( ) ;
15+ }
16+
1017 let llvm_ir_path = args. get ( 1 ) . context ( "LLVM IR file not specified" ) ?;
1118 let llvm_ir = std:: fs:: read_to_string ( llvm_ir_path) . context ( "couldn't read LLVM IR file" ) ?;
1219
@@ -15,3 +22,15 @@ fn main() -> anyhow::Result<()> {
1522
1623 Ok ( ( ) )
1724}
25+
26+ fn demangle ( ) -> anyhow:: Result < ( ) > {
27+ use std:: fmt:: Write as _;
28+
29+ let stdin = std:: io:: read_to_string ( std:: io:: stdin ( ) ) ?;
30+ let mut output = String :: with_capacity ( stdin. len ( ) ) ;
31+ for line in stdin. lines ( ) {
32+ writeln ! ( output, "{:#}" , rustc_demangle:: demangle( line) ) ?;
33+ }
34+ print ! ( "{output}" ) ;
35+ Ok ( ( ) )
36+ }
You can’t perform that action at this time.
0 commit comments