MCPcopy Create free account
hub / github.com/vercel/vercel / demangle_symbols

Function demangle_symbols

packages/python-analysis/scripts/profile-wasm.py:326–352  ·  view source on GitHub ↗

Demangle Rust symbols using rustfilt.

(entries)

Source from the content-addressed store, hash-verified

324
325
326def demangle_symbols(entries):
327 """Demangle Rust symbols using rustfilt."""
328 symbols = [e[2] for e in entries if e[2]]
329 if not symbols:
330 return entries
331
332 try:
333 demangled = run(["rustfilt"], input="\n".join(symbols))
334 demangled_list = demangled.strip().split("\n")
335 except Exception:
336 return entries
337
338 result = []
339 demangle_idx = 0
340 for section, crate, symbol, size in entries:
341 if symbol:
342 if demangle_idx < len(demangled_list):
343 symbol = demangled_list[demangle_idx]
344 demangle_idx += 1
345 # With LTO, all code is merged into one object file, so the
346 # object-based crate is just the top-level crate. Recover the
347 # real originating crate from the demangled symbol path.
348 sym_crate = crate_from_symbol(symbol)
349 if sym_crate:
350 crate = sym_crate
351 result.append((section, crate, symbol, size))
352 return result
353
354
355def crate_from_symbol(symbol):

Callers 1

mainFunction · 0.85

Calls 6

crate_from_symbolFunction · 0.85
splitMethod · 0.80
stripMethod · 0.80
appendMethod · 0.80
runFunction · 0.70
joinMethod · 0.45

Tested by

no test coverage detected