0

I recently have learnt about debugging inside vscode where I am trying to debug a simple cpp file.

#include <bits/stdc++.h>
using namespace std;
int main()
{

bool test = true;
int i = 0;
vector<int> v;
while (test)
{
    if (i == 5)
        test = false;
    else
    {
        cout << i << " ";
        i++;
        v.push_back(i);
    }
}
return 0;}

like variable i, I want to see the values inside vector v at any point of execution. irrespective of returning values, the debugger is returning the address for vector(v). Is there a way to achieve the same?

vscode

I tried the same thing on some online cpp debugger where I can see this particular functionality. online cpp debugger

  • 2
    first thing, NEVER use `bits/stdc++.h` – rioV8 Apr 13 '22 at 20:14
  • 1
    This is called "pretty printers", and I believe is enabled by running `python register_libstdcxx_printers(None)` or `python from libstdcxx.v6.printers import register_libstdcxx_printers; register_libstdcxx_printers(None)` in GDB (in the debug console). If this is the stock C/C++ extension, you also need to prepend `-exec`. What MinGW distribution do you use? – HolyBlackCat Apr 13 '22 at 20:15
  • @HolyBlackCat Thanks for this... But I am new to this. Can you tell me where I need to put this code to work? I am using MinGW w64 GNU Compiler. – Satyam Kumar Apr 13 '22 at 20:45
  • @rioV8 I know the consequences of using `bits/stdc++.h` Just for the testing purpose, I tried that header. – Satyam Kumar Apr 13 '22 at 20:47
  • I already told you where to put it, into the "debug console". "Mingw w64" is not specific enough, there are numerous distributions. What site did you download it from? – HolyBlackCat Apr 13 '22 at 20:48
  • **https://nuwen.net/mingw.html** from here, I had downloaded this particular file **mingw-18.0-without-git.exe** – Satyam Kumar Apr 13 '22 at 20:54
  • When putting the above commands inside the debug console, it says **Python scripting is not supported in this copy of GDB.** – Satyam Kumar Apr 13 '22 at 21:06
  • Which means you got a jank version of MinGW (or at least of GDB). [MSYS2](https://stackoverflow.com/q/30069830/2752075) has a good one. – HolyBlackCat Apr 13 '22 at 21:14
  • Please begin your comments with `@username`, otherwise we don't get notifications. – HolyBlackCat Apr 13 '22 at 21:14

0 Answers0