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 replaces source tree location in the debug info, in order to achieve repeatable builds.
      For example, 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.

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

See also: LLDB troubleshooting

Clone this wiki locally