Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Fix timeout for slow terminal #965

Merged
merged 1 commit into from
Feb 7, 2020
Merged

Conversation

Epikem
Copy link
Contributor

@Epikem Epikem commented Jan 27, 2020

Slow terminals like powershell with profile sometimes timeouts (microsoft/vscode-cpptools#2889). Also wait time does not seem to match with comment so I suggest increasing wait time.

Also adding Error_TimeoutWaitingForConnection to error message could be better (line 186).

@pieandcakes
Copy link
Collaborator

@Epikem Thank you for your submission. Can you tell me what you tested so know what else needs to be tested?

@pieandcakes pieandcakes self-requested a review January 27, 2020 18:58
@pieandcakes pieandcakes self-assigned this Jan 27, 2020
@Epikem
Copy link
Contributor Author

Epikem commented Jan 28, 2020

My Environment:

  • Visual Studio Community 2019 for MIEngine build.
  • Visual Studio Code 1.41.1
  • Visual Studio Code C/C++ extension 0.26.3
  • Powershell core 6.2.3
  • MinGW-w64 8.1.0 posix-seh

Followed this step to debug.
I tested this fix by replacing content in vscode cpp-tools' debugAdapters folder (C:\Users\...\.vscode\extensions\ms-vscode.cpptools-0.26.3\debugAdapters) with build output and launching vscode debug for simple cpp program after that. Compared with/without increased delay (20s, original 5s).

I checked the error(timeout) happened here does not appear with increased delay.
When I launch cpp debug, it opens new powershell terminal which usually fails by connection failure. But the connection failure does not occur when I don't close newly launched terminal and reuse it (I had to stop running command (WindowsDebugLauncher.exe) using ctrl+c), or if I remove all of the content in my powershell profile.
And same error happens even after increase delay(20s) when I add 20 second delay in powershell profile.

This is vscode debug console log when timeout happened:

1: (98) LaunchOptions<LocalLaunchOptions xmlns='http://schemas.microsoft.com/vstudio/MDDDebuggerOptions/2014'
1: (106) LaunchOptions  ExePath='c:\Users\...\dev\logs\sport\cpp\main.exe'
1: (107) LaunchOptions  WorkingDirectory='C:\Users\...\dev\logs'
1: (107) LaunchOptions  ExeArguments='&lt;c:\Users\...\dev\logs\sport\cpp/input.txt 2&gt;CON 1&gt;CON'
1: (107) LaunchOptions  MIMode='gdb'
1: (107) LaunchOptions  MIDebuggerPath='D:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/gdb.exe'
1: (107) LaunchOptions  WaitDynamicLibLoad='false'
1: (107) LaunchOptions>
1: (107) LaunchOptions    <SetupCommands>
1: (107) LaunchOptions        <Command IgnoreFailures='true' Description='Enable pretty-printing for gdb'>-enable-pretty-printing</Command>
1: (107) LaunchOptions    </SetupCommands>
1: (107) LaunchOptions</LocalLaunchOptions>
1: (176) Wait for connection completion.


1: (5208) Send Event AD7MessageEvent

And This is when timeout does not happen (after increase delay):

1: (116) LaunchOptions<LocalLaunchOptions xmlns='http://schemas.microsoft.com/vstudio/MDDDebuggerOptions/2014'
1: (140) LaunchOptions  ExePath='c:\Users\...\sport\cpp\main.exe'
1: (140) LaunchOptions  WorkingDirectory='C:\Users\...'
1: (141) LaunchOptions  ExeArguments='&lt;c:\Users\...\sport\cpp/input.txt 2&gt;CON 1&gt;CON'
1: (141) LaunchOptions  MIMode='gdb'
1: (141) LaunchOptions  MIDebuggerPath='D:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/gdb.exe'
1: (141) LaunchOptions  WaitDynamicLibLoad='false'
1: (141) LaunchOptions>
1: (141) LaunchOptions    <SetupCommands>
1: (141) LaunchOptions        <Command IgnoreFailures='true' Description='Enable pretty-printing for gdb'>-enable-pretty-printing</Command>
1: (141) LaunchOptions    </SetupCommands>
1: (141) LaunchOptions</LocalLaunchOptions>
1: (202) Wait for connection completion.
1: (6977) ->=thread-group-added,id="i1"
1: (6978) ->~"GNU gdb (GDB) 8.1\n"
1: (6979) ->~"Copyright (C) 2018 Free Software Foundation, Inc.\n"
1: (6980) ->~"License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law.  Type \"show copying\"\nand \"show warranty\" for details.\n"
1: (6981) ->~"This GDB was configured as \"x86_64-w64-mingw32\".\nType \"show configuration\" for configuration details."
1: (6981) ->~"\nFor bug reporting instructions, please see:\n"
1: (6982) ->~"<http://www.gnu.org/software/gdb/bugs/>.\n"
1: (6982) ->~"Find the GDB manual and other documentation resources online at:\n<http://www.gnu.org/software/gdb/documentation/>.\n"
1: (6982) ->~"For help, type \"help\".\n"
1: (6982) ->~"Type \"apropos word\" to search for commands related to \"word\".\n"
1: (6983) ->(gdb)
1: (6985) <-1001-gdb-set target-async on
1: (7000) ->1001^done
1: (7000) ->(gdb)

...(many messages)

1: (8562) ->(gdb)
<--   C (scopes-12): {"command":"scopes","arguments":{"frameId":1000},"type":"request","seq":12}
1: (9008) <-1031-stack-select-frame 0
1: (9013) ->1031^done
1: (9013) 1031: elapsed time 5
1: (9014) <-1032-stack-list-variables 0
1: (9014) ->(gdb)
1: (9014) ->&"\n"
1: (9014) ->^done
1: (9015) ->(gdb)
1: (9028) ->1032^done,variables=[]
1: (9028) 1032: elapsed time 14
1: (9028) ->(gdb)
1: (9029) ->&"\n"
1: (9029) ->^done
1: (9030) ->(gdb)

Other files in .vscode folder:

📂 launch.json

...
    {
      "name": "(gdb) Launch",
      "type": "cppdbg",
      "request": "launch",
      "preLaunchTask": "buildcpp",
      "program": "${fileDirname}/${fileBasenameNoExtension}.exe",
      "args": [
        "<${fileDirname}/input.txt"
      ],
      "stopAtEntry": false,
      "cwd": "${workspaceFolder}",
      "environment": [
      ],
      "logging":{
        "engineLogging": true,
        "trace":true
      },
      "externalConsole": false,
      "MIMode": "gdb",
      "miDebuggerPath": "D:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/gdb.exe",
      "setupCommands": [
        {
          "description": "Enable pretty-printing for gdb",
          "text": "-enable-pretty-printing",
          "ignoreFailures": true,
        }
      ]
    }
...

📂 c_cpp_properties.json

{
    "configurations": [
        {
            "name": "gcc",
            "includePath": [
                "${workspaceFolder}/**",
                "D:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/include",
                "D:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/**"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "compilerPath": "\"D:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/g++.exe\"",
            "cStandard": "c11",
            "cppStandard": "c++17",
            "intelliSenseMode": "gcc-x64",
            "browse": {
                "path": [
                    "${workspaceRoot}",
                    "D:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/include",
                    "D:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include"
                ],
                "limitSymbolsToIncludedHeaders": false,
                "databaseFilename": ""
            },
            "compilerArgs": [
                "-g"
            ]
        }
    ],
    "version": 4
}

📂 tasks.json

{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "msvc build",
      "type": "shell",
      "command": "cl.exe",
      "args": [
        "/EHsc",
        "/Zi",
        "/Fe:",
        "./sport/cpp/main.exe",
        "./sport/cpp/main.cpp"
      ],
      "group": "build",
      "presentation": {
        "reveal": "always"
      },
      "problemMatcher": "$msCompile"
    },
    {
      "label": "buildcpp",
      "command": "g++",
      "args": [
        "${file}",
        "-g",
        "-o",
        "${fileDirname}/${fileBasenameNoExtension}"
      ],
      "group": {
        "kind": "build",
        "isDefault": true
      },
      "problemMatcher": {
        "fileLocation": [
          "relative",
          "${workspaceRoot}"
        ],
        "pattern": {
          "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning error):\\s+(.*)$",
          "file": 1,
          "line": 2,
          "column": 3,
          "severity": 4,
          "message": 5
        }
      }
    }
  ]
}

@pieandcakes
Copy link
Collaborator

Thanks!

@pieandcakes pieandcakes merged commit a067825 into microsoft:master Feb 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants