fix(gdbgui): Fix support of gdbgui on Unix with Python 3.11

Closes https://github.com/espressif/esp-idf/issues/12764
pull/12901/merge
Roland Dobai 2024-01-03 16:08:32 +01:00
rodzic 0b8e6c66c4
commit c6acde833b
2 zmienionych plików z 21 dodań i 12 usunięć

Wyświetl plik

@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
# SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0
import json
import os
@ -405,15 +405,21 @@ def action_extensions(base_actions: Dict, project_path: str) -> Dict:
gdb = project_desc['monitor_toolprefix'] + 'gdb'
generate_gdbinit_files(gdb, gdbinit, project_desc)
# 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_list = get_gdb_args(project_desc)
gdb_args = '"{}"'.format(' '.join(gdb_args_list)) if len(gdb_args_list) == 1 else ' '.join(gdb_args_list)
args = ['gdbgui', '-g', gdb, '--gdb-args', gdb_args]
print(args)
if sys.version_info[:2] >= (3, 11):
# If we use Python 3.11+ then the only compatible gdbgui doesn't support the --gdb-args argument. This
# check is easier than checking gdbgui version or re-running the process in case of gdb-args-related
# failure.
gdb_args = ' '.join(gdb_args_list)
args = ['gdbgui', '-g', ' '.join((gdb, gdb_args))]
else:
# 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 = '"{}"'.format(' '.join(gdb_args_list)) if len(gdb_args_list) == 1 else ' '.join(gdb_args_list)
args = ['gdbgui', '-g', gdb, '--gdb-args', gdb_args]
if gdbgui_port is not None:
args += ['--port', gdbgui_port]
@ -425,10 +431,11 @@ def action_extensions(base_actions: Dict, project_path: str) -> Dict:
# pygdbmi).
env['PURE_PYTHON'] = '1'
try:
print('Running: ', args)
process = subprocess.Popen(args, stdout=gdbgui_out, stderr=subprocess.STDOUT, bufsize=1, env=env)
except (OSError, subprocess.CalledProcessError) as e:
print(e)
if sys.version_info[:2] >= (3, 11):
if sys.version_info[:2] >= (3, 11) and sys.platform == 'win32':
raise SystemExit('Unfortunately, gdbgui is supported only with Python 3.10 or older. '
'See: https://github.com/espressif/esp-idf/issues/10116. '
'Please use "idf.py gdb" or debug in Eclipse/Vscode instead.')

Wyświetl plik

@ -1,5 +1,7 @@
# Python package requirements for gdbgui support ESP-IDF.
# This feature can be enabled by running "install.{sh,bat,ps1,fish} --enable-gdbgui"
# gdbgui is not supported on Python 3.11. See https://github.com/cs01/gdbgui/issues/447
gdbgui; python_version < "3.11"
# gdbgui Python 3.11 issue https://github.com/cs01/gdbgui/issues/447 was fixed in 0.15.2.0. Windows users need an
# older Python to use since new gdbgui versions don't support Windows anymore.
gdbgui; sys_platform != 'win32'
gdbgui; sys_platform == 'win32' and python_version < "3.11"