07e88a9fba
The runnable output from the build system is the exe file. In native_posix the elf happend to also be runnable, but this is not the case in general, and not for native_sim or the nrf5*bsim boards. So lets use the exe instead. Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
47 lines
1.4 KiB
Python
47 lines
1.4 KiB
Python
# Copyright (c) 2023 Nordic Semiconductor
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
"""This file provides a ZephyrBinaryRunner that launches GDB."""
|
|
|
|
import argparse
|
|
from runners.core import ZephyrBinaryRunner, RunnerCaps, RunnerConfig
|
|
|
|
class NativeGDBBinaryRunner(ZephyrBinaryRunner):
|
|
"""Runs the ELF binary under GDB."""
|
|
|
|
@classmethod
|
|
def name(cls):
|
|
return 'native_gdb'
|
|
|
|
@classmethod
|
|
def capabilities(cls):
|
|
return RunnerCaps(commands={'debug'})
|
|
|
|
@classmethod
|
|
def do_add_parser(cls, parser: argparse.ArgumentParser):
|
|
pass
|
|
|
|
@classmethod
|
|
def do_create(cls, cfg: RunnerConfig, args: argparse.Namespace) -> ZephyrBinaryRunner:
|
|
return NativeGDBBinaryRunner(cfg)
|
|
|
|
def do_run(self, command: str, **kwargs):
|
|
assert command == 'debug'
|
|
|
|
# Clues to debug missing RunnerConfig values (in context of `west debug`):
|
|
# build/zephyr/runners.yaml is missing `gdb` or `elf_file`.
|
|
# board.cmake should have `board_finalize_runner_args(native_gdb)`.
|
|
# build/CMakeCache.txt should have `CMAKE_GDB`.
|
|
|
|
if self.cfg.gdb is None:
|
|
raise ValueError("The provided RunnerConfig is missing the required field 'gdb'.")
|
|
|
|
if self.cfg.exe_file is None:
|
|
raise ValueError("The provided RunnerConfig is missing the required field 'exe_file'.")
|
|
|
|
self.call([
|
|
self.cfg.gdb,
|
|
'--quiet',
|
|
self.cfg.exe_file,
|
|
])
|