tl;dr - cmake is building my .elf
file with the fake paths that my files lived at when they were mapped into docker. The files don't live at those paths on my actual machine. This is breaking GDB.
Detailed version -
I'm building my ESP-IDF project with docker. The command looks like this...
docker run --rm -v $PWD:/project -w /project espressif/idf:release-v4.4 idf.py build
I run this from the root of my ESP-IDF project, it creates the container, maps my current directory to /project
in the container, hops into the container in that /project
directory, and it builds the project for me. Everything there is great.
I recently started using JTAG with GDB, and one of the things it asks for is the elf file that the build process put in my build
directory. Cool - build/myProject.elf
is right there next to the build/myProject.bin
I spin up OpenOCD, The JTAG board is hooked up to my board, and I hit the "play" button on the GDB debugging instance I configured for this..... And this is when the problem happens.
I have a breakpoint in components/dispatch/dispatch.cpp
, but VSCode tries to open the file project/components/dispatch/dispatch.cpp
. This file, obviously, doesn't exist. That project
folder was just an artifact of the docker build process.
What can I do about this? It seems like this issue might be an issue with cmake? Can I override the path that cmake builds into all my file paths in that elf file? Can I change my launch.json
file to revise the paths in the elf file? How would you approach this?
What can I do about this?
One of a few things:
ln -s . project
on UNIX (not sure how this would work on Windows).-fdebug-prefix-map=project=.
to tell GCC (at compile time) that the project
subdirectory should map to current directory as far as debugging sources go. Documentation.set substitute-path project .
to remap project
to current directory. Documentation.