Skip to content

Program suddenly exit when call si or n or other continue command in repl. #898

@Katzeee

Description

@Katzeee

Debug adapter definition and debug configuration

Installed adapter via Mason, I tried cpptools and codelldb, both have this issue.
Here is my config, should the same as wiki's.

return {
   adapters = {
     codelldb = {
       type = "server",
       port = "${port}",
       executable = {
          command = codelldb_path,
          args = { "--port", "${port}" },
        },
      },
      cppdbg = {
           id = "cppdbg",
           type = "executable",
          command = install_root_dir .. "/bin/OpenDebugAD7",
       },
  },
  configurations = {
    cpp = {
      name = "Launch File",
      type = "cppdbg",
      -- type = "codelldb",
      request = "launch",
      program = function() return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file") end
      cwd = "${workspaceFolder}",
      stopOnEntry = false,
    },
  },
}

Debug adapter version

No response

Steps to Reproduce

#include <iostream>
#include <memory>
int f() {
  static int x = 0;
  x++;
  return 1;
}
int main() {
  int x = 0;
  for (int i = 0; i < 5; i++) {
    x += 1;
  }
  f();
  auto node = std::make_unique<int>(1);
  std::cout << &node << " " << node.get() << std::endl;
}

I set the breakpoint at line 5, then dap.continue, dap.repl.open, call -exec si, the program suddenly exit.

Expected Result

I expect the program stop at this line, repl output something like

0x00005555555551c3    6    x++;

as it output when I debug it using gdb or lldb.
I find the output message and a stop event in dap.log, but it is wierd that I also got this session debug message in it.

[ DEBUG ] 2023-03-15T08:30:02Z+0800 ] .../xac/.local/share/nvim/lazy/nvi
m-dap/lua/dap/session.lua:932 ] 1       {
  body = {
    category = "stdout",
    output = "0x00005555555551c3\t6\t  x++;\n"
  },
  event = "output",
  seq = 43,
  type = "event"
}
[ DEBUG ] 2023-03-15T08:30:02Z+0800 ] .../xac/.local/share/nvim/lazy/nvi
m-dap/lua/dap/session.lua:932 ] 1       {
  body = {
    allThreadsStopped = true,
    column = 1,
    line = 6,
    reason = "step",
    source = {
      checksums = {},
      name = "x.cpp",
      path = "/home/xac/x.cpp",
      sources = {}
    },
    threadId = 198705
  },
  event = "stopped",
  seq = 46,
  type = "event"
}
[ DEBUG ] 2023-03-15T08:30:02Z+0800 ] .../xac/.local/share/nvim/lazy/nvi
m-dap/lua/dap/session.lua:648 ] "Received stopped event, but a.out [1987
05] is already stopped. Resuming newly stopped thread. To disable this s
et the `auto_continue_if_many_stopped` option to false."

seems the program exit before the stopped event? I'm new to dap so I can't figure out whether it's a bug of dap.

Actual Result

There's no need other logs. I found that I can get it work by setting auto_continue_if_many_stopped to false.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions