简体   繁体   中英

Symbolic breakpoint on Macro in XCode

I'm using CocoaLumberjack ( https://github.com/CocoaLumberjack/CocoaLumberjack ) in my application.

It has a couple of different log macros that I use for example:
DDLogInfo
DDLogVerbose
DDLogWarn
DDLogError

These are defined as macros. I want to create a symbolic breakpoint that will break on all 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. 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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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