mfussenegger / nvim-dap

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

[lldb-vscode] Breakpoint unverified in nvim-dap but resolved accurately in lldb cli? #1184

Closed ibhagwan closed 3 months ago

ibhagwan commented 3 months ago

Debug adapter definition and debug configuration

dap.adapters.lldb = {
  type = "executable",
  command = "/usr/bin/lldb-vscode",
  name = "lldb"
}

dap.configurations.c = {
  {
    name = "[LLDB] Launch Executable",
    type = "lldb",
    request = "launch",
    program = require("utils").dap_pick_exec, -- utility to pick exec using fzf-lua
    cwd = "${workspaceFolder}",
    stopOnEntry = false,
    args = {},
  },
  {
    name = "[LLDB] Attach to process",
    type = "lldb",
    request = "attach",
    pid = require("utils").dap_pick_process, -- utility to pick process using fzf-lua
    args = {},
  },
}

Debug adapter version

lldb version 17.0.6

Steps to Reproduce

In an attempt to debug https://github.com/neovim/neovim/issues/20726, I compiled neovim nightly from source using

make CMAKE_BUILD_TYPE=Debug

Resulting binary is ~18MB and seems to contain debug symbols, if I use lldb directly (launch or attach to pid) I can set breakpoints in the cli and they seem to resolve fine:

(lldb) process attach --pid 17509
Process 17509 stopped
* thread #1, name = 'nvim', stop reason = signal SIGSTOP
    frame #0: 0x00007f1b2d4210f9 libc.so.6`__GI_epoll_pwait(epfd=3, events=0x00007fff97d69350, maxevents=1024, timeout=-1, set=0x0000000000000000) at epoll_pwait.c:40:10
  thread #2, name = 'iou-sqp-17509', stop reason = signal SIGSTOP
    frame #0: 0x0000000000000000
error: memory read failed for 0x0
  thread #3, name = 'iou-sqp-17509', stop reason = signal SIGSTOP
    frame #0: 0x0000000000000000
error: memory read failed for 0x0
Executable module set to "/shared/bhagwan/Sources/nvim/neovim/build/bin/nvim".
Architecture set to: x86_64-unknown-linux-gnu.
(lldb)
There is a running process, detach from it and attach?: [Y/n] n
(lldb) breakpoint set -f src/nvim/state.c -l 62
Breakpoint 1: where = nvim`state_enter + 96 at state.c:62:13, address = 0x000055ae66efab49
(lldb) breakpoint list
Current breakpoints:
1: file = 'src/nvim/state.c', line = 62, exact_match = 0, locations = 1, resolved = 1, hit count = 0
  1.1: where = nvim`state_enter + 96 at state.c:62:13, address = 0x000055ae66efab49, resolved, hit count = 0
(lldb) breakpoint set -f src/nvim/terminal.c -l 665
Breakpoint 2: where = nvim`terminal_execute + 15 at terminal.c:665:18, address = 0x000055ae66f20d5d
(lldb) breakpoint list
Current breakpoints:
1: file = 'src/nvim/state.c', line = 62, exact_match = 0, locations = 1, resolved = 1, hit count = 0
  1.1: where = nvim`state_enter + 96 at state.c:62:13, address = 0x000055ae66efab49, resolved, hit count = 0

2: file = 'src/nvim/terminal.c', line = 665, exact_match = 0, locations = 1, resolved = 1, hit count = 0
  2.1: where = nvim`terminal_execute + 15 at terminal.c:665:18, address = 0x000055ae66f20d5d, resolved, hit count = 0
(lldb) breakpoint set -f src/nvim/getchar.c -l 1486
Breakpoint 3: where = nvim`vgetc + 23 at getchar.c:1491:7, address = 0x000055ae66d7a04e
(lldb)
Breakpoint 4: where = nvim`vgetc + 23 at getchar.c:1491:7, address = 0x000055ae66d7a04e
(lldb) breakpoint list
Current breakpoints:
1: file = 'src/nvim/state.c', line = 62, exact_match = 0, locations = 1, resolved = 1, hit count = 0
  1.1: where = nvim`state_enter + 96 at state.c:62:13, address = 0x000055ae66efab49, resolved, hit count = 0

2: file = 'src/nvim/terminal.c', line = 665, exact_match = 0, locations = 1, resolved = 1, hit count = 0
  2.1: where = nvim`terminal_execute + 15 at terminal.c:665:18, address = 0x000055ae66f20d5d, resolved, hit count = 0

3: file = 'src/nvim/getchar.c', line = 1486, exact_match = 0, locations = 1, resolved = 1, hit count = 0
  3.1: where = nvim`vgetc + 23 at getchar.c:1491:7, address = 0x000055ae66d7a04e, resolved, hit count = 0

