Merge branch 'feature/add_freertos_gdb_integration' into 'master'

tools: add freertos support to GDB

Closes GCC-226

See merge request espressif/esp-idf!17571
This commit is contained in:
Roland Dobai
2022-04-28 14:36:58 +08:00
2 changed files with 17 additions and 8 deletions

View File

@@ -84,8 +84,18 @@ def action_extensions(base_actions, project_path):
print('Failed to close/kill {}'.format(target)) print('Failed to close/kill {}'.format(target))
processes[target] = None # to indicate this has ended processes[target] = None # to indicate this has ended
def create_local_gdbinit(gdbinit, elf_file): def is_gdb_with_python(gdb):
# execute simple python command to check is it supported
return subprocess.run([gdb, '--batch-silent', '--ex', 'python import os'], stderr=subprocess.DEVNULL).returncode == 0
def create_local_gdbinit(gdb, gdbinit, elf_file):
with open(gdbinit, 'w') as f: with open(gdbinit, 'w') as f:
if is_gdb_with_python(gdb):
f.write('python\n')
f.write('import sys\n')
f.write(f'sys.path = {sys.path}\n')
f.write('import freertos_gdb\n')
f.write('end\n')
if os.name == 'nt': if os.name == 'nt':
elf_file = elf_file.replace('\\','\\\\') elf_file = elf_file.replace('\\','\\\\')
f.write('file {}\n'.format(elf_file)) f.write('file {}\n'.format(elf_file))
@@ -192,7 +202,7 @@ def action_extensions(base_actions, project_path):
gdb = project_desc['monitor_toolprefix'] + 'gdb' gdb = project_desc['monitor_toolprefix'] + 'gdb'
if gdbinit is None: if gdbinit is None:
gdbinit = os.path.join(local_dir, 'gdbinit') gdbinit = os.path.join(local_dir, 'gdbinit')
create_local_gdbinit(gdbinit, os.path.join(args.build_dir, project_desc['app_elf'])) create_local_gdbinit(gdb, gdbinit, os.path.join(args.build_dir, project_desc['app_elf']))
# this is a workaround for gdbgui # this is a workaround for gdbgui
# gdbgui is using shlex.split for the --gdb-args option. When the input is: # gdbgui is using shlex.split for the --gdb-args option. When the input is:
@@ -270,11 +280,7 @@ def action_extensions(base_actions, project_path):
watch_openocd = Thread(target=_check_openocd_errors, args=(fail_if_openocd_failed, action, ctx, )) watch_openocd = Thread(target=_check_openocd_errors, args=(fail_if_openocd_failed, action, ctx, ))
watch_openocd.start() watch_openocd.start()
processes['threads_to_join'].append(watch_openocd) processes['threads_to_join'].append(watch_openocd)
desc_path = os.path.join(args.build_dir, 'project_description.json') project_desc = get_project_desc(args, ctx)
if not os.path.exists(desc_path):
ensure_build_directory(args, ctx.info_name)
with open(desc_path, 'r') as f:
project_desc = json.load(f)
elf_file = os.path.join(args.build_dir, project_desc['app_elf']) elf_file = os.path.join(args.build_dir, project_desc['app_elf'])
if not os.path.exists(elf_file): if not os.path.exists(elf_file):
@@ -283,7 +289,7 @@ def action_extensions(base_actions, project_path):
local_dir = project_desc['build_dir'] local_dir = project_desc['build_dir']
if gdbinit is None: if gdbinit is None:
gdbinit = os.path.join(local_dir, 'gdbinit') gdbinit = os.path.join(local_dir, 'gdbinit')
create_local_gdbinit(gdbinit, elf_file) create_local_gdbinit(gdb, gdbinit, elf_file)
args = [gdb, *get_gdb_args(gdbinit, project_desc)] args = [gdb, *get_gdb_args(gdbinit, project_desc)]
if gdb_tui is not None: if gdb_tui is not None:
args += ['-tui'] args += ['-tui']

View File

@@ -14,3 +14,6 @@ esptool
# kconfig and menuconfig dependencies # kconfig and menuconfig dependencies
kconfiglib kconfiglib
windows-curses; sys_platform == 'win32' windows-curses; sys_platform == 'win32'
# gdb extensions dependencies
freertos_gdb