Environment requirements: Python (2.7 version can, 3.x not measured), MinGW official version (you may already have), gdb2013-02-04 (here https://code.google.com/p/qp-gcc/downloads/ List download, if there is a newer version, should also be able, currently 2013-02-04 is the latest version)
The recommended way for GDB to support STL is to use Python script. It is said that all aspects are better than that stl-views-1.0.3.gdb (for this, can refer to http://blog.csdn.net/someonea/article/details/2979369)
Currently the MINGW official GDB is 7.6.1 and does not support Python script. The way to check if it supports Python scripting is to: Enter the GDB terminal:
Python print sys.version If the version number is printed, it is OK, otherwise, it will say that GDB does not support
Https://code.google.com/p/qp-gcc/downloads/list the GDB in this link is Python-enabled, you can download it and add it to the front of the PATH environment variable, This will be used by default when starting from CMD (because it looks like the system read PATH variable is read from left to right, find the first one to end)
Then run GDB at the terminal and enter Python print sys.version to verify
Then save the following code to PP.GDB (theoretically, any directory can be, but recommended in the personal directory, such as C:\Users\your_username, or working directory, two places to put a copy is OK)
python Import 'c:/mingw/share/gcc-4.7.2/python/libstdcxx/v6') from Import register_libstdcxx_printersregister_libstdcxx_printers (None) End
Note that the above directory should be changed according to your actual situation, for example, mine is
Sys.path.insert (0, ' d:/mingw/share/gcc-4.8.1/python/libstdcxx/v6 ')
Then, when you start GDB, you can enter the source pp.gdb in the GDB terminal (if you put it in your personal directory, you may want to add a directory prefix), you will load the settings here, you can see the contents of the STL
However, it is a bit of a hassle to enter this command every time you start, we can put this command in the. Gdbinit and let gdb load automatically when it starts
I find it impossible to put. Gdbinit in the current working directory, Gdb.exe directory, a feasible method is:
Put the. Gdbinit into your personal directory, such as C:\Users\your_username, and put the pp.gdb in the same directory. Gdbinit is the source pp.gdb
Then set the environment variable home for Windows to C:\Users\your_username (on my Computer, this environment variable does not exist, you might as well)
This will do so, and when you start GDB, it will automatically load. gdbinit, you can automatically use Python script to print the contents of the STL, using the same method and printing common variables, is the P variable_name
Reference:
Http://wiki.codeblocks.org/index.php?title=Pretty_Printers
Https://sourceware.org/gdb/wiki/STLSupport