microsoft / microsoft/vscode-cpptools

[WSL] Unable to input data during debugging

Offen
#2,013 11 Kommentare 6 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

bug debugger
Vorherrschende Sprache
TypeScript
Sterne
6.2k
Forks
1.7k
Ø Merge
14 Std. 46 Min.
Gemergte PRs (30 T.)
61

Beschreibung

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne damit, das Problem mit der gezeigten launch.json zu reproduzieren, insbesondere pipeTransport, externalConsole und den scanf-Aufruf des C++-Programms unter WSL. Vergleiche das Eingabeverhalten mit der GDB-Sitzung im Terminal; als erledigt gilt die Aufgabe, wenn während des Debuggens Zahlen eingegeben werden können und die Ausführung bis zu printf fortschreitet.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
cpp, vscode
Bereich
devtools
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
25/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.