简体   繁体   中英

LLDB Debugger - Define custom types display

In our codebase, we're using libfixmath, a library used to calculate floating point values based on its. Hence, the values themselves are all ints underneath, but we want our debugger to display them as floats when stopping on a breakpoint.

We're using AppCode as an IDE on OSX, making Apps for iOS in C++ and Objective-C if that matters.

How can we achieve that?

lldb has a way to provide custom formatting for specific types. Look here for details:

http://lldb.llvm.org/varformats.html

The only restriction is that this facility maps types -> formatting options. So you can't do things like "If I see an int in some context, treat it as a float", you can only do so for ALL ints. But if you have a wrapper type that contains the ints in question, you could pretty easily write a formatter that reinterprets the contents of the wrapper type.

The LLDB API's will render values using the data formatters described above, as will all the command-line commands that present data. AppCode may use lldb's implementation of the gdb-MI interface, and I don't think that supports the data formatters. So you may or may not be able to see the results in their Locals view.

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