microsoft / microsoft/vscode-cpptools

Printing characters for file.peek() in watch window - debug

Offen
#1,015 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

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

Beschreibung

Typing file.peek() in the watch window under debug mode prints this message while stepping in my code: file.peek(): Couldn't find method std::ifstream::peek.

I have added a .natvis file but I am still unable to see what the peek method is analyzing in the watch window.

I also get the error Unable to step out. Operation failed with error code 0x80004004 while trying to step out (SHIFT+F11) in my code which is probably due to gdb according to this post: #215. EDIT: I corrected the link.

  • OS : Ubuntu 16.04.2 LTS
  • VSCode : Version 1.14.2
  • gdb : GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.04) 7.11.1
  • vscode.cpptools-0.12.2

Any ideas on how to have file.peek() in the watch window show the strings?

Here is a sample code along with my natvis and json files:
debugFct.cpp:

#include <iostream>
#include <fstream>
using namespace std; // using only on test code

int main(){
    int numChar = 0;
    char numb;
    do {
        ++numChar;
        if (file.peek() == '\n')
            break;
        cout << numb << " ";
    }
    while(file.get(numb));
    return 0;
}

debug.natvis file placed in /usr/share/code/ folder:

<?xml version="1.0" encoding="utf-8"?>  
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">  
<Type Name="file.peek()">
    <DisplayString>{file.peek(),[1]su}</DisplayString>
</Type>
</AutoVisualizer>

launch.json:

"version": "0.2.0",
"configurations": [
        {
            "name": "(gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceRoot}/debugFct",
            "args": ["-D_GLIBCXX_DEBUG"],
            "stopAtEntry": false,
            "cwd": "${workspaceRoot}",
            "environment": [],
            "externalConsole": true,
            "MIMode": "gdb",
            "miDebuggerPath": "/usr/bin/gdb",
            "showDisplayString": true,
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-exec -enable-pretty-printing",
                    "ignoreFailures": true
                },
                { 
                    "text": "handle SIGPIPE nostop noprint pass", 
                    "description": "ignore SIGPIPE", 
                    "ignoreFailures": true 
                }
            ]
        }
    ]

settings.json:

"files.associations": {
    "string": "cpp",
    "iostream": "cpp",
    "istream": "cpp",
    "iosfwd": "cpp"
},
"C_Cpp.intelliSenseEngine": "Default",
"code-runner.executorMap":{
    "cpp": "cd $dir && g++ $fileName -std=c++11 -o $fileNameWithoutExt && $dir$fileNameWithoutExt"
},
"editor.minimap.enabled": false,
"vsicons.presets.tsOfficial": true,
"workbench.iconTheme": "vscode-icons"

Thank you

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 mit der Reproduktion in debugFct.cpp und den zugehörigen Dateien debug.natvis, launch.json und settings.json. Reproduziere die Auswertung im Überwachungsfenster unter den aufgeführten Versionen von VS Code, cpptools, Ubuntu und gdb, und trenne sie anschließend vom Fehler beim Heraustreten mit SHIFT+F11. Als erledigt gilt das Issue, wenn sein Umfang bestätigt ist und entweder eine unterstützte Möglichkeit zur Anzeige der per Peek untersuchten Zeichen oder eine dokumentierte Einschränkung vorliegt.

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
Muss geklärt werden
Anfängerfreundlichkeit
25/100

Neue Issues direkt in Ihr Postfach

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