golang / vscode-go

Go extension for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=golang.Go
Other
3.89k stars 751 forks source link

could not debug through remote ssh extensions #2192

Closed jihenry closed 2 years ago

jihenry commented 2 years ago

Please answer the following before submitting your issue:

Note: Please include any substantial examples (debug session output, stacktraces, etc) as linked gists.

  1. What version of Delve are you using (dlv version)? Delve Debugger Version: 1.8.2
  2. What version of Go are you using? (go version)? go version go1.16.13 darwin/amd64
  3. What operating system and processor architecture are you using? Darwin 192.168.0.102 19.4.0 Darwin Kernel Version 19.4.0: Wed Mar 4 22:28:40 PST 2020; root:xnu-6153.101.6~15/RELEASE_X86_64 x86_64
  4. What did you do? connect mac use vscode through vscode remote-ssh extension,the below is launch.json that can't work, { "name": "gotest", "type": "go", "request": "launch", "dlvFlags": [ "--log", "--log-output", "dap,debugger,fncall,rpc,debuglineerr,lldbout,minidump,gdbwire" ], "program": "${file}", "mode": "auto" }
  5. What did you expect to see? can debug like local
  6. What did you see instead? image Starting: /Users/wdoeasy/go/bin/dlv dap --check-go-version=false --log --log-output dap,debugger,fncall,rpc,debuglineerr,lldbout,minidump,gdbwire --listen=127.0.0.1:56815 --log-dest=3 from /Users/wdoeasy/Documents/workspace/test/go DAP server listening at: 127.0.0.1:56815 2022-04-16T20:50:13+08:00 debug layer=dap DAP server pid = 15624 2022-04-16T20:50:13+08:00 debug layer=dap DAP connection 1 started 2022-04-16T20:50:13+08:00 debug layer=dap [<- from client]{"seq":1,"type":"request","command":"initialize","arguments":{"clientID":"vscode","clientName":"Visual Studio Code","adapterID":"go","locale":"zh-cn","linesStartAt1":true,"columnsStartAt1":true,"pathFormat":"path","supportsVariableType":true,"supportsVariablePaging":true,"supportsRunInTerminalRequest":true,"supportsMemoryReferences":true,"supportsProgressReporting":true,"supportsInvalidatedEvent":true}} 2022-04-16T20:50:13+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,"supportTerminateDebuggee":true,"supportsDelayedStackTraceLoading":true,"supportsLogPoints":true,"supportsDisassembleRequest":true,"supportsClipboardContext":true,"supportsSteppingGranularity":true,"supportsInstructionBreakpoints":true}} 2022-04-16T20:50:13+08:00 debug layer=dap [<- from client]{"seq":2,"type":"request","command":"launch","arguments":{"name":"gotest","type":"go","request":"launch","dlvFlags":["--log","--log-output","dap,debugger,fncall,rpc,debuglineerr,lldbout,minidump,gdbwire"],"program":"./main.go","mode":"debug","configurationTarget":5,"packagePathToGoModPathMap":{"/Users/wdoeasy/Documents/workspace/test/go":"/Users/wdoeasy/Documents/workspace/test/go"},"debugAdapter":"dlv-dap","showRegisters":false,"showGlobalVariables":false,"substitutePath":[],"showLog":false,"logOutput":"debugger","hideSystemGoroutines":false,"dlvToolPath":"/Users/wdoeasy/go/bin/dlv","env":{"GOPATH":"/Users/wdoeasy/go"},"buildDir":"/Users/wdoeasy/Documents/workspace/test/go","sessionId":"1f560a82-35e1-4b47-9db8-477140aefcb6"}} 2022-04-16T20:50:13+08:00 debug layer=dap parsed launch config: { "mode": "debug", "program": "./main.go", "env": { "GOPATH": "/Users/wdoeasy/go" }, "backend": "default", "stackTraceDepth": 50 } 2022-04-16T20:50:14+08:00 debug layer=dap building from "/Users/wdoeasy/Documents/workspace/test/go": [go build -o /Users/wdoeasy/Documents/workspace/test/go/debug_bin -gcflags all=-N -l ./main.go] 2022-04-16T20:50:14+08:00 debug layer=dap launching binary '/Users/wdoeasy/Documents/workspace/test/go/debug_bin' with config: { "mode": "debug", "program": "/Users/wdoeasy/Documents/workspace/test/go/main.go", "cwd": "/Users/wdoeasy/Documents/workspace/test/go", "output": "/Users/wdoeasy/Documents/workspace/test/go/__debug_bin", "dlvCwd": "/Users/wdoeasy/Documents/workspace/test/go", "env": { "GOPATH": "/Users/wdoeasy/go" }, "backend": "default", "stackTraceDepth": 50 } 2022-04-16T20:50:14+08:00 info layer=debugger launching process with args: [/Users/wdoeasy/Documents/workspace/test/go/debug_bin] 2022-04-16T20:50:14+08:00 debug layer=gdbconn executing /Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Versions/A/Resources/debugserver [--stdin-path /dev/stdin --stdout-path /dev/stdout --stderr-path /dev/stderr -g -l stdout -F -R 127.0.0.1:56823 -- /Users/wdoeasy/Documents/workspace/test/go/debug_bin] argv[0] = 127.0.0.1:56823 argv[1] = /Users/wdoeasy/Documents/workspace/test/go/__debug_bin debugserver-@(#)PROGRAM:LLDB PROJECT:lldb-1200.0.44 for x86_64. host = '127.0.0.1' port = 56823 inferior_argv[0] = '/Users/wdoeasy/Documents/workspace/test/go/debug_bin' 1 +0.000000 sec [3d16/0307]: RNBRunLoopLaunchInferior Launching '/Users/wdoeasy/Documents/workspace/test/go/debug_bin'... 2 +0.000324 sec [3d16/0307]: DNBProcessLaunch ( path='/Users/wdoeasy/Documents/workspace/test/go/__debug_bin', argv = 0x7fa71b5042f0, envp = 0x7fa71b504cb0, working_dir=(null), stdin=/dev/stdin, stdout=/dev/stdout, stderr=/dev/stderr, no-stdio=0, launch_flavor = 1, disable_aslr = 0, err = 0x7ffeeef47020, err_len = 1024) called... 3 +0.000187 sec [3d16/0307]: MachProcess::MachProcess() 4 +0.000017 sec [3d16/0307]: MachProcess::SetState(Unloaded) ignoring redundant state change... 5 +0.000018 sec [3d16/0307]: LaunchForDebug( path = '/Users/wdoeasy/Documents/workspace/test/go/debug_bin', argv = 0x7fa71b5042f0, envp = 0x7fa71b504cb0, launch_flavor = 1, disable_aslr = 0 ) 6 +0.000008 sec [3d16/0307]: MachProcess::SetState(Launching) upating state (previous state was Unloaded), event_mask = 0x00000001 7 +0.000022 sec [3d16/0307]: PosixSpawnChildForPTraceDebugging ( path='/Users/wdoeasy/Documents/workspace/test/go/__debug_bin', argv=0x7fa71b5042f0, envp=0x7fa71b504cb0, working_dir=(null), stdin=/dev/stdin, stdout=/dev/stdout stderr=/dev/stderr, no-stdio=0) 8 +0.000018 sec [3d16/0307]: ::posix_spawnattr_init ( &attr ) err = 0x00000000 9 +0.000037 sec [3d16/0307]: ::posix_spawnattr_setflags ( &attr, POSIX_SPAWN_START_SUSPENDED ) err = 0x00000000 10 +0.000023 sec [3d16/0307]: ::posix_spawn_file_actions_init ( &file_actions ) err = 0x00000000 11 +0.000018 sec [3d16/0307]: ::posix_spawn_file_actions_addopen (&file_actions, filedes=STDIN_FILENO, path='/dev/stdin') err = 0x00000000 12 +0.000006 sec [3d16/0307]: ::posix_spawn_file_actions_addopen (&file_actions, filedes=STDOUT_FILENO, path='/dev/stdout') err = 0x00000000 13 +0.000007 sec [3d16/0307]: ::posix_spawn_file_actions_addopen (&file_actions, filedes=STDERR_FILENO, path='/dev/stderr') err = 0x00000000 14 +0.000996 sec [3d16/0307]: ::posix_spawnp ( pid => 15639, path = '/Users/wdoeasy/Documents/workspace/test/go/__debug_bin', file_actions = 0x7ffeeef46880, attr = 0x7ffeeef46890, argv = 0x7fa71b5042f0, envp = 0x7fa71b504cb0 ) err = 0x00000000 15 +0.000063 sec [3d16/0307]: MachProcess::PosixSpawnChildForPTraceDebugging ( ) pid=15639, cpu_type=0x01000007 16 +0.000009 sec [3d16/0307]: DNBArchProtocol::SetDefaultArchitecture (cpu_type=0x01000007) => 1 17 +0.000019 sec [3d16/0307]: ::posix_spawn_file_actions_destroy ( &file_actions ) err = 0x00000000 18 +0.000015 sec [3d16/0307]: MachTask::StartExceptionThread ( ) error: MachTask::TaskPortForProcessID task_for_pid failed: ::task_for_pid ( target_tport = 0x0103, pid = 15639, &task ) => err = 0x00000005 ((os/kern) failure) 19 +0.053100 sec [3d16/0307]: error: ::task_for_pid ( target_tport = 0x0103, pid = 15639, &task ) => err = 0x00000005 ((os/kern) failure) err = ::task_for_pid ( target_tport = 0x0103, pid = 15639, &task ) => err = 0x00000005 ((os/kern) failure) (0x00000005) error: MachTask::TaskPortForProcessID task_for_pid failed: ::task_for_pid ( target_tport = 0x0103, pid = 15639, &task ) => err = 0x00000005 ((os/kern) failure) 20 +0.048992 sec [3d16/0307]: error: ::task_for_pid ( target_tport = 0x0103, pid = 15639, &task ) => err = 0x00000005 ((os/kern) failure) err = ::task_for_pid ( target_tport = 0x0103, pid = 15639, &task ) => err = 0x00000005 ((os/kern) failure) (0x00000005) error: MachTask::TaskPortForProcessID task_for_pid failed: ::task_for_pid ( target_tport = 0x0103, pid = 15639, &task ) => err = 0x00000005 ((os/kern) failure) 21 +0.049977 sec [3d16/0307]: error: ::task_for_pid ( target_tport = 0x0103, pid = 15639, &task ) => err = 0x00000005 ((os/kern) failure) err = ::task_for_pid ( target_tport = 0x0103, pid = 15639, &task ) => err = 0x00000005 ((os/kern) failure) (0x00000005) error: MachTask::TaskPortForProcessID task_for_pid failed: ::task_for_pid ( target_tport = 0x0103, pid = 15639, &task ) => err = 0x00000005 ((os/kern) failure) 22 +0.038977 sec [3d16/0307]: error: ::task_for_pid ( target_tport = 0x0103, pid = 15639, &task ) => err = 0x00000005 ((os/kern) failure) err = ::task_for_pid ( target_tport = 0x0103, pid = 15639, &task ) => err = 0x00000005 ((os/kern) failure) (0x00000005) error: MachTask::TaskPortForProcessID task_for_pid failed: ::task_for_pid ( target_tport = 0x0103, pid = 15639, &task ) => err = 0x00000005 ((os/kern) failure) 23 +0.043858 sec [3d16/0307]: error: ::task_for_pid ( target_tport = 0x0103, pid = 15639, &task ) => err = 0x00000005 ((os/kern) failure) err = ::task_for_pid ( target_tport = 0x0103, pid = 15639, &task ) => err = 0x00000005 ((os/kern) failure) (0x00000005) error: MachTask::TaskPortForProcessID task_for_pid failed: ::task_for_pid ( target_tport = 0x0103, pid = 15639, &task ) => err = 0x00000005 ((os/kern) failure) 24 +0.036991 sec [3d16/0307]: error: ::task_for_pid ( target_tport = 0x0103, pid = 15639, &task ) => err = 0x00000005 ((os/kern) failure) err = ::task_for_pid ( target_tport = 0x0103, pid = 15639, &task ) => err = 0x00000005 ((os/kern) failure) (0x00000005) error: MachTask::TaskPortForProcessID task_for_pid failed: ::task_for_pid ( target_tport = 0x0103, pid = 15639, &task ) => err = 0x00000005 ((os/kern) failure) 25 +0.038660 sec [3d16/0307]: error: ::task_for_pid ( target_tport = 0x0103, pid = 15639, &task ) => err = 0x00000005 ((os/kern) failure) err = ::task_for_pid ( target_tport = 0x0103, pid = 15639, &task ) => err = 0x00000005 ((os/kern) failure) (0x00000005) error: MachTask::TaskPortForProcessID task_for_pid failed: ::task_for_pid ( target_tport = 0x0103, pid = 15639, &task ) => err = 0x00000005 ((os/kern) failure) 26 +0.039447 sec [3d16/0307]: error: ::task_for_pid ( target_tport = 0x0103, pid = 15639, &task ) => err = 0x00000005 ((os/kern) failure) err = ::task_for_pid ( target_tport = 0x0103, pid = 15639, &task ) => err = 0x00000005 ((os/kern) failure) (0x00000005) error: MachTask::TaskPortForProcessID task_for_pid failed: ::task_for_pid ( target_tport = 0x0103, pid = 15639, &task ) => err = 0x00000005 ((os/kern) failure) 27 +0.047432 sec [3d16/0307]: error: ::task_for_pid ( target_tport = 0x0103, pid = 15639, &task ) => err = 0x00000005 ((os/kern) failure) err = ::task_for_pid ( target_tport = 0x0103, pid = 15639, &task ) => err = 0x00000005 ((os/kern) failure) (0x00000005) error: MachTask::TaskPortForProcessID task_for_pid failed: ::task_for_pid ( target_tport = 0x0103, pid = 15639, &task ) => err = 0x00000005 ((os/kern) failure) 28 +0.037218 sec [3d16/0307]: error: ::task_for_pid ( target_tport = 0x0103, pid = 15639, &task ) => err = 0x00000005 ((os/kern) failure) err = ::task_for_pid ( target_tport = 0x0103, pid = 15639, &task ) => err = 0x00000005 ((os/kern) failure) (0x00000005) error: MachTask::StartExceptionThread (): task invalid, exception thread start failed. 29 +0.011718 sec [3d16/0307]: MachProcess::StartSTDIOThread ( ) 30 +0.000076 sec [3d16/0307]: MachProcess::SetState(Attaching) upating state (previous state was Launching), event_mask = 0x00000001 31 +0.000021 sec [3d16/0a03]: MachProcess::STDIOThread ( arg = 0x7fa71c00a800 ) thread starting... 32 +0.000024 sec [3d16/0a03]: MachProcess::STDIOThread (0x7fa71c00a800): thread exiting... 33 +0.000030 sec [3d16/0307]: successfully spawned pid 15639 34 +0.000008 sec [3d16/0307]: (DebugNub) new pid is 15639... hello error: MachTask::TaskPortForProcessID task_for_pid failed: ::task_for_pid ( target_tport = 0x0103, pid = 15639, &task ) => err = 0x00000005 ((os/kern) failure) 35 +0.034466 sec [3d16/0307]: error: ::task_for_pid ( target_tport = 0x0103, pid = 15639, &task ) => err = 0x00000005 ((os/kern) failure) err = ::task_for_pid ( target_tport = 0x0103, pid = 15639, &task ) => err = 0x00000005 ((os/kern) failure) (0x00000005) error: MachTask::TaskPortForProcessID task_for_pid failed: ::task_for_pid ( target_tport = 0x0103, pid = 15639, &task ) => err = 0x00000005 ((os/kern) failure) 36 +0.044931 sec [3d16/0307]: error: ::task_for_pid ( target_tport = 0x0103, pid = 15639, &task ) => err = 0x00000005 ((os/kern) failure) err = ::task_for_pid ( target_tport = 0x0103, pid = 15639, &task ) => err = 0x00000005 ((os/kern) failure) (0x00000005) error: MachTask::TaskPortForProcessID task_for_pid failed: ::task_for_pid ( target_tport = 0x0103, pid = 15639, &task ) => err = 0x00000005 ((os/kern) failure) 37 +0.044339 sec [3d16/0307]: error: ::task_for_pid ( target_tport = 0x0103, pid = 15639, &task ) => err = 0x00000005 ((os/kern) failure) err = ::task_for_pid ( target_tport = 0x0103, pid = 15639, &task ) => err = 0x00000005 ((os/kern) failure) (0x00000005) error: MachTask::TaskPortForProcessID task_for_pid failed: ::task_for_pid ( target_tport = 0x0103, pid = 15639, &task ) => err = 0x00000005 ((os/kern) failure) 38 +0.045575 sec [3d16/0307]: error: ::task_for_pid ( target_tport = 0x0103, pid = 15639, &task ) => err = 0x00000005 ((os/kern) failure) err = ::task_for_pid ( target_tport = 0x0103, pid = 15639, &task ) => err = 0x00000005 ((os/kern) failure) (0x00000005) error: MachTask::TaskPortForProcessID task_for_pid failed: ::task_for_pid ( target_tport = 0x0103, pid = 15639, &task ) => err = 0x00000005 ((os/kern) failure) 39 +0.046393 sec [3d16/0307]: error: ::task_for_pid ( target_tport = 0x0103, pid = 15639, &task ) => err = 0x00000005 ((os/kern) failure) err = ::task_for_pid ( target_tport = 0x0103, pid = 15639, &task ) => err = 0x00000005 ((os/kern) failure) (0x00000005) error: MachTask::TaskPortForProcessID task_for_pid failed: ::task_for_pid ( target_tport = 0x0103, pid = 15639, &task ) => err = 0x00000005 ((os/kern) failure) 40 +0.039653 sec [3d16/0307]: error: ::task_for_pid ( target_tport = 0x0103, pid = 15639, &task ) => err = 0x00000005 ((os/kern) failure) err = ::task_for_pid ( target_tport = 0x0103, pid = 15639, &task ) => err = 0x00000005 ((os/kern) failure) (0x00000005) error: MachTask::TaskPortForProcessID task_for_pid failed: ::task_for_pid ( target_tport = 0x0103, pid = 15639, &task ) => err = 0x00000005 ((os/kern) failure) 41 +0.052664 sec [3d16/0307]: error: ::task_for_pid ( target_tport = 0x0103, pid = 15639, &task ) => err = 0x00000005 ((os/kern) failure) err = ::task_for_pid ( target_tport = 0x0103, pid = 15639, &task ) => err = 0x00000005 ((os/kern) failure) (0x00000005) error: MachTask::TaskPortForProcessID task_for_pid failed: ::task_for_pid ( target_tport = 0x0103, pid = 15639, &task ) => err = 0x00000005 ((os/kern) failure) 42 +0.051857 sec [3d16/0307]: error: ::task_for_pid ( target_tport = 0x0103, pid = 15639, &task ) => err = 0x00000005 ((os/kern) failure) err = ::task_for_pid ( target_tport = 0x0103, pid = 15639, &task ) => err = 0x00000005 ((os/kern) failure) (0x00000005) error: MachTask::TaskPortForProcessID task_for_pid failed: ::task_for_pid ( target_tport = 0x0103, pid = 15639, &task ) => err = 0x00000005 ((os/kern) failure) 43 +0.052107 sec [3d16/0307]: error: ::task_for_pid ( target_tport = 0x0103, pid = 15639, &task ) => err = 0x00000005 ((os/kern) failure) err = ::task_for_pid ( target_tport = 0x0103, pid = 15639, &task ) => err = 0x00000005 ((os/kern) failure) (0x00000005) error: MachTask::TaskPortForProcessID task_for_pid failed: ::task_for_pid ( target_tport = 0x0103, pid = 15639, &task ) => err = 0x00000005 ((os/kern) failure) 44 +0.050205 sec [3d16/0307]: error: ::task_for_pid ( target_tport = 0x0103, pid = 15639, &task ) => err = 0x00000005 ((os/kern) failure) err = ::task_for_pid ( target_tport = 0x0103, pid = 15639, &task ) => err = 0x00000005 ((os/kern) failure) (0x00000005) Could not get task port for process, sending SIGKILL and exiting. 45 +0.010128 sec [3d16/0307]: MachProcess::~MachProcess() 46 +0.000014 sec [3d16/0307]: MachProcess::SetState(Unloaded) upating state (previous state was Attaching), event_mask = 0x00000002 47 +0.000071 sec [3d16/0307]: RNBRunLoopLaunchInferior DNBProcessLaunch() returned error: 'failed to get the task for process 15639' error: failed to launch process /Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Versions/A/Resources/debugserver: failed to get the task for process 15639

48 +0.000022 sec [3d16/0307]: 921081 RNBRemote::StopReadRemoteDataThread called Exiting.

49 +0.000022 sec [3d16/0307]: RNBRemote::~RNBRemote() 50 +0.000007 sec [3d16/0307]: 30 RNBRemote::StopReadRemoteDataThread called 2022-04-16T20:50:15+08:00 debug layer=dap Failed to launch: could not launch process: stub exited while waiting for connection: exit status 0 2022-04-16T20:50:15+08:00 debug layer=dap [-> to client]{"seq":0,"type":"response","request_seq":2,"success":false,"command":"launch","message":"Failed to launch","body":{"error":{"id":3000,"format":"Failed to launch: could not launch process: stub exited while waiting for connection: exit status 0","showUser":true}}}

ycao56 commented 2 years ago

I am hitting same issue.

ycao56 commented 2 years ago

Another found might be related: If I try to manually start a dlv --headless server through the terminal established by remote development, I got same error

~/Dev/gi/n/edge-infra master !1 ❯ dlv debug cmd/linkerdctl/main.go --headless --listen=:12345 --accept-multiclient --continue
API server listening at: [::]:12345
2022-04-19T20:54:00-04:00 warning layer=rpc Listening for remote connections (connections are not authenticated nor encrypted)
debugserver-@(#)PROGRAM:LLDB  PROJECT:lldb-1316.0.9.41
 for x86_64.
error: failed to launch process /Library/Developer/CommandLineTools/Library/PrivateFrameworks/LLDB.framework/Versions/A/Resources/debugserver: failed to get the task for process 36710
Exiting.
could not launch process: stub exited while waiting for connection: exit status 0
findleyr commented 2 years ago

This looks like it may be a problem running the lldb debugserver. We've seen similar issues in the past (e.g. #1637), but in this case it looks unrelated to Apply M1 (since you're on amd64).

We'll discuss in our weekly triage meeting, but poking around for this error returned this: https://lists.llvm.org/pipermail/lldb-dev/2019-July/015264.html

Are you able to try running delve from a graphical session, to see if you get an authentication popup?

gopherbot commented 2 years ago

Timed out in state WaitingForInfo. Closing.

(I am just a bot, though. Please speak up if this is a mistake or you have the requested information.)