From 2d12315b62bcc23eb6cd84d62391daac4d0a639a Mon Sep 17 00:00:00 2001 From: Alexey Lapshin Date: Mon, 25 Aug 2025 12:20:44 +0700 Subject: [PATCH] fix(tools): clean gdbinit files generation --- components/espcoredump/espcoredump.py | 2 +- tools/cmake/prefix_map.cmake | 5 +---- tools/cmake/project.cmake | 1 - tools/cmake/project_description.json.in | 1 - tools/idf_py_actions/debug_ext.py | 7 +++++-- tools/test_build_system/test_reproducible_build.py | 2 +- 6 files changed, 8 insertions(+), 10 deletions(-) diff --git a/components/espcoredump/espcoredump.py b/components/espcoredump/espcoredump.py index a20abb9028..b1f9ca5db8 100755 --- a/components/espcoredump/espcoredump.py +++ b/components/espcoredump/espcoredump.py @@ -29,7 +29,7 @@ def get_prefix_map_gdbinit_path(prog_path: str) -> Any: with open(desc_path, encoding='utf-8') as f: project_desc = json.load(f) - return project_desc.get('debug_prefix_map_gdbinit') + return project_desc['gdbinit_files']['02_prefix_map'] def main() -> None: diff --git a/tools/cmake/prefix_map.cmake b/tools/cmake/prefix_map.cmake index 2e3a98f2a5..6b1ff4b6d4 100644 --- a/tools/cmake/prefix_map.cmake +++ b/tools/cmake/prefix_map.cmake @@ -45,13 +45,10 @@ function(__generate_prefix_map compile_options_var) get_filename_component(compiler_sysroot "${compiler_sysroot}/.." REALPATH) list(APPEND compile_options "-fdebug-prefix-map=${compiler_sysroot}=/TOOLCHAIN") string(APPEND gdbinit_file_lines "set substitute-path /TOOLCHAIN ${compiler_sysroot}\n") - - file(WRITE "${BUILD_DIR}/prefix_map_gdbinit" "${gdbinit_file_lines}") # TODO IDF-11667 - idf_build_set_property(DEBUG_PREFIX_MAP_GDBINIT "${gdbinit_path}") else() set(gdbinit_file_lines "# There is no prefix map defined for the project.\n") endif() - # Write prefix_map_gdbinit file even it is empty. + # Write prefix_map file even it is empty. file(MAKE_DIRECTORY ${gdbinit_dir}) file(WRITE "${gdbinit_path}" "${gdbinit_file_lines}") idf_build_set_property(GDBINIT_FILES_PREFIX_MAP "${gdbinit_path}") diff --git a/tools/cmake/project.cmake b/tools/cmake/project.cmake index 520069a1f5..3ba5875682 100644 --- a/tools/cmake/project.cmake +++ b/tools/cmake/project.cmake @@ -351,7 +351,6 @@ function(__project_info test_components) include(${sdkconfig_cmake}) idf_build_get_property(COMPONENT_KCONFIGS KCONFIGS) idf_build_get_property(COMPONENT_KCONFIGS_PROJBUILD KCONFIG_PROJBUILDS) - idf_build_get_property(debug_prefix_map_gdbinit DEBUG_PREFIX_MAP_GDBINIT) __generate_gdbinit() idf_build_get_property(gdbinit_files_prefix_map GDBINIT_FILES_PREFIX_MAP) diff --git a/tools/cmake/project_description.json.in b/tools/cmake/project_description.json.in index 5940be1ba3..c130d300d6 100644 --- a/tools/cmake/project_description.json.in +++ b/tools/cmake/project_description.json.in @@ -29,7 +29,6 @@ "build_component_paths" : ${build_component_paths_json}, "build_component_info" : ${build_component_info_json}, "all_component_info" : ${all_component_info_json}, - "debug_prefix_map_gdbinit": "${debug_prefix_map_gdbinit}", "gdbinit_files": { "01_symbols": "${gdbinit_files_symbols}", "02_prefix_map": "${gdbinit_files_prefix_map}", diff --git a/tools/idf_py_actions/debug_ext.py b/tools/idf_py_actions/debug_ext.py index 019128d7da..14bc3ed2a0 100644 --- a/tools/idf_py_actions/debug_ext.py +++ b/tools/idf_py_actions/debug_ext.py @@ -125,7 +125,7 @@ def action_extensions(base_actions: dict, project_path: str) -> dict: espcoredump_kwargs['chip_rev'] = chip_rev_to_int(chip_rev) # for reproducible builds - extra_gdbinit_file = project_desc.get('debug_prefix_map_gdbinit', None) + extra_gdbinit_file = project_desc['gdbinit_files']['02_prefix_map'] if extra_gdbinit_file: espcoredump_kwargs['extra_gdbinit_file'] = extra_gdbinit_file @@ -285,7 +285,10 @@ def action_extensions(base_actions: dict, project_path: str) -> dict: gdb_args.append(f'-x={gdb_x_list[gdb_x_index]}') gdb_x_list.pop(gdb_x_index) continue - if name == 'connect' and gdb_x_list: # TODO IDF-11692 + # If the user provides a gdbinit file with name not in the "gdbinit_files" list, + # we assume the connection logic is defined within it. + # Otherwise, the configuration may be invalid. + if name == 'connect' and gdb_x_list: continue gdb_args.append(f'-x={path}') # append user-defined gdbinit files diff --git a/tools/test_build_system/test_reproducible_build.py b/tools/test_build_system/test_reproducible_build.py index 96027ba5b4..4e819b2042 100644 --- a/tools/test_build_system/test_reproducible_build.py +++ b/tools/test_build_system/test_reproducible_build.py @@ -63,7 +63,7 @@ def test_reproducible_builds(app_name: str, idf_py: IdfPyFunc, test_app_copy: Pa '--batch', '--quiet', '-x', - f'{build_first}/prefix_map_gdbinit', + f'{build_first}/gdbinit/prefix_map', '-ex', 'set logging enabled', '-ex',