mfussenegger / nvim-dap

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

gdb does not shut down gracefully #1150

Closed TristanLeclair closed 5 months ago

TristanLeclair commented 5 months ago

Debug adapter definition and debug configuration

I built gdb 14.1 from source as it is not available on Ubuntu 22.04 (running on WSL2). I built it with the --with-python=/usr/bin/python3 flag.

I load it in a lazy-nvim config file.

  local dapui = require("dapui")
  dapui.setup()
  local dap = require("dap")
  -- dapui configuration...  
  -- ...

  dap.adapters.gdb = {
    type = "executable",
    command = "gdb",
    args = { "-i", "dap" },
  }
  dap.configurations.c = {
    {
      name = "Launch",
      type = "gdb",
      request = "launch",
      linux = {
        MIMode = "gdb",
        miDebuggerPath = "/usr/local/bin/gdb"
      },
      program = function()
        return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file")
      end,
      cwd = "${workspaceFolder}",
    },
  }

Debug adapter version

14.1

Steps to Reproduce

  1. I run :DapContinue on a c file.
  2. The debugger starts and runs fine.
  3. Once the program ends, it throws a python error.

Expected Result

I would expect it to shutdown the same way gdb would in the terminal. [Inferior 1 (process 207571) exited normally]

Actual Result

This immediately follows the output of the program.

Exception in thread DAP:
Traceback (most recent call last):
  File "/usr/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.10/threading.py", line 953, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/share/gdb/python/gdb/dap/startup.py", line 51, in really_start_dap
    target()
  File "/usr/local/share/gdb/python/gdb/dap/startup.py", line 73, in ensure_dap_thread
    return func(*args, **kwargs)
  File "/usr/local/share/gdb/python/gdb/dap/server.py", line 117, in main_loop
    cmd = read_json(self.in_stream)
  File "/usr/local/share/gdb/python/gdb/dap/io.py", line 37, in read_json
    while len(data) < content_length:
TypeError: '<' not supported between instances of 'int' and 'NoneType'

dap.log contents for the error

