diff --git a/platformio/commands/debug.py b/platformio/commands/debug.py index 7abb1976..44e3302a 100644 --- a/platformio/commands/debug.py +++ b/platformio/commands/debug.py @@ -120,8 +120,9 @@ def cli(ctx, project_dir, project_conf, environment, verbose, interface, __unpro rebuild_prog = helpers.is_prog_obsolete( debug_config.program_path ) or not helpers.has_debug_symbols(debug_config.program_path) - else: - rebuild_prog = not os.path.isfile(debug_config.program_path) + + if not (debug_config.program_path and os.path.isfile(debug_config.program_path)): + rebuild_prog = True if preload or (not rebuild_prog and load_mode != "always"): # don't load firmware through debug server diff --git a/platformio/debug/config/base.py b/platformio/debug/config/base.py index 4143117d..13fd804f 100644 --- a/platformio/debug/config/base.py +++ b/platformio/debug/config/base.py @@ -88,7 +88,12 @@ class DebugConfigBase: # pylint: disable=too-many-instance-attributes @property def init_break(self): - result = self.env_options.get("debug_init_break") + missed = object() + result = self.env_options.get("debug_init_break", missed) + if result != missed: + return result + else: + result = None if not result: result = self.tool_settings.get("init_break") return result or ProjectOptions["env.debug_init_break"].default @@ -196,13 +201,14 @@ class DebugConfigBase: # pylint: disable=too-many-instance-attributes raise NotImplementedError def reveal_patterns(self, source, recursive=True): + program_path = self.program_path or "" patterns = { "PLATFORMIO_CORE_DIR": get_project_core_dir(), "PYTHONEXE": proc.get_pythonexe_path(), "PROJECT_DIR": self.project_config.path, - "PROG_PATH": self.program_path, - "PROG_DIR": os.path.dirname(self.program_path), - "PROG_NAME": os.path.basename(os.path.splitext(self.program_path)[0]), + "PROG_PATH": program_path, + "PROG_DIR": os.path.dirname(program_path), + "PROG_NAME": os.path.basename(os.path.splitext(program_path)[0]), "DEBUG_PORT": self.port, "UPLOAD_PROTOCOL": self.upload_protocol, "INIT_BREAK": self.init_break or "",