Note that there are some explanatory texts on larger screens.

plurals
  1. POGetting around LLDB printing problems e.g. CLLocationCoordinate2D and recognizing Macros in debugger
    primarykey
    data
    text
    <p>LLDB has various problems printing struct fields of double type, as documented here: <a href="https://stackoverflow.com/questions/9900929/strange-behavior-in-lldb-when-printing-a-double-type-struct-member">strange-behavior-in-lldb-when-printing-a-double-type-struct-member</a>. </p> <p>In my own case I tried to print a struct of type CLLocationCoordinate2D. As of Xcode 4.5.2 the error in printing CLLocationCoordinate2D persists.</p> <p>Looking for ways around this bug I came across a nice macro, LOG_EXPR, in this blog: <a href="http://vgable.com/blog/2010/08/19/the-most-useful-objective-c-code-ive-ever-written/" rel="nofollow noreferrer">http://vgable.com/blog/2010/08/19/the-most-useful-objective-c-code-ive-ever-written/</a></p> <p>It does a great job of logging types into the debugger, but can't be called from the debugger.</p> <p>Has anyone figured out a way to do something like LOG_EXPR while debugging in the LLDB command line interface, or any other improved printing that will work on arbitrary structs from the command line, other than switching back to GDB?</p> <p>Here's what happens when I type in LLDB:</p> <pre><code>(lldb) p (CLLocationCoordinate2D)[self mapSetPointLatLon] (CLLocationCoordinate2D) $4 = { (CLLocationDegrees) latitude = 42.4604 (CLLocationDegrees) longitude = 42.4604 (double) easting = 42.4604 (double) northing = -71.5179 } </code></pre> <p>Notice the redundant and wrong lines added by lldb.</p> <p>Here's what happens (at the same breakpoint) when I compile LOG_EXPR into my code:</p> <pre><code>Line of Code (not debugger): LOG_EXPR(self.mapSetPointLatLon); produces the correct output in the debugger output: 2013-01-26 14:02:17.555 S6E11[79116:c07] self.mapSetPointLatLon = {latitude=42.4604,longitude=-71.5179} </code></pre> <p>At the same breakpoint if I try to invoke LOG_EXPR from the command line, this is what happens:</p> <pre><code>(lldb) expr LOG_EXPR(self.mapSetPointLatLon); error: use of undeclared identifier 'LOG_EXPR' error: 1 errors parsing expression (lldb) </code></pre> <p>Here's another example, since it turns out there is a case when you can get the debugger to do the right thing.</p> <p>Here's my code fragment where I assign the struct 2 ways:</p> <pre><code>CLLocationCoordinate2D defloc = CLLocationCoordinate2DMake(kStartingLat, kStartingLon); [[self.verticalPagingViewController mapPagingViewController] setMapSetPointLatLon: defloc]; </code></pre> <p>If I just print the variable it works.</p> <pre><code>(lldb) p defloc (CLLocationCoordinate2D) $1 = { (CLLocationDegrees) latitude = 42.4604 (CLLocationDegrees) longitude = -71.5179 } </code></pre> <p>If I'm casting the type of the return value of an accessor method, it fails.</p> <pre><code>(lldb) p (CLLocationCoordinate2D)[[self.verticalPagingViewController mapPagingViewController] mapSetPointLatLon] (CLLocationCoordinate2D) $2 = { (CLLocationDegrees) latitude = 0 (CLLocationDegrees) longitude = 0 (double) easting = 0 (double) northing = 0 } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload