Skip to content
New issue

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

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

Already on GitHub? # to your account

Debugging with lldb-vscode on windows raises an exception and displays disassembly #307

Closed
EricR86 opened this issue Sep 18, 2021 · 17 comments

Comments

@EricR86
Copy link

EricR86 commented Sep 18, 2021

Debug adapter definition and debug configuration

-- Adapter
local lldb_executable = 'C:/Program Files/LLVM/bin/lldb-vscode.exe'
dap.adapters.lldb = {
type = 'executable',
command = lldb_executable,
name = "lldb",
}

-- Rust Configuration
dap.configurations.rust = {
{
name = "Launch Rust",
type = "lldb",
request = "launch",
program = "C:/Projects/rust/rlox/target/debug/rlox.exe",
cwd = '${workspaceFolder}',
stopOnEntry = true,
args = {},
runInTerminal = false,
},
}

Debug adapter version

12.0.1

Steps to Reproduce

  1. Download latest LLVM release from Github (lldb version 12.0.1)
  2. Create an empty rust project with cargo create, can be a simple hello world app
  3. Set a breakpoint, attempt to "continue" through the Lua API calls
  4. Some sort of exception is raised(?) and you're presented with disassembly

Expected Result

Debugger to break on line specified.

Actual Result

[ DEBUG ] 2021-09-17T20:29:20Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:750 ] "request" {
arguments = {
adapterID = "nvim-dap",
clientId = "neovim",
clientname = "neovim",
columnsStartAt1 = true,
linesStartAt1 = true,
locale = "en_US",
pathFormat = "path",
supportsRunInTerminalRequest = true,
supportsVariableType = true
},
command = "initialize",
seq = 0,
type = "request"
}
[ DEBUG ] 2021-09-17T20:29:20Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:510 ] {
body = {
exceptionBreakpointFilters = { {
default = false,
filter = "cpp_catch",
label = "C++ Catch"
}, {
default = false,
filter = "cpp_throw",
label = "C++ Throw"
}, {
default = false,
filter = "objc_catch",
label = "Objective C Catch"
}, {
default = false,
filter = "objc_throw",
label = "Objective C Throw"
}, {
default = false,
filter = "swift_catch",
label = "Swift Catch"
}, {
default = false,
filter = "swift_throw",
label = "Swift Throw"
} },
supportTerminateDebuggee = true,
supportsCompletionsRequest = false,
supportsConditionalBreakpoints = true,
supportsConfigurationDoneRequest = true,
supportsDelayedStackTraceLoading = true,
supportsEvaluateForHovers = true,
supportsExceptionInfoRequest = true,
supportsExceptionOptions = true,
supportsFunctionBreakpoints = true,
supportsGotoTargetsRequest = false,
supportsHitConditionalBreakpoints = true,
supportsLoadedSourcesRequest = false,
supportsModulesRequest = false,
supportsRestartFrame = false,
supportsRestartRequest = false,
supportsRunInTerminalRequest = true,
supportsSetVariable = true,
supportsStepBack = false,
supportsStepInTargetsRequest = false,
supportsValueFormattingOptions = true
},
command = "initialize",
request_seq = 0,
seq = 0,
success = true,
type = "response"
}
[ DEBUG ] 2021-09-17T20:29:20Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:750 ] "request" {
arguments = {
args = {},
cwd = "C:\Projects\rust\rlox",
name = "Launch Rust",
program = "C:/Projects/rust/rlox/target/debug/rlox.exe",
request = "launch",
runInTerminal = false,
stopOnEntry = true,
type = "lldb"
},
command = "launch",
seq = 1,
type = "request"
}
[ DEBUG ] 2021-09-17T20:29:20Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:510 ] {
command = "launch",
request_seq = 1,
seq = 0,
success = true,
type = "response"
}
[ DEBUG ] 2021-09-17T20:29:20Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:510 ] {
body = {
isLocalProcess = true,
name = "C:\Projects\rust\rlox\target\debug\rlox.exe",
startMethod = "launch",
systemProcessId = 5984
},
event = "process",
seq = 0,
type = "event"
}
[ DEBUG ] 2021-09-17T20:29:20Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:510 ] {
event = "initialized",
seq = 0,
type = "event"
}
[ DEBUG ] 2021-09-17T20:29:20Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:510 ] {
body = {
allThreadsStopped = true,
preserveFocusHint = false,
reason = "exception",
threadCausedFocus = true,
threadId = 10320
},
event = "stopped",
seq = 0,
type = "event"
}
[ DEBUG ] 2021-09-17T20:29:20Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:750 ] "request" {
arguments = {
breakpoints = { {
line = 11
} },
lines = { 11 },
source = {
name = "main.rs",
path = "C:\Projects\rust\rlox\src\main.rs"
}
},
command = "setBreakpoints",
seq = 2,
type = "request"
}
[ DEBUG ] 2021-09-17T20:29:20Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:750 ] "request" {
command = "threads",
seq = 3,
type = "request"
}
[ DEBUG ] 2021-09-17T20:29:20Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:510 ] {
body = {
breakpoints = { {
id = 1,
line = 11,
source = {
name = "main.rs",
path = "C:\Projects\rust\rlox\src\main.rs"
},
verified = false
} }
},
command = "setBreakpoints",
request_seq = 2,
seq = 0,
success = true,
type = "response"
}
[ INFO ] 2021-09-17T20:29:20Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:434 ] "Server rejected breakpoint" {
id = 1,
line = 11,
source = {
name = "main.rs",
path = "C:\Projects\rust\rlox\src\main.rs"
},
verified = false
}
[ DEBUG ] 2021-09-17T20:29:20Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:750 ] "request" {
arguments = {
filters = {}
},
command = "setExceptionBreakpoints",
seq = 4,
type = "request"
}
[ DEBUG ] 2021-09-17T20:29:20Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:510 ] {
body = {
threads = { {
id = 4400,
name = "Thread #4"
}, {
id = 10320,
name = "Thread #1"
}, {
id = 15348,
name = "Thread #3"
}, {
id = 21032,
name = "Thread #2"
} }
},
command = "threads",
request_seq = 3,
seq = 0,
success = true,
type = "response"
}
[ DEBUG ] 2021-09-17T20:29:20Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:750 ] "request" {
arguments = {
threadId = 10320
},
command = "exceptionInfo",
seq = 5,
type = "request"
}
[ DEBUG ] 2021-09-17T20:29:20Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:750 ] "request" {
arguments = {
threadId = 10320
},
command = "stackTrace",
seq = 6,
type = "request"
}
[ DEBUG ] 2021-09-17T20:29:20Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:510 ] {
command = "setExceptionBreakpoints",
request_seq = 4,
seq = 0,
success = true,
type = "response"
}
[ DEBUG ] 2021-09-17T20:29:20Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:750 ] "request" {
command = "configurationDone",
seq = 7,
type = "request"
}
[ DEBUG ] 2021-09-17T20:29:20Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:510 ] {
body = {
breakMode = "always",
description = "Exception 0x80000003 encountered at address 0x7ffc321606b0",
exceptionId = "exception"
},
command = "exceptionInfo",
request_seq = 5,
seq = 0,
success = true,
type = "response"
}
[ DEBUG ] 2021-09-17T20:29:20Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:510 ] {
body = {
stackFrames = { {
column = 0,
id = 524288,
line = 215,
name = "LdrInitShimEngineDynamic",
source = {
name = "LdrInitShimEngineDynamic",
sourceReference = 1
}
}, {
column = 0,
id = 524289,
line = 3291,
name = "LdrInitShimEngineDynamic",
source = {
sourceReference = 1
}
}, {
column = 0,
id = 524290,
line = 123,
name = "LdrInitializeThunk",
source = {
name = "LdrInitializeThunk",
sourceReference = 2
}
}, {
column = 0,
id = 524291,
line = 33,
name = "LdrInitializeThunk",
source = {
sourceReference = 2
}
}, {
column = 0,
id = 524292,
line = 5,
name = "LdrInitializeThunk",
source = {
sourceReference = 2
}
} },
totalFrames = 5
},
command = "stackTrace",
request_seq = 6,
seq = 0,
success = true,
type = "response"
}
[ DEBUG ] 2021-09-17T20:29:20Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:750 ] "request" {
arguments = {
source = {
name = "LdrInitShimEngineDynamic",
sourceReference = 1
},
sourceReference = 1
},
command = "source",
seq = 8,
type = "request"
}
[ DEBUG ] 2021-09-17T20:29:20Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:750 ] "request" {
arguments = {
frameId = 524288
},
command = "scopes",
seq = 9,
type = "request"
}
[ DEBUG ] 2021-09-17T20:29:20Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:510 ] {
command = "configurationDone",
request_seq = 7,
seq = 0,
success = true,
type = "response"
}
[ DEBUG ] 2021-09-17T20:29:20Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:510 ] {
body = {
allThreadsStopped = true,
preserveFocusHint = false,
reason = "exception",
threadCausedFocus = true,
threadId = 10320
},
event = "stopped",
seq = 0,
type = "event"
}
[ DEBUG ] 2021-09-17T20:29:20Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:270 ] "Thread stopped, but another thread is already stopped, telling thread to continue"
[ DEBUG ] 2021-09-17T20:29:20Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:750 ] "request" {
arguments = {
threadId = 10320
},
command = "continue",
seq = 10,
type = "request"
}
[ DEBUG ] 2021-09-17T20:29:20Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:510 ] {
body = {
content = "0x7FFC32160350: <0> movq %rsp, %rax\n0x7FFC32160353: <3> movq %rbx,
** CUT OUT LOTS OF DISSASSEMBLY HERE *
int3 \n0x7FFC3216483F: <17647> int3 \n",
mimeType = "text/x-lldb.disassembly"
},
command = "source",
request_seq = 8,
seq = 0,
success = true,
type = "response"
}
[ DEBUG ] 2021-09-17T20:29:20Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:510 ] {
body = {
scopes = { {
expensive = false,
name = "Locals",
namedVariables = 0,
variablesReference = 1
}, {
expensive = false,
name = "Globals",
namedVariables = 0,
variablesReference = 2
}, {
expensive = false,
name = "Registers",
namedVariables = 2,
variablesReference = 3
} }
},
command = "scopes",
request_seq = 9,
seq = 0,
success = true,
type = "response"
}
[ DEBUG ] 2021-09-17T20:29:20Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:510 ] {
body = {
allThreadsContinued = true
},
command = "continue",
request_seq = 10,
seq = 0,
success = true,
type = "response"
}
[ WARN ] 2021-09-17T20:29:20Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:518 ] "No callback for " {
body = {
allThreadsContinued = true
},
command = "continue",
request_seq = 10,
seq = 0,
success = true,
type = "response"
}
[ DEBUG ] 2021-09-17T20:29:20Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:750 ] "request" {
arguments = {
variablesReference = 1
},
command = "variables",
seq = 11,
type = "request"
}
[ DEBUG ] 2021-09-17T20:29:20Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:750 ] "request" {
arguments = {
variablesReference = 2
},
command = "variables",
seq = 12,
type = "request"
}
[ DEBUG ] 2021-09-17T20:29:20Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:750 ] "request" {
arguments = {
variablesReference = 3
},
command = "variables",
seq = 13,
type = "request"
}

@EricR86
Copy link
Author

EricR86 commented Sep 18, 2021

This is what the bug looks like in action:
render1631925090457

@danielnehrig
Copy link
Contributor

does not look like a dap issue
i think it does a fallback on the binary asm because it can not resolve the path to your source files

im not on windows but i'd try to overwrite the
cwd = '${workspaceFolder}',
to the actual path of the project and see if it fixes it for
this might be some weird windows pathing related issue

@EricR86
Copy link
Author

EricR86 commented Sep 23, 2021

Tried hardcoding all the paths to no avail. I've simplified the issue to some python/extension related crash on lldb-vscode by creating an empty rust project and running :lua require'dap'.continue on it. I've also confirmed I have no other Python versions other than 3.6.8 on my system or anywhere on my path and it can import encodings just fine.

[ DEBUG ] 2021-09-22T23:37:30Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:750 ]	"request"	{
  arguments = {
    adapterID = "nvim-dap",
    clientId = "neovim",
    clientname = "neovim",
    columnsStartAt1 = true,
    linesStartAt1 = true,
    locale = "en_US",
    pathFormat = "path",
    supportsRunInTerminalRequest = true,
    supportsVariableType = true
  },
  command = "initialize",
  seq = 0,
  type = "request"
}
[ DEBUG ] 2021-09-22T23:37:30Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:510 ]	{
  body = {
    exceptionBreakpointFilters = { {
        default = false,
        filter = "cpp_catch",
        label = "C++ Catch"
      }, {
        default = false,
        filter = "cpp_throw",
        label = "C++ Throw"
      }, {
        default = false,
        filter = "objc_catch",
        label = "Objective C Catch"
      }, {
        default = false,
        filter = "objc_throw",
        label = "Objective C Throw"
      }, {
        default = false,
        filter = "swift_catch",
        label = "Swift Catch"
      }, {
        default = false,
        filter = "swift_throw",
        label = "Swift Throw"
      } },
    supportTerminateDebuggee = true,
    supportsCompletionsRequest = false,
    supportsConditionalBreakpoints = true,
    supportsConfigurationDoneRequest = true,
    supportsDelayedStackTraceLoading = true,
    supportsEvaluateForHovers = true,
    supportsExceptionInfoRequest = true,
    supportsExceptionOptions = true,
    supportsFunctionBreakpoints = true,
    supportsGotoTargetsRequest = false,
    supportsHitConditionalBreakpoints = true,
    supportsLoadedSourcesRequest = false,
    supportsModulesRequest = false,
    supportsProgressReporting = true,
    supportsRestartFrame = false,
    supportsRestartRequest = false,
    supportsRunInTerminalRequest = true,
    supportsSetVariable = true,
    supportsStepBack = false,
    supportsStepInTargetsRequest = false,
    supportsValueFormattingOptions = true
  },
  command = "initialize",
  request_seq = 0,
  seq = 0,
  success = true,
  type = "response"
}
[ DEBUG ] 2021-09-22T23:37:30Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:750 ]	"request"	{
  arguments = {
    args = {},
    cwd = "c:/Projects/rust/dap-test",
    name = "Rust",
    program = "C:\\Projects\\rust\\dap-test\\target\\debug\\dap-test.exe",
    request = "launch",
    runInTerminal = false,
    stopOnEntry = true,
    type = "lldb"
  },
  command = "launch",
  seq = 1,
  type = "request"
}
[ ERROR ] 2021-09-22T23:37:30Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:661 ]	"stderr"	{
  command = "C:/Program Files/LLVM/bin/lldb-vscode.exe",
  name = "lldb",
  type = "executable"
}	"Fatal Python error: Py_Initialize: unable to load the file system codec\r\nModuleNotFoundError: No module named 'encodings'\r\n"
[ ERROR ] 2021-09-22T23:37:30Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:661 ]	"stderr"	{
  command = "C:/Program Files/LLVM/bin/lldb-vscode.exe",
  name = "lldb",
  type = "executable"
}	"\r\nCurrent thread 0x"
[ ERROR ] 2021-09-22T23:37:30Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:661 ]	"stderr"	{
  command = "C:/Program Files/LLVM/bin/lldb-vscode.exe",
  name = "lldb",
  type = "executable"
}	"000060ac (most recent call first):\r\n"
[ ERROR ] 2021-09-22T23:37:30Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:661 ]	"stderr"	{
  command = "C:/Program Files/LLVM/bin/lldb-vscode.exe",
  name = "lldb",
  type = "executable"
}	'PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.\r\nStack dump:\r\n0.\tProgram arguments: "C:/'
[ ERROR ] 2021-09-22T23:37:30Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:661 ]	"stderr"	{
  command = "C:/Program Files/LLVM/bin/lldb-vscode.exe",
  name = "lldb",
  type = "executable"
}	'Program Files/LLVM/bin/lldb-vscode.exe"\r\n1.\tProgram arguments: "C:/Program Files/LLVM/bin\\\\lldb-vscode.exe"\r\n'
[ ERROR ] 2021-09-22T23:37:30Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:661 ]	"stderr"	{
  command = "C:/Program Files/LLVM/bin/lldb-vscode.exe",
  name = "lldb",
  type = "executable"
}	" #0 0x00007ff789af2056 C:\\Program Files\\LLVM\\bin\\lldb-vscode.exe 0x52056 (C:\\Program Files\\LLVM\\bin\\lldb-vscode.exe+0x52056)\r\n #1 0x00007ff789af2056 \r\n #2 0x00007ff789af2056 (C:\\Program Files\\LLVM\\bin\\lldb-vscode.exe+0x52056)\r\n #3 "
[ ERROR ] 2021-09-22T23:37:30Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:661 ]	"stderr"	{
  command = "C:/Program Files/LLVM/bin/lldb-vscode.exe",
  name = "lldb",
  type = "executable"
}	"0x00007fff74401881 C:\\Program Files\\Python36\\python36.dll 0x5d260 C:\\Program Files\\Python36\\python36.dll 0x72f49\r\n #4 0x00007fff74401881 C:\\Program Files\\LLVM\\bin\\liblldb.dll 0x76118e C:\\Program Files\\LLVM\\bin\\liblldb.dll 0x760da6\r\n #5 0x00007fff74401881 C:\\Program Files\\LLVM\\bin\\liblldb.dll 0x762603 C:\\Program Files\\LLVM\\bin\\liblldb.dll 0x3816a4\r\n #6 0x00007fff74401881 C:\\Program Files\\LLVM\\bin\\liblldb.dll 0x36ea7f C:\\Program Files\\LLVM\\bin\\liblldb.dll 0x6f7a80\r\n #7 0x00007fff74401881 C:\\Program Files\\LLVM\\bin\\liblldb.dll 0x6f7817 C:\\Program Files\\LLVM\\bin\\liblldb.dll 0x6f7443\r\n #8 0x00007fff74401881 C:\\Program Files\\LLVM\\bin\\liblldb.dll 0x4bf373 C:\\Program Files\\LLVM\\bin\\liblldb.dll 0x48c03c\r\n #9 0x00007fff74401881 C:\\Program Files\\LLVM\\bin\\liblldb.dll 0x6d7917 C:\\Program Files\\LLVM\\bin\\liblldb.dll 0x49a1ac\r\n#10 0x00007fff74401881 C:\\Program Files\\LLVM\\bin\\liblldb.dll 0x13cf3d C:\\Program Files\\LLVM\\bin\\lldb-vscode.exe 0x9dae\r\n#11 0x00007fff74401881 C:\\Program Files\\LLVM\\bin\\lldb-vscode.exe 0x316e7 C:\\Program Files\\LLVM\\bin\\lldb-vscode.exe 0x262b\r\n#12 0x00007fff74401881 C:\\Program Files\\LLVM\\bin\\lldb-vscode.exe 0x6a274 (C:\\WINDOWS\\System32\\ucrtbase.dll+0x71881)\r\n#13 0x00007fff74401881 \r\n#14 0x00007fff74401881 (C:\\WINDOWS\\System32\\ucrtbase.dll+0x71881)\r\n"
[ ERROR ] 2021-09-22T23:37:30Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:661 ]	"stderr"	{
  command = "C:/Program Files/LLVM/bin/lldb-vscode.exe",
  name = "lldb",
  type = "executable"
}	"0x00007FF789AF2056 (0x0000D1E6E50C13FE 0x00007FFF76B26777 0x0000000000000016 0x00007FF789AF2050)"
[ ERROR ] 2021-09-22T23:37:30Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:661 ]	"stderr"	{
  command = "C:/Program Files/LLVM/bin/lldb-vscode.exe",
  name = "lldb",
  type = "executable"
}	"\r\n0x00007FFF74401881 (0x0000000000000001 0x0000000000000000 0x0000000000000000 0x000000E43E98DDA0), raise() + 0x1E1 bytes(s)\r\n0x00007FFF74402851 (0x0000000000000003 0x0000000000000003 0x0000000000000002 0x0000026482F11078), abort() + 0x31 bytes(s)\r\n0x000000005122D260"
[ ERROR ] 2021-09-22T23:37:30Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:661 ]	"stderr"	{
  command = "C:/Program Files/LLVM/bin/lldb-vscode.exe",
  name = "lldb",
  type = "executable"
}	" (0x00000264823DA320 0x0000026482F05EF8 0x0000026482F11078 0x0000000000000000), Py_FatalError() + 0x13C bytes(s)\r\n0x0000000051242F49 (0x00007FFEED719165 0x0000000000000010 0x000000E43E98E018 0x000000E43E98DF78), _PyThreadState_UncheckedGet() + 0x15CE5 bytes(s)\r\n0x00007FFEE948118E (0x00000000000000D8 0x00007FFE00000000 0x00002A30C5021E80 0x0000000000000000), PyInit__lldb() + 0x57D31E bytes(s)\r\n0x00007FFEE9480DA6 (0x0000000482AD17C0 0x0000026482321540 0x0000026482ACF801 0x00002A30C5021F00), PyInit__lldb() + 0x57CF36 bytes(s)\r\n0x00007FFEE9482603 (0x0000000000000001 0x00007FFEE914D982 0x0000026480841DF0 0x00007FFEE914BC57), PyInit__lldb() + 0x57E793 bytes(s)\r\n"
[ ERROR ] 2021-09-22T23:37:30Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:661 ]	"stderr"	{
  command = "C:/Program Files/LLVM/bin/lldb-vscode.exe",
  name = "lldb",
  type = "executable"
}	"0x00007FFEE90A16A4 (0x00000264807F0000 0x0000000000000002 0x000000E43E98E4F0 0x000002648230B9B0)"
[ ERROR ] 2021-09-22T23:37:30Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:661 ]	"stderr"	{
  command = "C:/Program Files/LLVM/bin/lldb-vscode.exe",
  name = "lldb",
  type = "executable"
}	", PyInit__lldb() + 0x19D834 bytes(s)\r\n"
[ ERROR ] 2021-09-22T23:37:30Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:661 ]	"stderr"	{
  command = "C:/Program Files/LLVM/bin/lldb-vscode.exe",
  name = "lldb",
  type = "executable"
}	"0x00007FFEE908EA7F (0x000000E43E98EB50 0x00000264808E3760 0x0000026482324020 0x00007FFFFD0003FE), PyInit__lldb() + 0x18AC0F bytes(s)\r\n0x00007FFEE9417A80 (0x00000000016100B5 0x00000000000000A7 0x000002648248CE90 0x00000264807F0150), PyInit__lldb() + 0x513C10 bytes(s)\r\n0x00007FFEE9417817 (0x0000000000000018 0x0000000000000004 0x00000264807F0000 0x000000E43E98E559), PyInit__lldb() + 0x5139A7 bytes(s)\r\n0x00007FFEE9417443 (0x0000026482ACD790 0x0000000000000063 0x0000000000000282 0x00007FFF748BC045)"
[ ERROR ] 2021-09-22T23:37:30Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:661 ]	"stderr"	{
  command = "C:/Program Files/LLVM/bin/lldb-vscode.exe",
  name = "lldb",
  type = "executable"
}	", PyInit__lldb() + 0x5135D3 bytes(s)\r\n0x00007FFEE91DF373 (0x000000E43E98E840 0x0000000000000000 0x0000000000000000 0x000000000000007D), PyInit__lldb() + 0x2DB503 bytes(s)\r\n0x00007FFEE91AC03C (0x00000264807F0320 0x0000000000000000 0x00002A30C5021870 0x0000000000000000), PyInit__lldb() + 0x2A81CC bytes(s)\r\n0x00007FFEE93F7917 (0x0000000000000000 0x0000000000000030 0x0000000000000020 0x0000000000000008), PyInit__lldb() + 0x4F3AA7 bytes(s)"
[ ERROR ] 2021-09-22T23:37:30Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:661 ]	"stderr"	{
  command = "C:/Program Files/LLVM/bin/lldb-vscode.exe",
  name = "lldb",
  type = "executable"
}	"\r\n0x00007FFEE91BA1AC (0x0000000000000020 0x0000000000000000 0x00000264823D7E60 0x000000E43E98EBF9), PyInit__lldb() + 0x2B633C bytes(s)\r\n"
[ ERROR ] 2021-09-22T23:37:30Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:661 ]	"stderr"	{
  command = "C:/Program Files/LLVM/bin/lldb-vscode.exe",
  name = "lldb",
  type = "executable"
}	"0x00007FFEE8E5CF3D (0x0000000000000000 0x0000026400000000 0x00000264807F0100 0x00000264823D9220), ?Launch@SBTarget@lldb@@QEAA?AVSBProcess@2@AEAVSBLaunchInfo@2@AEAVSBError@2@@Z() + 0x3CD bytes(s)\r\n0x00007FF789AA9DAE (0x0000000000000640 0x0000026482283BD8 0x00000264823D7C80 0x000000000000159A)\r\n0x00007FF789AD16E7 (0x0000000000004410 0x00007FFF00000000 0x00000000007D007F 0x0000000000000005)\r\n0x00007FF789AA262B (0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000)\r\n0x00007FF789B0A274 (0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000)\r\n0x00007FFF75A37034 (0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000), BaseThreadInitThunk() + 0x14 bytes(s)\r\n0x00007FFF76B62651 (0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000)"
[ ERROR ] 2021-09-22T23:37:30Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:661 ]	"stderr"	{
  command = "C:/Program Files/LLVM/bin/lldb-vscode.exe",
  name = "lldb",
  type = "executable"
}	", RtlUserThreadStart() + 0x21 bytes(s)\r\n"

