Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automatically show properties of C++ objects in Xcode debugger

The Xcode debug area can sometimes show a summary of the most important variables inside of an object that's in the list, without the need to expand the object to see it's individual members.

Is there a way for me to teach the debugger about my own C++ objects to do the same? Let's say I have a simple class with a single member variable:

class Foo
{
    int bar;
};

And the debug area should show something like the following:

aVariableOfTypeFoo = (Foo) bar=123

I know that some C++ objects are able to do this (for example std::vector shows it's size), but I wasn't able to figure out if this is somehow configurable, or if it's built-in in the debugger/Xcode itself.

I'm using Xcode 5.0.1

Thanks

like image 356
Jan Holecek Avatar asked Dec 09 '13 13:12

Jan Holecek


People also ask

What is LLDB in Xcode?

LLDB is a debugging component used in the LLVM project which was developed by the LLVM developer group. Xcode uses the LLDB as the default debugging tool. The full form of LLDB is Low-level debugger. Breakpoints help a developer to stop the execution of the program at any point.

How do I see variables in Xcode?

See Variable Values in Code and the Variable Viewer When your app pauses at a breakpoint, hover over a variable in your source code to view its current value. If the variable is an image or other type that isn't expressible as text, click the Quick Look button at the upper-right to see a preview of the variable.

Does Xcode have a debugger?

When you run an application in Xcode, the debugger is automatically started and attached to the process of the application. Click the Run button in the top left or press Command + R. From the moment the application is up and running, we can start inspecting the process and, if necessary, debug it.

How do I create a symbolic breakpoint in Xcode?

Navigate to the second last tab on the left panel with a breakpoint picture. Click the “+” icon at the lower left of the Breakpoint Navigator and select Symbolic Breakpoint.


1 Answers

You can change the summary description for a given type selecting Edit Summary Format... by right clicking on a variable of that type.

enter image description here

The format in your case is pretty simple and will look like this: bar = {$VAR.bar} For more information about formats check the "Using Data Formatters" section in the Xcode User Guide (pages 42 & 43).

enter image description here

like image 200
Tomas Camin Avatar answered Sep 24 '22 14:09

Tomas Camin