Reputation: 1096
Im using Xcode for C++ development via an external build system. If I use Xcode 6.2 (lldb 320.4.160) everything works fine, i can set breakpoints, and they are being hit - everything nice. However, if I want to upgrade to a newer version of Xcode e.g. 7.3 (lldb 350.0.21.3) my breakpoints aren't being hit anymore. My research so far is telling me that the new lldb can't set the breakpoints for some reason.
once I stop execution of the program and type (lldb) breakpoint list
my output looks like this:
Current breakpoints:
1: file = '/full/path/to/src/main.cpp', line = 842, exact_match = 0, locations = 0 (pending)
2: file = '/full/path/to/src/class.cpp', line = 383, exact_match = 0, locations = 0 (pending)
3: file = '/full/path/to/src/Homie.cpp', line = 12, exact_match = 0, locations = 0 (pending)
the (pending)
at the end shows that the bp could not be set correctly. If I now set a breakpoint in the lldb via breakpoint set --file main.cpp --line 842
I get a breakpoint of which (lldb) breakpoint list
is giving the following output:
4: file = 'main.cpp', line = 12, exact_match = 0, locations = 1, resolved = 1, hit count = 0
4.1: where = TEST`::__cxx_global_array_dtor() + 29 at main.cpp:842, address = 0x000000010027130d, resolved, hit count = 0
this breakpoint is being hit during program execution - everything nice
If I try to set the breakpoints on the same executable using Xcode 6.2 the debugger can successfully find the source file even with the full file path.
How can I make the new lldb version set the breakpoints correctly?
Thanks!
Upvotes: 0
Views: 763
Reputation: 27203
Xcode always sets file & line breakpoints using it's notion of the full path to the source. When Xcode is building the project, it can make sure it's "full path to source" and what it provided the compiler (and which the compiler then writes in the debug information) are the same. But with an external build system, they may not be the same (e.g. the build system may refer to the path through complicated relative paths, or through symlinks, etc...) The debugger doesn't resolve paths for all the source file paths, that is just too expensive for big projects. So if these don't match setting breakpoints by full path won't work.
You can find out what path the debugger thinks your main.cpp has by setting your breakpoint, then finding the address of the location (0x000000010027130d in the example above) and running the command:
(lldb) image lookup -va 0x000000010027130d
One of the output lines will be the compile unit:
CompileUnit: id = {0x00000000}, file = "/tmp/hello-world.c", language = "c99"
Is the full path given here the same as the one you saw when Xcode set the breakpoint. If it is then I don't know what could be going wrong, but if they aren't, you know the why, and that may point you in the direction of fixing it.
Upvotes: 0