2021-10-04 16:59:15 +02:00
|
|
|
from dataclasses import dataclass
|
2018-11-03 14:06:14 +01:00
|
|
|
import json
|
|
|
|
import logging
|
2018-12-05 21:22:06 +01:00
|
|
|
import os
|
2024-07-29 04:07:44 +02:00
|
|
|
from pathlib import Path
|
2018-11-03 14:06:14 +01:00
|
|
|
import re
|
|
|
|
import subprocess
|
2024-07-29 04:07:44 +02:00
|
|
|
from typing import Union
|
2018-11-03 14:06:14 +01:00
|
|
|
|
2022-10-27 01:17:21 +02:00
|
|
|
from esphome.const import CONF_COMPILE_PROCESS_LIMIT, CONF_ESPHOME, KEY_CORE
|
2021-10-04 16:59:15 +02:00
|
|
|
from esphome.core import CORE, EsphomeError
|
2019-02-13 16:54:02 +01:00
|
|
|
from esphome.util import run_external_command, run_external_process
|
2018-11-03 14:06:14 +01:00
|
|
|
|
|
|
|
_LOGGER = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
2019-04-17 12:06:00 +02:00
|
|
|
def patch_structhash():
|
|
|
|
# Patch platformio's structhash to not recompile the entire project when files are
|
|
|
|
# removed/added. This might have unintended consequences, but this improves compile
|
|
|
|
# times greatly when adding/removing components and a simple clean build solves
|
|
|
|
# all issues
|
|
|
|
from os import makedirs
|
2024-07-29 04:07:44 +02:00
|
|
|
from os.path import getmtime, isdir, join
|
|
|
|
|
|
|
|
from platformio.run import cli, helpers
|
2019-04-17 12:06:00 +02:00
|
|
|
|
2019-08-27 21:33:01 +02:00
|
|
|
def patched_clean_build_dir(build_dir, *args):
|
2020-09-16 12:38:33 +02:00
|
|
|
from platformio import fs
|
2019-10-18 15:33:30 +02:00
|
|
|
from platformio.project.helpers import get_project_dir
|
2021-03-07 20:03:16 +01:00
|
|
|
|
2019-05-28 16:00:00 +02:00
|
|
|
platformio_ini = join(get_project_dir(), "platformio.ini")
|
2019-04-17 12:06:00 +02:00
|
|
|
|
|
|
|
# if project's config is modified
|
|
|
|
if isdir(build_dir) and getmtime(platformio_ini) > getmtime(build_dir):
|
2020-09-16 12:38:33 +02:00
|
|
|
fs.rmtree(build_dir)
|
2019-04-17 12:06:00 +02:00
|
|
|
|
|
|
|
if not isdir(build_dir):
|
|
|
|
makedirs(build_dir)
|
|
|
|
|
2019-10-18 15:33:30 +02:00
|
|
|
helpers.clean_build_dir = patched_clean_build_dir
|
2022-06-21 01:53:51 +02:00
|
|
|
cli.clean_build_dir = patched_clean_build_dir
|
2019-04-17 12:06:00 +02:00
|
|
|
|
|
|
|
|
2021-09-19 19:22:28 +02:00
|
|
|
IGNORE_LIB_WARNINGS = f"(?:{'|'.join(['Hash', 'Update'])})"
|
2019-10-19 14:04:14 +02:00
|
|
|
FILTER_PLATFORMIO_LINES = [
|
2021-03-07 20:03:16 +01:00
|
|
|
r"Verbose mode can be enabled via `-v, --verbose` option.*",
|
|
|
|
r"CONFIGURATION: https://docs.platformio.org/.*",
|
|
|
|
r"DEBUG: Current.*",
|
2021-10-22 16:52:43 +02:00
|
|
|
r"LDF Modes:.*",
|
2023-03-19 20:11:18 +01:00
|
|
|
r"LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf.*",
|
2021-09-19 19:22:28 +02:00
|
|
|
f"Looking for {IGNORE_LIB_WARNINGS} library in registry",
|
|
|
|
f"Warning! Library `.*'{IGNORE_LIB_WARNINGS}.*` has not been found in PlatformIO Registry.",
|
|
|
|
f"You can ignore this message, if `.*{IGNORE_LIB_WARNINGS}.*` is a built-in library.*",
|
2021-03-07 20:03:16 +01:00
|
|
|
r"Scanning dependencies...",
|
2019-10-19 14:04:14 +02:00
|
|
|
r"Found \d+ compatible libraries",
|
2021-03-07 20:03:16 +01:00
|
|
|
r"Memory Usage -> http://bit.ly/pio-memory-usage",
|
2019-10-19 14:04:14 +02:00
|
|
|
r"Found: https://platformio.org/lib/show/.*",
|
|
|
|
r"Using cache: .*",
|
2021-03-07 20:03:16 +01:00
|
|
|
r"Installing dependencies",
|
2021-10-22 16:52:43 +02:00
|
|
|
r"Library Manager: Already installed, built-in library",
|
2021-03-07 20:03:16 +01:00
|
|
|
r"Building in .* mode",
|
|
|
|
r"Advanced Memory Usage is available via .*",
|
2021-10-22 16:52:43 +02:00
|
|
|
r"Merged .* ELF section",
|
|
|
|
r"esptool.py v.*",
|
|
|
|
r"Checking size .*",
|
|
|
|
r"Retrieving maximum program size .*",
|
|
|
|
r"PLATFORM: .*",
|
|
|
|
r"PACKAGES:.*",
|
|
|
|
r" - framework-arduinoespressif.* \(.*\)",
|
|
|
|
r" - tool-esptool.* \(.*\)",
|
|
|
|
r" - toolchain-.* \(.*\)",
|
|
|
|
r"Creating BIN file .*",
|
2019-10-19 14:04:14 +02:00
|
|
|
]
|
|
|
|
|
|
|
|
|
2020-03-12 01:22:45 +01:00
|
|
|
def run_platformio_cli(*args, **kwargs) -> Union[str, int]:
|
2018-12-05 21:22:06 +01:00
|
|
|
os.environ["PLATFORMIO_FORCE_COLOR"] = "true"
|
2019-03-03 16:50:06 +01:00
|
|
|
os.environ["PLATFORMIO_BUILD_DIR"] = os.path.abspath(CORE.relative_pioenvs_path())
|
2021-09-20 09:07:38 +02:00
|
|
|
os.environ.setdefault(
|
|
|
|
"PLATFORMIO_LIBDEPS_DIR", os.path.abspath(CORE.relative_piolibdeps_path())
|
2021-03-07 20:03:16 +01:00
|
|
|
)
|
|
|
|
cmd = ["platformio"] + list(args)
|
2019-01-19 17:54:41 +01:00
|
|
|
|
2019-10-19 14:04:14 +02:00
|
|
|
if not CORE.verbose:
|
2021-03-07 20:03:16 +01:00
|
|
|
kwargs["filter_lines"] = FILTER_PLATFORMIO_LINES
|
2019-10-19 14:04:14 +02:00
|
|
|
|
2021-03-07 20:03:16 +01:00
|
|
|
if os.environ.get("ESPHOME_USE_SUBPROCESS") is not None:
|
2019-06-28 11:29:37 +02:00
|
|
|
return run_external_process(*cmd, **kwargs)
|
|
|
|
|
|
|
|
import platformio.__main__
|
2021-03-07 20:03:16 +01:00
|
|
|
|
2019-06-28 11:29:37 +02:00
|
|
|
patch_structhash()
|
2021-03-07 20:03:16 +01:00
|
|
|
return run_external_command(platformio.__main__.main, *cmd, **kwargs)
|
2018-11-03 14:06:14 +01:00
|
|
|
|
|
|
|
|
2020-03-12 01:22:45 +01:00
|
|
|
def run_platformio_cli_run(config, verbose, *args, **kwargs) -> Union[str, int]:
|
2021-03-07 20:03:16 +01:00
|
|
|
command = ["run", "-d", CORE.build_path]
|
2018-11-03 14:06:14 +01:00
|
|
|
if verbose:
|
2021-03-07 20:03:16 +01:00
|
|
|
command += ["-v"]
|
2018-11-03 14:06:14 +01:00
|
|
|
command += list(args)
|
|
|
|
return run_platformio_cli(*command, **kwargs)
|
|
|
|
|
|
|
|
|
|
|
|
def run_compile(config, verbose):
|
2022-10-27 01:17:21 +02:00
|
|
|
args = []
|
|
|
|
if CONF_COMPILE_PROCESS_LIMIT in config[CONF_ESPHOME]:
|
|
|
|
args += [f"-j{config[CONF_ESPHOME][CONF_COMPILE_PROCESS_LIMIT]}"]
|
|
|
|
return run_platformio_cli_run(config, verbose, *args)
|
2018-11-03 14:06:14 +01:00
|
|
|
|
|
|
|
|
2021-10-04 16:59:15 +02:00
|
|
|
def _run_idedata(config):
|
2021-03-07 20:03:16 +01:00
|
|
|
args = ["-t", "idedata"]
|
2020-03-12 01:16:05 +01:00
|
|
|
stdout = run_platformio_cli_run(config, False, *args, capture_stdout=True)
|
2019-11-02 21:19:15 +01:00
|
|
|
match = re.search(r'{\s*".*}', stdout)
|
2018-11-03 14:06:14 +01:00
|
|
|
if match is None:
|
2021-10-04 16:59:15 +02:00
|
|
|
_LOGGER.error("Could not match idedata, please report this error")
|
|
|
|
_LOGGER.error("Stdout: %s", stdout)
|
|
|
|
raise EsphomeError
|
|
|
|
|
2018-11-03 14:06:14 +01:00
|
|
|
try:
|
2021-10-04 16:59:15 +02:00
|
|
|
return json.loads(match.group())
|
2018-11-03 14:06:14 +01:00
|
|
|
except ValueError:
|
2021-10-04 16:59:15 +02:00
|
|
|
_LOGGER.error("Could not parse idedata", exc_info=True)
|
|
|
|
_LOGGER.error("Stdout: %s", stdout)
|
|
|
|
raise
|
|
|
|
|
|
|
|
|
|
|
|
def _load_idedata(config):
|
|
|
|
platformio_ini = Path(CORE.relative_build_path("platformio.ini"))
|
2021-10-23 12:38:57 +02:00
|
|
|
temp_idedata = Path(CORE.relative_internal_path("idedata", f"{CORE.name}.json"))
|
2021-10-04 16:59:15 +02:00
|
|
|
|
|
|
|
changed = False
|
|
|
|
if not platformio_ini.is_file() or not temp_idedata.is_file():
|
|
|
|
changed = True
|
|
|
|
elif platformio_ini.stat().st_mtime >= temp_idedata.stat().st_mtime:
|
|
|
|
changed = True
|
2018-11-03 14:06:14 +01:00
|
|
|
|
2021-10-04 16:59:15 +02:00
|
|
|
if not changed:
|
|
|
|
try:
|
|
|
|
return json.loads(temp_idedata.read_text(encoding="utf-8"))
|
|
|
|
except ValueError:
|
|
|
|
pass
|
2018-11-03 14:06:14 +01:00
|
|
|
|
2021-10-04 16:59:15 +02:00
|
|
|
temp_idedata.parent.mkdir(exist_ok=True, parents=True)
|
2018-11-03 14:06:14 +01:00
|
|
|
|
2021-10-04 16:59:15 +02:00
|
|
|
data = _run_idedata(config)
|
2018-11-03 14:06:14 +01:00
|
|
|
|
2021-10-04 16:59:15 +02:00
|
|
|
temp_idedata.write_text(json.dumps(data, indent=2) + "\n", encoding="utf-8")
|
|
|
|
return data
|
2018-11-03 14:06:14 +01:00
|
|
|
|
2021-10-04 16:59:15 +02:00
|
|
|
|
|
|
|
KEY_IDEDATA = "idedata"
|
|
|
|
|
|
|
|
|
|
|
|
def get_idedata(config) -> "IDEData":
|
|
|
|
if KEY_IDEDATA in CORE.data[KEY_CORE]:
|
|
|
|
return CORE.data[KEY_CORE][KEY_IDEDATA]
|
|
|
|
idedata = IDEData(_load_idedata(config))
|
|
|
|
CORE.data[KEY_CORE][KEY_IDEDATA] = idedata
|
|
|
|
return idedata
|
2018-11-03 14:06:14 +01:00
|
|
|
|
|
|
|
|
|
|
|
# ESP logs stack trace decoder, based on https://github.com/me-no-dev/EspExceptionDecoder
|
|
|
|
ESP8266_EXCEPTION_CODES = {
|
2019-01-19 16:50:17 +01:00
|
|
|
0: "Illegal instruction (Is the flash damaged?)",
|
2018-11-03 14:06:14 +01:00
|
|
|
1: "SYSCALL instruction",
|
|
|
|
2: "InstructionFetchError: Processor internal physical address or data error during "
|
2021-03-07 20:03:16 +01:00
|
|
|
"instruction fetch",
|
2018-11-03 14:06:14 +01:00
|
|
|
3: "LoadStoreError: Processor internal physical address or data error during load or store",
|
|
|
|
4: "Level1Interrupt: Level-1 interrupt as indicated by set level-1 bits in the INTERRUPT "
|
2021-03-07 20:03:16 +01:00
|
|
|
"register",
|
2018-11-03 14:06:14 +01:00
|
|
|
5: "Alloca: MOVSP instruction, if caller's registers are not in the register file",
|
2019-01-19 16:50:17 +01:00
|
|
|
6: "Integer Divide By Zero",
|
2018-11-03 14:06:14 +01:00
|
|
|
7: "reserved",
|
|
|
|
8: "Privileged: Attempt to execute a privileged operation when CRING ? 0",
|
|
|
|
9: "LoadStoreAlignmentCause: Load or store to an unaligned address",
|
|
|
|
10: "reserved",
|
|
|
|
11: "reserved",
|
|
|
|
12: "InstrPIFDataError: PIF data error during instruction fetch",
|
|
|
|
13: "LoadStorePIFDataError: Synchronous PIF data error during LoadStore access",
|
|
|
|
14: "InstrPIFAddrError: PIF address error during instruction fetch",
|
|
|
|
15: "LoadStorePIFAddrError: Synchronous PIF address error during LoadStore access",
|
|
|
|
16: "InstTLBMiss: Error during Instruction TLB refill",
|
|
|
|
17: "InstTLBMultiHit: Multiple instruction TLB entries matched",
|
|
|
|
18: "InstFetchPrivilege: An instruction fetch referenced a virtual address at a ring level "
|
2021-03-07 20:03:16 +01:00
|
|
|
"less than CRING",
|
2018-11-03 14:06:14 +01:00
|
|
|
19: "reserved",
|
|
|
|
20: "InstFetchProhibited: An instruction fetch referenced a page mapped with an attribute "
|
2021-03-07 20:03:16 +01:00
|
|
|
"that does not permit instruction fetch",
|
2018-11-03 14:06:14 +01:00
|
|
|
21: "reserved",
|
|
|
|
22: "reserved",
|
|
|
|
23: "reserved",
|
|
|
|
24: "LoadStoreTLBMiss: Error during TLB refill for a load or store",
|
|
|
|
25: "LoadStoreTLBMultiHit: Multiple TLB entries matched for a load or store",
|
|
|
|
26: "LoadStorePrivilege: A load or store referenced a virtual address at a ring level less "
|
2021-03-07 20:03:16 +01:00
|
|
|
"than ",
|
2018-11-03 14:06:14 +01:00
|
|
|
27: "reserved",
|
2019-01-19 16:50:17 +01:00
|
|
|
28: "Access to invalid address: LOAD (wild pointer?)",
|
|
|
|
29: "Access to invalid address: STORE (wild pointer?)",
|
2018-11-03 14:06:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
def _decode_pc(config, addr):
|
|
|
|
idedata = get_idedata(config)
|
|
|
|
if not idedata.addr2line_path or not idedata.firmware_elf_path:
|
2019-11-02 21:19:15 +01:00
|
|
|
_LOGGER.debug("decode_pc no addr2line")
|
2018-11-03 14:06:14 +01:00
|
|
|
return
|
2021-03-07 20:03:16 +01:00
|
|
|
command = [idedata.addr2line_path, "-pfiaC", "-e", idedata.firmware_elf_path, addr]
|
2018-11-03 14:06:14 +01:00
|
|
|
try:
|
2019-12-07 18:28:55 +01:00
|
|
|
translation = subprocess.check_output(command).decode().strip()
|
2018-11-03 14:06:14 +01:00
|
|
|
except Exception: # pylint: disable=broad-except
|
2019-11-02 21:19:15 +01:00
|
|
|
_LOGGER.debug("Caught exception for command %s", command, exc_info=1)
|
2018-11-03 14:06:14 +01:00
|
|
|
return
|
|
|
|
|
|
|
|
if "?? ??:0" in translation:
|
|
|
|
# Nothing useful
|
|
|
|
return
|
2021-03-07 20:03:16 +01:00
|
|
|
translation = translation.replace(" at ??:?", "").replace(":?", "")
|
2018-11-03 14:06:14 +01:00
|
|
|
_LOGGER.warning("Decoded %s", translation)
|
|
|
|
|
|
|
|
|
|
|
|
def _parse_register(config, regex, line):
|
|
|
|
match = regex.match(line)
|
|
|
|
if match is not None:
|
|
|
|
_decode_pc(config, match.group(1))
|
|
|
|
|
|
|
|
|
2021-03-07 20:03:16 +01:00
|
|
|
STACKTRACE_ESP8266_EXCEPTION_TYPE_RE = re.compile(r"[eE]xception \((\d+)\):")
|
|
|
|
STACKTRACE_ESP8266_PC_RE = re.compile(r"epc1=0x(4[0-9a-fA-F]{7})")
|
|
|
|
STACKTRACE_ESP8266_EXCVADDR_RE = re.compile(r"excvaddr=0x(4[0-9a-fA-F]{7})")
|
2021-09-20 11:47:51 +02:00
|
|
|
STACKTRACE_ESP32_PC_RE = re.compile(r".*PC\s*:\s*(?:0x)?(4[0-9a-fA-F]{7}).*")
|
2021-03-07 20:03:16 +01:00
|
|
|
STACKTRACE_ESP32_EXCVADDR_RE = re.compile(r"EXCVADDR\s*:\s*(?:0x)?(4[0-9a-fA-F]{7})")
|
2021-07-26 11:10:56 +02:00
|
|
|
STACKTRACE_ESP32_C3_PC_RE = re.compile(r"MEPC\s*:\s*(?:0x)?(4[0-9a-fA-F]{7})")
|
|
|
|
STACKTRACE_ESP32_C3_RA_RE = re.compile(r"RA\s*:\s*(?:0x)?(4[0-9a-fA-F]{7})")
|
2021-03-07 20:03:16 +01:00
|
|
|
STACKTRACE_BAD_ALLOC_RE = re.compile(
|
|
|
|
r"^last failed alloc call: (4[0-9a-fA-F]{7})\((\d+)\)$"
|
|
|
|
)
|
|
|
|
STACKTRACE_ESP32_BACKTRACE_RE = re.compile(
|
2021-09-20 11:47:51 +02:00
|
|
|
r"Backtrace:(?:\s*0x[0-9a-fA-F]{8}:0x[0-9a-fA-F]{8})+"
|
2021-03-07 20:03:16 +01:00
|
|
|
)
|
|
|
|
STACKTRACE_ESP32_BACKTRACE_PC_RE = re.compile(r"4[0-9a-f]{7}")
|
|
|
|
STACKTRACE_ESP8266_BACKTRACE_PC_RE = re.compile(r"4[0-9a-f]{7}")
|
2018-11-03 14:06:14 +01:00
|
|
|
|
|
|
|
|
|
|
|
def process_stacktrace(config, line, backtrace_state):
|
|
|
|
line = line.strip()
|
|
|
|
# ESP8266 Exception type
|
|
|
|
match = re.match(STACKTRACE_ESP8266_EXCEPTION_TYPE_RE, line)
|
|
|
|
if match is not None:
|
2020-10-13 03:55:18 +02:00
|
|
|
code = int(match.group(1))
|
2021-03-07 20:03:16 +01:00
|
|
|
_LOGGER.warning(
|
|
|
|
"Exception type: %s", ESP8266_EXCEPTION_CODES.get(code, "unknown")
|
|
|
|
)
|
2018-11-03 14:06:14 +01:00
|
|
|
|
|
|
|
# ESP8266 PC/EXCVADDR
|
|
|
|
_parse_register(config, STACKTRACE_ESP8266_PC_RE, line)
|
|
|
|
_parse_register(config, STACKTRACE_ESP8266_EXCVADDR_RE, line)
|
|
|
|
# ESP32 PC/EXCVADDR
|
|
|
|
_parse_register(config, STACKTRACE_ESP32_PC_RE, line)
|
|
|
|
_parse_register(config, STACKTRACE_ESP32_EXCVADDR_RE, line)
|
2021-07-26 11:10:56 +02:00
|
|
|
# ESP32-C3 PC/RA
|
|
|
|
_parse_register(config, STACKTRACE_ESP32_C3_PC_RE, line)
|
|
|
|
_parse_register(config, STACKTRACE_ESP32_C3_RA_RE, line)
|
2018-11-03 14:06:14 +01:00
|
|
|
|
|
|
|
# bad alloc
|
|
|
|
match = re.match(STACKTRACE_BAD_ALLOC_RE, line)
|
|
|
|
if match is not None:
|
2021-03-07 20:03:16 +01:00
|
|
|
_LOGGER.warning(
|
|
|
|
"Memory allocation of %s bytes failed at %s", match.group(2), match.group(1)
|
|
|
|
)
|
2018-11-03 14:06:14 +01:00
|
|
|
_decode_pc(config, match.group(1))
|
|
|
|
|
|
|
|
# ESP32 single-line backtrace
|
|
|
|
match = re.match(STACKTRACE_ESP32_BACKTRACE_RE, line)
|
|
|
|
if match is not None:
|
|
|
|
_LOGGER.warning("Found stack trace! Trying to decode it")
|
|
|
|
for addr in re.finditer(STACKTRACE_ESP32_BACKTRACE_PC_RE, line):
|
|
|
|
_decode_pc(config, addr.group())
|
|
|
|
|
|
|
|
# ESP8266 multi-line backtrace
|
2021-03-07 20:03:16 +01:00
|
|
|
if ">>>stack>>>" in line:
|
2018-11-03 14:06:14 +01:00
|
|
|
# Start of backtrace
|
|
|
|
backtrace_state = True
|
|
|
|
_LOGGER.warning("Found stack trace! Trying to decode it")
|
2021-03-07 20:03:16 +01:00
|
|
|
elif "<<<stack<<<" in line:
|
2018-11-03 14:06:14 +01:00
|
|
|
# End of backtrace
|
|
|
|
backtrace_state = False
|
|
|
|
|
|
|
|
if backtrace_state:
|
|
|
|
for addr in re.finditer(STACKTRACE_ESP8266_BACKTRACE_PC_RE, line):
|
|
|
|
_decode_pc(config, addr.group())
|
|
|
|
|
|
|
|
return backtrace_state
|
|
|
|
|
|
|
|
|
2021-10-04 16:59:15 +02:00
|
|
|
@dataclass
|
|
|
|
class FlashImage:
|
|
|
|
path: str
|
|
|
|
offset: str
|
|
|
|
|
|
|
|
|
2019-12-07 18:28:55 +01:00
|
|
|
class IDEData:
|
2018-11-03 14:06:14 +01:00
|
|
|
def __init__(self, raw):
|
2021-10-04 16:59:15 +02:00
|
|
|
self.raw = raw
|
2018-11-03 14:06:14 +01:00
|
|
|
|
|
|
|
@property
|
|
|
|
def firmware_elf_path(self):
|
2021-10-04 16:59:15 +02:00
|
|
|
return self.raw["prog_path"]
|
|
|
|
|
|
|
|
@property
|
|
|
|
def firmware_bin_path(self) -> str:
|
|
|
|
return str(Path(self.firmware_elf_path).with_suffix(".bin"))
|
2018-11-03 14:06:14 +01:00
|
|
|
|
|
|
|
@property
|
2022-10-05 09:09:27 +02:00
|
|
|
def extra_flash_images(self) -> list[FlashImage]:
|
2018-11-03 14:06:14 +01:00
|
|
|
return [
|
2021-10-04 16:59:15 +02:00
|
|
|
FlashImage(path=entry["path"], offset=entry["offset"])
|
|
|
|
for entry in self.raw["extra"]["flash_images"]
|
2018-11-03 14:06:14 +01:00
|
|
|
]
|
|
|
|
|
|
|
|
@property
|
2021-10-04 16:59:15 +02:00
|
|
|
def cc_path(self) -> str:
|
2018-11-03 14:06:14 +01:00
|
|
|
# For example /Users/<USER>/.platformio/packages/toolchain-xtensa32/bin/xtensa-esp32-elf-gcc
|
2021-10-04 16:59:15 +02:00
|
|
|
return self.raw["cc_path"]
|
2018-11-03 14:06:14 +01:00
|
|
|
|
|
|
|
@property
|
2021-10-04 16:59:15 +02:00
|
|
|
def addr2line_path(self) -> str:
|
2018-11-03 14:06:14 +01:00
|
|
|
# replace gcc at end with addr2line
|
2020-10-13 03:55:18 +02:00
|
|
|
|
|
|
|
# Windows
|
2021-10-04 16:59:15 +02:00
|
|
|
if self.cc_path.endswith(".exe"):
|
|
|
|
return f"{self.cc_path[:-7]}addr2line.exe"
|
2020-10-13 03:55:18 +02:00
|
|
|
|
2021-10-04 16:59:15 +02:00
|
|
|
return f"{self.cc_path[:-3]}addr2line"
|