microsoft / microsoft/vscode-cpptools
Locals in Variables spinning forever when the below attached program is debugged
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- TypeScript
- Star
- 6.2k
- Fork
- 1.7k
- Merge trung bình
- 14 giờ 46 phút
- Pull request đã merge (30 ngày)
- 61
Mô tả
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:
- Run the below program in gdb debugger
- set break at function subarr
- 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;
}
`
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Tái hiện vấn đề bằng chương trình C++ đính kèm, đặt breakpoint trong subarr và quan sát chế độ xem Locals khi quá trình thực thi dừng lại. Trước tiên, hãy kiểm tra cấu hình debugger và các nhật ký hiện có; được xem là hoàn tất khi chế độ xem Locals được hiển thị thay vì quay vô hạn.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- cpp, vscode
- Lĩnh vực
- developer-experience, tooling
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Cần làm rõ
- Mức phù hợp với người mới
- 25/100