microsoft / microsoft/MIEngine

vscode cppdbg should not launch a new terminal when using attach mode

Open
#1,532 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
859
Forks
233
Avg merge
1d 6h
Merged PRs (30d)
3

Description

Related: https://github.com/microsoft/vscode-cpptools/issues/14118

Environment
  • OS and version: Windows 10
  • VS Code: 1.107.1
  • C/C++ extension: 1.29.3
  • OS and version of remote machine (if applicable): RHEL 8
  • GDB / LLDB version: 16.3
Bug Summary and Steps to Reproduce

Bug Summary:
When using attach mode, vscode cppdbg should not start a new terminal. The terminal is always empty and useless.

Steps to reproduce:

  1. Install C/C++ extension and Tasks Shell Input extension.

  2. launch.json:

    {
        "version": "0.2.0",
        "configurations": [
            {
                "name": "(gdb) Attach",
                "type": "cppdbg",
                "request": "attach",
                "program": "${workspaceFolder}/main",
                "processId": "${input:processID}",
                "MIMode": "gdb"
            }
        ],
        "inputs": [
            {
                "id": "processID",
                "type": "command",
                "command": "shellCommand.execute",
                "args": {
                    "command": "cat ${workspaceFolder}/main.pid",
                    "useFirstResult": true
                }
            }
        ]
    }
    
  3. main.c:

    #include <stdio.h>
    #include <stdlib.h>
    #include <unistd.h>
    
    int main() {
        FILE *fp = fopen("main.pid", "w");
        if (!fp) {
            return EXIT_FAILURE;
        }
        fprintf(fp, "%ld\n", (long) getpid());
        fclose(fp);
    
        while (1) {
            puts("Hello");
            sleep(3);
        }
        return EXIT_SUCCESS;
    }
    
  4. Compile and run:

    gcc -g main.c -o main
    
    ./main
    
  5. Run - Start Debugging


We need the "attach" mode because the actual program need a special way to launch.

But in "attach" mode, the terminal "cppdbg: main" is useless (and distracting). It will always be empty, because the program prints and reads at its own terminal.

Maybe cppdbg should not launch a terminal when using attach mode, or we need an option at launch.json to make cppdbg not to launch a terminal.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue from launch.json using the cppdbg attach configuration, main.c, and GDB 16.3, then start debugging through VS Code. Trace the attach-mode path responsible for creating the terminal and determine whether completion means suppressing it by default or adding a launch.json option; verify that the terminal is no longer opened for attach sessions.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, cpp, vscode
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.