mirror of
https://github.com/esphome/esphome.git
synced 2025-10-23 20:23:50 +01:00
merge
This commit is contained in:
@@ -20,6 +20,21 @@ from .const import (
|
|||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
def _map_section_name(raw_section: str) -> str | None:
|
||||||
|
"""Map raw section name to standard section.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
raw_section: Raw section name from ELF file (e.g., ".iram0.text", ".rodata.str1.1")
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Standard section name (".text", ".rodata", ".data", ".bss") or None
|
||||||
|
"""
|
||||||
|
for standard_section, patterns in SECTION_MAPPING.items():
|
||||||
|
if any(pattern in raw_section for pattern in patterns):
|
||||||
|
return standard_section
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
# Get the list of actual ESPHome components by scanning the components directory
|
# Get the list of actual ESPHome components by scanning the components directory
|
||||||
@cache
|
@cache
|
||||||
def get_esphome_components():
|
def get_esphome_components():
|
||||||
@@ -154,17 +169,8 @@ class MemoryAnalyzer:
|
|||||||
size_hex = match.group(2)
|
size_hex = match.group(2)
|
||||||
size = int(size_hex, 16)
|
size = int(size_hex, 16)
|
||||||
|
|
||||||
# Map various section names to standard categories
|
# Map to standard section name
|
||||||
mapped_section = None
|
mapped_section = _map_section_name(section_name)
|
||||||
if ".text" in section_name or ".iram" in section_name:
|
|
||||||
mapped_section = ".text"
|
|
||||||
elif ".rodata" in section_name:
|
|
||||||
mapped_section = ".rodata"
|
|
||||||
elif ".data" in section_name and "bss" not in section_name:
|
|
||||||
mapped_section = ".data"
|
|
||||||
elif ".bss" in section_name:
|
|
||||||
mapped_section = ".bss"
|
|
||||||
|
|
||||||
if mapped_section:
|
if mapped_section:
|
||||||
if mapped_section not in self.sections:
|
if mapped_section not in self.sections:
|
||||||
self.sections[mapped_section] = MemorySection(
|
self.sections[mapped_section] = MemorySection(
|
||||||
@@ -179,13 +185,6 @@ class MemoryAnalyzer:
|
|||||||
def _parse_symbols(self) -> None:
|
def _parse_symbols(self) -> None:
|
||||||
"""Parse symbols from ELF file."""
|
"""Parse symbols from ELF file."""
|
||||||
|
|
||||||
def map_section_name(raw_section: str) -> str | None:
|
|
||||||
"""Map raw section name to standard section."""
|
|
||||||
for standard_section, patterns in SECTION_MAPPING.items():
|
|
||||||
if any(pattern in raw_section for pattern in patterns):
|
|
||||||
return standard_section
|
|
||||||
return None
|
|
||||||
|
|
||||||
def parse_symbol_line(line: str) -> tuple[str, str, int, str] | None:
|
def parse_symbol_line(line: str) -> tuple[str, str, int, str] | None:
|
||||||
"""Parse a single symbol line from objdump output.
|
"""Parse a single symbol line from objdump output.
|
||||||
|
|
||||||
@@ -211,7 +210,7 @@ class MemoryAnalyzer:
|
|||||||
# Find section, size, and name
|
# Find section, size, and name
|
||||||
for i, part in enumerate(parts):
|
for i, part in enumerate(parts):
|
||||||
if part.startswith("."):
|
if part.startswith("."):
|
||||||
section = map_section_name(part)
|
section = _map_section_name(part)
|
||||||
if section and i + 1 < len(parts):
|
if section and i + 1 < len(parts):
|
||||||
try:
|
try:
|
||||||
size = int(parts[i + 1], 16)
|
size = int(parts[i + 1], 16)
|
||||||
|
Reference in New Issue
Block a user