在设备上调试时,XCode/GDB 在自动继续断点处停止

发布于 2024-10-14 02:37:14 字数 746 浏览 5 评论 0原文

我刚刚发现(感谢另一个非常有帮助的帖子) 我可以使用 GDB 命令创建断点,将信息记录到 GDB 控制台,无论是在设备上还是在模拟器上进行调试。这就像 NSLog,但更好的是您不必等待控制台跟上,您没有烦人的时间戳,并且您可以在运行时通过 XCode 断点视图打开/关闭它们)。

非常好,我投入了时间来弄清楚如何最好地一起记录消息和变量。 (使用 GDB 命令 po [NSString stringWithFormat: @"Your message: %d %@",variable,[[object expression] description]])以获得最大的多功能性。

模拟器中的一切都运行得非常好。当我最终开始进行设备调试时,我收到的消息很好,但 GDB 在每个断点上都停止,尽管我通过选中断点视图中的框将它们配置为自动继续。

我尝试向每个断点添加一个“继续”命令,它起作用了,但 GDB 也开始喷出有关每个断点命中的信息,并在每行之后告诉我“继续”。

我的问题:

  1. 你会遇到这种情况吗?
  2. 我可以更改一些内容,以便自动继续功能也可以在设备上运行吗?
  3. 我可以告诉 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:

  1. Does this happen for you?
  2. Can I change something so that auto-continue also works on the device
  3. Can I tell GDB to be less verbose and only give me the output I print?

Please help!!

David

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

韵柒 2024-10-21 02:37:14

David,

您可能想熟悉一些有用的控制台命令。

info b (lists all breakpoints)
ena (enables all breakpoints)
dis (disables all breakpoints)
ena X (enable breakpoint number X)
dis X (disable breakpoint number X)

GDB 还支持条件断点:

cond X [condition]

并且,命中断点时自动执行的命令:

command X 

Aaron

David,

There are some useful console commands that you might want to familiarize yourself with.

info b (lists all breakpoints)
ena (enables all breakpoints)
dis (disables all breakpoints)
ena X (enable breakpoint number X)
dis X (disable breakpoint number X)

GDB also supports conditional breakpoints:

cond X [condition]

And, commands to execute automatically when a breakpoint is hit:

command X 

Aaron

棒棒糖 2024-10-21 02:37:14

另一个非常有用的选项是观察点 - 仅当给定表达式更改时才中断。

Another very useful option is a watchpoint - break only when given expression changes.

獨角戲 2024-10-21 02:37:14

我也遇到过同样的行为。事实证明,XCode 在预期的行上重复了断点。也许存在一个错误,左键单击偶尔会添加隐藏的断点而不是禁用?

解决方案是这样的:

  1. 选择左侧导航器框架的“断点导航器”选项卡
  2. ,手动或通过在导航器底部的搜索框中输入类名来查找重复的断点。 (请记住,列表的多个项目部分可能都包含同一类的断点)
  3. 右键单击其中一个并选择“编辑”以确定是否继续。
  4. 右键单击不需要的断点并删除

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:

  1. Select the "Breakpoint Navigator" tab of the Navigator frame on the left
  2. Look for duplicate breakpoints either manually or by entering the class name in the search box at the bottom of the Navigator. (remember that multiple project sections of the list may both contain a breakpoint for the same class)
  3. Right-click on one and select Edit to figure out if it's the continue or not.
  4. Right-click on the unwanted breakpoint and delete
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文