• 请不要在回答技术问题时复制粘贴 AI 生成的内容
oldman
V2EX  ›  程序员

单步调试是不是本身就是个错误?大家平时怎么De-Bug(广义)的?

  •  
  •   oldman · Jun 29, 2011 · 5934 views
    This topic created in 5438 days ago, the information mentioned may be changed or developed.
    5 replies    1970-01-01 08:00:00 +08:00
    oldman
        1
    oldman  
    OP
       Jun 29, 2011
    呃,都没人回答啊。。我先说说我自己的吧

    现在工作主业是c++的Windows平台开发,开发过程中一般出啥问题也就是调试为主;只是现在越来越接触脚本,发现脚本世界的大家都不提倡单步调试,我也是这样做的,那么现在的问题是这样的:
    (1)是因为脚本不太好调试而大家不提倡调试,还是单步调试的思路本身就是不对的?
    (2)非脚本世界里可不可以继续推行不提倡调试的思想?
    dreampuf
        2
    dreampuf  
       Jun 29, 2011
    也许这里的讨论会对你有帮助
    http://stackoverflow.com/questions/602138/is-a-debugger-the-mother-of-all-evil

    + you're wasting your time because all that time put into debugging can never be reused. It's a one time hack in the sense that if you have another bug later, you'll probably need to start all over again, and
    + you've only solved this one bug, and while it might only occur for this specific scenario that you tested, you most likely did not solve a more general problem. That's because you're not thinking in generality, you're in a debugging mindset, not a general mindset.
    ayanamist
        3
    ayanamist  
       Jun 29, 2011
    我不是很赞同。断言确实有用,但如果大量使用断言是会降低性能的吧。而且在一些crash类的bug,依靠dump出来的东西进行debug是很常见的吧。
    yelusiku
        4
    yelusiku  
       Jun 29, 2011
    没有人会问木匠,美工刀本身是不是个错误。
    调试器只是种工具,论到工具的偏好,完全就是个人问题。

    软件开发涵盖的范围非常广,有些技术/方法论在某些领域非常适用,在另一些领域恰恰相反。
    比如楼主在windows下做c++开发,应该也接触过一些多线程同步的问题。
    这种问题就是有调试器的帮助也并不容易解决,更不用说断言、单元测试的无力了。
    这主要是因为这类问题的困难在于问题本身,好的工具也只能提供一些辅助。
    所以说软件工程领域没有银弹,调试技术不是,别的方法论也不会是。

    至于不提倡调试提倡TDD这种论战,个人更觉得是类似Windows vs Linux、Vim vs Emacs,倾向于宗教了。
    yelusiku
        5
    yelusiku  
       Jun 29, 2011
    @ayanamist 断言应该是不会影响性能的,毕竟最终的产品中不会包含断言。大量的logging如果包含在最终产品里,倒是会影响性能。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2664 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 15:32 · PVG 23:32 · LAX 08:32 · JFK 11:32
    ♥ Do have faith in what you're doing.