<legend id='gngUy'><style id='gngUy'><dir id='gngUy'><q id='gngUy'></q></dir></style></legend>

    <small id='gngUy'></small><noframes id='gngUy'>

    • <bdo id='gngUy'></bdo><ul id='gngUy'></ul>
  1. <tfoot id='gngUy'></tfoot>

    <i id='gngUy'><tr id='gngUy'><dt id='gngUy'><q id='gngUy'><span id='gngUy'><b id='gngUy'><form id='gngUy'><ins id='gngUy'></ins><ul id='gngUy'></ul><sub id='gngUy'></sub></form><legend id='gngUy'></legend><bdo id='gngUy'><pre id='gngUy'><center id='gngUy'></center></pre></bdo></b><th id='gngUy'></th></span></q></dt></tr></i><div id='gngUy'><tfoot id='gngUy'></tfoot><dl id='gngUy'><fieldset id='gngUy'></fieldset></dl></div>

      使用 gdb 调试 C++ STL/Boost 的最佳实践

      时间:2023-07-19

          <tbody id='vO6C5'></tbody>
          • <bdo id='vO6C5'></bdo><ul id='vO6C5'></ul>
            <i id='vO6C5'><tr id='vO6C5'><dt id='vO6C5'><q id='vO6C5'><span id='vO6C5'><b id='vO6C5'><form id='vO6C5'><ins id='vO6C5'></ins><ul id='vO6C5'></ul><sub id='vO6C5'></sub></form><legend id='vO6C5'></legend><bdo id='vO6C5'><pre id='vO6C5'><center id='vO6C5'></center></pre></bdo></b><th id='vO6C5'></th></span></q></dt></tr></i><div id='vO6C5'><tfoot id='vO6C5'></tfoot><dl id='vO6C5'><fieldset id='vO6C5'></fieldset></dl></div>

            <legend id='vO6C5'><style id='vO6C5'><dir id='vO6C5'><q id='vO6C5'></q></dir></style></legend>
              <tfoot id='vO6C5'></tfoot>

              1. <small id='vO6C5'></small><noframes id='vO6C5'>

                本文介绍了使用 gdb 调试 C++ STL/Boost 的最佳实践的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                用gdb调试,任何使用STL/boost的c++代码仍然是一场噩梦.任何在 STL 中使用过 gdb 的人都知道这一点.例如,在此处中查看一些调试会话的示例运行.

                Debugging with gdb, any c++ code that uses STL/boost is still a nightmare. Anyone who has used gdb with STL knows this. For example, see sample runs of some debugging sessions in code here.

                我试图通过收集提示来减轻痛苦.您能否评论我在下面收集的技巧(特别是您一直在使用的技巧以及您建议对它们进行的任何更改)-我列出的技巧是按技术性递减顺序排列的.

                I am trying to reduce the pain by collecting tips. Can you please comment on the tips I have collected below (particularly which ones you have been using and any changes you would recommend on them) - I have listed the tips is decreasing order of technicality.

                • 是否有人在使用 "Stanford GDB STL utils" 和 "UCF GDB utils"?是否有一些用于提升数据结构的实用程序?上面的实用程序似乎不能递归使用,例如在一个命令中以清晰的方式打印 boost::shared_ptr 的向量.
                • 编写您的 .gdbinit 文件.例如,包括在 UCF GDB 实用程序底部列出的 C++ 相关美化器.
                • 使用已检查/调试的 STL/Boost 库,例如 STLport.
                • 使用日志记录(例如此处所述)
                • Is anyone using "Stanford GDB STL utils" and "UCF GDB utils"? Is there some such utils for boost data structures? The utils above do not seem to be usable recursively, for example for printing vector of a boost::shared_ptr in a legible manner within one command.
                • Write your .gdbinit file. Include, for example, C++ related beautifiers, listed at the bottom of UCF GDB utils.
                • Use checked/debug STL/Boost library, such as STLport.
                • Use logging (for example as described here)

                更新:GDB 有一个新的 C++ 分支.

                推荐答案

                也许不是你要找的那种技巧",但我不得不说,我从 C++ 转向几年后的经验 &STL 到 C++ &提升 &STL 是我现在花在 GDB 上的时间比以前少了很多.我把这归结为以下几点:

                Maybe not the sort of "tip" you were looking for, but I have to say that my experience after a few years of moving from C++ & STL to C++ & boost & STL is that I now spend a lot less time in GDB than I used to. I put this down to a number of things:

                • 提升智能指针(特别是共享指针",以及需要性能时的指针容器).我不记得上次我必须写一个显式删除(删除是 C++ 恕我直言的转到").GDB 需要花费大量时间来追踪无效和泄漏的指针.
                • boost 充满了经过验证的代码,用于您可能会在其他情况下将劣质版本组合在一起.例如 boost::bimap 非常适合 LRU 缓存逻辑的通用模式.还有一堆 GDB 时间.
                • 采用单元测试.boost::test 的 AUTO 宏意味着设置测试用例绝对轻而易举(比 CppUnit 更容易).早在它被内置到您必须附加调试器的任何东西之前,它就会捕获很多东西.
                • 与此相关的是,像 boost::bind 这样的工具可以更轻松地进行测试设计.例如,算法可以更通用,并且与它们所操作的类型的联系更少;这使得将它们插入到测试垫片/代理/模拟对象等中变得更加容易(而且事实上,接触 boost 的模板特性会鼓励你敢于模板化"你以前从未考虑过的东西,产生类似的测试好处).
                • boost::array.C 数组"性能,在调试版本中进行范围检查.
                • boost 充满了很棒的代码,你会忍不住从中学习
                • boost smart pointers (particularly "shared pointer", and the pointer containers when performance is needed). I can't remember the last time I had to write an explicit delete (delete is the "goto" of C++ IMHO). There goes a lot of GDB time tracking down invalid and leaking pointers.
                • boost is full of proven code for things you'd probably hack together an inferior version of otherwise. e.g boost::bimap is great for the common pattern of LRU caching logic. There goes another heap of GDB time.
                • Adopting unittesting. boost::test's AUTO macros mean it's an absolute doddle to set up test cases (easier than CppUnit). This catches lots of stuff long before it gets built into anything you'd have to attach a debugger to.
                • Related to that, tools like boost::bind make it easier to design-for-test. e.g algorithms can be more generic and less tied up with the types they operate on; this makes plugging them into test shims/proxies/mock objects etc easier (that and the fact that exposure to boost's template-tasticness will encourage you to "dare to template" things you'd never have considered before, yielding similar testing benefits).
                • boost::array. "C array" performance, with range checking in debug builds.
                • boost is full of great code you can't help but learn from

                这篇关于使用 gdb 调试 C++ STL/Boost 的最佳实践的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:我如何使用 Boost Random 下一篇:boost::shared_ptr 和 std::shared_ptr 的同居

                相关文章

              2. <i id='DhX6Y'><tr id='DhX6Y'><dt id='DhX6Y'><q id='DhX6Y'><span id='DhX6Y'><b id='DhX6Y'><form id='DhX6Y'><ins id='DhX6Y'></ins><ul id='DhX6Y'></ul><sub id='DhX6Y'></sub></form><legend id='DhX6Y'></legend><bdo id='DhX6Y'><pre id='DhX6Y'><center id='DhX6Y'></center></pre></bdo></b><th id='DhX6Y'></th></span></q></dt></tr></i><div id='DhX6Y'><tfoot id='DhX6Y'></tfoot><dl id='DhX6Y'><fieldset id='DhX6Y'></fieldset></dl></div>

                  <tfoot id='DhX6Y'></tfoot>
                    <bdo id='DhX6Y'></bdo><ul id='DhX6Y'></ul>
                  1. <small id='DhX6Y'></small><noframes id='DhX6Y'>

                    <legend id='DhX6Y'><style id='DhX6Y'><dir id='DhX6Y'><q id='DhX6Y'></q></dir></style></legend>