How to Specify processId When Debugging with dlv-dap

According to the official documentation, I need to specify processId, when I want to attach to a remote running process.

When using attach mode outside of local host, you need to specify the processId in the config since the processId resolution feature cannot gather information about processes running remotely.

First, I checked the PID of the process (api-svr) that I need to debug on the remote server:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code> PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1 root 20 0 1237620 6116 3024 S 0.0 0.0 3:24.63 supervisord
14 root 20 0 3110424 609456 21152 S 0.0 0.9 45:21.22 api-svr
</code>
<code> PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 1 root 20 0 1237620 6116 3024 S 0.0 0.0 3:24.63 supervisord 14 root 20 0 3110424 609456 21152 S 0.0 0.9 45:21.22 api-svr </code>
   PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND                                                                                                                                      
     1 root      20   0 1237620   6116   3024 S   0.0   0.0   3:24.63 supervisord                                                                                                                                  
    14 root      20   0 3110424 609456  21152 S   0.0   0.9  45:21.22 api-svr

Then, I forwarded a port locally using the command kubectl port-forward deployments/*** 11458:11458 -n *****, and entered dlv dap –listen=:11458 –log –log-output=dap in the remote pod. After starting the debug session locally, the following error occurred in the pod:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>root:bin$ dlv dap --listen=:11458 --log --log-output=dap
DAP server listening at: [::]:11458
2024-05-29T18:26:56+08:00 warning layer=rpc Listening for remote connections (connections are not authenticated nor encrypted)
2024-05-29T18:26:56+08:00 debug layer=dap DAP server pid = 17968
2024-05-29T18:27:17+08:00 debug layer=dap DAP connection 1 started
2024-05-29T18:27:17+08:00 debug layer=dap [<- from client]{"seq":1,"type":"request","command":"initialize","arguments":{"clientID":"vscode","clientName":"Visual Studio Code","adapterID":"go","locale":"en","linesStartAt1":true,"columnsStartAt1":true,"pathFormat":"path","supportsVariableType":true,"supportsVariablePaging":true,"supportsRunInTerminalRequest":true,"supportsMemoryReferences":true,"supportsProgressReporting":true,"supportsInvalidatedEvent":true,"supportsMemoryEvent":true,"supportsArgsCanBeInterpretedByShell":true,"supportsStartDebuggingRequest":true}}
2024-05-29T18:27:17+08:00 debug layer=dap [-> to client]{"seq":0,"type":"response","request_seq":1,"success":true,"command":"initialize","body":{"supportsConfigurationDoneRequest":true,"supportsFunctionBreakpoints":true,"supportsConditionalBreakpoints":true,"supportsEvaluateForHovers":true,"supportsSetVariable":true,"supportsExceptionInfoRequest":true,"supportsDelayedStackTraceLoading":true,"supportsLogPoints":true,"supportsDisassembleRequest":true,"supportsClipboardContext":true,"supportsSteppingGranularity":true,"supportsInstructionBreakpoints":true}}
2024-05-29T18:27:17+08:00 debug layer=dap [<- from client]{"seq":2,"type":"request","command":"attach","arguments":{"name":"Attach to remote process","type":"go","debugAdapter":"dlv-dap","request":"attach","mode":"remote","program":"/usr/local/trpc/bin/api-svr","processId":14,"host":"127.0.0.1","port":11458,"__configurationTarget":6,"packagePathToGoModPathMap":{"/data/workspace/repos/protocol/csproto/api/tmp-1716954334266622446":"/data/workspace/repos/protocol/csproto/api/tmp-1716954334266622446","/data/workspace/repos/protocol/service/game-service/tmp-1716954459120449930":"/data/workspace/repos/protocol/service/game-service/tmp-1716954459120449930","/data/workspace/repos/protocol/service/game-service/tmp-1716954556533632740":"/data/workspace/repos/protocol/service/game-service/tmp-1716954556533632740"},"showRegisters":false,"showGlobalVariables":false,"substitutePath":[],"showLog":false,"logOutput":"debugger","dlvFlags":[],"hideSystemGoroutines":false,"dlvToolPath":"/data/workspace/go-env/bin/dlv","env":{"GOPATH":"/data/workspace/go-env/"},"__sessionId":"f2b8819c-65f7-4128-a239-ee57c9b57e9a"}}
2024-05-29T18:27:17+08:00 debug layer=dap parsed launch config: {
"mode": "remote",
"processId": 14,
"backend": "default",
"stackTraceDepth": 50
}
2024-05-29T18:27:17+08:00 debug layer=dap Failed to attach: no debugger found
2024-05-29T18:27:17+08:00 debug layer=dap [-> to client]{"seq":0,"type":"response","request_seq":2,"success":false,"command":"attach","message":"Failed to attach","body":{"error":{"id":3001,"format":"Failed to attach: no debugger found","showUser":true}}}
2024-05-29T18:27:17+08:00 debug layer=dap [<- from client]{"seq":3,"type":"request","command":"disconnect","arguments":{}}
2024-05-29T18:27:17+08:00 debug layer=dap [-> to client]{"seq":0,"type":"response","request_seq":3,"success":true,"command":"disconnect"}
2024-05-29T18:27:17+08:00 debug layer=dap [-> to client]{"seq":0,"type":"event","event":"terminated","body":{}}
2024-05-29T18:27:17+08:00 debug layer=dap DAP server stopping...
2024-05-29T18:27:17+08:00 debug layer=dap DAP server stopped
</code>
<code>root:bin$ dlv dap --listen=:11458 --log --log-output=dap DAP server listening at: [::]:11458 2024-05-29T18:26:56+08:00 warning layer=rpc Listening for remote connections (connections are not authenticated nor encrypted) 2024-05-29T18:26:56+08:00 debug layer=dap DAP server pid = 17968 2024-05-29T18:27:17+08:00 debug layer=dap DAP connection 1 started 2024-05-29T18:27:17+08:00 debug layer=dap [<- from client]{"seq":1,"type":"request","command":"initialize","arguments":{"clientID":"vscode","clientName":"Visual Studio Code","adapterID":"go","locale":"en","linesStartAt1":true,"columnsStartAt1":true,"pathFormat":"path","supportsVariableType":true,"supportsVariablePaging":true,"supportsRunInTerminalRequest":true,"supportsMemoryReferences":true,"supportsProgressReporting":true,"supportsInvalidatedEvent":true,"supportsMemoryEvent":true,"supportsArgsCanBeInterpretedByShell":true,"supportsStartDebuggingRequest":true}} 2024-05-29T18:27:17+08:00 debug layer=dap [-> to client]{"seq":0,"type":"response","request_seq":1,"success":true,"command":"initialize","body":{"supportsConfigurationDoneRequest":true,"supportsFunctionBreakpoints":true,"supportsConditionalBreakpoints":true,"supportsEvaluateForHovers":true,"supportsSetVariable":true,"supportsExceptionInfoRequest":true,"supportsDelayedStackTraceLoading":true,"supportsLogPoints":true,"supportsDisassembleRequest":true,"supportsClipboardContext":true,"supportsSteppingGranularity":true,"supportsInstructionBreakpoints":true}} 2024-05-29T18:27:17+08:00 debug layer=dap [<- from client]{"seq":2,"type":"request","command":"attach","arguments":{"name":"Attach to remote process","type":"go","debugAdapter":"dlv-dap","request":"attach","mode":"remote","program":"/usr/local/trpc/bin/api-svr","processId":14,"host":"127.0.0.1","port":11458,"__configurationTarget":6,"packagePathToGoModPathMap":{"/data/workspace/repos/protocol/csproto/api/tmp-1716954334266622446":"/data/workspace/repos/protocol/csproto/api/tmp-1716954334266622446","/data/workspace/repos/protocol/service/game-service/tmp-1716954459120449930":"/data/workspace/repos/protocol/service/game-service/tmp-1716954459120449930","/data/workspace/repos/protocol/service/game-service/tmp-1716954556533632740":"/data/workspace/repos/protocol/service/game-service/tmp-1716954556533632740"},"showRegisters":false,"showGlobalVariables":false,"substitutePath":[],"showLog":false,"logOutput":"debugger","dlvFlags":[],"hideSystemGoroutines":false,"dlvToolPath":"/data/workspace/go-env/bin/dlv","env":{"GOPATH":"/data/workspace/go-env/"},"__sessionId":"f2b8819c-65f7-4128-a239-ee57c9b57e9a"}} 2024-05-29T18:27:17+08:00 debug layer=dap parsed launch config: { "mode": "remote", "processId": 14, "backend": "default", "stackTraceDepth": 50 } 2024-05-29T18:27:17+08:00 debug layer=dap Failed to attach: no debugger found 2024-05-29T18:27:17+08:00 debug layer=dap [-> to client]{"seq":0,"type":"response","request_seq":2,"success":false,"command":"attach","message":"Failed to attach","body":{"error":{"id":3001,"format":"Failed to attach: no debugger found","showUser":true}}} 2024-05-29T18:27:17+08:00 debug layer=dap [<- from client]{"seq":3,"type":"request","command":"disconnect","arguments":{}} 2024-05-29T18:27:17+08:00 debug layer=dap [-> to client]{"seq":0,"type":"response","request_seq":3,"success":true,"command":"disconnect"} 2024-05-29T18:27:17+08:00 debug layer=dap [-> to client]{"seq":0,"type":"event","event":"terminated","body":{}} 2024-05-29T18:27:17+08:00 debug layer=dap DAP server stopping... 2024-05-29T18:27:17+08:00 debug layer=dap DAP server stopped </code>
root:bin$ dlv dap --listen=:11458 --log --log-output=dap
DAP server listening at: [::]:11458
2024-05-29T18:26:56+08:00 warning layer=rpc Listening for remote connections (connections are not authenticated nor encrypted)
2024-05-29T18:26:56+08:00 debug layer=dap DAP server pid = 17968
2024-05-29T18:27:17+08:00 debug layer=dap DAP connection 1 started
2024-05-29T18:27:17+08:00 debug layer=dap [<- from client]{"seq":1,"type":"request","command":"initialize","arguments":{"clientID":"vscode","clientName":"Visual Studio Code","adapterID":"go","locale":"en","linesStartAt1":true,"columnsStartAt1":true,"pathFormat":"path","supportsVariableType":true,"supportsVariablePaging":true,"supportsRunInTerminalRequest":true,"supportsMemoryReferences":true,"supportsProgressReporting":true,"supportsInvalidatedEvent":true,"supportsMemoryEvent":true,"supportsArgsCanBeInterpretedByShell":true,"supportsStartDebuggingRequest":true}}
2024-05-29T18:27:17+08:00 debug layer=dap [-> to client]{"seq":0,"type":"response","request_seq":1,"success":true,"command":"initialize","body":{"supportsConfigurationDoneRequest":true,"supportsFunctionBreakpoints":true,"supportsConditionalBreakpoints":true,"supportsEvaluateForHovers":true,"supportsSetVariable":true,"supportsExceptionInfoRequest":true,"supportsDelayedStackTraceLoading":true,"supportsLogPoints":true,"supportsDisassembleRequest":true,"supportsClipboardContext":true,"supportsSteppingGranularity":true,"supportsInstructionBreakpoints":true}}
2024-05-29T18:27:17+08:00 debug layer=dap [<- from client]{"seq":2,"type":"request","command":"attach","arguments":{"name":"Attach to remote process","type":"go","debugAdapter":"dlv-dap","request":"attach","mode":"remote","program":"/usr/local/trpc/bin/api-svr","processId":14,"host":"127.0.0.1","port":11458,"__configurationTarget":6,"packagePathToGoModPathMap":{"/data/workspace/repos/protocol/csproto/api/tmp-1716954334266622446":"/data/workspace/repos/protocol/csproto/api/tmp-1716954334266622446","/data/workspace/repos/protocol/service/game-service/tmp-1716954459120449930":"/data/workspace/repos/protocol/service/game-service/tmp-1716954459120449930","/data/workspace/repos/protocol/service/game-service/tmp-1716954556533632740":"/data/workspace/repos/protocol/service/game-service/tmp-1716954556533632740"},"showRegisters":false,"showGlobalVariables":false,"substitutePath":[],"showLog":false,"logOutput":"debugger","dlvFlags":[],"hideSystemGoroutines":false,"dlvToolPath":"/data/workspace/go-env/bin/dlv","env":{"GOPATH":"/data/workspace/go-env/"},"__sessionId":"f2b8819c-65f7-4128-a239-ee57c9b57e9a"}}
2024-05-29T18:27:17+08:00 debug layer=dap parsed launch config: {
        "mode": "remote",
        "processId": 14,
        "backend": "default",
        "stackTraceDepth": 50
}
2024-05-29T18:27:17+08:00 debug layer=dap Failed to attach: no debugger found
2024-05-29T18:27:17+08:00 debug layer=dap [-> to client]{"seq":0,"type":"response","request_seq":2,"success":false,"command":"attach","message":"Failed to attach","body":{"error":{"id":3001,"format":"Failed to attach: no debugger found","showUser":true}}}
2024-05-29T18:27:17+08:00 debug layer=dap [<- from client]{"seq":3,"type":"request","command":"disconnect","arguments":{}}
2024-05-29T18:27:17+08:00 debug layer=dap [-> to client]{"seq":0,"type":"response","request_seq":3,"success":true,"command":"disconnect"}
2024-05-29T18:27:17+08:00 debug layer=dap [-> to client]{"seq":0,"type":"event","event":"terminated","body":{}}
2024-05-29T18:27:17+08:00 debug layer=dap DAP server stopping...
2024-05-29T18:27:17+08:00 debug layer=dap DAP server stopped

My VSCode launch.json configuration is as follows:

{
“version”: “0.2.0”,
“configurations”: [
{
“name”: “Attach to remote process”,
“type”: “go”,
“debugAdapter”: “dlv-dap”,
“request”: “attach”,
“mode”: “remote”,
“program”: “/usr/local/trpc/bin/api-svr”,
“processId”: 14,
“host”: “127.0.0.1”,
“port”: 11458,
}
]
}
vscode error

New contributor

wknclizu is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật