Skip to content

cppvsdbg can't step over Standard Library calls #879

@aaccioly

Description

@aaccioly

Looks like Visual Code is not working as expecting when I try to Step Over a call to std::cout (F10) with Visual Studio Debugger. gdb on the other hand is working fine.

Visual Studio Code Version: 1.13.1
cpptools version: 0.12.0
Compiler: Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24210 for x86
OS: Windows 7 Enterprise

Steps to reproduce:

  1. Run the build_cl task (Ctrl+P task build_cl)
  2. Put a breakpoint in helloworld.cpp line 5
  3. Open the debug view (Ctrl+Shift+D)
  4. Select configuration (Windows) Launch
  5. Start Debugging (F5)
  6. Step Over until the first cout instruction (F10 3 times)

What happens

Visual Studio Code can't step over this call. F10 does not advance. Debug console outputs Access violation in ntdll.dll. Call Stack displays threads Paused on Exception.

Access violation

What should happen

It should step Over std::cout just like it does when we compile with task build_gcc and debug with (gdb) Launch configuration.

Example Project

helloworld.cpp

#include <iostream>

int main()
{
  int x = 10;
  int y = 20;
  std::cout << "Hello World!" << std::endl;
  std::cout << x << " " << y << std::endl;
  int z = 30;
  std::cout << z << std::endl;
}

tasks.json

{
    "version": "0.1.0",
    "tasks": [
        {
            "taskName": "build_cl",
            "command": "build.bat",
            "isShellCommand": true,
            "showOutput": "always"
        },
        {
            "taskName": "build_gcc",
            "command": "g++.exe",
            "isShellCommand": true,
            "args": ["-g", "-o", "output/hello.exe", "helloworld.cpp"],
            "showOutput": "always"
        }
    ]
}

build.bat

@echo off
cd output
call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64
set compilerflags=/Od /Zi /EHsc
set linkerflags=/OUT:hello.exe /DEBUG
cl.exe %compilerflags% ..\helloworld.cpp /link %linkerflags%

launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceRoot}/output/hello.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceRoot}",
            "environment": [],
            "externalConsole": true,
            "MIMode": "gdb",
            "miDebuggerPath": "gdb.exe",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ]
        },
        {
            "name": "(Windows) Launch",
            "type": "cppvsdbg",
            "request": "launch",
            "program": "${workspaceRoot}/output/hello.exe",
            "symbolSearchPath": "${workspaceRoot}/output",
            "externalConsole": true,
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceRoot}",
            "environment": []
        }
    ]
}

Debug logs

--------------------------------------------------------------------------------
You may only use the C/C++ Extension for Visual Studio Code with Visual Studio
Code, Visual Studio or Xamarin Studio software to help you develop and test your
applications.
--------------------------------------------------------------------------------
Loaded 'C:\Users\N662831\Documents\Projects\C-C++\test-vscode\output\hello.exe'. Symbols are loaded.
Loaded 'C:\Windows\System32\ntdll.dll'. Symbols are not loaded.
Loaded 'C:\Windows\System32\kernel32.dll'. Symbols are not loaded.
Loaded 'C:\Windows\System32\KernelBase.dll'. Symbols are not loaded.
Loaded 'C:\Windows\System32\sysfer.dll'. Symbols are not loaded.
Loaded 'C:\Windows\System32\advapi32.dll'. Symbols are not loaded.
Loaded 'C:\Windows\System32\msvcrt.dll'. Symbols are not loaded.
Loaded 'C:\Windows\System32\sechost.dll'. Symbols are not loaded.
Loaded 'C:\Windows\System32\rpcrt4.dll'. Symbols are not loaded.
Exception thrown at 0x000007FEFCC6A06D in hello.exe: Microsoft C++ exception: SysferException at memory location 0x00000000001DD540.
Exception thrown at 0x000007FEFCC6A06D in hello.exe: Microsoft C++ exception: SysferException at memory location 0x00000000001DD540.
Exception thrown at 0x000007FEFCC6A06D in hello.exe: Microsoft C++ exception: SysferException at memory location 0x00000000001DD540.
Exception thrown at 0x000007FEFCC6A06D in hello.exe: Microsoft C++ exception: SysferException at memory location 0x00000000001DD540.
Exception thrown at 0x000007FEFCC6A06D in hello.exe: Microsoft C++ exception: SysferException at memory location 0x00000000001DD540.
Exception thrown at 0x000007FEFCC6A06D in hello.exe: Microsoft C++ exception: SysferException at memory location 0x00000000001DD540.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions