microsoft / microsoft/vscode-cpptools

GDB stops on break points which are not set

Open
#10,432 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

debugger more info needed
Dominant language
TypeScript
Stars
6.2k
Forks
1.7k
Avg merge
14h 46m
Merged PRs (30d)
61

Description

Environment
  • OS and version:
    windows 10
  • VS Code:
    Version: 1.74.3 (user setup)
    Commit: 97dec172d3256f8ca4bfb2143f3f76b503ca0534
    Date: 2023-01-09T16:59:02.252Z
    Electron: 19.1.8
    Chromium: 102.0.5005.167
    Node.js: 16.14.2
    V8: 10.2.154.15-electron.0
    OS: Windows_NT x64 10.0.19045
    Sandboxed: No
  • C/C++ extension:
    v1.13.9
  • OS and version of remote machine (if applicable):
  • GDB / LLDB version:
    GNU gdb (GDB) 12.1 (mingw64)
Bug Summary and Steps to Reproduce

Bug Summary:
Steps to reproduce:
run the code in debug :

int calcualteSkyLine(const std::vector<int>& skyline)
{
 

    int brushCount = 0;
    int prevHeight = 0;

    for(const auto& elm : skyline)
    {
        if(elm > prevHeight)
        {
            brushCount = brushCount + (elm - prevHeight);
        }
        prevHeight = elm ;         
    }
    return brushCount;
}

int main(int argv,char** argc)
{
    
    const std::vector<int>  buldingvec = {1,3,2,1,2,1,5,3,3,4,2};
    calcualteSkyLine(buldingvec);
    return 0;
}

see the debug line stops on breaks that are not set in the IDE very annoying ... happens in every project random stops

image
image

Debugger Configurations
{
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: g++.exe build active file",
            "command": "C:\\msys64\\mingw64\\bin\\g++.exe",
            "args": [
                "--debug",
                "-g",
                "${file}",
                "-o",
                "${fileDirname}\\${fileBasenameNoExtension}.exe"
            ],
            "options": {
                "cwd": "C:\\msys64\\mingw64\\bin"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "Task generated by Debugger."
        }
    ],
    "version": "2.0.0"
}



{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/${fileBasenameNoExtension}.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": true,  //this will call a dos prompt window for cin and cout
            "MIMode": "gdb",
            "miDebuggerPath": "C:\\msys64\\mingw64\\bin\\gdb.exe",
            "preLaunchTask": "cppbuild", //this must same as command in task.json
            "logging": {"trace": true, "traceResponse": true,
                        "engineLogging": true,
                        "exceptions": true,
                        "moduleLoad": true,
                        "programOutput": true},
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ]
        }
    ]
}
Debugger Logs
=thread-group-added,id="i1"
GNU gdb (GDB) 12.1
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-w64-mingw32".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word".
Warning: Debuggee TargetArchitecture not detected, assuming x86_64.
=cmd-param-changed,param="pagination",value="off"
[New Thread 1116.0x3448]
[New Thread 1116.0x12c]
[New Thread 1116.0x1d04]

Thread 1 hit Breakpoint 1, main (argv=1, argc=0x1e3e63329b0) at C:\dev\my\cpp\mingw_projects\Questions\Q4\main.cpp:54
54	    const std::vector<int>  buldingvec = {1,3,2,1,2,1,5,3,3,4,2};
Loaded 'C:\Windows\SYSTEM32\ntdll.dll'. Symbols loaded.
Loaded 'C:\Windows\System32\kernel32.dll'. Symbols loaded.
Loaded 'C:\Windows\System32\KernelBase.dll'. Symbols loaded.
Loaded 'C:\Program Files\SentinelOne\Sentinel Agent 22.2.4.558\InProcessClient64.dll'. Symbols loaded.
Loaded 'C:\Windows\System32\advapi32.dll'. Symbols loaded.
Loaded 'C:\Windows\System32\msvcrt.dll'. Symbols loaded.
Loaded 'C:\Windows\System32\sechost.dll'. Symbols loaded.
Loaded 'C:\Windows\System32\rpcrt4.dll'. Symbols loaded.
Loaded 'C:\msys64\mingw64\bin\libgcc_s_seh-1.dll'. Symbols loaded.
Loaded 'C:\msys64\mingw64\bin\libstdc++-6.dll'. Symbols loaded.
Loaded 'C:\msys64\mingw64\bin\libwinpthread-1.dll'. Symbols loaded.