@EricR86
Copy link
Author

EricR86 commented Sep 23, 2021

I can confirm when resolving the python issues, it reverts back to raising an exception and dumping out the assembly.

@EricR86 EricR86 changed the title Rust debugging with lldb-vscode on windows raises an exception and displays disassembly Debugging with lldb-vscode on windows raises an exception and displays disassembly Sep 23, 2021
@EricR86
Copy link
Author

EricR86 commented Sep 23, 2021

I can also reliably reproduce this with a hello world program written in C.

Here is the dap log:

[ DEBUG ] 2021-09-23T19:06:40Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:750 ]	"request"	{
  arguments = {
    adapterID = "nvim-dap",
    clientId = "neovim",
    clientname = "neovim",
    columnsStartAt1 = true,
    linesStartAt1 = true,
    locale = "en_US",
    pathFormat = "path",
    supportsRunInTerminalRequest = true,
    supportsVariableType = true
  },
  command = "initialize",
  seq = 0,
  type = "request"
}
[ DEBUG ] 2021-09-23T19:06:40Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:510 ]	{
  body = {
    exceptionBreakpointFilters = { {
        default = false,
        filter = "cpp_catch",
        label = "C++ Catch"
      }, {
        default = false,
        filter = "cpp_throw",
        label = "C++ Throw"
      }, {
        default = false,
        filter = "objc_catch",
        label = "Objective C Catch"
      }, {
        default = false,
        filter = "objc_throw",
        label = "Objective C Throw"
      }, {
        default = false,
        filter = "swift_catch",
        label = "Swift Catch"
      }, {
        default = false,
        filter = "swift_throw",
        label = "Swift Throw"
      } },
    supportTerminateDebuggee = true,
    supportsCompletionsRequest = false,
    supportsConditionalBreakpoints = true,
    supportsConfigurationDoneRequest = true,
    supportsDelayedStackTraceLoading = true,
    supportsEvaluateForHovers = true,
    supportsExceptionInfoRequest = true,
    supportsExceptionOptions = true,
    supportsFunctionBreakpoints = true,
    supportsGotoTargetsRequest = false,
    supportsHitConditionalBreakpoints = true,
    supportsLoadedSourcesRequest = false,
    supportsModulesRequest = false,
    supportsProgressReporting = true,
    supportsRestartFrame = false,
    supportsRestartRequest = false,
    supportsRunInTerminalRequest = true,
    supportsSetVariable = true,
    supportsStepBack = false,
    supportsStepInTargetsRequest = false,
    supportsValueFormattingOptions = true
  },
  command = "initialize",
  request_seq = 0,
  seq = 0,
  success = true,
  type = "response"
}
[ DEBUG ] 2021-09-23T19:06:40Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:750 ]	"request"	{
  arguments = {
    args = {},
    cwd = "C:\\Projects\\hello-c",
    name = "claunch",
    program = "C:\\Projects\\hello-c\\Debug\\hello-c.exe",
    request = "launch",
    runInTerminal = false,
    stopOnEntry = true,
    type = "lldb"
  },
  command = "launch",
  seq = 1,
  type = "request"
}
[ DEBUG ] 2021-09-23T19:06:40Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:510 ]	{
  command = "launch",
  request_seq = 1,
  seq = 0,
  success = true,
  type = "response"
}
[ DEBUG ] 2021-09-23T19:06:40Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:510 ]	{
  body = {
    isLocalProcess = true,
    name = "C:\\Projects\\hello-c\\Debug\\hello-c.exe",
    startMethod = "launch",
    systemProcessId = 11192
  },
  event = "process",
  seq = 0,
  type = "event"
}
[ DEBUG ] 2021-09-23T19:06:40Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:510 ]	{
  event = "initialized",
  seq = 0,
  type = "event"
}
[ DEBUG ] 2021-09-23T19:06:40Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:750 ]	"request"	{
  arguments = {
    filters = {}
  },
  command = "setExceptionBreakpoints",
  seq = 2,
  type = "request"
}
[ DEBUG ] 2021-09-23T19:06:40Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:510 ]	{
  command = "setExceptionBreakpoints",
  request_seq = 2,
  seq = 0,
  success = true,
  type = "response"
}
[ DEBUG ] 2021-09-23T19:06:40Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:750 ]	"request"	{
  command = "configurationDone",
  seq = 3,
  type = "request"
}
[ DEBUG ] 2021-09-23T19:06:40Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:510 ]	{
  command = "configurationDone",
  request_seq = 3,
  seq = 0,
  success = true,
  type = "response"
}
[ DEBUG ] 2021-09-23T19:06:40Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:510 ]	{
  body = {
    allThreadsStopped = true,
    preserveFocusHint = false,
    reason = "exception",
    threadCausedFocus = true,
    threadId = 29036
  },
  event = "stopped",
  seq = 0,
  type = "event"
}
[ DEBUG ] 2021-09-23T19:06:40Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:750 ]	"request"	{
  command = "threads",
  seq = 4,
  type = "request"
}
[ DEBUG ] 2021-09-23T19:06:40Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:510 ]	{
  body = {
    threads = { {
        id = 29036,
        name = "Thread #1"
      } }
  },
  command = "threads",
  request_seq = 4,
  seq = 0,
  success = true,
  type = "response"
}
[ DEBUG ] 2021-09-23T19:06:40Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:750 ]	"request"	{
  arguments = {
    threadId = 29036
  },
  command = "exceptionInfo",
  seq = 5,
  type = "request"
}
[ DEBUG ] 2021-09-23T19:06:40Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:750 ]	"request"	{
  arguments = {
    threadId = 29036
  },
  command = "stackTrace",
  seq = 6,
  type = "request"
}
[ DEBUG ] 2021-09-23T19:06:40Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:510 ]	{
  body = {
    breakMode = "always",
    description = "Exception 0x80000003 encountered at address 0x7ffb6cea06b0",
    exceptionId = "exception"
  },
  command = "exceptionInfo",
  request_seq = 5,
  seq = 0,
  success = true,
  type = "response"
}
[ DEBUG ] 2021-09-23T19:06:41Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:510 ]	{
  body = {
    stackFrames = { {
        column = 0,
        id = 524288,
        line = 215,
        name = "LdrInitShimEngineDynamic",
        source = {
          name = "LdrInitShimEngineDynamic",
          sourceReference = 1
        }
      } },
    totalFrames = 1
  },
  command = "stackTrace",
  request_seq = 6,
  seq = 0,
  success = true,
  type = "response"
}
[ DEBUG ] 2021-09-23T19:06:41Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:750 ]	"request"	{
  arguments = {
    source = {
      name = "LdrInitShimEngineDynamic",
      sourceReference = 1
    },
    sourceReference = 1
  },
  command = "source",
  seq = 7,
  type = "request"
}
[ DEBUG ] 2021-09-23T19:06:41Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:750 ]	"request"	{
  arguments = {
    frameId = 524288
  },
  command = "scopes",
  seq = 8,
  type = "request"
}
[ DEBUG ] 2021-09-23T19:06:41Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:510 ]	{
  body = {
    content = "0x7FFB6CEA0350: <0>             movq %rsp, %rax\n0x7FFB6CEA0353: <3>             movq %rbx,
   * lots of disassembly cut out here *
    mimeType = "text/x-lldb.disassembly"
  },
  command = "source",
  request_seq = 7,
  seq = 0,
  success = true,
  type = "response"
}
[ DEBUG ] 2021-09-23T19:06:41Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:510 ]	{
  body = {
    scopes = { {
        expensive = false,
        name = "Locals",
        namedVariables = 0,
        variablesReference = 1
      }, {
        expensive = false,
        name = "Globals",
        namedVariables = 0,
        variablesReference = 2
      }, {
        expensive = false,
        name = "Registers",
        namedVariables = 2,
        variablesReference = 3
      } }
  },
  command = "scopes",
  request_seq = 8,
  seq = 0,
  success = true,
  type = "response"
}
[ DEBUG ] 2021-09-23T19:06:41Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:750 ]	"request"	{
  arguments = {
    variablesReference = 1
  },
  command = "variables",
  seq = 9,
  type = "request"
}
[ DEBUG ] 2021-09-23T19:06:41Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:750 ]	"request"	{
  arguments = {
    variablesReference = 2
  },
  command = "variables",
  seq = 10,
  type = "request"
}
[ DEBUG ] 2021-09-23T19:06:41Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:750 ]	"request"	{
  arguments = {
    variablesReference = 3
  },
  command = "variables",
  seq = 11,
  type = "request"
}
[ DEBUG ] 2021-09-23T19:06:41Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:510 ]	{
  body = {
    variables = {}
  },
  command = "variables",
  request_seq = 9,
  seq = 0,
  success = true,
  type = "response"
}
[ DEBUG ] 2021-09-23T19:06:41Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:510 ]	{
  body = {
    variables = {}
  },
  command = "variables",
  request_seq = 10,
  seq = 0,
  success = true,
  type = "response"
}
[ DEBUG ] 2021-09-23T19:06:41Z-0400 ] ...data\site\pack\packer\start\nvim-dap\lua\dap\session.lua:510 ]	{
  body = {
    variables = { {
        evaluateName = "General Purpose Registers",
        id = 0,
        name = "General Purpose Registers",
        type = "",
        value = "",
        variablesReference = 4
      }, {
        evaluateName = "Floating Point Registers",
        id = 1,
        name = "Floating Point Registers",
        type = "",
        value = "",
        variablesReference = 5
      } }
  },
  command = "variables",
  request_seq = 11,
  seq = 0,
  success = true,
  type = "response"
}

@spindensity
Copy link

spindensity commented Sep 24, 2021

It is not a dap issue.

The lldb shipped with official llvm on windows does not support MSVC toolchain, it only supports MinGW toolchain. The lldb shipped with CodeLLDB supports both , but seems not to support dap(no lldb-vscode shipped).

@mfussenegger
Copy link
Owner

CodeLLDB is also using the debug adapter protocol, so it should be possible to get it working with nvim-dap as well.

(I guess the issues encountered here are part of the reason why vimspector recommends CodeLLDB)

@spindensity
Copy link

CodeLLDB is also using the debug adapter protocol, so it should be possible to get it working with nvim-dap as well.

(I guess the issues encountered here are part of the reason why vimspector recommends CodeLLDB)

Yes, after looking at the source code structure, I found CodeLLDB using dap with its own rust implementation, there may be some way to get it to work with nvim-dap, but more investigation is needed.

I think building lldb manually should be the easy way.

@EricR86
Copy link
Author

EricR86 commented Sep 24, 2021

The lldb shipped with official llvm on windows does not support MSVC toolchain, it only supports MinGW toolchain.

Is there a source for this? The reason why I ask is I have already tried building lldb-vscode using Visual Studio/MSVC toolchain with the exact same result. Unless there is some LLDB compile flag I am missing that specifically enables MSVC toolchain debugging and I cannot find any mention of it.

