2019-07-23 19:37:31 +00:00
|
|
|
import json
|
|
|
|
import os
|
2021-01-26 02:49:01 +00:00
|
|
|
import re
|
2019-07-23 19:37:31 +00:00
|
|
|
import shlex
|
2021-01-26 02:49:01 +00:00
|
|
|
import subprocess
|
|
|
|
import sys
|
|
|
|
import threading
|
2019-07-23 19:37:31 +00:00
|
|
|
import time
|
|
|
|
from threading import Thread
|
2021-10-26 02:41:13 +00:00
|
|
|
from typing import Any, Dict, List
|
2019-07-23 19:37:31 +00:00
|
|
|
|
|
|
|
from idf_py_actions.errors import FatalError
|
|
|
|
from idf_py_actions.tools import ensure_build_directory
|
|
|
|
|
|
|
|
PYTHON = sys.executable
|
|
|
|
|
|
|
|
|
|
|
|
def action_extensions(base_actions, project_path):
|
2021-01-26 02:49:01 +00:00
|
|
|
OPENOCD_OUT_FILE = 'openocd_out.txt'
|
|
|
|
GDBGUI_OUT_FILE = 'gdbgui_out.txt'
|
2019-07-23 19:37:31 +00:00
|
|
|
# Internal dictionary of currently active processes, threads and their output files
|
2021-01-26 02:49:01 +00:00
|
|
|
processes = {'threads_to_join': [], 'openocd_issues': None}
|
2020-04-14 08:45:20 +00:00
|
|
|
|
|
|
|
def _check_for_common_openocd_issues(file_name, print_all=True):
|
2021-01-26 02:49:01 +00:00
|
|
|
if processes['openocd_issues'] is not None:
|
|
|
|
return processes['openocd_issues']
|
2020-04-14 08:45:20 +00:00
|
|
|
try:
|
2021-01-26 02:49:01 +00:00
|
|
|
message = 'Please check JTAG connection!'
|
|
|
|
with open(file_name, 'r') as f:
|
2020-04-14 08:45:20 +00:00
|
|
|
content = f.read()
|
|
|
|
if print_all:
|
|
|
|
print(content)
|
2021-01-26 02:49:01 +00:00
|
|
|
if re.search(r'Address already in use', content):
|
|
|
|
message = ('Please check if another process uses the mentioned ports. OpenOCD already running, perhaps in the background?\n'
|
|
|
|
'Please list all processes to check if OpenOCD is already running; if so, terminate it before starting OpenOCD from idf.py')
|
2020-04-14 08:45:20 +00:00
|
|
|
finally:
|
2021-01-26 02:49:01 +00:00
|
|
|
processes['openocd_issues'] = message
|
2020-04-14 08:45:20 +00:00
|
|
|
return message
|
2019-07-23 19:37:31 +00:00
|
|
|
|
|
|
|
def _check_openocd_errors(fail_if_openocd_failed, target, ctx):
|
|
|
|
if fail_if_openocd_failed:
|
2021-01-26 02:49:01 +00:00
|
|
|
if 'openocd' in processes and processes['openocd'] is not None:
|
|
|
|
p = processes['openocd']
|
|
|
|
name = processes['openocd_outfile_name']
|
2019-07-23 19:37:31 +00:00
|
|
|
# watch OpenOCD (for 5x500ms) to check if it hasn't terminated or outputs an error
|
|
|
|
for _ in range(5):
|
|
|
|
if p.poll() is not None:
|
2021-01-26 02:49:01 +00:00
|
|
|
print('OpenOCD exited with {}'.format(p.poll()))
|
2019-07-23 19:37:31 +00:00
|
|
|
break
|
2021-01-26 02:49:01 +00:00
|
|
|
with open(name, 'r') as f:
|
2019-07-23 19:37:31 +00:00
|
|
|
content = f.read()
|
2021-01-26 02:49:01 +00:00
|
|
|
if re.search(r'no device found', content):
|
2019-07-23 19:37:31 +00:00
|
|
|
break
|
2021-01-26 02:49:01 +00:00
|
|
|
if re.search(r'Listening on port \d+ for gdb connections', content):
|
2019-07-23 19:37:31 +00:00
|
|
|
# expect OpenOCD has started successfully - stop watching
|
|
|
|
return
|
|
|
|
time.sleep(0.5)
|
|
|
|
else:
|
|
|
|
return
|
|
|
|
# OpenOCD exited or error message detected -> print possible output and terminate
|
2020-04-14 08:45:20 +00:00
|
|
|
raise FatalError('Action "{}" failed due to errors in OpenOCD:\n{}'.format(target, _check_for_common_openocd_issues(name)), ctx)
|
2019-07-23 19:37:31 +00:00
|
|
|
|
|
|
|
def _terminate_async_target(target):
|
|
|
|
if target in processes and processes[target] is not None:
|
|
|
|
try:
|
2021-01-26 02:49:01 +00:00
|
|
|
if target + '_outfile' in processes:
|
|
|
|
processes[target + '_outfile'].close()
|
2019-07-23 19:37:31 +00:00
|
|
|
p = processes[target]
|
|
|
|
if p.poll() is None:
|
|
|
|
p.terminate()
|
|
|
|
# waiting 10x100ms for the process to terminate gracefully
|
|
|
|
for _ in range(10):
|
|
|
|
if p.poll() is not None:
|
|
|
|
break
|
|
|
|
time.sleep(0.1)
|
|
|
|
else:
|
|
|
|
p.kill()
|
2021-01-26 02:49:01 +00:00
|
|
|
if target + '_outfile_name' in processes:
|
|
|
|
if target == 'openocd':
|
|
|
|
print(_check_for_common_openocd_issues(processes[target + '_outfile_name'], print_all=False))
|
|
|
|
os.unlink(processes[target + '_outfile_name'])
|
2019-07-23 19:37:31 +00:00
|
|
|
except Exception as e:
|
|
|
|
print(e)
|
2021-01-26 02:49:01 +00:00
|
|
|
print('Failed to close/kill {}'.format(target))
|
2019-07-23 19:37:31 +00:00
|
|
|
processes[target] = None # to indicate this has ended
|
|
|
|
|
|
|
|
def create_local_gdbinit(gdbinit, elf_file):
|
2021-01-26 02:49:01 +00:00
|
|
|
with open(gdbinit, 'w') as f:
|
|
|
|
if os.name == 'nt':
|
2019-07-23 19:37:31 +00:00
|
|
|
elf_file = elf_file.replace('\\','\\\\')
|
2020-12-30 15:40:48 +00:00
|
|
|
f.write('file {}\n'.format(elf_file))
|
|
|
|
f.write('target remote :3333\n')
|
2021-01-26 02:49:01 +00:00
|
|
|
f.write('mon reset halt\n')
|
|
|
|
f.write('flushregs\n')
|
|
|
|
f.write('thb app_main\n')
|
|
|
|
f.write('c\n')
|
2019-07-23 19:37:31 +00:00
|
|
|
|
|
|
|
def debug_cleanup():
|
2021-01-26 02:49:01 +00:00
|
|
|
print('cleaning up debug targets')
|
|
|
|
for t in processes['threads_to_join']:
|
2019-07-23 19:37:31 +00:00
|
|
|
if threading.currentThread() != t:
|
|
|
|
t.join()
|
2021-01-26 02:49:01 +00:00
|
|
|
_terminate_async_target('openocd')
|
|
|
|
_terminate_async_target('gdbgui')
|
|
|
|
_terminate_async_target('gdb')
|
2019-07-23 19:37:31 +00:00
|
|
|
|
2020-04-09 12:54:10 +00:00
|
|
|
def post_debug(action, ctx, args, **kwargs):
|
2019-07-23 19:37:31 +00:00
|
|
|
""" Deal with asynchronous targets, such as openocd running in background """
|
2021-01-26 02:49:01 +00:00
|
|
|
if kwargs['block'] == 1:
|
|
|
|
for target in ['openocd', 'gdbgui']:
|
2019-07-23 19:37:31 +00:00
|
|
|
if target in processes and processes[target] is not None:
|
|
|
|
break
|
|
|
|
else:
|
|
|
|
return
|
|
|
|
try:
|
|
|
|
p = processes[target]
|
2021-01-26 02:49:01 +00:00
|
|
|
name = processes[target + '_outfile_name']
|
2019-07-23 19:37:31 +00:00
|
|
|
pos = 0
|
|
|
|
while True:
|
2021-01-26 02:49:01 +00:00
|
|
|
with open(name, 'r') as f:
|
2019-07-23 19:37:31 +00:00
|
|
|
f.seek(pos)
|
|
|
|
for line in f:
|
|
|
|
print(line.rstrip())
|
|
|
|
pos = f.tell()
|
|
|
|
if p.poll() is not None:
|
|
|
|
print('"{}" exited with {}'.format(target, p.poll()))
|
|
|
|
break
|
|
|
|
time.sleep(0.5)
|
|
|
|
except KeyboardInterrupt:
|
2021-01-26 02:49:01 +00:00
|
|
|
print('Terminated -> exiting debug utility targets')
|
|
|
|
_terminate_async_target('openocd')
|
|
|
|
_terminate_async_target('gdbgui')
|
2019-07-23 19:37:31 +00:00
|
|
|
|
|
|
|
def get_project_desc(args, ctx):
|
2021-01-26 02:49:01 +00:00
|
|
|
desc_path = os.path.join(args.build_dir, 'project_description.json')
|
2019-07-23 19:37:31 +00:00
|
|
|
if not os.path.exists(desc_path):
|
|
|
|
ensure_build_directory(args, ctx.info_name)
|
2021-01-26 02:49:01 +00:00
|
|
|
with open(desc_path, 'r') as f:
|
2019-07-23 19:37:31 +00:00
|
|
|
project_desc = json.load(f)
|
|
|
|
return project_desc
|
|
|
|
|
|
|
|
def openocd(action, ctx, args, openocd_scripts, openocd_commands):
|
|
|
|
"""
|
|
|
|
Execute openocd as external tool
|
|
|
|
"""
|
2020-07-03 16:20:08 +00:00
|
|
|
OPENOCD_TAGET_CONFIG = {
|
2021-01-26 02:49:01 +00:00
|
|
|
'esp32': '-f board/esp32-wrover-kit-3.3v.cfg',
|
|
|
|
'esp32s2': '-f board/esp32s2-kaluga-1.cfg',
|
2020-07-03 16:20:08 +00:00
|
|
|
}
|
2021-01-26 02:49:01 +00:00
|
|
|
if os.getenv('OPENOCD_SCRIPTS') is None:
|
|
|
|
raise FatalError('OPENOCD_SCRIPTS not found in the environment: Please run export.sh/export.bat', ctx)
|
|
|
|
openocd_arguments = os.getenv('OPENOCD_COMMANDS') if openocd_commands is None else openocd_commands
|
2019-07-23 19:37:31 +00:00
|
|
|
project_desc = get_project_desc(args, ctx)
|
|
|
|
if openocd_arguments is None:
|
|
|
|
# use default value if commands not defined in the environment nor command line
|
2021-01-26 02:49:01 +00:00
|
|
|
target = project_desc['target']
|
|
|
|
default_args = '-f interface/ftdi/esp32_devkitj_v1.cfg -f target/{}.cfg'.format(target)
|
2020-07-03 16:20:08 +00:00
|
|
|
openocd_arguments = OPENOCD_TAGET_CONFIG.get(target, default_args)
|
2019-07-23 19:37:31 +00:00
|
|
|
print('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
|
|
|
|
if openocd_scripts is not None:
|
2021-01-26 02:49:01 +00:00
|
|
|
openocd_arguments += ' -s {}'.format(openocd_scripts)
|
|
|
|
local_dir = project_desc['build_dir']
|
|
|
|
args = ['openocd'] + shlex.split(openocd_arguments)
|
2019-07-23 19:37:31 +00:00
|
|
|
openocd_out_name = os.path.join(local_dir, OPENOCD_OUT_FILE)
|
2021-01-26 02:49:01 +00:00
|
|
|
openocd_out = open(openocd_out_name, 'a+')
|
2019-07-23 19:37:31 +00:00
|
|
|
try:
|
|
|
|
process = subprocess.Popen(args, stdout=openocd_out, stderr=subprocess.STDOUT, bufsize=1)
|
|
|
|
except Exception as e:
|
|
|
|
print(e)
|
2021-01-26 02:49:01 +00:00
|
|
|
raise FatalError('Error starting openocd. Please make sure it is installed and is present in executable paths', ctx)
|
2019-07-23 19:37:31 +00:00
|
|
|
|
2021-01-26 02:49:01 +00:00
|
|
|
processes['openocd'] = process
|
|
|
|
processes['openocd_outfile'] = openocd_out
|
|
|
|
processes['openocd_outfile_name'] = openocd_out_name
|
|
|
|
print('OpenOCD started as a background task {}'.format(process.pid))
|
2019-07-23 19:37:31 +00:00
|
|
|
|
2021-10-26 02:41:13 +00:00
|
|
|
def get_gdb_args(gdbinit, project_desc: Dict[str, Any]) -> List[str]:
|
|
|
|
args = ['-x={}'.format(gdbinit)]
|
|
|
|
debug_prefix_gdbinit = project_desc.get('debug_prefix_map_gdbinit')
|
|
|
|
if debug_prefix_gdbinit:
|
|
|
|
args.append('-ix={}'.format(debug_prefix_gdbinit))
|
|
|
|
return args
|
|
|
|
|
2020-04-15 17:02:14 +00:00
|
|
|
def gdbui(action, ctx, args, gdbgui_port, gdbinit, require_openocd):
|
2019-07-23 19:37:31 +00:00
|
|
|
"""
|
|
|
|
Asynchronous GDB-UI target
|
|
|
|
"""
|
|
|
|
project_desc = get_project_desc(args, ctx)
|
2021-01-26 02:49:01 +00:00
|
|
|
local_dir = project_desc['build_dir']
|
|
|
|
gdb = project_desc['monitor_toolprefix'] + 'gdb'
|
2020-04-15 17:02:14 +00:00
|
|
|
if gdbinit is None:
|
|
|
|
gdbinit = os.path.join(local_dir, 'gdbinit')
|
2021-01-26 02:49:01 +00:00
|
|
|
create_local_gdbinit(gdbinit, os.path.join(args.build_dir, project_desc['app_elf']))
|
2021-10-26 02:41:13 +00:00
|
|
|
|
|
|
|
# this is a workaround for gdbgui
|
|
|
|
# gdbgui is using shlex.split for the --gdb-args option. When the input is:
|
|
|
|
# - '"-x=foo -x=bar"', would return ['foo bar']
|
|
|
|
# - '-x=foo', would return ['-x', 'foo'] and mess up the former option '--gdb-args'
|
|
|
|
# so for one item, use extra double quotes. for more items, use no extra double quotes.
|
|
|
|
gdb_args = get_gdb_args(gdbinit, project_desc)
|
|
|
|
gdb_args = '"{}"'.format(' '.join(gdb_args)) if len(gdb_args) == 1 else ' '.join(gdb_args)
|
|
|
|
args = ['gdbgui', '-g', gdb, '--gdb-args', gdb_args]
|
|
|
|
print(args)
|
|
|
|
|
2019-07-23 19:37:31 +00:00
|
|
|
if gdbgui_port is not None:
|
2021-01-26 02:49:01 +00:00
|
|
|
args += ['--port', gdbgui_port]
|
2019-07-23 19:37:31 +00:00
|
|
|
gdbgui_out_name = os.path.join(local_dir, GDBGUI_OUT_FILE)
|
2021-01-26 02:49:01 +00:00
|
|
|
gdbgui_out = open(gdbgui_out_name, 'a+')
|
2021-04-27 12:27:22 +00:00
|
|
|
env = os.environ.copy()
|
|
|
|
# The only known solution for https://github.com/cs01/gdbgui/issues/359 is to set the following environment
|
|
|
|
# variable. The greenlet package cannot be downgraded for compatibility with other requirements (gdbgui,
|
|
|
|
# pygdbmi).
|
|
|
|
env['PURE_PYTHON'] = '1'
|
2019-07-23 19:37:31 +00:00
|
|
|
try:
|
2021-04-27 12:27:22 +00:00
|
|
|
process = subprocess.Popen(args, stdout=gdbgui_out, stderr=subprocess.STDOUT, bufsize=1, env=env)
|
2019-07-23 19:37:31 +00:00
|
|
|
except Exception as e:
|
|
|
|
print(e)
|
2021-09-16 14:48:03 +00:00
|
|
|
raise FatalError('Error starting gdbgui. Please make sure gdbgui has been installed with '
|
|
|
|
'"install.{sh,bat,ps1,fish} --enable-gdbgui" and can be started.', ctx)
|
2019-07-23 19:37:31 +00:00
|
|
|
|
2021-01-26 02:49:01 +00:00
|
|
|
processes['gdbgui'] = process
|
|
|
|
processes['gdbgui_outfile'] = gdbgui_out
|
|
|
|
processes['gdbgui_outfile_name'] = gdbgui_out_name
|
|
|
|
print('gdbgui started as a background task {}'.format(process.pid))
|
2019-07-23 19:37:31 +00:00
|
|
|
_check_openocd_errors(fail_if_openocd_failed, action, ctx)
|
|
|
|
|
|
|
|
def global_callback(ctx, global_args, tasks):
|
|
|
|
def move_to_front(task_name):
|
|
|
|
for index, task in enumerate(tasks):
|
|
|
|
if task.name == task_name:
|
|
|
|
tasks.insert(0, tasks.pop(index))
|
|
|
|
break
|
|
|
|
|
2021-01-26 02:49:01 +00:00
|
|
|
debug_targets = any([task.name in ('openocd', 'gdbgui') for task in tasks])
|
2019-07-23 19:37:31 +00:00
|
|
|
if debug_targets:
|
|
|
|
# Register the meta cleanup callback -> called on FatalError
|
2021-01-26 02:49:01 +00:00
|
|
|
ctx.meta['cleanup'] = debug_cleanup
|
|
|
|
move_to_front('gdbgui') # possibly 2nd
|
|
|
|
move_to_front('openocd') # always 1st
|
2019-07-23 19:37:31 +00:00
|
|
|
# followed by "monitor", "gdb" or "gdbtui" in any order
|
|
|
|
|
2021-01-26 02:49:01 +00:00
|
|
|
post_action = ctx.invoke(ctx.command.get_command(ctx, 'post_debug'))
|
|
|
|
if any([task.name in ('monitor', 'gdb', 'gdbtui') for task in tasks]):
|
|
|
|
post_action.action_args['block'] = 0
|
2019-07-23 19:37:31 +00:00
|
|
|
else:
|
2021-01-26 02:49:01 +00:00
|
|
|
post_action.action_args['block'] = 1
|
2019-07-23 19:37:31 +00:00
|
|
|
tasks.append(post_action) # always last
|
2021-01-26 02:49:01 +00:00
|
|
|
if any([task.name == 'openocd' for task in tasks]):
|
2019-07-23 19:37:31 +00:00
|
|
|
for task in tasks:
|
2021-01-26 02:49:01 +00:00
|
|
|
if task.name in ('gdb', 'gdbgui', 'gdbtui'):
|
|
|
|
task.action_args['require_openocd'] = True
|
2019-07-23 19:37:31 +00:00
|
|
|
|
|
|
|
def run_gdb(gdb_args):
|
|
|
|
p = subprocess.Popen(gdb_args)
|
2021-01-26 02:49:01 +00:00
|
|
|
processes['gdb'] = p
|
2019-07-23 19:37:31 +00:00
|
|
|
return p.wait()
|
|
|
|
|
2020-04-15 17:02:14 +00:00
|
|
|
def gdbtui(action, ctx, args, gdbinit, require_openocd):
|
2019-07-23 19:37:31 +00:00
|
|
|
"""
|
|
|
|
Synchronous GDB target with text ui mode
|
|
|
|
"""
|
2020-04-15 17:02:14 +00:00
|
|
|
gdb(action, ctx, args, 1, gdbinit, require_openocd)
|
2019-07-23 19:37:31 +00:00
|
|
|
|
2020-04-15 17:02:14 +00:00
|
|
|
def gdb(action, ctx, args, gdb_tui, gdbinit, require_openocd):
|
2019-07-23 19:37:31 +00:00
|
|
|
"""
|
|
|
|
Synchronous GDB target
|
|
|
|
"""
|
|
|
|
watch_openocd = Thread(target=_check_openocd_errors, args=(fail_if_openocd_failed, action, ctx, ))
|
|
|
|
watch_openocd.start()
|
2021-01-26 02:49:01 +00:00
|
|
|
processes['threads_to_join'].append(watch_openocd)
|
|
|
|
desc_path = os.path.join(args.build_dir, 'project_description.json')
|
2019-07-23 19:37:31 +00:00
|
|
|
if not os.path.exists(desc_path):
|
|
|
|
ensure_build_directory(args, ctx.info_name)
|
2021-01-26 02:49:01 +00:00
|
|
|
with open(desc_path, 'r') as f:
|
2019-07-23 19:37:31 +00:00
|
|
|
project_desc = json.load(f)
|
|
|
|
|
2021-01-26 02:49:01 +00:00
|
|
|
elf_file = os.path.join(args.build_dir, project_desc['app_elf'])
|
2019-07-23 19:37:31 +00:00
|
|
|
if not os.path.exists(elf_file):
|
2021-01-26 02:49:01 +00:00
|
|
|
raise FatalError('ELF file not found. You need to build & flash the project before running debug targets', ctx)
|
|
|
|
gdb = project_desc['monitor_toolprefix'] + 'gdb'
|
|
|
|
local_dir = project_desc['build_dir']
|
2020-04-15 17:02:14 +00:00
|
|
|
if gdbinit is None:
|
|
|
|
gdbinit = os.path.join(local_dir, 'gdbinit')
|
|
|
|
create_local_gdbinit(gdbinit, elf_file)
|
2021-10-26 02:41:13 +00:00
|
|
|
args = [gdb, *get_gdb_args(gdbinit, project_desc)]
|
2019-07-23 19:37:31 +00:00
|
|
|
if gdb_tui is not None:
|
|
|
|
args += ['-tui']
|
2021-10-26 02:41:13 +00:00
|
|
|
t = Thread(target=run_gdb, args=(args,))
|
2019-07-23 19:37:31 +00:00
|
|
|
t.start()
|
|
|
|
while True:
|
|
|
|
try:
|
|
|
|
t.join()
|
|
|
|
break
|
|
|
|
except KeyboardInterrupt:
|
|
|
|
# Catching Keyboard interrupt, as this is used for breaking running program in gdb
|
|
|
|
continue
|
|
|
|
finally:
|
|
|
|
watch_openocd.join()
|
2020-09-17 13:08:54 +00:00
|
|
|
try:
|
2021-01-26 02:49:01 +00:00
|
|
|
processes['threads_to_join'].remove(watch_openocd)
|
2020-09-17 13:08:54 +00:00
|
|
|
except ValueError:
|
|
|
|
# Valid scenario: watch_openocd task won't be in the list if openocd not started from idf.py
|
|
|
|
pass
|
2019-07-23 19:37:31 +00:00
|
|
|
|
|
|
|
fail_if_openocd_failed = {
|
2021-01-26 02:49:01 +00:00
|
|
|
'names': ['--require-openocd', '--require_openocd'],
|
|
|
|
'help':
|
|
|
|
('Fail this target if openocd (this targets dependency) failed.\n'),
|
|
|
|
'is_flag': True,
|
|
|
|
'default': False,
|
2019-07-23 19:37:31 +00:00
|
|
|
}
|
2020-04-15 17:02:14 +00:00
|
|
|
gdbinit = {
|
2021-01-26 02:49:01 +00:00
|
|
|
'names': ['--gdbinit'],
|
|
|
|
'help': ('Specify the name of gdbinit file to use\n'),
|
|
|
|
'default': None,
|
2020-04-15 17:02:14 +00:00
|
|
|
}
|
2019-07-23 19:37:31 +00:00
|
|
|
debug_actions = {
|
2021-01-26 02:49:01 +00:00
|
|
|
'global_action_callbacks': [global_callback],
|
|
|
|
'actions': {
|
|
|
|
'openocd': {
|
|
|
|
'callback': openocd,
|
|
|
|
'help': 'Run openocd from current path',
|
|
|
|
'options': [
|
2019-07-23 19:37:31 +00:00
|
|
|
{
|
2021-01-26 02:49:01 +00:00
|
|
|
'names': ['--openocd-scripts', '--openocd_scripts'],
|
|
|
|
'help':
|
|
|
|
('Script directory for openocd cfg files.\n'),
|
|
|
|
'default':
|
2019-07-23 19:37:31 +00:00
|
|
|
None,
|
|
|
|
},
|
|
|
|
{
|
2021-01-26 02:49:01 +00:00
|
|
|
'names': ['--openocd-commands', '--openocd_commands'],
|
|
|
|
'help':
|
|
|
|
('Command line arguments for openocd.\n'),
|
|
|
|
'default': None,
|
2019-07-23 19:37:31 +00:00
|
|
|
}
|
|
|
|
],
|
2021-01-26 02:49:01 +00:00
|
|
|
'order_dependencies': ['all', 'flash'],
|
2019-07-23 19:37:31 +00:00
|
|
|
},
|
2021-01-26 02:49:01 +00:00
|
|
|
'gdb': {
|
|
|
|
'callback': gdb,
|
|
|
|
'help': 'Run the GDB.',
|
|
|
|
'options': [
|
2019-07-23 19:37:31 +00:00
|
|
|
{
|
2021-01-26 02:49:01 +00:00
|
|
|
'names': ['--gdb-tui', '--gdb_tui'],
|
|
|
|
'help':
|
|
|
|
('run gdb in TUI mode\n'),
|
|
|
|
'default':
|
2019-07-23 19:37:31 +00:00
|
|
|
None,
|
2020-04-15 17:02:14 +00:00
|
|
|
}, gdbinit, fail_if_openocd_failed
|
2019-07-23 19:37:31 +00:00
|
|
|
],
|
2021-01-26 02:49:01 +00:00
|
|
|
'order_dependencies': ['all', 'flash'],
|
2019-07-23 19:37:31 +00:00
|
|
|
},
|
2021-01-26 02:49:01 +00:00
|
|
|
'gdbgui': {
|
|
|
|
'callback': gdbui,
|
|
|
|
'help': 'GDB UI in default browser.',
|
|
|
|
'options': [
|
2019-07-23 19:37:31 +00:00
|
|
|
{
|
2021-01-26 02:49:01 +00:00
|
|
|
'names': ['--gdbgui-port', '--gdbgui_port'],
|
|
|
|
'help':
|
|
|
|
('The port on which gdbgui will be hosted. Default: 5000\n'),
|
|
|
|
'default':
|
2019-07-23 19:37:31 +00:00
|
|
|
None,
|
2020-04-15 17:02:14 +00:00
|
|
|
}, gdbinit, fail_if_openocd_failed
|
2019-07-23 19:37:31 +00:00
|
|
|
],
|
2021-01-26 02:49:01 +00:00
|
|
|
'order_dependencies': ['all', 'flash'],
|
2019-07-23 19:37:31 +00:00
|
|
|
},
|
2021-01-26 02:49:01 +00:00
|
|
|
'gdbtui': {
|
|
|
|
'callback': gdbtui,
|
|
|
|
'help': 'GDB TUI mode.',
|
|
|
|
'options': [gdbinit, fail_if_openocd_failed],
|
|
|
|
'order_dependencies': ['all', 'flash'],
|
2019-07-23 19:37:31 +00:00
|
|
|
},
|
2021-08-11 13:24:17 +00:00
|
|
|
'post-debug': {
|
|
|
|
'callback': post_debug,
|
|
|
|
'help': 'Utility target to read the output of async debug action and stop them.',
|
|
|
|
'options': [
|
|
|
|
{
|
|
|
|
'names': ['--block', '--block'],
|
|
|
|
'help':
|
|
|
|
('Set to 1 for blocking the console on the outputs of async debug actions\n'),
|
|
|
|
'default': 0,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
'order_dependencies': [],
|
|
|
|
},
|
2021-01-26 02:49:01 +00:00
|
|
|
'post_debug': {
|
|
|
|
'callback': post_debug,
|
2021-08-11 13:24:17 +00:00
|
|
|
'deprecated': {
|
|
|
|
'removed': 'v5.0',
|
|
|
|
'message': 'Please use "post-debug" instead.',
|
|
|
|
},
|
|
|
|
'hidden': True,
|
2021-01-26 02:49:01 +00:00
|
|
|
'help': 'Utility target to read the output of async debug action and stop them.',
|
|
|
|
'options': [
|
2019-07-23 19:37:31 +00:00
|
|
|
{
|
2021-01-26 02:49:01 +00:00
|
|
|
'names': ['--block', '--block'],
|
|
|
|
'help':
|
|
|
|
('Set to 1 for blocking the console on the outputs of async debug actions\n'),
|
|
|
|
'default': 0,
|
2019-07-23 19:37:31 +00:00
|
|
|
},
|
|
|
|
],
|
2021-01-26 02:49:01 +00:00
|
|
|
'order_dependencies': [],
|
2019-07-23 19:37:31 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
return debug_actions
|