blob: 288363d2e0bede1a1b69e03350f71d59b86f33c0 [file] [log] [blame]
Marti Bolivarab822642019-01-23 08:31:06 -07001# Copyright (c) 2018 Open Source Foundries Limited.
2# Copyright 2019 Foundries.io
Martí Bolívareb95bed2020-02-10 06:40:29 -08003# Copyright (c) 2020 Nordic Semiconductor ASA
Marti Bolivarab822642019-01-23 08:31:06 -07004#
5# SPDX-License-Identifier: Apache-2.0
6
Martí Bolívareb95bed2020-02-10 06:40:29 -08007'''west "debug", "debugserver", and "attach" commands.'''
Marti Bolivarab822642019-01-23 08:31:06 -07008
9from textwrap import dedent
10
11from west.commands import WestCommand
12
Martí Bolívar6e4c2b92020-06-25 12:58:58 -070013from run_common import add_parser_common, do_run_common
Marti Bolivarab822642019-01-23 08:31:06 -070014
15
16class Debug(WestCommand):
17
18 def __init__(self):
19 super(Debug, self).__init__(
20 'debug',
Marti Bolivar808028b2019-01-28 10:45:02 -070021 # Keep this in sync with the string in west-commands.yml.
Marti Bolivarab822642019-01-23 08:31:06 -070022 'flash and interactively debug a Zephyr application',
23 dedent('''
Martí Bolívareb95bed2020-02-10 06:40:29 -080024 Connect to the board, flash the program, and start a
25 debugging session. Use "west attach" instead to attach
Martí Bolívar6e4c2b92020-06-25 12:58:58 -070026 a debugger without reflashing.'''),
Marti Bolivarab822642019-01-23 08:31:06 -070027 accepts_unknown_args=True)
Martí Bolívareb95bed2020-02-10 06:40:29 -080028 self.runner_key = 'debug-runner' # in runners.yaml
Marti Bolivarab822642019-01-23 08:31:06 -070029
30 def do_add_parser(self, parser_adder):
Martí Bolívareb95bed2020-02-10 06:40:29 -080031 return add_parser_common(self, parser_adder)
Marti Bolivarab822642019-01-23 08:31:06 -070032
33 def do_run(self, my_args, runner_args):
Martí Bolívareb95bed2020-02-10 06:40:29 -080034 do_run_common(self, my_args, runner_args)
Marti Bolivarab822642019-01-23 08:31:06 -070035
36
37class DebugServer(WestCommand):
38
39 def __init__(self):
40 super(DebugServer, self).__init__(
41 'debugserver',
Marti Bolivar808028b2019-01-28 10:45:02 -070042 # Keep this in sync with the string in west-commands.yml.
Marti Bolivarab822642019-01-23 08:31:06 -070043 'connect to board and launch a debug server',
44 dedent('''
45 Connect to the board and launch a debug server which accepts
46 incoming connections for debugging the connected board.
47
48 The debug server binds to a known port, and allows client software
49 started elsewhere to connect to it and debug the running
Martí Bolívar6e4c2b92020-06-25 12:58:58 -070050 Zephyr image.'''),
Marti Bolivarab822642019-01-23 08:31:06 -070051 accepts_unknown_args=True)
Martí Bolívareb95bed2020-02-10 06:40:29 -080052 self.runner_key = 'debug-runner' # in runners.yaml
Marti Bolivarab822642019-01-23 08:31:06 -070053
54 def do_add_parser(self, parser_adder):
Martí Bolívareb95bed2020-02-10 06:40:29 -080055 return add_parser_common(self, parser_adder)
Marti Bolivarab822642019-01-23 08:31:06 -070056
57 def do_run(self, my_args, runner_args):
Martí Bolívareb95bed2020-02-10 06:40:29 -080058 do_run_common(self, my_args, runner_args)
Marti Bolivarab822642019-01-23 08:31:06 -070059
Marti Bolivar808028b2019-01-28 10:45:02 -070060
Marti Bolivarab822642019-01-23 08:31:06 -070061class Attach(WestCommand):
62
63 def __init__(self):
64 super(Attach, self).__init__(
65 'attach',
Marti Bolivar808028b2019-01-28 10:45:02 -070066 # Keep this in sync with the string in west-commands.yml.
Marti Bolivarab822642019-01-23 08:31:06 -070067 'interactively debug a board',
Martí Bolívar6e4c2b92020-06-25 12:58:58 -070068 "Like \"west debug\", but doesn't reflash the program.",
Marti Bolivarab822642019-01-23 08:31:06 -070069 accepts_unknown_args=True)
Martí Bolívareb95bed2020-02-10 06:40:29 -080070 self.runner_key = 'debug-runner' # in runners.yaml
Marti Bolivarab822642019-01-23 08:31:06 -070071
72 def do_add_parser(self, parser_adder):
Martí Bolívareb95bed2020-02-10 06:40:29 -080073 return add_parser_common(self, parser_adder)
Marti Bolivarab822642019-01-23 08:31:06 -070074
75 def do_run(self, my_args, runner_args):
Martí Bolívareb95bed2020-02-10 06:40:29 -080076 do_run_common(self, my_args, runner_args)