Skip to content

Breakpoints are not getting hit

vadimcn edited this page Sep 16, 2021 · 9 revisions

Symptom: Debugger does not stop on breakpoints / breakpoints are grayed out.

This usually means one of the two things:

  • The debugger cannot locate debugging information for the module you are setting a breakpoint in.
    Please make sure that you are compiling with debug information emission enabled. Most C++ compilers, as well as the Rust compiler, use -g flag for this purpose. You can check whether your binary has debug info by following these instructions.

  • The path of file you are setting a breakpoint in does not match source path stored in the debugging information. This may happen because:

    • You are debugging on a different machine than the program was compiled on. This includes compiling or debugging in a Docker container if the source tree is not mounted at exactly the same location. To correct this, add "sourceMap": { "<source tree path at compilation time>": "<source tree path during debugging>" } to your launch configuration. The latter is usually ${workspaceFolder}.
    • Your build system or compiler rewrites source tree location embedded in the debug info:
      • In order to achieve repeatable builds, Bazel, makes source file paths relative to the current directory. To fix, add "sourceMap": { "/proc/self/cwd": "<source tree path> } to your launch configuration on Linux, or "sourceMap": { ".": "<source tree path>" } on MacOS or Windows.
      • If debugging a Rust program, check whether the source path contained symlinks: rustc replaces symlinks with their targets. To fix, add "sourceMap": {"<original path>: "<symlinked path>"}.

    In this case, you should still be able to set function breakpoints, which may help in diagnosing the problem: once stopped on a breakpoint, use commands such as source info or breakpoint list --verbose to see what's going on. Use debug_info command to dump source paths of all compilation units in the currently loaded modules.

See also: LLDB troubleshooting

Clone this wiki locally