0

I am following the VS Code tutorial on Using GCC with MinGW but have some issues when it comes to the debugger.

I have installed Cygwin gcc-g++ (Version:10.2.0-1) and am able to compile and create an .exe with the basic "Hello World" source code they provided. Debugging using Cygwin gdb (Version: 9.2-1) also starts and executes without issue.

The debugger seems to be working fine: I can see local variables, add varaibles to the Watch list, step through the program and set breakpoints as needed. My issue is that the variables list looks vastly different than that shown in the referenced tutorial and much more complicated.

It shows quite a bit of detail (allocators used, type definitions, pointer values, etc) but does not (as far as I can tell) show arguably the most important item when debugging: the variables value.

See the picture below to see what I mean. Note that variable "msg" here is the same as declared in the tutorial:

vector<string> msg {"Hello", "C++", "World", "from", "VS Code", "and the C++ extension!"};

Surely I am missing something here, but cannot figure out what.

enter image description here

5
  • You're not. msg is a std::vector<string>. It's not a simple type once you look under the hood. If you want to see the elements, start with _M_start. It can make you appreciate the phrase "it just works." Commented Apr 7, 2021 at 19:29
  • Yes I get that, but why then does the tutorial I linked show a much more simplified view? Each element of the vector is immediately presented [0]: "Hello" [1]: "C++", etc. No matter how many of the different properties I expand, I can never reach something that looks like this. Commented Apr 7, 2021 at 19:35
  • Does it really matter? For what it's worth, your view is what I see using WSL. Commented Apr 7, 2021 at 19:39
  • Yes? Well, in this specific example, no, because I know exactly what this vector string is filled with. But in general, I would like to see the values contained in, for example, a vector of strings while debugging. Shouldn't this be possible? The closest I could get with the current configuration (by opening many, many of the expandable arrows) was the first value of the string, "Hello". Commented Apr 7, 2021 at 19:47
  • I mean, you say you're following that guide, but you installed Cygwin instead of the minGW-w64 installation they recommended. Technically, you were off the rails from the beginning. Maybe that's all that needs fixing. Who knows. Does your launch.json match the guide's? What about tasks.json? You just came here, said everything was working fine, but you don't like the way your debugger window presents variables, even though all the information is there. Maybe the screenshot is just being re-used and isn't accurate. Commented Apr 7, 2021 at 20:03

1 Answer 1

1

My issue was I was using Cygwin instead of minGW as @sweenish pointed out. After installing minGW and reconfiguring all the required settings (tasks.json/launch.josn/etc), the variables appear as they should. The issue with using the Cygwin implementation is probably something to do with the "pretty-print" libraries.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.