5

Sorry if this has been asked before, but I don't get the previous given answers. I'm new to VS Code and know a bit of c++ coding. I tried the tutorial for windows/mingw : https://code.visualstudio.com/docs/cpp/config-mingw#_step-through-the-code and done everything so far. The sample code has been build and I want to debug now, but my variables view is showing something different when stepping through the application when debugging. (see attached image) enter image description here The word should contain any of the strings, as well as msg should show something different. My watch for a self made i int shows correctly, though. Whats'up? I did everything as in the tutorial.

also: the terminal tab does not output the msg from cout, but I see it in the debug console instead. (see image in tutorial just above the chapter 'set a watch')

launch.json is:

{
    // 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": "g++.exe - Aktive Datei erstellen und debuggen",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
            "args": [],
            "stopAtEntry": true,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "miDebuggerPath": "C:\\MinGW\\bin\\gdb.exe",
            "setupCommands": [
                {
                    "description": "Automatische Strukturierung und Einrückung für \"gdb\" aktivieren",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "C/C++: g++.exe build active file"
        }
    ]
}

sorry, i'm a newb to vs code :-/

drescherjm
  • 10,365
  • 5
  • 44
  • 64
Robscot75
  • 81
  • 1
  • 4
  • What is the output of `-exec info pretty-printer` in the debug console? – Evg Jun 23 '20 at 15:18
  • The debug console shows: [...] . Warning: Debuggee TargetArchitecture not detected, assuming x86_64. =cmd-param-changed,param="pagination",value="off" =cmd-param-changed,param="args",value="2>CON 1>CON ", for example [...] – Robscot75 Jun 23 '20 at 15:36
  • I think it's solved: I re-installed using the 64bit version of MinGW as I had an old 32 bit version running via mingw-get. Now everything looks nice. Was not believing it had to do with mingw as it ran under eclipse (which I'm installing as a comparison IDE). – Robscot75 Jun 23 '20 at 20:58
  • Related: https://stackoverflow.com/questions/4985414/how-to-enable-gdb-pretty-printing-for-c-stl-objects-in-eclipse-cdt – HolyBlackCat Jun 23 '20 at 21:06

2 Answers2

3

I re-installed using the 64bit version of MinGW from sourceforge as I had an old 32 bit version running via mingw-get.

Robscot75
  • 81
  • 1
  • 4
0

One possible cause is that pretty-printing did not display UTF-8 content correctly. You can either:

  1. Set it to UTF-8 charset (VSCode debugger having issues with character encoding)
  2. Disable pretty-printing (Cannot see any variable values while debugging)
Adrian Mole
  • 49,934
  • 160
  • 51
  • 83
Ielixmar
  • 58
  • 4