microsoft / microsoft/vscode-cpptools

[WSL] Unable to input data during debugging

Aperta
#2,013 11 commenti 6 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

bug debugger
Lingua principale
TypeScript
Stelle
6.2k
Fork
1.7k
Merge medio
14h 46m
PR unite (30g)
61

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia riproducendo il problema con il launch.json mostrato, in particolare pipeTransport, externalConsole e la chiamata a scanf del programma C++ sotto WSL. Confronta il comportamento dell'input con la sessione GDB nel terminale; il lavoro è completato quando è possibile inserire numeri durante il debug e l'esecuzione procede fino a printf.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
cpp, vscode
Ambito
devtools
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.