LLDB Debugger - Define custom types display

722 views Asked by At

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?

1

There are 1 answers

0
Jim Ingham On

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.