热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

通过添加'print'语句进行调试的正确名称是什么-Whatisthepropernamefordoingdebuggingbyadding'print'statements

Therearemanywaysofdoingdebugging,usingadebuggerisone,butthesimpleoneforthehumble,

There are many ways of doing debugging, using a debugger is one, but the simple one for the humble, lazy, programmer is to just add a bunch of print statements to your code.

有许多方法可以进行调试,使用调试器就是其中之一,但对于谦虚,懒惰的程序员来说,简单的方法就是在代码中添加一堆打印语句。

i.e.

 def foo(x):
     print 'Hey wow, we got to foo!', x

     ...

     print 'foo is returning:', bar
     return bar

Is there a proper name for this style of debugging?

这种调试方式是否有正确的名称?

19 个解决方案

#1


50  

Yes - it's known as printf() debugging, named after the ubiquitous C function:

是的 - 它被称为printf()调试,以无处不在的C函数命名:

Used to describe debugging work done by inserting commands that output more or less carefully chosen status information at key points in the program flow, observing that information and deducing what's wrong based on that information.

用于描述通过插入命令来完成调试工作,这些命令在程序流程的关键点输出或多或少精心选择的状态信息,观察该信息并根据该信息推断出错误。

-- printf() debugging@everything2

- printf()debugging @ everything2

Native users of other languages no doubt refer to it by the default print / log / or trace command available for their coding platform of choice, but i've heard the "printf()" name used to refere to this technique in many languages other than C. Perhaps this is due to its history: while BASIC and FORTRAN had basic but serviceable PRINT commands, C generally required a bit more work to format various data types: printf() was (and often still is) by far the most convenient means to this end, providing many built-in formatting options. Its cousin, fprintf(), takes another parameter, the stream to write to: this allowed a careful "debugger" to direct diagnostic information to stderr (possibly itself redirected to a log file) while leaving the output of the program uncorrupted.

其他语言的原生用户毫无疑问通过可用于其编码平台的默认print / log /或trace命令来引用它,但我听说过“printf()”名称用于以其他语言引用此技术可能这是由于它的历史:虽然BASIC和FORTRAN具有基本但可维护的PRINT命令,但C通常需要更多的工作来格式化各种数据类型:printf()是(并且通常仍然是)最方便的意味着为此,提供了许多内置的格式化选项。它的堂兄fprintf()接受另一个参数,即要写入的流:这允许小心的“调试器”将诊断信息定向到stderr(可能自身重定向到日志文件),同时保持程序输出不被破坏。

Although often looked down on by users of modern debugging software, printf() debugging continues to prove itself indispensable: the wildly popular FireBug tool for the Firefox web browser (and similar tools now available for other browsers) is built around a console window into which web page scripts can log errors or diagnostic messages containing formatted data.

虽然现代调试软件的用户经常看不起,但printf()调试仍然证明自己是不可或缺的:用于Firefox网络浏览器的流行的FireBug工具(以及现在可用于其他浏览器的类似工具)是围绕控制台窗口构建的。网页脚本可以记录包含格式化数据的错误或诊断消息。

#2


29  

I've heard it called Caveman Debugging

我听说它叫做Caveman Debugging

#3


24  

I thought the following quote would be apropos:

我认为以下引用将是适当的:

"The most effective debugging tool is still careful thought, coupled with judiciously placed print statements."

“最有效的调试工具仍然经过深思熟虑,再加上明智的打印声明。”

  • Brian Kernighan, "Unix for Beginners" (1979)
  • Brian Kernighan,“Unix初学者”(1979)

#4


17  

I call it Tracing.

我称之为追踪。

#5


6  

me and my team mates calling it "Oldschool Debuging".

我和我的队友称之为“Oldschool Debuging”。

#6


5  

In the same sense as exploratory programming, I like calling it exploratory debugging. This follows when the debugger is not powerful enough to examine complex types in the program, or invoke helper functions separately, or you just don't know enough about a bug to use said features directly.

与探索性编程一样,我喜欢称之为探索式调试。当调试器的功能不足以检查程序中的复杂类型,或单独调用辅助函数,或者您只是不了解直接使用所述功能的错误时,就会出现这种情况。

#7


5  

I call this "Hi, Mom" programming.

我称之为“嗨,妈妈”编程。

#8


5  

Seat of your pants debugging :)

你的裤子座位调试:)

When you're on an embedded system, when you're at the bleeding edge and the language you're coding in doesn't have a debugger yet, when your debugger is behaving strangely and you want to restore some sanity, and you want to understand how re-entrancy is working in multi-threaded code,....

当你在嵌入式系统上时,当你处于最前沿时,你编写的语言还没有调试器,当你的调试器表现得很奇怪并且你想要恢复一些理智,你想要要理解多线程代码中的重入是如何工作的,....

#9


4  

I have also heard the term "MessageBox debugging" from the VB crowd to refer to this 'style' of 'debugging'.

我也听过VB人群中的“MessageBox调试”这个术语,指的是'调试'的'风格'。

#10


4  

I embedded systems its often the only method to instrument the code. Unfortunately printing takes time and effects the real-time flow of the system. So we also instrument via "tracing" where information about the state of the system (function entry exit etc) is written to a internal buffer to be dumped and parsed later. Real embedded programmers can debug by blinking an LED ;)

我嵌入式系统通常是检测代码的唯一方法。不幸的是,打印需要时间并影响系统的实时流程。因此,我们还通过“跟踪”进行检测,其中有关系统状态(函数入口退出等)的信息被写入内部缓冲区以便稍后转储和解析。真正的嵌入式程序员可以通过闪烁LED进行调试;)

#11


3  

I've heard "Gutenberg debugging" being used, in the honor of the guy who invented the printing press.

为了纪念发明印刷机的人,我听说“Gutenberg调试”正在使用中。

#12


3  

I would call it simply "logging".

我称之为“记录”。

#13


2  

I usually refer to it as tracing.

我通常称它为追踪。

Note that in Visual Studio you can set breakpoints which just add tracing. Right click on a breakpoint, select "when hit..." and check the "Print a message" option.

请注意,在Visual Studio中,您可以设置仅添加跟踪的断点。右键单击断点,选择“点击时...”并选中“打印消息”选项。

#14


2  

Also, in .Net you can add debugging statements (I think it actually is Debug.WriteLine) to output to the console. These statments are only included in debug builds - the compiler will automatically leave them out when you do a release build.

此外,在.Net中,您可以添加调试语句(我认为它实际上是Debug.WriteLine)以输出到控制台。这些语句仅包含在调试版本中 - 编译器会在您执行发布版本时自动将它们排除在外。

#15


2  

Classic Debugging

#16


1  

Manual Assertions? Debugger Phobia?

手动断言?调试器恐惧症?

#17


1  

verbose debugging !

详细调试!

#18


1  

(Good logging is incredibly valuable for debugging problems in running production systems. Lots of useless verbose print statements aren't, but logging something interesting when something important or unexpected occurred is incredibly important. If the only way you know how to debug problems is with a debugger, you're going to find yourself in quite the tight spot when the service you've built is broken for some of your users but you can't reproduce the problem locally.)

(良好的日志记录对于调试运行生产系统中的问题非常有价值。许多无用的详细打印语句不是,但在发生重要或意外事件时记录一些有趣的东西非常重要。如果您知道如何调试问题的唯一方法是一个调试器,如果您为某些用户破坏了您构建的服务但是您无法在本地重现该问题,那么您将发现自己处于相当紧张的位置。)

#19


1  

I have always known it by the term 'quick-and-dirty debugging', or just 'dirty debugging' in short.

我总是用“快速和脏调试”这个词来形容它,或者简称为“脏调试”。


推荐阅读
  • 本文介绍了Windows操作系统的版本及其特点,包括Windows 7系统的6个版本:Starter、Home Basic、Home Premium、Professional、Enterprise、Ultimate。Windows操作系统是微软公司研发的一套操作系统,具有人机操作性优异、支持的应用软件较多、对硬件支持良好等优点。Windows 7 Starter是功能最少的版本,缺乏Aero特效功能,没有64位支持,最初设计不能同时运行三个以上应用程序。 ... [详细]
  • 本文由编程笔记#小编为大家整理,主要介绍了logistic回归(线性和非线性)相关的知识,包括线性logistic回归的代码和数据集的分布情况。希望对你有一定的参考价值。 ... [详细]
  • 向QTextEdit拖放文件的方法及实现步骤
    本文介绍了在使用QTextEdit时如何实现拖放文件的功能,包括相关的方法和实现步骤。通过重写dragEnterEvent和dropEvent函数,并结合QMimeData和QUrl等类,可以轻松实现向QTextEdit拖放文件的功能。详细的代码实现和说明可以参考本文提供的示例代码。 ... [详细]
  • sklearn数据集库中的常用数据集类型介绍
    本文介绍了sklearn数据集库中常用的数据集类型,包括玩具数据集和样本生成器。其中详细介绍了波士顿房价数据集,包含了波士顿506处房屋的13种不同特征以及房屋价格,适用于回归任务。 ... [详细]
  • 开发笔记:实验7的文件读写操作
    本文介绍了使用C++的ofstream和ifstream类进行文件读写操作的方法,包括创建文件、写入文件和读取文件的过程。同时还介绍了如何判断文件是否成功打开和关闭文件的方法。通过本文的学习,读者可以了解如何在C++中进行文件读写操作。 ... [详细]
  • 先看官方文档TheJavaTutorialshavebeenwrittenforJDK8.Examplesandpracticesdescribedinthispagedontta ... [详细]
  • 本文介绍了OpenStack的逻辑概念以及其构成简介,包括了软件开源项目、基础设施资源管理平台、三大核心组件等内容。同时还介绍了Horizon(UI模块)等相关信息。 ... [详细]
  • IOS开发之短信发送与拨打电话的方法详解
    本文详细介绍了在IOS开发中实现短信发送和拨打电话的两种方式,一种是使用系统底层发送,虽然无法自定义短信内容和返回原应用,但是简单方便;另一种是使用第三方框架发送,需要导入MessageUI头文件,并遵守MFMessageComposeViewControllerDelegate协议,可以实现自定义短信内容和返回原应用的功能。 ... [详细]
  • Android工程师面试准备及设计模式使用场景
    本文介绍了Android工程师面试准备的经验,包括面试流程和重点准备内容。同时,还介绍了建造者模式的使用场景,以及在Android开发中的具体应用。 ... [详细]
  • 基于Socket的多个客户端之间的聊天功能实现方法
    本文介绍了基于Socket的多个客户端之间实现聊天功能的方法,包括服务器端的实现和客户端的实现。服务器端通过每个用户的输出流向特定用户发送消息,而客户端通过输入流接收消息。同时,还介绍了相关的实体类和Socket的基本概念。 ... [详细]
  • 合并列值-合并为一列问题需求:createtabletab(Aint,Bint,Cint)inserttabselect1,2,3unionallsel ... [详细]
  • 本文介绍了在Cpp中将字符串形式的数值转换为int或float等数值类型的方法,主要使用了strtol、strtod和strtoul函数。这些函数可以将以null结尾的字符串转换为long int、double或unsigned long类型的数值,且支持任意进制的字符串转换。相比之下,atoi函数只能转换十进制数值且没有错误返回。 ... [详细]
  • 本文介绍了使用Python编写购物程序的实现步骤和代码示例。程序启动后,用户需要输入工资,并打印商品列表。用户可以根据商品编号选择购买商品,程序会检测余额是否充足,如果充足则直接扣款,否则提醒用户。用户可以随时退出程序,在退出时打印已购买商品的数量和余额。附带了完整的代码示例。 ... [详细]
  • HashMap的相关问题及其底层数据结构和操作流程
    本文介绍了关于HashMap的相关问题,包括其底层数据结构、JDK1.7和JDK1.8的差异、红黑树的使用、扩容和树化的条件、退化为链表的情况、索引的计算方法、hashcode和hash()方法的作用、数组容量的选择、Put方法的流程以及并发问题下的操作。文章还提到了扩容死链和数据错乱的问题,并探讨了key的设计要求。对于对Java面试中的HashMap问题感兴趣的读者,本文将为您提供一些有用的技术和经验。 ... [详细]
  • 本文介绍了在Linux中执行.sh脚本时出现/bin/sh^M: bad interpreter: No such file or directory异常的原因分析,并提供了两种解决方法:在Windows下进行编码格式转换,或在Linux中修改文件格式和执行权限。具体操作步骤也在摘要中给出。 ... [详细]
author-avatar
mobiledu2502934191
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有