[ DEBUG ] 2024-02-04T00:48:57Z-0500 ] ...ecla/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:1366 ]    "Spawning debug adapter"    {
  args = { "-i", "dap" },
  command = "gdb",
  type = "executable"
}
[ DEBUG ] 2024-02-04T00:48:57Z-0500 ] ...ecla/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:1676 ]    "request"   {
  arguments = {
    adapterID = "nvim-dap",
    clientID = "neovim",
    clientName = "neovim",
    columnsStartAt1 = true,
    linesStartAt1 = true,
    locale = "C.UTF-8",
    pathFormat = "path",
    supportsProgressReporting = true,
    supportsRunInTerminalRequest = true,
    supportsStartDebuggingRequest = true,
    supportsVariableType = true
  },
  command = "initialize",
  seq = 1,
  type = "request"
}
[ DEBUG ] 2024-02-04T00:48:57Z-0500 ] ...ecla/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 2   {
  body = {
    category = "stdout",
    output = "GNU gdb (GDB) 14.1\n"
  },
  event = "output",
  seq = 1,
  type = "event"
}
[ DEBUG ] 2024-02-04T00:48:57Z-0500 ] ...ecla/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 2   {
  body = {
    category = "stdout",
    output = "Copyright (C) 2023 Free Software Foundation, Inc.\n"
  },
  event = "output",
  seq = 2,
  type = "event"
}
[ DEBUG ] 2024-02-04T00:48:57Z-0500 ] ...ecla/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 2   {
  body = {
    category = "stdout",
    output = "License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\n"
  },
  event = "output",
  seq = 3,
  type = "event"
}
[ DEBUG ] 2024-02-04T00:48:57Z-0500 ] ...ecla/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 2   {
  body = {
    category = "stdout",
    output = "This is free software: you are free to change and redistribute it.\n"
  },
  event = "output",
  seq = 4,
  type = "event"
}
[ DEBUG ] 2024-02-04T00:48:57Z-0500 ] ...ecla/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 2   {
  body = {
    category = "stdout",
    output = "There is NO WARRANTY, to the extent permitted by law.\n"
  },
  event = "output",
  seq = 5,
  type = "event"
}
[ DEBUG ] 2024-02-04T00:48:57Z-0500 ] ...ecla/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 2   {
  body = {
    category = "stdout",
    output = 'Type "show copying" and "show warranty" for details.\n'
  },
  event = "output",
  seq = 6,
  type = "event"
}
[ DEBUG ] 2024-02-04T00:48:57Z-0500 ] ...ecla/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 2   {
  body = {
    category = "stdout",
    output = 'This GDB was configured as "x86_64-pc-linux-gnu".\n'
  },
  event = "output",
  seq = 7,
  type = "event"
}
[ DEBUG ] 2024-02-04T00:48:57Z-0500 ] ...ecla/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 2   {
  body = {
    category = "stdout",
    output = 'Type "show configuration" for configuration details.\n'
  },
  event = "output",
  seq = 8,
  type = "event"
}
[ DEBUG ] 2024-02-04T00:48:57Z-0500 ] ...ecla/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 2   {
  body = {
    category = "stdout",
    output = "For bug reporting instructions, please see:\n"
  },
  event = "output",
  seq = 9,
  type = "event"
}
[ DEBUG ] 2024-02-04T00:48:57Z-0500 ] ...ecla/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 2   {
  body = {
    category = "stdout",
    output = "<https://www.gnu.org/software/gdb/bugs/>.\n"
  },
  event = "output",
  seq = 10,
  type = "event"
}
[ DEBUG ] 2024-02-04T00:48:57Z-0500 ] ...ecla/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 2   {
  body = {
    category = "stdout",
    output = "Find the GDB manual and other documentation resources online at:\n"
  },
  event = "output",
  seq = 11,
  type = "event"
}
[ DEBUG ] 2024-02-04T00:48:57Z-0500 ] ...ecla/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 2   {
  body = {
    category = "stdout",
    output = "    <http://www.gnu.org/software/gdb/documentation/>.\n"
  },
  event = "output",
  seq = 12,
  type = "event"
}
[ DEBUG ] 2024-02-04T00:48:57Z-0500 ] ...ecla/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 2   {
  body = {
    category = "stdout",
    output = "\n"
  },
  event = "output",
  seq = 13,
  type = "event"
}
[ DEBUG ] 2024-02-04T00:48:57Z-0500 ] ...ecla/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 2   {
  body = {
    category = "stdout",
    output = 'For help, type "help".\n'
  },
  event = "output",
  seq = 14,
  type = "event"
}
[ DEBUG ] 2024-02-04T00:48:57Z-0500 ] ...ecla/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 2   {
  body = {
    category = "stdout",
    output = 'Type "apropos word" to search for commands related to "word".\n'
  },
  event = "output",
  seq = 15,
  type = "event"
}
[ DEBUG ] 2024-02-04T00:48:57Z-0500 ] ...ecla/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 2   {
  body = {
    exceptionBreakpointFilters = { {
        filter = "assert",
        label = "Ada assertions",
        supportsCondition = true
      }, {
        filter = "exception",
        label = "Ada exceptions",
        supportsCondition = true
      }, {
        filter = "throw",
        label = "C++ exceptions, when thrown",
        supportsCondition = true
      }, {
        filter = "rethrow",
        label = "C++ exceptions, when re-thrown",
        supportsCondition = true
      }, {
        filter = "catch",
        label = "C++ exceptions, when caught",
        supportsCondition = true
      } },
    supportTerminateDebuggee = true,
    supportsBreakpointLocationsRequest = true,
    supportsConditionalBreakpoints = true,
    supportsConfigurationDoneRequest = true,
    supportsDelayedStackTraceLoading = true,
    supportsDisassembleRequest = true,
    supportsEvaluateForHovers = true,
    supportsExceptionFilterOptions = true,
    supportsFunctionBreakpoints = true,
    supportsHitConditionalBreakpoints = true,
    supportsInstructionBreakpoints = true,
    supportsLoadedSourcesRequest = true,
    supportsLogPoints = true,
    supportsModulesRequest = true,
    supportsReadMemoryRequest = true,
    supportsSetExpression = true,
    supportsSetVariable = true,
    supportsSingleThreadExecutionRequests = true,
    supportsSteppingGranularity = true,
    supportsTerminateRequest = true,
    supportsValueFormattingOptions = true,
    supportsWriteMemoryRequest = true
  },
  command = "initialize",
  request_seq = 1,
  seq = 16,
  success = true,
  type = "response"
}
[ DEBUG ] 2024-02-04T00:48:57Z-0500 ] ...ecla/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 2   {
  event = "initialized",
  seq = 17,
  type = "event"
}
[ DEBUG ] 2024-02-04T00:48:57Z-0500 ] ...ecla/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:1676 ]    "request"   {
  arguments = {
    cwd = "/home/tlecla/projects/c/C_Playground",
    linux = {
      MIMode = "gdb",
      miDebuggerPath = "/usr/local/bin/gdb"
    },
    name = "Launch",
    program = "/home/tlecla/projects/c/C_Playground/test_stuff",
    request = "launch",
    type = "gdb"
  },
  command = "launch",
  seq = 2,
  type = "request"
}
[ DEBUG ] 2024-02-04T00:48:57Z-0500 ] ...ecla/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:1676 ]    "request"   {
  arguments = {
    filters = {}
  },
  command = "setExceptionBreakpoints",
  seq = 3,
  type = "request"
}
[ DEBUG ] 2024-02-04T00:48:57Z-0500 ] ...ecla/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 2   {
  command = "launch",
  request_seq = 2,
  seq = 18,
  success = true,
  type = "response"
}
[ DEBUG ] 2024-02-04T00:48:57Z-0500 ] ...ecla/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 2   {
  body = {
    module = {
      id = "/home/tlecla/projects/c/C_Playground/test_stuff",
      name = "/home/tlecla/projects/c/C_Playground/test_stuff",
      path = "/home/tlecla/projects/c/C_Playground/test_stuff"
    },
    reason = "new"
  },
  event = "module",
  seq = 19,
  type = "event"
}
[ DEBUG ] 2024-02-04T00:48:57Z-0500 ] ...ecla/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 2   {
  body = {
    breakpoints = {}
  },
  command = "setExceptionBreakpoints",
  request_seq = 3,
  seq = 20,
  success = true,
  type = "response"
}
[ DEBUG ] 2024-02-04T00:48:57Z-0500 ] ...ecla/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:1676 ]    "request"   {
  command = "configurationDone",
  seq = 4,
  type = "request"
}
[ DEBUG ] 2024-02-04T00:48:57Z-0500 ] ...ecla/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 2   {
  command = "configurationDone",
  request_seq = 4,
  seq = 21,
  success = true,
  type = "response"
}
[ DEBUG ] 2024-02-04T00:48:57Z-0500 ] ...ecla/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 2   {
  body = {
    reason = "started",
    threadId = 1
  },
  event = "thread",
  seq = 22,
  type = "event"
}
[ DEBUG ] 2024-02-04T00:48:57Z-0500 ] ...ecla/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 2   {
  body = {
    module = {
      id = "/lib64/ld-linux-x86-64.so.2",
      name = "/lib64/ld-linux-x86-64.so.2",
      path = "/lib64/ld-linux-x86-64.so.2"
    },
    reason = "new"
  },
  event = "module",
  seq = 23,
  type = "event"
}
[ DEBUG ] 2024-02-04T00:48:57Z-0500 ] ...ecla/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 2   {
  body = {
    module = {
      id = "system-supplied DSO at 0x7ffff7fc1000",
      name = "system-supplied DSO at 0x7ffff7fc1000"
    },
    reason = "new"
  },
  event = "module",
  seq = 24,
  type = "event"
}
[ DEBUG ] 2024-02-04T00:48:57Z-0500 ] ...ecla/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 2   {
  body = {
    module = {
      id = "/lib/x86_64-linux-gnu/libc.so.6",
      name = "/lib/x86_64-linux-gnu/libc.so.6",
      path = "/lib/x86_64-linux-gnu/libc.so.6"
    },
    reason = "new"
  },
  event = "module",
  seq = 25,
  type = "event"
}
[ DEBUG ] 2024-02-04T00:48:57Z-0500 ] ...ecla/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 2   {
  body = {
    category = "stdout",
    output = "boo\n"
  },
  event = "output",
  seq = 26,
  type = "event"
}
[ DEBUG ] 2024-02-04T00:48:57Z-0500 ] ...ecla/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 2   {
  body = {
    reason = "exited",
    threadId = 1
  },
  event = "thread",
  seq = 27,
  type = "event"
}
[ DEBUG ] 2024-02-04T00:48:57Z-0500 ] ...ecla/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 2   {
  body = {
    exitCode = 0
  },
  event = "exited",
  seq = 28,
  type = "event"
}
[ DEBUG ] 2024-02-04T00:48:57Z-0500 ] ...ecla/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 2   {
  event = "terminated",
  seq = 29,
  type = "event"
}
[ DEBUG ] 2024-02-04T00:48:57Z-0500 ] ...ecla/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 2   {
  body = {
    category = "stdout",
    output = "Exception in thread DAP:\n"
  },
  event = "output",
  seq = 30,
  type = "event"
}
[ DEBUG ] 2024-02-04T00:48:57Z-0500 ] ...ecla/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 2   {
  body = {
    category = "stdout",
    output = "Traceback (most recent call last):\n"
  },
  event = "output",
  seq = 31,
  type = "event"
}
[ DEBUG ] 2024-02-04T00:48:57Z-0500 ] ...ecla/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 2   {
  body = {
    category = "stdout",
    output = '  File "/usr/lib/python3.10/threading.py", line 1016, in _bootstrap_inner\n'
  },
  event = "output",
  seq = 32,
  type = "event"
}
[ DEBUG ] 2024-02-04T00:48:57Z-0500 ] ...ecla/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 2   {
  body = {
    category = "stdout",
    output = "    self.run()\n"
  },
  event = "output",
  seq = 33,
  type = "event"
}
[ DEBUG ] 2024-02-04T00:48:57Z-0500 ] ...ecla/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 2   {
  body = {
    category = "stdout",
    output = '  File "/usr/lib/python3.10/threading.py", line 953, in run\n'
  },
  event = "output",
  seq = 34,
  type = "event"
}
[ DEBUG ] 2024-02-04T00:48:57Z-0500 ] ...ecla/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 2   {
  body = {
    category = "stdout",
    output = "    self._target(*self._args, **self._kwargs)\n"
  },
  event = "output",
  seq = 35,
  type = "event"
}
[ DEBUG ] 2024-02-04T00:48:57Z-0500 ] ...ecla/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 2   {
  body = {
    category = "stdout",
    output = '  File "/usr/local/share/gdb/python/gdb/dap/startup.py", line 51, in really_start_dap\n'
  },
  event = "output",
  seq = 36,
  type = "event"
}
[ DEBUG ] 2024-02-04T00:48:57Z-0500 ] ...ecla/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 2   {
  body = {
    category = "stdout",
    output = "    target()\n"
  },
  event = "output",
  seq = 37,
  type = "event"
}
[ DEBUG ] 2024-02-04T00:48:57Z-0500 ] ...ecla/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 2   {
  body = {
    category = "stdout",
    output = '  File "/usr/local/share/gdb/python/gdb/dap/startup.py", line 73, in ensure_dap_thread\n'
  },
  event = "output",
  seq = 38,
  type = "event"
}
[ DEBUG ] 2024-02-04T00:48:57Z-0500 ] ...ecla/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 2   {
  body = {
    category = "stdout",
    output = "    return func(*args, **kwargs)\n"
  },
  event = "output",
  seq = 39,
  type = "event"
}
[ DEBUG ] 2024-02-04T00:48:57Z-0500 ] ...ecla/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 2   {
  body = {
    category = "stdout",
    output = '  File "/usr/local/share/gdb/python/gdb/dap/server.py", line 117, in main_loop\n'
  },
  event = "output",
  seq = 40,
  type = "event"
}
[ DEBUG ] 2024-02-04T00:48:57Z-0500 ] ...ecla/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 2   {
  body = {
    category = "stdout",
    output = "    cmd = read_json(self.in_stream)\n"
  },
  event = "output",
  seq = 41,
  type = "event"
}
[ DEBUG ] 2024-02-04T00:48:57Z-0500 ] ...ecla/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 2   {
  body = {
    category = "stdout",
    output = '  File "/usr/local/share/gdb/python/gdb/dap/io.py", line 37, in read_json\n'
  },
  event = "output",
  seq = 42,
  type = "event"
}
[ DEBUG ] 2024-02-04T00:48:57Z-0500 ] ...ecla/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 2   {
  body = {
    category = "stdout",
    output = "    while len(data) < content_length:\n"
  },
  event = "output",
  seq = 43,
  type = "event"
}
[ DEBUG ] 2024-02-04T00:48:57Z-0500 ] ...ecla/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:950 ] 2   {
  body = {
    category = "stdout",
    output = "TypeError: '<' not supported between instances of 'int' and 'NoneType'\n"
  },
  event = "output",
  seq = 44,
  type = "event"
}
mfussenegger commented 5 months ago

This was an issue in gdb. See https://sourceware.org/bugzilla/show_bug.cgi?id=31217

mlysle commented 3 months ago

I am getting the same exception on gdb 14.2. However, it happens on the first run as well.