Demangle a C++ symbol using c++filt
(mangled_name: str, cppfilt_path: str)
| 150 | |
| 151 | |
| 152 | def demangle_symbol(mangled_name: str, cppfilt_path: str) -> str: |
| 153 | """Demangle a C++ symbol using c++filt""" |
| 154 | try: |
| 155 | cmd = f'echo "{mangled_name}" | "{cppfilt_path}"' |
| 156 | proc = RunningProcess(cmd, shell=True, auto_run=True, timeout=10) |
| 157 | output = "" |
| 158 | from running_process import EndOfStream |
| 159 | |
| 160 | while line := proc.get_next_line(timeout=10): |
| 161 | if isinstance(line, EndOfStream): |
| 162 | break |
| 163 | output += str(line) |
| 164 | exit_code = proc.wait() |
| 165 | demangled = output.strip() |
| 166 | # If demangling failed, c++filt returns the original name |
| 167 | return demangled if demangled and demangled != mangled_name else mangled_name |
| 168 | except KeyboardInterrupt as ki: |
| 169 | handle_keyboard_interrupt(ki) |
| 170 | raise |
| 171 | except Exception as e: |
| 172 | print(f"Error demangling symbol: {mangled_name}") |
| 173 | print(f"Error: {e}") |
| 174 | return mangled_name |
| 175 | |
| 176 | |
| 177 | def analyze_symbols( |
no test coverage detected