File and line breakpoints are not getting hit
First you must make sure that your source files were compiled with
debug information. Typically this means passing
-g to the
compiler when compiling your source file.
When setting breakpoints in implementation source files
(.c, cpp, cxx, .m, .mm, etc), LLDB by default will only search for compile units whose filename matches. If your
code does tricky things like using #include to include source files:
% cat foo.c
This will cause breakpoints in "bar.c" to be inlined into the compile unit for "foo.c".
If your code does this, or if your build system combines multiple files in some way such
that breakpoints from one implementation file will be compiled into another implementation file,
you will need to tell LLDB to always search for inlined breakpoint locations
by adding the following line to your
% echo "settings set target.inline-breakpoint-strategy always" >> ~/.lldbinit
This tells LLDB to always look in all compile units and search for breakpoint locations by file and line even if the implementation file doesn't match. Setting breakpoints in header files always searches all compile units because inline functions are commonly defined in header files and often cause multiple breakpoints to have source line information that matches many header file paths.
If you set a file and line breakpoint using a full path to the source file, like Xcode does when setting a breakpoint in its GUI on Mac OS X when you click in the gutter of the source view, this path must match the full paths in the debug information. If the paths mismatch, possibly due to passing in a resolved source file path that doesn't match an unresolved path in the debug information, this can cause breakpoints to not be resolved. Try setting breakpoints using the file basename only.
If you are using an IDE and you move your project in your file system and build again, sometimes doing a clean then build will solve the issue.This will fix the issue if some .o files didn't get rebuilt after the move as the .o files in the build folder might still contain stale debug information with the old source locations.