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

Function decode_addresses

ci/decode_esp32_backtrace.py:120–170  ·  view source on GitHub ↗

Decode addresses using addr2line. Args: elf_file: Path to ELF file addresses: List of addresses to decode build_info_path: Optional path to build_info.json for finding addr2line

(
    elf_file: Path, addresses: list[str], build_info_path: Optional[Path] = None
)

Source from the content-addressed store, hash-verified

118
119
120def decode_addresses(
121 elf_file: Path, addresses: list[str], build_info_path: Optional[Path] = None
122) -> None:
123 """Decode addresses using addr2line.
124
125 Args:
126 elf_file: Path to ELF file
127 addresses: List of addresses to decode
128 build_info_path: Optional path to build_info.json for finding addr2line
129 """
130 # Try build_info.json first if provided
131 addr2line = None
132 if build_info_path:
133 addr2line = find_addr2line_from_build_info(build_info_path)
134
135 # Fall back to default search
136 if not addr2line:
137 addr2line = find_addr2line()
138
139 if not addr2line:
140 print("Error: Could not find addr2line tool", file=sys.stderr)
141 print("Make sure PlatformIO ESP32 toolchain is installed", file=sys.stderr)
142 print("Or provide --build-info with path to build_info.json", file=sys.stderr)
143 return
144
145 if not elf_file.exists():
146 print(f"Error: ELF file not found: {elf_file}", file=sys.stderr)
147 return
148
149 if not addresses:
150 print("No addresses to decode", file=sys.stderr)
151 return
152
153 # Run addr2line
154 cmd = [str(addr2line), "-e", str(elf_file), "-f", "-C"] + addresses
155
156 try:
157 result = subprocess.run(cmd, capture_output=True, text=True, check=True)
158 print("\n=== Decoded Stack Trace ===")
159
160 lines = result.stdout.strip().split("\n")
161 for i in range(0, len(lines), 2):
162 if i + 1 < len(lines):
163 func = lines[i]
164 loc = lines[i + 1]
165 addr = addresses[i // 2] if i // 2 < len(addresses) else "?"
166 print(f"{addr}: {func}")
167 print(f" at {loc}")
168
169 except subprocess.CalledProcessError as e:
170 print(f"Error running addr2line: {e}", file=sys.stderr)
171
172
173def extract_addresses_from_crash_log(log: str) -> list[str]:

Callers 1

mainFunction · 0.85

Calls 4

find_addr2lineFunction · 0.85
printFunction · 0.50
runMethod · 0.45

Tested by

no test coverage detected