Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting "Source not available, cannot jump to frame" when using C with lldb-dap on Mac M1 #1199

Open
benjitrosch opened this issue Apr 24, 2024 · 4 comments

Comments

@benjitrosch
Copy link

benjitrosch commented Apr 24, 2024

Debug adapter definition and debug configuration

dap.adapters.lldb = {
    type = 'executable',
    command = '/opt/homebrew/Cellar/llvm/18.1.4/bin/lldb-dap',
    name = 'lldb',
}

dap.configurations.cpp = {
    {
        name = 'game',
        type = 'lldb',
        request = 'launch',
        program = function()
            return vim.fn.getcwd() .. '/build/game'
        end,
        cwd = '${workspaceFolder}',
        stopOnEntry = true, -- When this is set to false, I cannot even pause the application because it cannot find the thread
        args = {},
    },
}

dap.configurations.c = dap.configurations.cpp

Debug adapter version

0.7.0

Steps to Reproduce

  1. Build with CMake (with debug symbols using -g): cmake -B build -DCMAKE_BUILD_TYPE=Debug followed by cmake --build build
  2. Set a breakpoint: :lua require'dap'.toggle_breakpoint()
  3. Launch the executable: :lua require'dap'.continue()
  4. It is paused as expected (due to stopOnEntry) and message "Source not available, cannot jump to frame" appears
  5. After playing the breakpoint is not stopped at

Expected Result

The executable should pause at breakpoint.

I've verified that debug symbols are being created, and additionally this works when I've manually tested outside of neovim using my terminal and the regular lldb command. However, using nvim-dap and lldb-dap does not work.

Actual Result

dap.log

@mfussenegger
Copy link
Owner

mfussenegger commented Apr 25, 2024

The stacktraces reported by the debug adapter have no sources:

    stackFrames = { {
        column = 0,
        id = 524288,
        instructionPointerReference = "0x100E7E4C8",
        line = 0,
        name = "__sanitizer::SizeClassAllocator32<__asan::AP32<__sanitizer::LocalAddressSpaceView>>::PopulateFreeList(__sanitizer::AllocatorStats*, __sanitizer::SizeClassAllocator32LocalCache<__sanitizer::SizeClassAllocator32<__asan::AP32<__sanitizer::LocalAddressSpaceView>>>*, __sanitizer::SizeClassAllocator32<__asan::AP32<__sanitizer::LocalAddressSpaceView>>::SizeClassInfo*, unsigned long)",
        presentationHint = "subtle"
      }, {

Not much the client can do about that.
Given that you didn't' post any sources I also can't reproduce this.

@benjitrosch
Copy link
Author

@mfussenegger sorry about that, my mistake. Here's small repo for you to use: https://github.com/benjitrosch/c-dap-example/tree/main

@mfussenegger
Copy link
Owner

The example works fine for me - tested with all 3: lldb-vscode (version 17.0.6) , codelldb and gdb.

stackFrames from lldb-vscode look like this for me:

  body = {
    stackFrames = { {
        column = 3,
        id = 524288,
        line = 13,
        name = "main",
        source = {
          name = "main.c",
          path = "/path/to/benjitrosch/c-dap-example/main.c"
        }
      }, {
        column = 0,
        id = 524289,
        line = 27,
        name = "___lldb_unnamed_symbol3264",
        source = {
          name = "___lldb_unnamed_symbol3264",
          sourceReference = 1
        }
      }, {

@benjitrosch
Copy link
Author

benjitrosch commented Apr 25, 2024

Thanks for trying it out. Really weird that it's not working for me.

I'm using lldb-dap which gets installed from brew install llvm which is at version 18.1.4. I tried downgrading with brew install llvm@17 but then neither lldb-dap nor lldb-vscode were anywhere to be found.

Not sure what other info I could provide, please LMK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants