防止特定线程上的断点-LLDB

发布于 2025-02-04 18:46:01 字数 193 浏览 1 评论 0原文

我知道如何创建/修改断点以仅使用Breakpoint修改< brekaskoint-id&gt>仅在特定线程上停止。 -t< thread-name>,但是我可以以相反的方式做到这一点,以防止断点停止特定线程?

我有一个日志线程,它使用与其他线程进行调试相同功能的函数,每次击中时都必须继续它是很烦人的。

I know how to create/modify a breakpoint to stop only on a specific thread using breakpoint modify <breakpoint-id> -T <thread-name>, but can I do it the other way around, preventing the breakpoint to stop on a specific thread?

I have a log thread that use the same function I'm trying to debug on other threads and it's annoying to have to let it continue every time it hits.

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

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

发布评论

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

评论(1

↙温凉少女 2025-02-11 18:46:01

您可以使用LLDB Python API和Python断点回调来执行此类操作。回调返回“应该停止”值,即如果返回该值,则如果返回为真,则在断点处停止,然后false您继续。

因此:例如:

(lldb) breakpoint command add -s python -o 'return frame.thread.name != "MyThread"'

您想要的是。请注意,在此示例中,我没有提供断点ID。在LLDB中,意思是“在最后一组断点上行动”。但是,如果要添加命令的命令并不是您设置的最后一个断点,也可以提供断点ID。而且,如果要将其添加到多个断点,则可以指定断点ID列表。

此处的API和回调格式还有更多内容:

https:// https://lldb.llldb.llv.m.org/python_api.htmll.htmlllv/python_api.htmll

https://lldb.llvm.org/use/python-reference.html#running-a-python-script-when-a-abreakpoint-gets-hit

请注意,这会与应有的 -停止回调每次击中断点时都会迫使停止。 LLDB自动符合很快,因此对于许多应用程序,这不是问题。但是,从停车到调试器和后退并不便宜,因此,如果您的断点处于工作循环中并每秒击中数十万次,这将减慢速度。如果最终是一个问题,并且您可以控制源代码,那么像Eljay在评论中建议的技巧非常方便。

You can do this sort of thing using the lldb Python API and Python breakpoint callbacks. The callback returns a "should stop" value, i.e. if it returns True, you stop at the breakpoint, and False you continue.

So for instance:

(lldb) breakpoint command add -s python -o 'return frame.thread.name != "MyThread"'

is what you wanted. Note, in this example, I didn't provide a breakpoint ID. In lldb that means "act on the last set breakpoint". But you can also supply the breakpoint ID if the one you want to add the command to doesn't happen to be the last breakpoint you set. And if you want to add it to multiple breakpoints, you can specify a breakpoint ID list.

There's more on the API's and the callback format here:

https://lldb.llvm.org/python_api.html

https://lldb.llvm.org/use/python-reference.html#running-a-python-script-when-a-breakpoint-gets-hit

Note, however, that breakpoints with should-stop callbacks will force a stop every time the breakpoint is hit. lldb auto-continues pretty quickly, so for many applications this isn't a problem. But just getting from the stop over to the debugger and back is not cheap, so if your breakpoint is in a work loop and getting hit hundreds of thousands of times a second, this is going to slow down the run. If that ends up being a problem and you control your source code, tricks like the one Eljay suggested in the comments can be really handy.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文