Thread 1 hit Breakpoint 4, calcualteSkyLine (skyline=std::vector of length 11, capacity 11 = {...}) at C:\dev\my\cpp\mingw_projects\Questions\Q4\main.cpp:37
37	    int brushCount = 0;
Execute debugger commands using "-exec <command>", for example "-exec info registers" will list registers in use (when GDB is the debugger)
[New Thread 1116.0x5434]

Thread 1 hit Breakpoint 8, calcualteSkyLine (skyline=std::vector of length 11, capacity 11 = {...}) at C:\dev\my\cpp\mingw_projects\Questions\Q4\main.cpp:42
42	        if(elm > prevHeight)

Thread 1 hit Breakpoint 8, calcualteSkyLine (skyline=std::vector of length 11, capacity 11 = {...}) at C:\dev\my\cpp\mingw_projects\Questions\Q4\main.cpp:42
42	        if(elm > prevHeight)

Thread 1 hit Breakpoint 8, calcualteSkyLine (skyline=std::vector of length 11, capacity 11 = {...}) at C:\dev\my\cpp\mingw_projects\Questions\Q4\main.cpp:42
42	        if(elm > prevHeight)

Thread 1 hit Breakpoint 8, calcualteSkyLine (skyline=std::vector of length 11, capacity 11 = {...}) at C:\dev\my\cpp\mingw_projects\Questions\Q4\main.cpp:42
42	        if(elm > prevHeight)

Thread 1 hit Breakpoint 8, calcualteSkyLine (skyline=std::vector of length 11, capacity 11 = {...}) at C:\dev\my\cpp\mingw_projects\Questions\Q4\main.cpp:42
42	        if(elm > prevHeight)

Thread 1 hit Breakpoint 8, calcualteSkyLine (skyline=std::vector of length 11, capacity 11 = {...}) at C:\dev\my\cpp\mingw_projects\Questions\Q4\main.cpp:42
42	        if(elm > prevHeight)

Thread 1 hit Breakpoint 8, calcualteSkyLine (skyline=std::vector of length 11, capacity 11 = {...}) at C:\dev\my\cpp\mingw_projects\Questions\Q4\main.cpp:42
42	        if(elm > prevHeight)

Thread 1 hit Breakpoint 8, calcualteSkyLine (skyline=std::vector of length 11, capacity 11 = {...}) at C:\dev\my\cpp\mingw_projects\Questions\Q4\main.cpp:42
42	        if(elm > prevHeight)

Thread 1 hit Breakpoint 8, calcualteSkyLine (skyline=std::vector of length 11, capacity 11 = {...}) at C:\dev\my\cpp\mingw_projects\Questions\Q4\main.cpp:42
42	        if(elm > prevHeight)

Thread 1 hit Breakpoint 8, calcualteSkyLine (skyline=std::vector of length 11, capacity 11 = {...}) at C:\dev\my\cpp\mingw_projects\Questions\Q4\main.cpp:42
42	        if(elm > prevHeight)

Thread 1 hit Breakpoint 8, calcualteSkyLine (skyline=std::vector of length 11, capacity 11 = {...}) at C:\dev\my\cpp\mingw_projects\Questions\Q4\main.cpp:42
42	        if(elm > prevHeight)

Thread 1 hit Breakpoint 9, calcualteSkyLine (skyline=std::vector of length 11, capacity 11 = {...}) at C:\dev\my\cpp\mingw_projects\Questions\Q4\main.cpp:48
48	    return brushCount;

Thread 1 hit Breakpoint 6, calcualteSkyLine (skyline=std::vector of length 11, capacity 11 = {...}) at C:\dev\my\cpp\mingw_projects\Questions\Q4\main.cpp:49
49	}
[Thread 1116.0x5434 exited with code 0]
[Thread 1116.0x3448 exited with code 0]
[Thread 1116.0x12c exited with code 0]
[Thread 1116.0x1d04 exited with code 0]
[Inferior 1 (process 1116) exited normally]
The program 'c:\dev\my\cpp\mingw_projects\Questions\Q4\main.exe' has exited with code 0 (0x00000000).
Other Extensions

No response

Additional Information

No response

Contributor guide

Open the contributing guide

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

Start by reproducing the reported stops with the supplied C++ source, launch configuration, build task, GDB 12.1, and Windows 10 environment. Compare the debugger logs with the breakpoints configured in VS Code and determine why execution stops at lines 42, 48, and 49. Done means the debugger stops only at user-set breakpoints while preserving normal stepping and breakpoint behavior.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.