@spindensity
Copy link

I've managed to get CodeLLDB to work with nvim-dap on windows successfully. Here's the whole story:

  1. Please do not use lldb-vscode on windows.
    lldb shipped with official llvm on windows could not read debug information generated by MSVC, you need to copy msdia140.dll from Visual Studio installation directory to the directory directly containing lldb.exe. But that's not enough, now, lldb-vscode works well with vscode when debugging C and C++, but still does not work with vscode when debugging rust, it could not handle exception breakpoints in ntdll.dll and would output assembly instructions and terminate the debug session. It never works with nvim-dap on C, C++, or rust.

  2. Use CodeLLDB with nvim-dap
    It's simple. treat CodeLLDB as server type, the configurations are something like this:

local lldb_host = "127.0.0.1"
local lldb_port = 34567

dap.configurations.rust = {
    {
        name = "Debug",
        type = "lldb",
        request = "launch",
        host = lldb_host,
        port = lldb_port,
        program = function()
            return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file")
        end,
        cwd = "${workspaceFolder}",
        stopOnEntry = false,
        args = {},
    },
}

dap.adapters.lldb = function(callback, config)
    callback({ type = "server", host = config.host, port = config.port })
end

Open cmd, start the CodeLLDB:

/path/to/codelldb.exe --liblldb /path/to/liblldb.dll --port 34567

You can write some trivial functions to make it start automatically when executing require("dap").continue(), or you can use the --multi-session option and start it as a system service.

Some screenshots:

C:
Snipaste_2021-09-25_18-17-20

Rust:
Snipaste_2021-09-25_18-18-25

@EricR86
Copy link
Author

EricR86 commented Sep 25, 2021

This CodeLLDB configuration I can confirm works just fine in windows. Thanks!

@danielnehrig
Copy link
Contributor

can we close this ?

@lasse16
Copy link

lasse16 commented Sep 29, 2021

Sorry to further use this thread, but i found some (marginally) related info.

Showing disassembly is intended by CodeLLDB (here).
There is however an option to disable that.
"lldb.showDisassembly" : "never"

Normally this option would be set by the various configuration files in Visual Studio Code.
But, as we are using nvim, that is not possible.

One can however pass parameters to the codelldb binary via the --params flag.
These parameters are not passed in a shell-like format, but as stringified JSON, e.g.

./codelldb --params '{"showDisassembly" : "never"}

They are concatenated with the other options, so my guess is that they override previous set options, but I did not test this.
Here are the relevant sections of code in the CodeLLDB repo:
Parameter merging
Passable parameter
JSON.stringify (MozillaReference)

BTW, there is also the option of sourceLanguages, which allows to enable language-specific debugger features, mainly better visualization for rust-builtins.

