Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to examine the actual class of C++ object with LLDB?

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 knows the actual class

like image 690
HKTonyLee Avatar asked Dec 18 '12 04:12

HKTonyLee


People also ask

What is LLDB in C?

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”.

How do you use breakpoint in LLDB?

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 )

How do I display a variable in LLDB?

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.

What is GDB LLDB?

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.


1 Answers

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
like image 111
Enrico Granata Avatar answered Sep 22 '22 11:09

Enrico Granata