fix(gdbinit): build elf path from EXECUTABLE_NAME, not the target name

The EXECUTABLE build property holds a CMake target name, not a filesystem
path. Under Build system v1 the target happens to be created as
"<project>.elf", so concatenating BUILD_DIR with EXECUTABLE produced a valid
elf path by coincidence. Under Build system v2 the target is just "<project>"
and the elf is written as "<project>.elf" via CMake's executable suffix, so
the same concatenation pointed gdb at a non-existent file.

Construct the path explicitly from EXECUTABLE_NAME plus the .elf suffix so
the gdbinit consumer no longer depends on the producer naming its target
after the output file.
This commit is contained in:
Sudeep Mohanty
2026-06-12 09:28:30 +02:00
parent fc7eaf8569
commit 0e662bfa7d

View File

@@ -38,8 +38,9 @@ function(__generate_gdbinit)
set(symbols_gdbinit_path ${gdbinit_dir}/symbols)
set(py_extensions_gdbinit_path ${gdbinit_dir}/py_extensions)
set(connect_gdbinit_path ${gdbinit_dir}/connect)
idf_build_get_property(PROJECT_EXECUTABLE EXECUTABLE)
set(application_elf ${BUILD_DIR}/${PROJECT_EXECUTABLE})
# EXECUTABLE is a CMake target name; the on-disk elf is EXECUTABLE_NAME + ".elf".
idf_build_get_property(PROJECT_EXECUTABLE_NAME EXECUTABLE_NAME)
set(application_elf ${BUILD_DIR}/${PROJECT_EXECUTABLE_NAME}.elf)
file(MAKE_DIRECTORY ${gdbinit_dir})