PS:
I can also confirm that the CodeLLDB config from @spindensity is working.

@mfussenegger
Copy link
Owner

Sounds like the issue is resolved?

I created a wiki page for codelldb: https://github.com/mfussenegger/nvim-dap/wiki/C-C---Rust-(via--codelldb)
Please extend it with more information you find useful.

@spindensity
Copy link

Sounds like the issue is resolved?

I created a wiki page for codelldb: https://github.com/mfussenegger/nvim-dap/wiki/C-C---Rust-(via--codelldb) Please extend it with more information you find useful.

I got this error with the configurations posted on wiki:

Snipaste_2021-09-30_18-17-52

@spindensity
Copy link

Sounds like the issue is resolved?
I created a wiki page for codelldb: https://github.com/mfussenegger/nvim-dap/wiki/C-C---Rust-(via--codelldb) Please extend it with more information you find useful.

I got this error with the configurations posted on wiki:

Snipaste_2021-09-30_18-17-52

stopOnEntry = false solved the problem.

@lasse16
Copy link

lasse16 commented Oct 4, 2021

I edited the Wiki page. Please have a read through it.

Also, there is a similar issue on the rust-tools repo.
They defined a helper function for setting up CodeLLDB, see this section.
I already included that information in the wiki page.

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

No branches or pull requests

5 participants