Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I print C variables in LLDB Debugger?

As the question said. In Xcode 4.6.

Want to print ints, chars, arrays, custom structs etc etc.

Possible?

With Objective-C I could do something like:

int three = 3;

po [NSString stringWithFormat:@"%i", three];

Thanks.

like image 711
Adam Waite Avatar asked Apr 04 '13 15:04

Adam Waite


People also ask

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 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 )

Is LLDB compatible with GDB?

The standard LLDB installation provides you with an extensive set of commands designed to be compatible with familiar GDB commands. In addition to using the standard configuration, you can easily customize LLDB to suit your needs. Both GDB and LLDB are of course excellent debuggers without doubt.


1 Answers

po stands for Print Object, which essentially calls the description method on the object.

Use p to print an integer. For example:

p three
like image 159
J_D Avatar answered Oct 06 '22 18:10

J_D