search

Home  >  Q&A  >  body text

c++ - codeblock 调试时要怎么查看容器内元素的值?

ode

我像图中所示 在监视窗口输入 (decrptS.begin()) ,(decrptS.begin()+1)
显示

貌似是只能监视 raw type 基本类型

天蓬老师天蓬老师2767 days ago788

reply all(2)I'll reply

  • 天蓬老师

    天蓬老师2017-04-17 13:11:55

    I have never used CodeBlocks, but if a debugger wants to debug STL, it definitely needs a plug-in. A simple GDB or VC debugger will not work, and you need to add a plug-in.
    Because the internal implementation of each STL is different, for libstdc++, https://github.com/egmkang/gdb_printers__python
    If you are using libc++, you can see https://github.com/egmkang/pretty_printer_for_libcxx, The latter one was written by me

    I searched it for you, I’m really too lazy
    http://www.cnblogs.com/wanglikai91/archive/2011/11/08/2241432.html

    reply
    0
  • 黄舟

    黄舟2017-04-17 13:11:55

    If you use VC++2010 or above, the problem will be very simple. VC++'s debugger allows you to customize the appearance of the debugger when viewing element content, and it already comes with settings for STL . When you move the mouse over a container, it will directly tell you the contents of all containers. So @emgkang's answer says "Neither a simple GDB nor a VC debugger will work", which is wrong.

    I also wrote my own container class for some reason, and then used this xml to solve this problem. You only need to search for stl.natvis in the C drive, paste the file in the same folder, restart VC++, and your own class library plug-in will be ready. It is recommended that the questioner give it a try, use advanced tools, and don’t get hung up on CodeBlocks.

    https://github.com/vczh-libraries/Vlpp/blob/master/Release/vlpp.natvis

    reply
    0
  • Cancelreply