microsoft / microsoft/vscode-cpptools

Locals in Variables spinning forever when the below attached program is debugged

Abierto
#12,800 0 comentarios 3 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

debugger help wanted
Lenguaje dominante
TypeScript
Estrellas
6.2k
Forks
1.7k
Merge medio
14 h 46 min
PR fusionados (30 d)
61

Descripción

Environment
  • OS and version: macos
  • VS Code: 1.93.1
  • C/C++ extension: v1.21.6
  • OS and version of remote machine (if applicable):
  • GDB / LLDB version: lldb-1500.0.404.7
    Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)
Bug Summary and Steps to Reproduce

Bug Summary:

Steps to reproduce:

  1. Run the below program in gdb debugger
  2. set break at function subarr
  3. when breakpoint is hit, the locals variable starts to spin
Debugger Configurations
{
    "tasks": [
        {
            "label": "compile and run cpp",
            "type": "shell",
            "command": "g++ -std=c++17 -o ${fileBasenameNoExtension} ${file} && ./${fileBasenameNoExtension} < input.txt > output.txt && cat output.txt",
            "group": {
                "kind": "build",
                "isDefault": false
            }
        },
        {
            "label": "compile and run no input",
            "type": "shell",
            "command": "g++ -std=c++17 -o ${fileBasenameNoExtension} ${file} && ./${fileBasenameNoExtension}",
            "group": {
                "kind": "build",
                "isDefault": false
            }
        },
        {
            "label": "compile and run c",
            "type": "shell",
            "command": "gcc -o ${fileBasenameNoExtension} ${file} && ./${fileBasenameNoExtension} < input.txt > output.txt && cat output.txt",
            "group": {
                "kind": "build",
                "isDefault": false
            }
        },
        {
            "label": "compile and run python",
            "type": "shell",
            "command": "python3 ${file} < input.txt > output.txt && cat output.txt",
            "group": {
                "kind": "build",
                "isDefault": false
            }
        },
        {
            "type": "cppbuild",
            "label": "C/C++: clang++ build active file",
            "command": "/usr/bin/clang++",
            "args": [
                "-fcolor-diagnostics",
                "-fansi-escape-codes",
                "-g",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": false
            },
            "detail": "Task generated by Debugger."
        },
        {
            "type": "cppbuild",
            "label": "C/C++: clang build active file",
            "command": "/usr/bin/clang",
            "args": [
                "-fcolor-diagnostics",
                "-fansi-escape-codes",
                "-g",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": false
            },
            "detail": "Task generated by Debugger."
        },
        {
            "type": "cppbuild",
            "label": "C/C++: g++ build active file",
            "command": "/usr/bin/g++",
            "args": [
                "-fdiagnostics-color=always",
                "-g",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": false
            },
            "detail": "Task generated by Debugger."
        }
    ],
    "version": "2.0.0"
}
Debugger Logs
This is no launch.json file
Other Extensions

No response

Additional Information

Program being run
`#include <bits/stdc++.h>

int subarr(vector& nums, int p) {
int sum = 0;
int sz = nums.size();
for (int i = 0; i < sz; i++)
{
sum+=nums[i];
}
int target = sum % p;
unordered_map<int, int> umap; //<csum, idx>
umap[0] = -1;
int csum = 0;
int res = INT_MAX;
for (int i = 0; i < sz; i++)
{
csum += nums[i];
int other_half = (csum % p - target + p) % p;
if (umap.find(other_half) != umap.end())
{
res = min(res, i - umap[other_half]);
}
umap[csum] = i;
}
return res != INT_MAX ? res : -1;
}

int main(int argc, char const *argv[])
{
vector v{3,1,4,2};
int p = 6;
auto res = subarr(v, p);
cout << res << endl;
return 0;
}
`
Screenshot 2024-10-03 at 10 39 55 PM

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Reproduce el problema con el programa C++ adjunto, establece un punto de interrupción en subarr y observa la vista Locals cuando la ejecución se detenga. Comprueba primero la configuración del depurador y los registros disponibles; se considera terminado cuando la vista Locals se renderiza en lugar de girar indefinidamente.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
cpp, vscode
Área
developer-experience, tooling
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Necesita aclaración
Aptitud para principiantes
25/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.