Can't access self from within a block in lldb.

Originator:numist
Number:rdar://12578774 Date Originated:25-Oct-2012 05:32 PM
Status:Open Resolved:
Product:Developer Tools Product Version:Xcode Version 4.5.1 (4G1004)/LLDB-167.4
Classification:UI/Usability Reproducible:Always
 
Summary:
There are all kinds of things that are especially inaccessible in blocks, but self is by far the most annoying.

Steps to Reproduce:
- bar {
    dispatch_async(dispatch_get_global_queue(0, 0), ^{
        // breakpoint
    });
}

------------
(lldb) po self

Expected Results:
(Foo *) $1 = 0x07125ff0 <Foo: 0x7125ff0>

Actual Results:
error: use of undeclared identifier 'self'
error: 1 errors parsing expression

Regression:
If you weren't using blocks beforehand it sure feels like it!

Comments

Refiled as rdar://12584797 with new summary

Summary: There are all kinds of things that are occasionally inaccessible in blocks, but self is by far the most annoying. It seems to be due to scoping optimisation that is probably overkill for things compiled with -O0

Steps to Reproduce: New project -> iOS Empty Application -> paste into -application:didFinishLaunchingWithOptions:

// Reproduces
dispatch_async(dispatch_get_global_queue(0, 0), ^{
    if (launchOptions) {
        [[self retain] autorelease];
    }        

    NSLog(@"breakpoint here");
    // (lldb) po self
    // error: use of undeclared identifier 'self'
    // error: 1 errors parsing expression
});

// Reproduces
dispatch_async(dispatch_get_global_queue(0, 0), ^{
    NSLog(@"breakpoint here");
    // (lldb) po self
    // error: use of undeclared identifier 'self'
    // error: 1 errors parsing expression

    if (launchOptions) {
        [[self retain] autorelease];
    }
});

// Does not reproduce
dispatch_async(dispatch_get_global_queue(0, 0), ^{
    if (launchOptions) {
        [[self retain] autorelease];
    }

    NSLog(@"breakpoint here");
    // (lldb) po self
    // (AppDelegate *) $1 = 0x068914d0 <AppDelegate: 0x68914d0>

    if (launchOptions) {
        [[self retain] autorelease];
    }
});

Duped as 12579430

By heath.borders at Oct. 26, 2012, 3:03 a.m. (reply...)

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!