4: file = 'src/nvim/getchar.c', line = 1486, exact_match = 0, locations = 1, resolved = 1, hit count = 0
  4.1: where = nvim`vgetc + 23 at getchar.c:1491:7, address = 0x000055ae66d7a04e, resolved, hit count = 0

Expected Result

If the sources resolve in lldb cli, I expect the breakpoints to also resolve in nvim-dap.

Actual Result

However, if setting the breakpoints from nvim-dap, lldb seems to reject the breakpoints (inidcated by R in the sign column), relevant logs from dap.log below:

May or may not be relevant: my "Sources" directory is a symbolic link $HOME/Sources -> /shared/bhagwan/Sources with the neovim source compiled at /shared/bhagwan/Sources/nvim/neovim as evident in the logged paths

[ INFO ] 2024-03-30T17:04:47Z-0700 ] ...gwan/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:895 ]  "Breakpoint unverified" {
id = 1,
line = 1486,
source = {
name = "getchar.c",
path = "/shared/bhagwan/Sources/nvim/neovim/src/nvim/getchar.c"
},
verified = false
}
[ DEBUG ] 2024-03-30T17:04:47Z-0700 ] ...gwan/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:957 ] 1   {
body = {
breakpoints = { {
id = 2,
line = 665,
source = {
name = "terminal.c",
path = "/shared/bhagwan/Sources/nvim/neovim/src/nvim/terminal.c"
},
verified = false
} }
},
command = "setBreakpoints",
request_seq = 4,
seq = 0,
success = true,
type = "response"
}
[ INFO ] 2024-03-30T17:04:47Z-0700 ] ...gwan/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:895 ]  "Breakpoint unverified" {
id = 2,
line = 665,
source = {
name = "terminal.c",
path = "/shared/bhagwan/Sources/nvim/neovim/src/nvim/terminal.c"
},
verified = false
}
[ DEBUG ] 2024-03-30T17:04:47Z-0700 ] ...gwan/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:957 ] 1   {
body = {
breakpoints = { {
id = 3,
line = 62,
source = {
name = "state.c",
path = "/shared/bhagwan/Sources/nvim/neovim/src/nvim/state.c"
},
verified = false
} }
},
command = "setBreakpoints",
request_seq = 5,
seq = 0,
success = true,
type = "response"
}
[ INFO ] 2024-03-30T17:04:47Z-0700 ] ...gwan/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:895 ]  "Breakpoint unverified" {
id = 3,
line = 62,
source = {
name = "state.c",
path = "/shared/bhagwan/Sources/nvim/neovim/src/nvim/state.c"
},
verified = false
}
[ DEBUG ] 2024-03-30T17:04:47Z-0700 ] ...gwan/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:1683 ]    "request"   {
arguments = {
filters = {}
},
command = "setExceptionBreakpoints",
seq = 6,
type = "request"
}
[ DEBUG ] 2024-03-30T17:04:47Z-0700 ] ...gwan/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:957 ] 1   {
command = "setExceptionBreakpoints",
request_seq = 6,
seq = 0,
success = true,
type = "response"
}
[ DEBUG ] 2024-03-30T17:04:47Z-0700 ] ...gwan/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:1683 ]    "request"   {
command = "configurationDone",
seq = 7,
type = "request"
}
[ DEBUG ] 2024-03-30T17:04:47Z-0700 ] ...gwan/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:957 ] 1   {
command = "configurationDone",
request_seq = 7,
seq = 0,
success = true,
type = "response"
}
[ DEBUG ] 2024-03-30T17:05:07Z-0700 ] ...gwan/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:957 ] 1   {
body = {
exitCode = 0
},
event = "exited",
seq = 0,
type = "event"
}
[ DEBUG ] 2024-03-30T17:05:07Z-0700 ] ...gwan/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:957 ] 1   {
event = "terminated",
seq = 0,
statistics = {
memory = '{"strings":{"bytesTotal":2940928,"bytesUnused":1873648,"bytesUsed":1067280}}',
targets = '[{"breakpoints":[{"details":{"Breakpoint":{"BKPTOptions":{"AutoContinue":false,"ConditionText":"","EnabledState":true,"IgnoreCount":0,"OneShotState":false},"BKPTResolver":{"Options":{"Column":0,"Exact":false,"FileName":"/shared/bhagwan/Sources/nvim/neovim/src/nvim/getchar.c","Inlines":true,"LineNumber":1486,"Offset":0,"SkipPrologue":true},"Type":"FileAndLine"},"Hardware":false,"Names":["vscode"],"SearchFilter":{"Options":{},"Type":"Unconstrained"}}},"hitCount":0,"id":1,"internal":false,"numLocations":0,"numResolvedLocations":0,"resolveTime":0.068715999999999999},{"details":{"Breakpoint":{"BKPTOptions":{"AutoContinue":false,"ConditionText":"","EnabledState":true,"IgnoreCount":0,"OneShotState":false},"BKPTResolver":{"Options":{"Column":0,"Exact":false,"FileName":"/shared/bhagwan/Sources/nvim/neovim/src/nvim/terminal.c","Inlines":true,"LineNumber":665,"Offset":0,"SkipPrologue":true},"Type":"FileAndLine"},"Hardware":false,"Names":["vscode"],"SearchFilter":{"Options":{},"Type":"Unconstrained"}}},"hitCount":0,"id":2,"internal":false,"numLocations":0,"numResolvedLocations":0,"resolveTime":0.001152},{"details":{"Breakpoint":{"BKPTOptions":{"AutoContinue":false,"ConditionText":"","EnabledState":true,"IgnoreCount":0,"OneShotState":false},"BKPTResolver":{"Options":{"Column":0,"Exact":false,"FileName":"/shared/bhagwan/Sources/nvim/neovim/src/nvim/state.c","Inlines":true,"LineNumber":62,"Offset":0,"SkipPrologue":true},"Type":"FileAndLine"},"Hardware":false,"Names":["vscode"],"SearchFilter":{"Options":{},"Type":"Unconstrained"}}},"hitCount":0,"id":3,"internal":false,"numLocations":0,"numResolvedLocations":0,"resolveTime":0.0011230000000000001},{"details":{"Breakpoint":{"BKPTOptions":{"AutoContinue":false,"ConditionText":"","EnabledState":true,"IgnoreCount":0,"OneShotState":false},"BKPTResolver":{"Options":{"AddressOffset":5408,"ModuleName":"","Offset":0},"Type":"Address"},"Hardware":false,"SearchFilter":{"Options":{},"Type":"Unconstrained"}}},"hitCount":0,"id":-1,"internal":true,"kindDescription":"shared-library-event","numLocations":1,"numResolvedLocations":1,"resolveTime":0.00014200000000000001}],"expressionEvaluation":{"failures":0,"successes":0},"firstStopTime":0.18579642299999999,"frameVariable":{"failures":0,"successes":0},"launchOrAttachTime":0.021591780000000001,"moduleIdentifiers":[139943254994080,139943262069808,139943262119712,139943265413840,139943267130928,139943278683968],"signals":[{"SIGCHLD":1},{"SIGSTOP":3}],"sourceMapDeduceCount":0,"stopCount":3,"targetCreateTime":0.02938,"totalBreakpointResolveTime":0.071133000000000002}]',
totalDebugInfoByteSize = 24991615,
totalDebugInfoEnabled = 4,
totalDebugInfoIndexLoadedFromCache = 0,
totalDebugInfoIndexSavedToCache = 0,
totalDebugInfoIndexTime = 0.077427,
totalDebugInfoParseTime = 0.130615,
totalModuleCount = 6,
totalModuleCountHasDebugInfo = 4,
totalModuleCountWithIncompleteTypes = 0,
totalModuleCountWithVariableErrors = 0,
totalSymbolTableIndexTime = 0.003506,
totalSymbolTableParseTime = 0.052659,
totalSymbolTableStripped = 0,
totalSymbolTablesLoadedFromCache = 0,
totalSymbolTablesSavedToCache = 0
},
type = "event"
}
ibhagwan commented 3 months ago

FYI, did some more testing on this, same neovim build, both gdb and vscode-cpptools (essentially, also gdb) are both able to resolve and breakpoint the neovim binary at the right locations, lldb is also able to that via the cli but for some odd reason returns verified = false with nvim-dap.

mfussenegger commented 3 months ago

Sounds like a lldb-vscode issue, I don't think there's anything that can be done in nvim-dap about this

ibhagwan commented 3 months ago

Sounds like a lldb-vscode issue, I don't think there's anything that can be done in nvim-dap about this

Alright, I’ll close the issue then.