forked from platformio/platformio-core
Allow to pass multiple load commands to PIO Unified Debugger
This commit is contained in:
@ -73,7 +73,7 @@ class GDBClient(BaseProcess): # pylint: disable=too-many-instance-attributes
|
||||
"DEBUG_PORT": self.debug_options['port'],
|
||||
"UPLOAD_PROTOCOL": self.debug_options['upload_protocol'],
|
||||
"INIT_BREAK": self.debug_options['init_break'] or "",
|
||||
"LOAD_CMD": self.debug_options['load_cmd'] or "",
|
||||
"LOAD_CMDS": "\n".join(self.debug_options['load_cmds'] or []),
|
||||
}
|
||||
|
||||
self._debug_server.spawn(patterns)
|
||||
|
@ -93,11 +93,11 @@ def cli(ctx, project_dir, project_conf, environment, verbose, interface,
|
||||
raise exception.PlatformioException("\n".join(
|
||||
[result['out'], result['err']]))
|
||||
|
||||
debug_options['load_cmd'] = helpers.configure_esp32_load_cmd(
|
||||
debug_options['load_cmds'] = helpers.configure_esp32_load_cmds(
|
||||
debug_options, configuration)
|
||||
|
||||
rebuild_prog = False
|
||||
preload = debug_options['load_cmd'] == "preload"
|
||||
preload = debug_options['load_cmds'] == ["preload"]
|
||||
load_mode = debug_options['load_mode']
|
||||
if load_mode == "always":
|
||||
rebuild_prog = (
|
||||
@ -112,7 +112,7 @@ def cli(ctx, project_dir, project_conf, environment, verbose, interface,
|
||||
|
||||
if preload or (not rebuild_prog and load_mode != "always"):
|
||||
# don't load firmware through debug server
|
||||
debug_options['load_cmd'] = None
|
||||
debug_options['load_cmds'] = []
|
||||
|
||||
if rebuild_prog:
|
||||
if helpers.is_mi_mode(__unprocessed):
|
||||
|
@ -26,6 +26,7 @@ from platformio.commands.platform import \
|
||||
platform_install as cmd_platform_install
|
||||
from platformio.commands.run import cli as cmd_run
|
||||
from platformio.managers.platform import PlatformFactory
|
||||
from platformio.project.config import ProjectConfig
|
||||
|
||||
|
||||
class GDBBytesIO(BytesIO): # pylint: disable=too-few-public-methods
|
||||
@ -53,12 +54,11 @@ def get_default_debug_env(config):
|
||||
|
||||
def validate_debug_options(cmd_ctx, env_options):
|
||||
|
||||
def _cleanup_cmds(cmds):
|
||||
if not cmds:
|
||||
return []
|
||||
if not isinstance(cmds, list):
|
||||
cmds = cmds.split("\n")
|
||||
return [c.strip() for c in cmds if c.strip()]
|
||||
def _cleanup_cmds(items):
|
||||
items = ProjectConfig.parse_multi_values(items)
|
||||
return [
|
||||
"$LOAD_CMDS" if item == "$LOAD_CMD" else item for item in items
|
||||
]
|
||||
|
||||
try:
|
||||
platform = PlatformFactory.newPlatform(env_options['platform'])
|
||||
@ -115,8 +115,11 @@ def validate_debug_options(cmd_ctx, env_options):
|
||||
upload_protocol=env_options.get(
|
||||
"upload_protocol",
|
||||
board_config.get("upload", {}).get("protocol")),
|
||||
load_cmd=env_options.get("debug_load_cmd",
|
||||
tool_settings.get("load_cmd", "load")),
|
||||
load_cmds=_cleanup_cmds(
|
||||
env_options.get(
|
||||
"debug_load_cmds",
|
||||
tool_settings.get("load_cmds",
|
||||
tool_settings.get("load_cmd", "load")))),
|
||||
load_mode=env_options.get("debug_load_mode",
|
||||
tool_settings.get("load_mode", "always")),
|
||||
init_break=env_options.get(
|
||||
@ -173,9 +176,9 @@ def load_configuration(ctx, project_dir, env_name):
|
||||
return None
|
||||
|
||||
|
||||
def configure_esp32_load_cmd(debug_options, configuration):
|
||||
def configure_esp32_load_cmds(debug_options, configuration):
|
||||
ignore_conds = [
|
||||
debug_options['load_cmd'] != "load",
|
||||
debug_options['load_cmds'] != ["load"],
|
||||
"xtensa-esp32" not in configuration.get("cc_path", ""),
|
||||
not configuration.get("flash_extra_images"), not all([
|
||||
isfile(item['path'])
|
||||
@ -183,7 +186,7 @@ def configure_esp32_load_cmd(debug_options, configuration):
|
||||
])
|
||||
]
|
||||
if any(ignore_conds):
|
||||
return debug_options['load_cmd']
|
||||
return debug_options['load_cmds']
|
||||
|
||||
mon_cmds = [
|
||||
'monitor program_esp32 "{{{path}}}" {offset} verify'.format(
|
||||
@ -192,7 +195,7 @@ def configure_esp32_load_cmd(debug_options, configuration):
|
||||
]
|
||||
mon_cmds.append('monitor program_esp32 "{%s.bin}" 0x10000 verify' %
|
||||
escape_path(configuration['prog_path'][:-4]))
|
||||
return "\n".join(mon_cmds)
|
||||
return mon_cmds
|
||||
|
||||
|
||||
def has_debug_symbols(prog_path):
|
||||
|
@ -24,7 +24,7 @@ end
|
||||
target extended-remote $DEBUG_PORT
|
||||
$INIT_BREAK
|
||||
pio_reset_halt_target
|
||||
$LOAD_CMD
|
||||
$LOAD_CMDS
|
||||
monitor init
|
||||
pio_reset_halt_target
|
||||
"""
|
||||
@ -42,7 +42,7 @@ end
|
||||
target extended-remote $DEBUG_PORT
|
||||
$INIT_BREAK
|
||||
pio_reset_halt_target
|
||||
$LOAD_CMD
|
||||
$LOAD_CMDS
|
||||
pio_reset_halt_target
|
||||
"""
|
||||
|
||||
@ -59,7 +59,7 @@ end
|
||||
target extended-remote $DEBUG_PORT
|
||||
$INIT_BREAK
|
||||
pio_reset_halt_target
|
||||
$LOAD_CMD
|
||||
$LOAD_CMDS
|
||||
pio_reset_halt_target
|
||||
"""
|
||||
|
||||
@ -83,7 +83,7 @@ monitor swdp_scan
|
||||
attach 1
|
||||
set mem inaccessible-by-default off
|
||||
$INIT_BREAK
|
||||
$LOAD_CMD
|
||||
$LOAD_CMDS
|
||||
|
||||
set language c
|
||||
set *0xE000ED0C = 0x05FA0004
|
||||
@ -104,6 +104,6 @@ end
|
||||
target extended-remote $DEBUG_PORT
|
||||
$INIT_BREAK
|
||||
monitor erase
|
||||
$LOAD_CMD
|
||||
$LOAD_CMDS
|
||||
pio_reset_halt_target
|
||||
"""
|
||||
|
@ -176,7 +176,9 @@ ProjectOptions = OrderedDict([
|
||||
ConfigEnvOption(name="debug_init_break"),
|
||||
ConfigEnvOption(name="debug_init_cmds", multiple=True),
|
||||
ConfigEnvOption(name="debug_extra_cmds", multiple=True),
|
||||
ConfigEnvOption(name="debug_load_cmd"),
|
||||
ConfigEnvOption(name="debug_load_cmds",
|
||||
oldnames=["debug_load_cmd"],
|
||||
multiple=True),
|
||||
ConfigEnvOption(name="debug_load_mode",
|
||||
type=click.Choice(["always", "modified", "manual"])),
|
||||
ConfigEnvOption(name="debug_server", multiple=True),
|
||||
|
Reference in New Issue
Block a user