coredump: added the chip_rev field into the coredump header

This commit is contained in:
Aleksei Apaseev 2023-07-26 10:52:20 +08:00
parent ba51b09cb2
commit 6532076ad6

View File

@ -163,7 +163,6 @@ def action_extensions(base_actions: Dict, project_path: str) -> Dict:
espcoredump_kwargs = dict() espcoredump_kwargs = dict()
espcoredump_kwargs['port'] = args.port
espcoredump_kwargs['baud'] = args.baud espcoredump_kwargs['baud'] = args.baud
espcoredump_kwargs['gdb_timeout_sec'] = gdb_timeout_sec espcoredump_kwargs['gdb_timeout_sec'] = gdb_timeout_sec
espcoredump_kwargs['chip_rev'] = chip_rev_to_int(chip_rev) espcoredump_kwargs['chip_rev'] = chip_rev_to_int(chip_rev)
@ -174,7 +173,6 @@ def action_extensions(base_actions: Dict, project_path: str) -> Dict:
if extra_gdbinit_file: if extra_gdbinit_file:
espcoredump_kwargs['extra_gdbinit_file'] = extra_gdbinit_file espcoredump_kwargs['extra_gdbinit_file'] = extra_gdbinit_file
espcoredump_kwargs: Dict[str, Any] = dict()
core_format = None core_format = None
if core: if core:
@ -191,16 +189,8 @@ def action_extensions(base_actions: Dict, project_path: str) -> Dict:
sys.exit(1) sys.exit(1)
espcoredump_kwargs['port'] = args.port espcoredump_kwargs['port'] = args.port
espcoredump_kwargs['baud'] = args.baud espcoredump_kwargs['parttable_off'] = get_sdkconfig_value(project_desc['config_file'],
espcoredump_kwargs['gdb_timeout_sec'] = gdb_timeout_sec 'CONFIG_PARTITION_TABLE_OFFSET')
# for reproducible builds
extra_gdbinit_file = project_desc.get('debug_prefix_map_gdbinit', None)
if extra_gdbinit_file:
espcoredump_kwargs['extra_gdbinit_file'] = extra_gdbinit_file
espcoredump_kwargs['parttable_off'] = get_sdkconfig_value(project_desc['config_file'], 'CONFIG_PARTITION_TABLE_OFFSET')
if core_format: if core_format:
espcoredump_kwargs['core_format'] = core_format espcoredump_kwargs['core_format'] = core_format
@ -272,7 +262,8 @@ def action_extensions(base_actions: Dict, project_path: str) -> Dict:
base_ident = ' ' base_ident = ' '
rom_elfs_dir = os.getenv('ESP_ROM_ELF_DIR') rom_elfs_dir = os.getenv('ESP_ROM_ELF_DIR')
if not rom_elfs_dir: if not rom_elfs_dir:
raise FatalError('ESP_ROM_ELF_DIR environment variable is not defined. Please try to run IDF "install" and "export" scripts.') raise FatalError(
'ESP_ROM_ELF_DIR environment variable is not defined. Please try to run IDF "install" and "export" scripts.')
with open(os.path.join(os.path.dirname(os.path.realpath(__file__)), ESP_ROM_INFO_FILE), 'r') as f: with open(os.path.join(os.path.dirname(os.path.realpath(__file__)), ESP_ROM_INFO_FILE), 'r') as f:
roms = json.load(f) roms = json.load(f)
if target not in roms: if target not in roms:
@ -409,8 +400,9 @@ def action_extensions(base_actions: Dict, project_path: str) -> Dict:
# use default value if commands not defined in the environment nor command line # use default value if commands not defined in the environment nor command line
target = project_desc['target'] target = project_desc['target']
openocd_arguments = get_openocd_arguments(target) openocd_arguments = get_openocd_arguments(target)
print('Note: OpenOCD cfg not found (via env variable OPENOCD_COMMANDS nor as a --openocd-commands argument)\n' print(
'OpenOCD arguments default to: "{}"'.format(openocd_arguments)) 'Note: OpenOCD cfg not found (via env variable OPENOCD_COMMANDS nor as a --openocd-commands argument)\n'
'OpenOCD arguments default to: "{}"'.format(openocd_arguments))
# script directory is taken from the environment by OpenOCD, update only if command line arguments to override # script directory is taken from the environment by OpenOCD, update only if command line arguments to override
if openocd_scripts is not None: if openocd_scripts is not None:
openocd_arguments += ' -s {}'.format(openocd_scripts) openocd_arguments += ' -s {}'.format(openocd_scripts)
@ -496,8 +488,8 @@ def action_extensions(base_actions: Dict, project_path: str) -> Dict:
if debug_targets: if debug_targets:
# Register the meta cleanup callback -> called on FatalError # Register the meta cleanup callback -> called on FatalError
ctx.meta['cleanup'] = debug_cleanup ctx.meta['cleanup'] = debug_cleanup
move_to_front('gdbgui') # possibly 2nd move_to_front('gdbgui') # possibly 2nd
move_to_front('openocd') # always 1st move_to_front('openocd') # always 1st
# followed by "monitor", "gdb" or "gdbtui" in any order # followed by "monitor", "gdb" or "gdbtui" in any order
post_action = ctx.invoke(ctx.command.get_command(ctx, 'post_debug')) post_action = ctx.invoke(ctx.command.get_command(ctx, 'post_debug'))
@ -505,7 +497,7 @@ def action_extensions(base_actions: Dict, project_path: str) -> Dict:
post_action.action_args['block'] = 0 post_action.action_args['block'] = 0
else: else:
post_action.action_args['block'] = 1 post_action.action_args['block'] = 1
tasks.append(post_action) # always last tasks.append(post_action) # always last
if any([task.name == 'openocd' for task in tasks]): if any([task.name == 'openocd' for task in tasks]):
for task in tasks: for task in tasks:
if task.name in ('gdb', 'gdbgui', 'gdbtui'): if task.name in ('gdb', 'gdbgui', 'gdbtui'):
@ -517,11 +509,12 @@ def action_extensions(base_actions: Dict, project_path: str) -> Dict:
""" """
gdb(action, ctx, args, False, 1, gdbinit, require_openocd) gdb(action, ctx, args, False, 1, gdbinit, require_openocd)
def gdb(action: str, ctx: Context, args: PropertyDict, batch: bool, gdb_tui: Optional[int], gdbinit: Optional[str], require_openocd: bool) -> None: def gdb(action: str, ctx: Context, args: PropertyDict, batch: bool, gdb_tui: Optional[int], gdbinit: Optional[str],
require_openocd: bool) -> None:
""" """
Synchronous GDB target Synchronous GDB target
""" """
watch_openocd = Thread(target=_check_openocd_errors, args=(fail_if_openocd_failed, action, ctx, )) watch_openocd = Thread(target=_check_openocd_errors, args=(fail_if_openocd_failed, action, ctx,))
watch_openocd.start() watch_openocd.start()
processes['threads_to_join'].append(watch_openocd) processes['threads_to_join'].append(watch_openocd)
project_desc = get_project_desc(args, ctx) project_desc = get_project_desc(args, ctx)
@ -615,14 +608,14 @@ def action_extensions(base_actions: Dict, project_path: str) -> Dict:
{ {
'names': ['--openocd-scripts', '--openocd_scripts'], 'names': ['--openocd-scripts', '--openocd_scripts'],
'help': 'help':
('Script directory for openocd cfg files.\n'), ('Script directory for openocd cfg files.\n'),
'default': 'default':
None, None,
}, },
{ {
'names': ['--openocd-commands', '--openocd_commands'], 'names': ['--openocd-commands', '--openocd_commands'],
'help': 'help':
('Command line arguments for openocd.\n'), ('Command line arguments for openocd.\n'),
'default': None, 'default': None,
} }
], ],
@ -654,9 +647,9 @@ def action_extensions(base_actions: Dict, project_path: str) -> Dict:
{ {
'names': ['--gdbgui-port', '--gdbgui_port'], 'names': ['--gdbgui-port', '--gdbgui_port'],
'help': 'help':
('The port on which gdbgui will be hosted. Default: 5000\n'), ('The port on which gdbgui will be hosted. Default: 5000\n'),
'default': 'default':
None, None,
}, gdbinit, fail_if_openocd_failed }, gdbinit, fail_if_openocd_failed
], ],
'order_dependencies': ['all', 'flash'], 'order_dependencies': ['all', 'flash'],
@ -687,7 +680,7 @@ def action_extensions(base_actions: Dict, project_path: str) -> Dict:
{ {
'names': ['--block', '--block'], 'names': ['--block', '--block'],
'help': 'help':
('Set to 1 for blocking the console on the outputs of async debug actions\n'), ('Set to 1 for blocking the console on the outputs of async debug actions\n'),
'default': 0, 'default': 0,
}, },
], ],
@ -707,7 +700,7 @@ def action_extensions(base_actions: Dict, project_path: str) -> Dict:
{ {
'names': ['--block', '--block'], 'names': ['--block', '--block'],
'help': 'help':
('Set to 1 for blocking the console on the outputs of async debug actions\n'), ('Set to 1 for blocking the console on the outputs of async debug actions\n'),
'default': 0, 'default': 0,
}, },
], ],