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

1

7

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

Snapdragon answered 18/12, 2012 at 4:31 Comment(6)
What do you mean by "truth class"?Resorcinol
I think he means "actual class". C++ has no type information, ie normally C++ classes don't know what they are. Good debuggers use type formatting to work around this behavior, LLDB has a type description format, this might help a bit: lldb.llvm.org/varformats.htmlHutchings
@JoachimPileborg I have updated the questions ;) It's "actual class".Snapdragon
@LearnCocos2D I have updated the screenshot. You can see the type of pObject is CCObject*. But the LLDB knows it is actually CCString*. I do not know how to extract such information in the console...Snapdragon
As it's a pointer, have you tried e.g. p *pObject?Resorcinol
@JoachimPileborg Thanks~ but it is still not working... I have updated the screenshot.Snapdragon
D
7

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
Downdraft answered 16/1, 2013 at 1:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.