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

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

Open
jenmueller opened this issue Sep 7, 2017 · 2 comments
Open

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

jenmueller opened this issue Sep 7, 2017 · 2 comments
Labels

Comments

@jenmueller
Copy link

jenmueller commented Sep 7, 2017

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

@pieandcakes
Copy link
Contributor

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

This seems to be because you are attempting to step out on the last frame. in the Debug Console window, you should see the gdb error. The post you referenced doesn't seem to have anything to do with that error.

@jenmueller
Copy link
Author

I'm sorry, I made an error while referencing another post : should have been this issue.

asialasr pushed a commit to asialasr/vscode-cpptools that referenced this issue Mar 12, 2021
Made the ListProcesses() error message for the Docker 'Attach to Process' scenario more specific.

Before:
    Failed to list processes.
    'ps' command failed with exit code '126'.
    Error:
    ''
    Parsing '/proc' for process list failed.
    Error:
    ''

After:
    Failed to list processes.
    'ps' command failed with exit code '126'.
    Error:
    ''
    Parsing '/proc' for process list failed.
    Error:
    ''
    Ensure the selected Docker Connection target is a Linux Container.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants