Anton Unt
Anton Unt

Reputation: 1875

How do you print the current time in the LLDB debugger?

How do you do it? I am using XCode 4.5.2 and trying to make timestamps for an operation that's executing in the background.

Upvotes: 2

Views: 1800

Answers (1)

Jim Ingham
Jim Ingham

Reputation: 27173

While calling po [NSDate date] will give you the current time, it will involve running code in the target program, which is fairly slow, so you might not want to do that for instance in a breakpoint command that gets hit frequently.

If you want to do this without running code, the trick is to remember that lldb's "script" command gives you access to a full-on Python interpreter. So for instance:

(lldb) script import time
(lldb) script time.ctime()
'Thu Nov  7 12:21:22 2013'

Upvotes: 13

Related Questions