I am now developing Cocos2d-x with Xcode. But I do not know how to examine the actual class of C++ object with LLDB. As you can see in the image, the Xcode's inspector knows the actual class but p
or po
does not.
So the question is: How to examine the actual class of C++ object with LLDB?
LLDB is the default debugger in Xcode on macOS and supports debugging C, Objective-C and C++ on the desktop and iOS devices and simulator. All of the code in the LLDB project is available under the “Apache 2.0 License with LLVM exceptions”.
In lldb you can set breakpoints by typing either break or b followed by information on where you want the program to pause. After the b command, you can put either: a function name (e.g., b my_subroutine ) a line number (e.g., b 12 )
To do that, you can use %format inside an expression path, as in ${var. x->x%u}, which would display the value of x as an unsigned integer. Use this object's location (memory address, register name, …) Since lldb 3.7.
GDB is part of the GNU framework, and was created to work alongside of g++ , which is the GNU C++ compiler. LLDB is part of the LLVM framework, and was created to work alongside of clang++ , which is the LLVM C++ compiler. Ideally, you would use the debugger of the same framework that the compiler is part of.
This is because the Xcode UI has "dynamic types" enabled by default. Dynamic types are LLDB lingo for "I am going to figure out the actual type of this object". In order to get that same behavior at the console, you could try typing
(lldb) frame variable -d run-target pObject
In the open source LLDB, you could also type
(lldb) expr -d run-target -- pObject
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With