在设备上调试时,XCode/GDB 在自动继续断点处停止
我刚刚发现(感谢另一个非常有帮助的帖子) 我可以使用 GDB 命令创建断点,将信息记录到 GDB 控制台,无论是在设备上还是在模拟器上进行调试。这就像 NSLog,但更好的是您不必等待控制台跟上,您没有烦人的时间戳,并且您可以在运行时通过 XCode 断点视图打开/关闭它们)。
非常好,我投入了时间来弄清楚如何最好地一起记录消息和变量。 (使用 GDB 命令 po [NSString stringWithFormat: @"Your message: %d %@",variable,[[object expression] description]]
)以获得最大的多功能性。
模拟器中的一切都运行得非常好。当我最终开始进行设备调试时,我收到的消息很好,但 GDB 在每个断点上都停止,尽管我通过选中断点视图中的框将它们配置为自动继续。
我尝试向每个断点添加一个“继续”命令,它起作用了,但 GDB 也开始喷出有关每个断点命中的信息,并在每行之后告诉我“继续”。
我的问题:
- 你会遇到这种情况吗?
- 我可以更改一些内容,以便自动继续功能也可以在设备上运行吗?
- 我可以告诉 GDB 不那么冗长,只提供我打印的输出吗?
请帮忙!!
大卫
I just discovered (thanks to another very helpful post) that I can use GDB commands to create breakpoints that log information to the GDB console, whether debugging on the device or simulator. This is like NSLog, but much nicer in that you don't have to wait for the console to catch up, you don't have annoying timestamps, and you can turn them on/off at run time via the XCode breakpoint view).
Very nice, and I invested time figuring out how best to log messages and variables together. (Use the GDB command po [NSString stringWithFormat: @"Your message: %d %@",variable,[[object expression] description]]
) for maximum versatility.
Everything worked wonderfully in the simulator. When I finally got around to device debugging, I was getting the messages just fine, but GDB was STOPPING on every breakpoint despite the fact that I configured them to auto-continue by checking the box in the breakpoint view.
I tried adding a "continue" commmand to each breakpoint, and it worked but GDB also started spewing information about every breakpoint hit and telling me "Continuing" after every line.
My questions:
- Does this happen for you?
- Can I change something so that auto-continue also works on the device
- Can I tell GDB to be less verbose and only give me the output I print?
Please help!!
David
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
David,
您可能想熟悉一些有用的控制台命令。
GDB 还支持条件断点:
并且,命中断点时自动执行的命令:
Aaron
David,
There are some useful console commands that you might want to familiarize yourself with.
GDB also supports conditional breakpoints:
And, commands to execute automatically when a breakpoint is hit:
Aaron
另一个非常有用的选项是观察点 - 仅当给定表达式更改时才中断。
Another very useful option is a watchpoint - break only when given expression changes.
我也遇到过同样的行为。事实证明,XCode 在预期的行上重复了断点。也许存在一个错误,左键单击偶尔会添加隐藏的断点而不是禁用?
解决方案是这样的:
I've run into the same behavior. It turned out that XCode had duplicated the breakpoint at the intended line. Perhaps there's a bug where a left click occasionally adds a hidden breakpoint rather than disabling?
The solution was this: