mfussenegger / nvim-dap

Debug Adapter Protocol client implementation for Neovim

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Source location: unknown | Resolved location: 0 with breakpoints

nullchilly opened this issue · comments

Debug adapter definition and debug configuration

Installed adapter via codelldb
Configured as described in the wiki:

2022-05-27.01-05-49.mp4
local dap = require "dap"

vim.fn.sign_define("DapBreakpoint", { text = "ß", texthl = "", linehl = "", numhl = "" })
vim.fn.sign_define("DapBreakpointCondition", { text = "ü", texthl = "", linehl = "", numhl = "" })
-- Setup cool Among Us as avatar
vim.fn.sign_define("DapStopped", { text = "", texthl = "Error" })

-- 💀 Adjust the path to your executable
local cmd = '/home/nullchilly/code/codelldb/extension/adapter/codelldb'

dap.adapters.codelldb = function(on_adapter)
	-- This asks the system for a free port
	local tcp = vim.loop.new_tcp()
	tcp:bind('127.0.0.1', 0)
	local port = tcp:getsockname().port
	tcp:shutdown()
	tcp:close()

	-- Start codelldb with the port
	local stdout = vim.loop.new_pipe(false)
	local stderr = vim.loop.new_pipe(false)
	local opts = {
		stdio = {nil, stdout, stderr},
		args = {'--port', tostring(port)},
	}
	local handle
	local pid_or_err
	handle, pid_or_err = vim.loop.spawn(cmd, opts, function(code)
		stdout:close()
		stderr:close()
		handle:close()
		if code ~= 0 then
			print("codelldb exited with code", code)
		end
	end)
	if not handle then
		vim.notify("Error running codelldb: " .. tostring(pid_or_err), vim.log.levels.ERROR)
		stdout:close()
		stderr:close()
		return
	end
	vim.notify('codelldb started. pid=' .. pid_or_err)
	stderr:read_start(function(err, chunk)
		assert(not err, err)
		if chunk then
			vim.schedule(function()
				require("dap.repl").append(chunk)
			end)
		end
	end)
	local adapter = {
		type = 'server',
		host = '127.0.0.1',
		port = port
	}
	-- 💀
	-- Wait for codelldb to get ready and start listening before telling nvim-dap to connect
	-- If you get connect errors, try to increase 500 to a higher value, or check the stderr (Open the REPL)
	vim.defer_fn(function() on_adapter(adapter) end, 500)
end

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

I am so clueless right now...

Debug adapter version

1.7.0

Steps to Reproduce

  1. In a c++ file
  2. Run continue()
  3. Source location unknown

Expected Result

I just want to watch some variables but it won't even run even without breakpoints now :<

Actual Result

Logs (click to expand)
[ INFO ] 2022-05-27T00:55:31Z+0700 ] ...e/nvim/site/pack/packer/opt/nvim-dap/lua/dap/session.lua:1205 ]	"Session closed due to disconnect"

[ DEBUG ] 2022-05-27T00:55:44Z+0700 ] ...e/nvim/site/pack/packer/opt/nvim-dap/lua/dap/session.lua:853 ]	"Connecting to debug adapter"	{
  host = "127.0.0.1",
  port = 41683,
  type = "server"
}
[ DEBUG ] 2022-05-27T00:55:44Z+0700 ] ...e/nvim/site/pack/packer/opt/nvim-dap/lua/dap/session.lua:1110 ]	"request"	{
  arguments = {
    adapterID = "nvim-dap",
    clientId = "neovim",
    clientname = "neovim",
    columnsStartAt1 = true,
    linesStartAt1 = true,
    locale = "en_US.UTF-8",
    pathFormat = "path",
    supportsRunInTerminalRequest = true,
    supportsVariableType = true
  },
  command = "initialize",
  seq = 0,
  type = "request"
}
[ DEBUG ] 2022-05-27T00:55:44Z+0700 ] ...e/nvim/site/pack/packer/opt/nvim-dap/lua/dap/session.lua:756 ]	{
  body = {
    exceptionBreakpointFilters = { {
        default = true,
        filter = "cpp_throw",
        label = "C++: on throw"
      }, {
        default = false,
        filter = "cpp_catch",
        label = "C++: on catch"
      } },
    supportTerminateDebuggee = true,
    supportsCancelRequest = true,
    supportsCompletionsRequest = true,
    supportsConditionalBreakpoints = true,
    supportsConfigurationDoneRequest = true,
    supportsDataBreakpoints = true,
    supportsDelayedStackTraceLoading = true,
    supportsEvaluateForHovers = true,
    supportsFunctionBreakpoints = true,
    supportsGotoTargetsRequest = true,
    supportsHitConditionalBreakpoints = true,
    supportsLogPoints = true,
    supportsReadMemoryRequest = true,
    supportsRestartFrame = true,
    supportsSetVariable = true,
    supportsWriteMemoryRequest = true
  },
  command = "initialize",
  request_seq = 0,
  seq = 1,
  success = true,
  type = "response"
}
[ DEBUG ] 2022-05-27T00:55:44Z+0700 ] ...e/nvim/site/pack/packer/opt/nvim-dap/lua/dap/session.lua:1110 ]	"request"	{
  arguments = {
    cwd = "/home/nullchilly/.local/share",
    name = "Launch file",
    program = "/home/nullchilly/.local/share/out",
    request = "launch",
    stopOnEntry = true,
    type = "codelldb"
  },
  command = "launch",
  seq = 1,
  type = "request"
}
[ DEBUG ] 2022-05-27T00:55:44Z+0700 ] ...e/nvim/site/pack/packer/opt/nvim-dap/lua/dap/session.lua:756 ]	{
  body = {
    output = "Console is in 'commands' mode, prefix expressions with '?'.\n"
  },
  event = "output",
  seq = 2,
  type = "event"
}
[ DEBUG ] 2022-05-27T00:55:44Z+0700 ] ...e/nvim/site/pack/packer/opt/nvim-dap/lua/dap/session.lua:756 ]	{
  event = "initialized",
  seq = 3,
  type = "event"
}
[ DEBUG ] 2022-05-27T00:55:44Z+0700 ] ...e/nvim/site/pack/packer/opt/nvim-dap/lua/dap/session.lua:756 ]	{
  body = {
    module = {
      addressRange = "FFFFFFFFFFFFFFFF",
      id = "FFFFFFFFFFFFFFFF",
      name = "out",
      path = "/home/nullchilly/.local/share/out",
      symbolFilePath = "/home/nullchilly/.local/share/out",
      symbolStatus = "Symbols loaded."
    },
    reason = "new"
  },
  event = "module",
  seq = 4,
  type = "event"
}
[ DEBUG ] 2022-05-27T00:55:44Z+0700 ] ...e/nvim/site/pack/packer/opt/nvim-dap/lua/dap/session.lua:756 ]	{
  arguments = {
    args = { "/home/nullchilly/code/codelldb/extension/adapter/codelldb", "terminal-agent", "--connect=46143" },
    cwd = "",
    kind = "integrated",
    title = "Launch file"
  },
  command = "runInTerminal",
  seq = 5,
  type = "request"
}
[ DEBUG ] 2022-05-27T00:55:44Z+0700 ] ...e/nvim/site/pack/packer/opt/nvim-dap/lua/dap/session.lua:205 ]	"run_in_terminal"	{
  args = { "/home/nullchilly/code/codelldb/extension/adapter/codelldb", "terminal-agent", "--connect=46143" },
  cwd = "",
  kind = "integrated",
  title = "Launch file"
}
[ DEBUG ] 2022-05-27T00:55:44Z+0700 ] ...e/nvim/site/pack/packer/opt/nvim-dap/lua/dap/session.lua:1127 ]	"response"	{
  body = {
    processId = 1155299
  },
  command = "runInTerminal",
  request_seq = 5,
  seq = 2,
  success = true,
  type = "response"
}
[ DEBUG ] 2022-05-27T00:55:44Z+0700 ] ...e/nvim/site/pack/packer/opt/nvim-dap/lua/dap/session.lua:1110 ]	"request"	{
  arguments = {
    filters = { "cpp_throw" }
  },
  command = "setExceptionBreakpoints",
  seq = 3,
  type = "request"
}
[ DEBUG ] 2022-05-27T00:55:44Z+0700 ] ...e/nvim/site/pack/packer/opt/nvim-dap/lua/dap/session.lua:756 ]	{
  command = "setExceptionBreakpoints",
  request_seq = 3,
  seq = 6,
  success = true,
  type = "response"
}
[ DEBUG ] 2022-05-27T00:55:44Z+0700 ] ...e/nvim/site/pack/packer/opt/nvim-dap/lua/dap/session.lua:1110 ]	"request"	{
  command = "configurationDone",
  seq = 4,
  type = "request"
}
[ DEBUG ] 2022-05-27T00:55:44Z+0700 ] ...e/nvim/site/pack/packer/opt/nvim-dap/lua/dap/session.lua:756 ]	{
  command = "configurationDone",
  request_seq = 4,
  seq = 7,
  success = true,
  type = "response"
}
[ DEBUG ] 2022-05-27T00:55:44Z+0700 ] ...e/nvim/site/pack/packer/opt/nvim-dap/lua/dap/session.lua:756 ]	{
  body = {
    output = "Launching: /home/nullchilly/.local/share/out\n"
  },
  event = "output",
  seq = 8,
  type = "event"
}
[ DEBUG ] 2022-05-27T00:55:44Z+0700 ] ...e/nvim/site/pack/packer/opt/nvim-dap/lua/dap/session.lua:756 ]	{
  body = {
    output = "Launched process 1155303\n"
  },
  event = "output",
  seq = 9,
  type = "event"
}
[ DEBUG ] 2022-05-27T00:55:44Z+0700 ] ...e/nvim/site/pack/packer/opt/nvim-dap/lua/dap/session.lua:756 ]	{
  body = {
    category = "stderr",
    output = "Stop reason: signal SIGSTOP\n"
  },
  event = "output",
  seq = 10,
  type = "event"
}
[ DEBUG ] 2022-05-27T00:55:44Z+0700 ] ...e/nvim/site/pack/packer/opt/nvim-dap/lua/dap/session.lua:756 ]	{
  body = {
    allThreadsStopped = true,
    reason = "signal",
    text = "signal SIGSTOP",
    threadId = 1155303
  },
  event = "stopped",
  seq = 11,
  type = "event"
}
[ DEBUG ] 2022-05-27T00:55:44Z+0700 ] ...e/nvim/site/pack/packer/opt/nvim-dap/lua/dap/session.lua:756 ]	{
  command = "launch",
  request_seq = 1,
  seq = 12,
  success = true,
  type = "response"
}
[ DEBUG ] 2022-05-27T00:55:44Z+0700 ] ...e/nvim/site/pack/packer/opt/nvim-dap/lua/dap/session.lua:756 ]	{
  body = {
    module = {
      addressRange = "7FFFF7FC6000",
      id = "7FFFF7FC6000",
      name = "ld-linux-x86-64.so.2",
      path = "/usr/lib/ld-linux-x86-64.so.2",
      symbolFilePath = "/usr/lib/ld-linux-x86-64.so.2",
      symbolStatus = "Symbols loaded."
    },
    reason = "new"
  },
  event = "module",
  seq = 13,
  type = "event"
}
[ DEBUG ] 2022-05-27T00:55:44Z+0700 ] ...e/nvim/site/pack/packer/opt/nvim-dap/lua/dap/session.lua:756 ]	{
  body = {
    module = {
      addressRange = "7FFFF7FC4000",
      id = "7FFFF7FC4000",
      name = "[vdso]",
      path = "[vdso]",
      symbolStatus = "Symbols not found"
    },
    reason = "new"
  },
  event = "module",
  seq = 14,
  type = "event"
}
[ DEBUG ] 2022-05-27T00:55:44Z+0700 ] ...e/nvim/site/pack/packer/opt/nvim-dap/lua/dap/session.lua:756 ]	{
  body = {
    module = {
      addressRange = "555555554000",
      id = "555555554000",
      name = "out",
      path = "/home/nullchilly/.local/share/out",
      symbolFilePath = "/home/nullchilly/.local/share/out",
      symbolStatus = "Symbols loaded."
    },
    reason = "new"
  },
  event = "module",
  seq = 15,
  type = "event"
}
[ DEBUG ] 2022-05-27T00:55:44Z+0700 ] ...e/nvim/site/pack/packer/opt/nvim-dap/lua/dap/session.lua:1110 ]	"request"	{
  command = "threads",
  seq = 5,
  type = "request"
}
[ DEBUG ] 2022-05-27T00:55:44Z+0700 ] ...e/nvim/site/pack/packer/opt/nvim-dap/lua/dap/session.lua:756 ]	{
  body = {
    threads = { {
        id = 1155303,
        name = '1: tid=1155303 "out"'
      } }
  },
  command = "threads",
  request_seq = 5,
  seq = 16,
  success = true,
  type = "response"
}
[ DEBUG ] 2022-05-27T00:55:44Z+0700 ] ...e/nvim/site/pack/packer/opt/nvim-dap/lua/dap/session.lua:1110 ]	"request"	{
  arguments = {
    threadId = 1155303
  },
  command = "stackTrace",
  seq = 6,
  type = "request"
}
[ DEBUG ] 2022-05-27T00:55:44Z+0700 ] ...e/nvim/site/pack/packer/opt/nvim-dap/lua/dap/session.lua:1110 ]	"request"	{
  arguments = {
    threadId = 1155303
  },
  command = "stackTrace",
  seq = 7,
  type = "request"
}
[ DEBUG ] 2022-05-27T00:55:44Z+0700 ] ...e/nvim/site/pack/packer/opt/nvim-dap/lua/dap/session.lua:756 ]	{
  body = {
    stackFrames = { {
        column = 0,
        id = 1001,
        line = 3,
        name = "_start",
        presentationHint = "subtle",
        source = {
          name = "@_start",
          sourceReference = 1000
        }
      } },
    totalFrames = 1
  },
  command = "stackTrace",
  request_seq = 6,
  seq = 17,
  success = true,
  type = "response"
}
[ DEBUG ] 2022-05-27T00:55:44Z+0700 ] ...e/nvim/site/pack/packer/opt/nvim-dap/lua/dap/session.lua:1110 ]	"request"	{
  arguments = {
    source = {
      name = "@_start",
      sourceReference = 1000
    },
    sourceReference = 1000
  },
  command = "source",
  seq = 8,
  type = "request"
}
[ DEBUG ] 2022-05-27T00:55:44Z+0700 ] ...e/nvim/site/pack/packer/opt/nvim-dap/lua/dap/session.lua:1110 ]	"request"	{
  arguments = {
    frameId = 1001
  },
  command = "scopes",
  seq = 9,
  type = "request"
}
[ DEBUG ] 2022-05-27T00:55:44Z+0700 ] ...e/nvim/site/pack/packer/opt/nvim-dap/lua/dap/session.lua:756 ]	{
  body = {
    stackFrames = { {
        column = 0,
        id = 1002,
        line = 3,
        name = "_start",
        presentationHint = "subtle",
        source = {
          name = "@_start",
          sourceReference = 1000
        }
      } },
    totalFrames = 1
  },
  command = "stackTrace",
  request_seq = 7,
  seq = 18,
  success = true,
  type = "response"
}
[ DEBUG ] 2022-05-27T00:55:44Z+0700 ] ...e/nvim/site/pack/packer/opt/nvim-dap/lua/dap/session.lua:756 ]	{
  body = {
    content = '; id = {0x000001cf}, range = [0x000000000001dd40-0x000000000001dd48), name="_start"\n; Source location: unknown\n7FFFF7FE3D40: 48 89 E7                   movq   %rsp, %rdi\n7FFFF7FE3D43: E8 88 0C 00 00             callq  0x7ffff7fe49d0  ; _dl_start\n',
    mimeType = "text/x-lldb.disassembly"
  },
  command = "source",
  request_seq = 8,
  seq = 19,
  success = true,
  type = "response"
}
[ DEBUG ] 2022-05-27T00:55:44Z+0700 ] ...e/nvim/site/pack/packer/opt/nvim-dap/lua/dap/session.lua:756 ]	{
  body = {
    scopes = { {
        expensive = false,
        name = "Local",
        variablesReference = 1003
      }, {
        expensive = false,
        name = "Static",
        variablesReference = 1004
      }, {
        expensive = false,
        name = "Global",
        variablesReference = 1005
      }, {
        expensive = false,
        name = "Registers",
        variablesReference = 1006
      } }
  },
  command = "scopes",
  request_seq = 9,
  seq = 20,
  success = true,
  type = "response"
}
[ DEBUG ] 2022-05-27T00:55:44Z+0700 ] ...e/nvim/site/pack/packer/opt/nvim-dap/lua/dap/session.lua:1110 ]	"request"	{
  arguments = {
    variablesReference = 1003
  },
  command = "variables",
  seq = 10,
  type = "request"
}
[ DEBUG ] 2022-05-27T00:55:44Z+0700 ] ...e/nvim/site/pack/packer/opt/nvim-dap/lua/dap/session.lua:1110 ]	"request"	{
  arguments = {
    variablesReference = 1004
  },
  command = "variables",
  seq = 11,
  type = "request"
}
[ DEBUG ] 2022-05-27T00:55:44Z+0700 ] ...e/nvim/site/pack/packer/opt/nvim-dap/lua/dap/session.lua:1110 ]	"request"	{
  arguments = {
    variablesReference = 1005
  },
  command = "variables",
  seq = 12,
  type = "request"
}
[ DEBUG ] 2022-05-27T00:55:44Z+0700 ] ...e/nvim/site/pack/packer/opt/nvim-dap/lua/dap/session.lua:1110 ]	"request"	{
  arguments = {
    variablesReference = 1006
  },
  command = "variables",
  seq = 13,
  type = "request"
}
[ DEBUG ] 2022-05-27T00:55:44Z+0700 ] ...e/nvim/site/pack/packer/opt/nvim-dap/lua/dap/session.lua:1110 ]	"request"	{
  arguments = {
    variablesReference = 1003
  },
  command = "variables",
  seq = 14,
  type = "request"
}
[ DEBUG ] 2022-05-27T00:55:44Z+0700 ] ...e/nvim/site/pack/packer/opt/nvim-dap/lua/dap/session.lua:1110 ]	"request"	{
  arguments = {
    variablesReference = 1004
  },
  command = "variables",
  seq = 15,
  type = "request"
}
[ DEBUG ] 2022-05-27T00:55:44Z+0700 ] ...e/nvim/site/pack/packer/opt/nvim-dap/lua/dap/session.lua:1110 ]	"request"	{
  arguments = {
    variablesReference = 1005
  },
  command = "variables",
  seq = 16,
  type = "request"
}
[ DEBUG ] 2022-05-27T00:55:44Z+0700 ] ...e/nvim/site/pack/packer/opt/nvim-dap/lua/dap/session.lua:1110 ]	"request"	{
  arguments = {
    variablesReference = 1006
  },
  command = "variables",
  seq = 17,
  type = "request"
}
[ DEBUG ] 2022-05-27T00:55:44Z+0700 ] ...e/nvim/site/pack/packer/opt/nvim-dap/lua/dap/session.lua:756 ]	{
  body = {
    variables = {}
  },
  command = "variables",
  request_seq = 10,
  seq = 21,
  success = true,
  type = "response"
}
[ DEBUG ] 2022-05-27T00:55:44Z+0700 ] ...e/nvim/site/pack/packer/opt/nvim-dap/lua/dap/session.lua:756 ]	{
  body = {
    variables = {}
  },
  command = "variables",
  request_seq = 11,
  seq = 22,
  success = true,
  type = "response"
}
[ DEBUG ] 2022-05-27T00:55:44Z+0700 ] ...e/nvim/site/pack/packer/opt/nvim-dap/lua/dap/session.lua:756 ]	{
  body = {
    variables = {}
  },
  command = "variables",
  request_seq = 12,
  seq = 23,
  success = true,
  type = "response"
}
[ DEBUG ] 2022-05-27T00:55:44Z+0700 ] ...e/nvim/site/pack/packer/opt/nvim-dap/lua/dap/session.lua:756 ]	{
  body = {
    variables = { {
        evaluateName = "General Purpose Registers",
        name = "General Purpose Registers",
        value = "{rax:0x0000000000000000, rbx:0x0000000000000000, ...}",
        variablesReference = 1007
      }, {
        evaluateName = "Floating Point Registers",
        name = "Floating Point Registers",
        value = "{fctrl:0x037f, fstat:0x0000, ftag:0xffff, ...}",
        variablesReference = 1008
      }, {
        evaluateName = "Advanced Vector Extensions",
        name = "Advanced Vector Extensions",
        value = "{...}",
        variablesReference = 1009
      } }
  },
  command = "variables",
  request_seq = 13,
  seq = 24,
  success = true,
  type = "response"
}
[ DEBUG ] 2022-05-27T00:55:44Z+0700 ] ...e/nvim/site/pack/packer/opt/nvim-dap/lua/dap/session.lua:756 ]	{
  body = {
    variables = {}
  },
  command = "variables",
  request_seq = 14,
  seq = 25,
  success = true,
  type = "response"
}
[ DEBUG ] 2022-05-27T00:55:44Z+0700 ] ...e/nvim/site/pack/packer/opt/nvim-dap/lua/dap/session.lua:756 ]	{
  body = {
    variables = {}
  },
  command = "variables",
  request_seq = 15,
  seq = 26,
  success = true,
  type = "response"
}
[ DEBUG ] 2022-05-27T00:55:44Z+0700 ] ...e/nvim/site/pack/packer/opt/nvim-dap/lua/dap/session.lua:756 ]	{
  body = {
    variables = {}
  },
  command = "variables",
  request_seq = 16,
  seq = 27,
  success = true,
  type = "response"
}
[ DEBUG ] 2022-05-27T00:55:44Z+0700 ] ...e/nvim/site/pack/packer/opt/nvim-dap/lua/dap/session.lua:756 ]	{
  body = {
    variables = { {
        evaluateName = "General Purpose Registers",
        name = "General Purpose Registers",
        value = "{rax:0x0000000000000000, rbx:0x0000000000000000, ...}",
        variablesReference = 1010
      }, {
        evaluateName = "Floating Point Registers",
        name = "Floating Point Registers",
        value = "{fctrl:0x037f, fstat:0x0000, ftag:0xffff, ...}",
        variablesReference = 1011
      }, {
        evaluateName = "Advanced Vector Extensions",
        name = "Advanced Vector Extensions",
        value = "{...}",
        variablesReference = 1012
      } }
  },
  command = "variables",
  request_seq = 17,
  seq = 28,
  success = true,
  type = "response"
}

If I change to stopOnEntry = false the program does output 8

There is still that Resolved location: 0 though...

2022-05-27.01-23-31.mp4

Never mind I am a dum dum

Added debug flag and it is solved g++ cpp.cpp -g -o cpp

ezoic increase your site revenue