mardi 4 août 2015

Can't pass parameter of type CGColorRef in LLDB

I'm extending Facebook’s Chisel to be able to visualize a color from the debugger. I want it to work for UIColor, CIColor, and CGColorRef. The two object-based ones are working fine, but the CGColorRef is giving me trouble.

Here is the bug I'm working from, where I've already hashed out a bunch of the stuff from this question.

I've boiled the issue down to this test case:

If I have some function:

+ (UIColor *)someColor {
    UIColor *uiColor = [UIColor redColor];
    CGColorRef cgColor = uiColor.CGColor;
    UIColor *newUIColor = [UIColor colorWithCGColor:cgColor];
    return newUIColor;
}

And I set a breakpoint on the return newUIColor; line, this is what happens in LLDB:

(lldb) po cgColor
<CGColor 0x7f992b626710> [<CGColorSpace 0x7f992b70d5b0> (kCGColorSpaceDeviceRGB)] ( 0 0.478431 1 1 )

(lldb) po [UIColor colorWithCGColor:cgColor]
error: cannot initialize a parameter of type 'CGColor *' with an lvalue of type 'CGColorRef' (aka 'CGColor *')
error: 1 errors parsing expression
(lldb) po [UIColor colorWithCGColor:(CGColorRef)cgColor]
error: cannot initialize a parameter of type 'CGColor *' with an rvalue of type 'CGColorRef' (aka 'CGColor *')
error: 1 errors parsing expression
(lldb) po [UIColor colorWithCGColor:(id)cgColor]
error: cannot initialize a parameter of type 'CGColor *' with an rvalue of type 'id'
error: 1 errors parsing expression
(lldb) po [UIColor colorWithCGColor:(CGColor *)cgColor]
error: use of undeclared identifier 'CGColor'
error: expected expression
error: 2 errors parsing expression
(lldb) expr @import CoreGraphics
(lldb) po [UIColor colorWithCGColor:(CGColorRef)cgColor]
error: cannot initialize a parameter of type 'CGColor *' with an rvalue of type 'CGColorRef' (aka 'CGColor *')
error: 1 errors parsing expression
(lldb) po [UIColor colorWithCGColor:(CGColor *)cgColor]
error: cannot initialize a parameter of type 'CGColor *' with an rvalue of type 'CGColor *'
error: 1 errors parsing expression
(lldb) po [UIColor colorWithCGColor:(struct CGColor *)cgColor]
error: cannot initialize a parameter of type 'CGColor *' with an rvalue of type 'struct CGColor *'
error: 1 errors parsing expression

So, how can I get lldb to execute a line that takes a parameter of type CGColorRef?

Aucun commentaire:

Enregistrer un commentaire