microsoft / microsoft/vscode-cpptools
Failed to open /dev/tty with vscode debugger
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 6.2k
- Forks
- 1.7k
- Avg merge
- 14h 46m
- Merged PRs (30d)
- 61
Description
In my program, I tried to read /dev/tty. The program cannot open the file with vscode debugger, but the file is successfully opened with gdb command line.
The source code is:
#include <stdio.h>
#include <fcntl.h>
int main(int argc, char const *argv[])
{
int f = open("/dev/tty", O_RDONLY);
printf("open tty %d\n",f);
return 0;
}
The program is then build with g++ -g ./main.cpp.
When I use gdb to debug in vscode, it gives:
open tty -1
However, with command line gdb ./a.out, the file can be open successfully.
(gdb) r
Starting program: /home/miki0w0/c_test/a.out
open tty 3
[Inferior 1 (process 22818) exited normally]
(gdb) q
A same open issue can be found at https://stackoverflow.com/questions/52027368/unable-to-open-dev-ttyusb0-while-debugging-with-visual-studio-code-on-linux.
The vscode debugger works well in other cases. I wounder what causes the difference and how to fix it.
The environment is:
- OS and Version: Ubuntu 16.04
- VS Code Version: 1.32.3
- C/C++ Extension Version: 0.22.1
- Other extensions you installed (and if the issue persists after disabling them): None
Additional context
My configure file is:
launch.json.txt.
And the log information is included in this file:
debuglog.txt
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 by comparing the attached launch.json and debuglog.txt with the command-line gdb invocation, then inspect how the VS Code C++ debugger launches the program and provides its controlling terminal. Reproduce the issue on the stated Ubuntu 16.04 setup with the sample /dev/tty program; done means the VS Code debug run opens /dev/tty as the command-line run does.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, linux, vscode
- Domain
- devtools, operating-systems, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100