Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-4204] LLDB fails printing variables when self refers to an empty struct #4637

Open
swift-ci opened this issue Mar 9, 2017 · 9 comments
Labels
bug Something isn't working LLDB for Swift

Comments

@swift-ci
Copy link

swift-ci commented Mar 9, 2017

Previous ID SR-4204
Radar rdar://problem/31041089
Original Reporter marc (JIRA User)
Type Bug
Environment

Xcode 8.3 beta 4

Additional Detail from JIRA
Votes 2
Component/s LLDB for Swift
Labels Bug
Assignee jingham@apple.com (JIRA)
Priority Medium

md5: 2712502f1f5b9c6b70b6428e42cd954e

is duplicated by:

  • SR-4433 lldb expression command can't handle structs with no elements

Issue Description:

LLDB fails in 2 of the following cases:

struct Fail1 {

    func test(parameter: Int) {
        // 'po parameter' fails with "Couldn't materialize: couldn't get the value of self: extracting data from value failed"
        print(parameter)
    }
}

struct Fail2 {

    let test: Void = ()

    func test(parameter: Int) {
        // 'po parameter' fails with "<EXPR>:18:5: error: use of unresolved identifier '$__lldb_injected_self'"
        print(parameter)
    }
}

struct Success {

    let test = 0

    func test(parameter: Int) {
        // 'po parameter' works
        print(parameter)
    }
}
@belkadan
Copy link

belkadan commented Mar 9, 2017

Hm. That often means the project is set to compile with optimizations on, but it sounds like that's not the case?

@swift-ci
Copy link
Author

swift-ci commented Mar 9, 2017

Comment by Marc Knaup (JIRA)

@belkadan yep, the build using Debug configuration and both, the app target and the framework, use -Onone.

@swift-ci
Copy link
Author

swift-ci commented Mar 9, 2017

Comment by Marc Knaup (JIRA)

@belkadan I've just found a simple repro: it happens in all methods of structs which have no stored properties.

@belkadan
Copy link

belkadan commented Mar 9, 2017

Oh, that makes a lot of sense. We of course don't bother representing such a struct with any memory at run time, but that makes LLDB think there's no self at all.

Tagging in jingham@apple.com (JIRA User).

@belkadan
Copy link

@swift-ci create

@allenhumphreys
Copy link

marc (JIRA User) I seem to be experiencing this issue in Xcode 9.3. I'm getting a slightly different error though:

Couldn't apply expression side effects : couldn't get the data for variable self

I'm using a static struct with all static functions and a single static let property.

@swift-ci
Copy link
Author

swift-ci commented Apr 2, 2018

Comment by Michael Helmbrecht (JIRA)

Getting the same error as @allenhumphreys; using an empty enum with all static methods in Xcode 9.3.

@swift-ci
Copy link
Author

Comment by Worth Baker (JIRA)

Also getting this error on Xcode 9.3 when attempting lldb operations (po) on a struct with no properties and only static methods: "Couldn't apply expression side effects : couldn't get the data for variable self". Swapping the item from struct to class seems to fix the issue.

@bobergj
Copy link

bobergj commented Jun 7, 2018

Getting the same error (couldn't get the data for variable self) in Xcode 9.4, when trying to print out a variable in static method in a non-empty struct (has let properties).

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working LLDB for Swift
Projects
None yet
Development

No branches or pull requests

4 participants