mfussenegger / nvim-dap

Debug Adapter Protocol client implementation for Neovim
GNU General Public License v3.0
5.47k stars 194 forks source link

mac os m1 codelldb install with mason casue `Couldn't connect to localhost:xxx: ECONNREFUSED`, how to debug on macos arm cpu M1? #1031

Closed cxwx closed 1 year ago

cxwx commented 1 year ago

Debug adapter definition and debug configuration

dap.adapters.codelldb = {
  type = "server",
  host = "localhost",
  --port = "${port}",
  port = "13777",
  executable = {
    command = "codelldb",
    args = {
      "--port",
      "13777",
    },
  },
}

dap.configurations.cpp = { name = 'launch codelldb', type = 'codelldb', request = 'launch', program = function() return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') end, cwd = '${workspaceFolder}', stopOnEntry = false, args = {}, }

Debug adapter version

install by mason

Steps to Reproduce

try a simple code

#include <iostream>
#include <vector>

int main() {
  int a = 6;
  for (int i = 0; i <3; i++) {
    a++;
  }
  std::cout<<a<<std::endl;
}

g++ main.cpp -o main

try to debug

lua require('dap').continue() 

Expected Result

loaded

Actual Result

Couldn't connect to localhost:xxx: ECONNREFUSED

try to change ports but still not work?

qlibp commented 11 months ago

@cxwx How you get it to work? I encounter the same problem

ShuaiQA commented 11 months ago

May I ask how you solved it?

cxwx commented 11 months ago

failed, change to lldb-vscode

@cxwx How you get it to work? I encounter the same problem

angles-n-daemons commented 4 months ago

I spent some time looking at this today, the issue I found was that localhost was being translated at some point to the ipv6 address ::1, while codelldb wasn't binding to it. I used instead 127.0.0.1 as the host and it worked fine.

localhost -> 127.0.0.1