Failed to open /dev/tty with vscode debugger

オープン
#3,351 コメント 14 件 リアクション 7 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
cpp, linux, vscode

調査の方向性

まず、添付された launch.json と debuglog.txt をコマンドラインからの gdb の呼び出しと比較し、次に VS Code C++ デバッガーがどのようにプログラムを起動し、その制御端末を提供するかを調べます。指定された Ubuntu 16.04 環境でサンプルの /dev/tty プログラムを使って問題を再現します。VS Code のデバッグ実行で、コマンドラインからの実行と同じように /dev/tty が開かれれば完了です。

索引モデルが issue の本文から書いたものです。

説明

debugger

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

主要言語
TypeScript
スター
6.2k
フォーク
1.7k
平均マージ
14時間 46分
マージ済み PR(30日)
61

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

microsoft/vscode-cpptools のほかの issue

microsoft/vscode-cpptools の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。