My Neovim DAP Setup for C Debugging (2)

Neovim DAP with LLDB

Background

Inconveniences with the current setup

I was using Neovim DAP with GDB for C debugging. Here’re some inconveniences during the debug process:

  • needed fflush(0) for displaying standard output in the REPL (the small buffer below)
  • Gemini’s suggested solutions for obtaining standard input sounded too complicated, like:
    • attaching GDB to an external TTY, or

    • from a certain file

      dap.configurations.c = {
        {
          name = "Launch with File Input Redirection",
          type = "gdb", -- or codelldb
          request = "launch",
          program = function()
            return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file")
          end,
          cwd = "${workspaceFolder}",
          args = { "<", "input.txt" }, -- Passes input.txt as standard input
        },
      }
      

Popularity of an alternative compiler

AI Learning Club’s C course’s introduction says that Clang often offers a quicker compilation and more informative error messages. As a result, I was feeling motivated to connect Neovim DAP to LLDB instead.

[Read More]
Neovim  DAP  LLDB  C  clang