mirror of
https://github.com/espressif/esp-idf
synced 2025-03-10 09:39:10 -04:00
Merge branch 'bugfix/coredump_detect_v5.1' into 'release/v5.1'
tools: idf.py: fix detection of raw core dump file (v5.1) See merge request espressif/esp-idf!27842
This commit is contained in:
commit
6dc9cc81cc
@ -9,7 +9,6 @@ import subprocess
|
|||||||
import sys
|
import sys
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
from base64 import b64decode
|
|
||||||
from textwrap import indent
|
from textwrap import indent
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
from typing import Any, Dict, List, Optional
|
from typing import Any, Dict, List, Optional
|
||||||
@ -148,12 +147,10 @@ def action_extensions(base_actions: Dict, project_path: str) -> Dict:
|
|||||||
prog = os.path.join(project_desc['build_dir'], project_desc['app_elf'])
|
prog = os.path.join(project_desc['build_dir'], project_desc['app_elf'])
|
||||||
|
|
||||||
espcoredump_kwargs: Dict[str, Any] = dict()
|
espcoredump_kwargs: Dict[str, Any] = dict()
|
||||||
core_format = None
|
|
||||||
|
|
||||||
if core:
|
if core:
|
||||||
espcoredump_kwargs['core'] = core
|
espcoredump_kwargs['core'] = core
|
||||||
espcoredump_kwargs['chip'] = get_sdkconfig_value(project_desc['config_file'], 'CONFIG_IDF_TARGET')
|
espcoredump_kwargs['core_format'] = 'auto'
|
||||||
core_format = get_core_file_format(core)
|
|
||||||
elif coredump_to_flash:
|
elif coredump_to_flash:
|
||||||
# If the core dump is read from flash, we don't need to specify the --core-format argument at all.
|
# If the core dump is read from flash, we don't need to specify the --core-format argument at all.
|
||||||
# The format will be determined automatically
|
# The format will be determined automatically
|
||||||
@ -175,9 +172,6 @@ def action_extensions(base_actions: Dict, project_path: str) -> Dict:
|
|||||||
|
|
||||||
espcoredump_kwargs['parttable_off'] = get_sdkconfig_value(project_desc['config_file'], 'CONFIG_PARTITION_TABLE_OFFSET')
|
espcoredump_kwargs['parttable_off'] = get_sdkconfig_value(project_desc['config_file'], 'CONFIG_PARTITION_TABLE_OFFSET')
|
||||||
|
|
||||||
if core_format:
|
|
||||||
espcoredump_kwargs['core_format'] = core_format
|
|
||||||
|
|
||||||
if save_core:
|
if save_core:
|
||||||
espcoredump_kwargs['save_core'] = save_core
|
espcoredump_kwargs['save_core'] = save_core
|
||||||
|
|
||||||
@ -196,34 +190,6 @@ def action_extensions(base_actions: Dict, project_path: str) -> Dict:
|
|||||||
raise
|
raise
|
||||||
return coredump
|
return coredump
|
||||||
|
|
||||||
def get_core_file_format(core_file: str) -> str:
|
|
||||||
bin_v1 = 1
|
|
||||||
bin_v2 = 2
|
|
||||||
elf_crc32 = 256
|
|
||||||
elf_sha256 = 257
|
|
||||||
|
|
||||||
with open(core_file, 'rb') as f:
|
|
||||||
coredump_bytes = f.read(16)
|
|
||||||
|
|
||||||
if coredump_bytes.startswith(b'\x7fELF'):
|
|
||||||
return 'elf'
|
|
||||||
|
|
||||||
core_version = int.from_bytes(coredump_bytes[4:7], 'little')
|
|
||||||
if core_version in [bin_v1, bin_v2, elf_crc32, elf_sha256]:
|
|
||||||
# esp-coredump will determine automatically the core format (ELF or BIN)
|
|
||||||
return 'raw'
|
|
||||||
with open(core_file) as c:
|
|
||||||
coredump_str = c.read()
|
|
||||||
try:
|
|
||||||
b64decode(coredump_str)
|
|
||||||
except Exception:
|
|
||||||
print('The format of the provided core-file is not recognized. '
|
|
||||||
'Please ensure that the core-format matches one of the following: ELF (“elf”), '
|
|
||||||
'raw (raw) or base64-encoded (b64) binary')
|
|
||||||
sys.exit(1)
|
|
||||||
else:
|
|
||||||
return 'b64'
|
|
||||||
|
|
||||||
def is_gdb_with_python(gdb: str) -> bool:
|
def is_gdb_with_python(gdb: str) -> bool:
|
||||||
# execute simple python command to check is it supported
|
# execute simple python command to check is it supported
|
||||||
return subprocess.run([gdb, '--batch-silent', '--ex', 'python import os'],
|
return subprocess.run([gdb, '--batch-silent', '--ex', 'python import os'],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user