microsoft / microsoft/vscode-cpptools

[WSL] Unable to input data during debugging

オープン
#2,013 コメント 11 件 リアクション 6 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

bug debugger
主要言語
TypeScript
スター
6.2k
フォーク
1.7k
平均マージ
14時間 46分
マージ済み PR(30日)
61

説明

My Windows 10 version: 17134.48
VS Code: 1.23.1
C/C++ extension version: 0.17.1

I use VS Code (on windows) with WSL.
I found something wrong with debug.
my launch.json


            "name": "(gdb) WSL Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "/mnt/c/Users/xx/outAsciiCode",
            "args": [],
            "stopAtEntry": false,
            "cwd": "/mnt/c/Users/xx",
            "environment": [],
            "externalConsole": true,
            "logging": { "engineLogging": true},
            "pipeTransport": {
                "debuggerPath": "/usr/bin/gdb",
                "pipeProgram": "${env:windir}\\system32\\bash.exe",
                "pipeArgs": ["-c"],
                "pipeCwd": "/"
            },
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": false
                }
            ],
            "sourceFileMap": {
                "/mnt/c/Users/xx": "C:\\Users\\xx"
            }

and my main program:

int main(void)
{
    int a1, a2;
    scanf("%d %d", &a1, &a2);

    printf("%d\n%d\n", a1, a2);
    return 0;
}

and set breakpoints in scanf function and printf function.

First, when I use VS Code to debug this program
I CANNOT input two numbers to debug!

1: (2003) <-1020-stack-list-frames 0 1000
1: (2003) ->1020^done,stack=[frame={level="0",addr="0x0000000000400675",func="main",file="outAsciiCode.cpp",fullname="/mnt/c/Users/xx/outAsciiCode.cpp",line="23"}]
1: (2003) ->(gdb)
1: (2003) 1020: elapsed time 0
Execute debugger commands using "-exec <command>", for example "-exec info registers" will list registers in use (when GDB is the debugger)
Breakpoint 2, main () at outAsciiCode.cpp:23
23	    scanf("%d %d", &a1, &a2);
1: (2070) <-1021-stack-list-arguments 0 0 0
1: (2072) ->1021^done,stack-args=[frame={level="0",args=[]}]
1: (2073) ->(gdb)
1: (2073) 1021: elapsed time 2
1: (2123) <-1022-stack-list-variables 0
1: (2125) ->1022^done,variables=[{name="a1"},{name="a2"}]
1: (2125) ->(gdb)
1: (2127) 1022: elapsed time 3
1: (2139) <-1023-var-create - * "a1"
1: (2155) ->1023^done,name="var1",numchild="0",value="-71472",type="int",thread-id="1",has_more="0"
1: (2155) ->(gdb)
1: (2155) 1023: elapsed time 15
1: (2156) <-1024-var-create - * "a2"
1: (2159) ->1024^done,name="var2",numchild="0",value="32767",type="int",thread-id="1",has_more="0"
1: (2159) ->(gdb)
1: (2159) 1024: elapsed time 2

1: (131012) <--exec-continue
1: (131013) ->^running
1: (131014) ->*running,thread-id="all"
1: (131015) ->(gdb)

I try to input two numbers, but show

78 5
Unable to perform this action because the process is running.

and running without end.

Finally, I use terminal to debug the same program, and it works

Breakpoint 1, main () at outAsciiCode.cpp:21

(gdb) b main
Breakpoint 1 at 0x400661: file outAsciiCode.cpp, line 21.
(gdb) r
Starting program: /mnt/c/Users/xx/outAsciiCode
21      {
(gdb) n
23          scanf("%d %d", &a1, &a2);
(gdb) n
45 78
31          printf("%d\n%d\n", a1, a2);
(gdb) n
45
78
33      }
(gdb)

So, can you fix it? Thanks

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず、示されている launch.json を使って問題を再現します。特に、WSL 上での pipeTransport、externalConsole、および C++ プログラムの scanf 呼び出しを確認してください。入力動作をターミナルの GDB セッションと比較します。デバッグ中に数値を入力でき、実行が printf まで進めば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
cpp, vscode
領域
devtools
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。