7

At $DAYJOB, I am trying to implement reproducible builds to make debugging released software where we no longer have the full debug versions on our build servers easier, using the tips from reproducible-builds.org.

Using the -ffile-prefix-map=/path/to/build=src option in GCC to avoid leaking internal file paths does help making some error messages cleaner, but does produce problems when using GDB. I am in /path/to/build/some/binary/ and hitting a breakpoint in /path/to/build/lib/cclib/:

Breakpoint 1, [...]
at src/lib/cclib/eventloop.cc:154
154    src/lib/cclib/eventloop.cc: No such file or directory.
(gdb)

As a workaround, I can symlink src to the root of the build tree, but is there a better way to make sure gdb understands the mapping?

3
  • Try adding the build directory to the source path (with the directory command). Commented Apr 21, 2021 at 10:27
  • I guess I would also need to remove the src component from the rewrite, since this does not actually exist (unless the source repo is checked out as src)? Commented Apr 21, 2021 at 12:57
  • 1
    See also this question for an additional insight. Commented Sep 13, 2023 at 17:57

1 Answer 1

8

GDB has a few configuration commands to direct the way it searches for source code. In your case, where you have a tree of source code and you need to change a path prefix, set substitute-path DWARF-compilation-dir actual-dir should be all you need to do.

set substitute-path src /path/to/build
Sign up to request clarification or add additional context in comments.

1 Comment

That did not work with my setup, until I changed the remapping to -ffile-prefix-map=/path/to/build=/src, i.e., adding a leading slash to the source. With that change, set substitute-path /src /path/to/build works fine!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.