microsoft / microsoft/vscode-cpptools
Printing characters for file.peek() in watch window - debug
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 6.2k
- Forks
- 1.7k
- Avg merge
- 14h 46m
- Merged PRs (30d)
- 61
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the reproduction in debugFct.cpp and its debug.natvis, launch.json, and settings.json files. Reproduce the watch-window evaluation under the listed VS Code, cpptools, Ubuntu, and gdb versions, then separate it from the SHIFT+F11 step-out error. Done means the issue has a confirmed scope and either a supported way to display the peeked characters or a documented limitation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, vscode
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100