简体   繁体   English

调试器失败时如何调试程序

[英]How can I debug a program when debugger fails

I am debugging an Iphone program with the simulator in xCode and I have one last issue to resolve but I need help resolving it for the following reason: when it happens the program goes into debugging mode but no errors appear (no BAD ACCESS appears) and it does not show where the code fails. 我正在使用xCode中的模拟器调试Iphone程序,但我有最后一个问题要解决,但由于以下原因我需要帮助解决该问题:发生这种情况时,程序进入调试模式,但没有错误出现(没有错误访问),并且它不会显示代码在哪里失败。 Putting some variables as global helps me to see their values to start pin pointing where the bug is but before I go into this fully I would like to know what techniques/tools you guys use to debug these situations. 将一些变量设置为全局变量可以帮助我查看它们的值,以开始指出错误的位置,但是在我全面研究之前,我想知道你们用来调试这些情况的技术/工具。

If it helps Im debugging the following: I merged some code into the SpeakHere demo. 如果它可以帮助我调试以下内容:我将一些代码合并到SpeakHere演示中。 The code was added in the C++ modules of the program (AQRecorder.h and .mm). 该代码已添加到程序的C ++模块(AQRecorder.h和.mm)中。 I seem to have pinpointed the problem code in a function I wrote. 我似乎已经在我编写的函数中指出了问题代码。

My favourite is always to add debugging code and log it to a file. 我最喜欢的总是添加调试代码并将其记录到文件中。 This allows me so report any and all information I need to resolve the issue if the debugger is not working properly. 这样,我可以报告调试器无法正常运行时解决该问题所需的所有信息。

I normally control the debugging code by use of a flag which I can manipulate at run time or by the command line. 通常,我使用一个可以在运行时或通过命令行操作的标志来控制调试代码。

If the error is (and it probably is) a memory management issue, printing log entries is really not going to help. 如果错误是(很可能是)内存管理问题,则打印日志条目真的无济于事。

I would reccomend learning how to use Instruments, and use its tools to track down the memory leak when it occurs rather than waiting until the application crashes later on. 我建议学习如何使用Instruments,并使用其工具来跟踪发生的内存泄漏,而不必等到以后应用程序崩溃。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM