简体   繁体   English

XCode中宏的符号断点

[英]Symbolic breakpoint on Macro in XCode

I'm using CocoaLumberjack ( https://github.com/CocoaLumberjack/CocoaLumberjack ) in my application. 我在我的应用程序中使用CocoaLumberjack( https://github.com/CocoaLumberjack/CocoaLumberjack )。

It has a couple of different log macros that I use for example: 它有几个不同的日志宏,例如:
DDLogInfo DDLogInfo
DDLogVerbose DDLogVerbose
DDLogWarn DDLogWarn
DDLogError DDLogError

These are defined as macros. 这些被定义为宏。 I want to create a symbolic breakpoint that will break on all DDLogError. 我想创建一个将在所有DDLogError上中断的符号断点。 How do I do that? 我怎么做?

In short, you don't. 简而言之,您不需要。 Macros are precompiler directives. 宏是预编译器指令。 By the time your program is compiled and running, macros are gone. 到程序编译并运行时,宏消失了。

Symbolic breakpoints break on specific instance methods and function calls. 符号断点会中断特定的实例方法和函数调用。

The best you might be able to do is to create a dummy method and edit the definition of your DDLogError macro to call that method. 您可能能够做的最好的事情是创建一个虚拟方法并编辑DDLogError宏的定义以调用该方法。 Then you could set a breakpoint (symbolic or actual) on that method. 然后,您可以在该方法上设置断点(符号或实际)。

lldb has a "source regular expression breakpoint" that might help out with this. lldb具有一个“源正则表达式断点”,可能对此有所帮助。 It will search the text of your source files for some pattern and if the pattern matches set a breakpoint on that source line. 它将在源文件的文本中搜索某种模式,如果该模式匹配,则在该源代码行上设置一个断点。 You say: 你说:

(lldb) break set -p "DDLog"

It isn't as convenient for you maybe, because with no arguments it just looks in the current source file, and you can specify any number of files like: 这可能对您来说不太方便,因为没有参数它只会在当前源文件中查找,并且您可以指定任意数量的文件,例如:

(lldb) break set -p "DDLog" -f foo.c -f bar.c

but there's no way currently to say "all source files" so you might get tired typing all your files in. But if you only need to set these macro breakpoint in a few files, this might come in handy. 但是目前没有办法说“所有源文件”,因此您可能会厌倦键入所有文件。但是,如果您只需要在几个文件中设置这些宏断点,则可能会派上用场。

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

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