MCPcopy Create free account
hub / github.com/FastLED/FastLED / demangle_gnu_linkonce_symbols

Function demangle_gnu_linkonce_symbols

ci/inspect_binary.py:46–79  ·  view source on GitHub ↗

Demangle .gnu.linkonce.t symbols in the map file. Args: cpp_filt_path (Path): Path to c++filt executable. map_text (str): Content of the map file. Returns: str: Map file content with demangled symbols.

(cpp_filt_path: Path, map_text: str)

Source from the content-addressed store, hash-verified

44
45
46def demangle_gnu_linkonce_symbols(cpp_filt_path: Path, map_text: str) -> str:
47 """
48 Demangle .gnu.linkonce.t symbols in the map file.
49
50 Args:
51 cpp_filt_path (Path): Path to c++filt executable.
52 map_text (str): Content of the map file.
53
54 Returns:
55 str: Map file content with demangled symbols.
56 """
57 # Extract all .gnu.linkonce.t symbols
58 pattern = r"\.gnu\\.linkonce\\.t\\.(.+?)\\s"
59 matches = re.findall(pattern, map_text)
60
61 if not matches:
62 return map_text
63
64 # Create a block of text with the extracted symbols
65 symbols_block = "\n".join(matches)
66
67 # Demangle the symbols
68 demangled_block = cpp_filt(cpp_filt_path, symbols_block)
69
70 # Create a dictionary of mangled to demangled symbols
71 demangled_dict = dict(zip(matches, demangled_block.strip().split("\n")))
72
73 # Replace the mangled symbols with demangled ones in the original text
74 for mangled, demangled in demangled_dict.items():
75 map_text = map_text.replace(
76 f".gnu.linkonce.t.{mangled}", f".gnu.linkonce.t.{demangled}"
77 )
78
79 return map_text
80
81
82def parse_args() -> argparse.Namespace:

Callers 1

mainFunction · 0.85

Calls 2

itemsMethod · 0.80
cpp_filtFunction · 0.70

Tested by

no test coverage detected