0

As per this question, I am unable to get LLDB to display the actual source code when debugging.

Thanks to the accepted answer on that question, I have traced the problem to how Tup builds variants (e.g. debug, production etc):

  1. It works in a subdirectory per-variant
  2. It does not copy the source into the subdirectory
  3. It does build all outputs (.o files and the executable itself) in the subdirectory

Because of this, LLDB can't find the original source files when debugging.

So my question is: how can I either coerce Tup to feed different paths in to the build process or tell LLDB what is actually going on?

Community
  • 1
  • 1
Leo
  • 4,217
  • 4
  • 25
  • 41

1 Answers1

2

I was able to solve this in two parts:

1. Get Tup to use accurate paths

Firstly, so that the executable refers to the .o files at their actual location, Tup must be made to run in a chroot (more info here, and in the docs). This is done by putting c after a caret in the Tup command.

So my build commands went from something like

: foreach code/*.cpp |> ^o compile %f^ $(COMPILER) $(COMPILER_FLAGS) %f -o %o |> %B.o {code_object_files}

to

: foreach code/*.cpp |> ^oc compile %f^ $(COMPILER) $(COMPILER_FLAGS) %f -o %o |> %B.o {code_object_files}`

This got the right paths into the executable, but the .o files still referred to the source files as though they were in the build subdirectory, rather than the main directory, leading to:

2. Tell LLDB where to look for the source

So LLDB thinks the source is at /Users/leo/project/subdirectory/code but they are actually at /Users/leo/project/code. This is solved as per this question by telling LLDB to substitute one path for another:

(lldb) settings set target.source-map /Users/leo/project/subdirectory /Users/leo/project

(This didn't seem to work with relative paths, which is a shame as it means a per-dev-machine solution is needed. If anyone knows of a solution that would work regardless of where the project is then let me know!)

You can also automate this by having LLDB source a file with this line in: lldb -s path/to/lldb/config/file.

Community
  • 1
  • 1
Leo
  • 4,217
  • 4
  • 25
  • 41