llvm带来很多很多好用的东西,比如clang,还有一个STL实现:libcxx.其优点不表,就说怎么打印STL容器内的元素吧.

  实际上gdb,包括任何调试工具,都是不了解STL的,因为他不知道STL内部是怎么实现的.所以需要展示STL内部元素的时候,就需要用到一些脚本,或者插件之类的(VS也是这样).gdb在7.x支持python写插件,所以很多人都用python插件来打印libstdc++容器内的元素.

  llvm官方本身没有实现pretty printers,包括lldb这个项目也一样(只是实现了部分容器的parser).

  本来还想讲讲怎么实现一个容器的parser,不过想想其实很简单了,看着sample很快就学会了.

  不卖关子了,这边给出llvm libcxx基本上所有容器的pretty printer,https://github.com/egmkang/pretty_printer_for_libcxx/

  暂时不支持vector<bool>和bitset,如果有需要的话,知会一声,我去写.

  写的时候参考了:

  http://tromey.com/blog/?p=524

  http://tromey.com/blog/?p=546

  https://access.redhat.com/knowledge/docs/en-US/Red_Hat_Enterprise_Linux/6/html/Developer_Guide/debuggingprettyprinters.html

  

相关文章:

  • 2022-12-23
  • 2021-09-22
  • 2021-09-14
  • 2022-02-09
  • 2021-11-23
  • 2021-11-15
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-03-08
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案