为什么在 IDE 中调试更好? [英] Why is debugging better in an IDE?

查看:17
本文介绍了为什么在 IDE 中调试更好?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从事软件开发已有 20 多年了,使用 C、Perl、SQL、Java、PHP、JavaScript 和最近的 Python 进行编程.我从来没有遇到过我无法通过仔细考虑调试的问题,以及正确放置的调试 print 语句.

I've been a software developer for over twenty years, programming in C, Perl, SQL, Java, PHP, JavaScript, and recently Python. I've never had a problem I could not debug using some careful thought, and well-placed debugging print statements.

我尊重很多人说我的技术很原始,在 IDE 中使用真正的调试器要好得多.然而,根据我的观察,IDE 用户使用我的石刀和熊皮似乎并没有比我调试得更快或更成功.我真诚地愿意学习正确的工具,但从未有人向我展示过使用可视化调试器具有令人信服的优势.

I respect that many people say that my techniques are primitive, and using a real debugger in an IDE is much better. Yet from my observation, IDE users don't appear to debug faster or more successfully than I can, using my stone knives and bear skins. I'm sincerely open to learning the right tools, I've just never been shown a compelling advantage to using visual debuggers.

此外,除了如何设置断点和显示变量内容的基础知识之外,我从未阅读过介绍如何使用 IDE 进行有效调试的教程或书籍.

Moreover, I have never read a tutorial or book that showed how to debug effectively using an IDE, beyond the basics of how to set breakpoints and display the contents of variables.

我错过了什么?是什么让 IDE 调试工具比仔细使用诊断 print 语句更有效?

What am I missing? What makes IDE debugging tools so much more effective than thoughtful use of diagnostic print statements?

您能否推荐一些资源(教程、书籍、截屏视频)来展示更精细的 IDE 调试技术?

Can you suggest resources (tutorials, books, screencasts) that show the finer techniques of IDE debugging?

甜蜜的答案!非常感谢大家抽出宝贵的时间.很有启发性.我投了很多票,没有投反对票.

Sweet answers! Thanks much to everyone for taking the time. Very illuminating. I voted up many, and voted none down.

一些值得注意的点:

  • 调试器可以帮助我对变量、代码或运行时环境的任何其他方面进行临时检查或更改,而手动调试需要我停止、编辑和重新执行应用程序(可能需要重新编译).
  • 调试器可以附加到正在运行的进程或使用故障转储,而手动调试则需要重现"缺陷的步骤.
  • 调试器可以以更易读的方式轻松显示复杂的数据结构、多线程环境或完整的运行时堆栈.
  • 调试器提供了许多方法来减少执行几乎所有调试任务的时间和重复性工作.
  • 可视化调试器和控制台调试器都很有用,并且有许多共同的特性.
  • 集成到 IDE 中的可视化调试器还可让您在单个集成开发环境(因此得名)中方便地访问智能编辑和 IDE 的所有其他功能.
  • Debuggers can help me do ad hoc inspection or alteration of variables, code, or any other aspect of the runtime environment, whereas manual debugging requires me to stop, edit, and re-execute the application (possibly requiring recompilation).
  • Debuggers can attach to a running process or use a crash dump, whereas with manual debugging, "steps to reproduce" a defect are necessary.
  • Debuggers can display complex data structures, multi-threaded environments, or full runtime stacks easily and in a more readable manner.
  • Debuggers offer many ways to reduce the time and repetitive work to do almost any debugging tasks.
  • Visual debuggers and console debuggers are both useful, and have many features in common.
  • A visual debugger integrated into an IDE also gives you convenient access to smart editing and all the other features of the IDE, in a single integrated development environment (hence the name).

推荐答案

IDE 调试器将通过代码中的跟踪消息为您提供的一些功能示例:

Some examples of some abilities that an IDE debugger will give you over trace messages in code:

  • 随时查看调用堆栈,为您提供当前堆栈框架的上下文.
  • 进入您无法重新编译以添加跟踪的库(假设您可以访问调试符号)
  • 在程序运行时更改变量值
  • 编辑并继续 - 在代码运行时更改代码并立即查看更改结果的能力
  • 能够观察变量,了解它们何时发生变化
  • 能够跳过或重复代码部分,以查看代码的执行情况.这使您可以在进行理论更改之前对其进行测试.
  • 实时检查内存内容
  • 在抛出某些异常时提醒您,即使它们是由应用程序处理的.
  • 条件断点;仅在特殊情况下停止应用程序,以便您分析堆栈和变量.
  • 在多线程应用程序中查看线程上下文,这可能难以通过跟踪实现(因为来自不同线程的跟踪将在输出中交错).
  • View the call stack at any point in time, giving you a context for your current stack frame.
  • Step into libraries that you are not able to re-compile for the purposes of adding traces (assuming you have access to the debug symbols)
  • Change variable values while the program is running
  • Edit and continue - the ability to change code while it is running and immediately see the results of the change
  • Be able to watch variables, seeing when they change
  • Be able to skip or repeat sections of code, to see how the code will perform. This allows you to test out theoretical changes before making them.
  • Examine memory contents in real-time
  • Alert you when certain exceptions are thrown, even if they are handled by the application.
  • Conditional breakpointing; stopping the application only in exceptional circumstances to allow you to analyse the stack and variables.
  • View the thread context in multi-threaded applications, which can be difficult to achieve with tracing (as the traces from different threads will be interleaved in the output).

总之,打印语句(通常)是静态的,如果您的原始语句不够详细,您需要重新编译以获取更多信息.IDE 消除了这种静态障碍,为您提供了一个触手可及的动态工具包.

In summary, print statements are (generally) static and you'll need to re-compile to get additional information if your original statements weren't detailed enough. The IDE removes this static barrier, giving you a dynamic toolkit at your fingertips.

当我第一次开始编码时,我不明白调试器有什么大不了的,我认为我可以通过跟踪实现任何目标(当然,那是在 unix 上,调试器是 GDB).但是一旦你学会了如何正确使用图形调试器,你就不想再回到打印语句了.

When I first started coding, I couldn't understand what the big deal with debuggers was and I thought I could achieve anything with tracing (granted, that was on unix and the debugger was GDB). But once you learn how to properly use a graphical debugger, you don't want to go back to print statements.

这篇关于为什么在 IDE 中调试更好?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