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-14713] [Swift 5.4] lldb fails to print values inside generic types if compiled with -disable-reflection-metadata #4310

Open
swift-ci opened this issue Jun 2, 2021 · 1 comment
Labels
bug Something isn't working LLDB for Swift

Comments

@swift-ci
Copy link

swift-ci commented Jun 2, 2021

Previous ID SR-14713
Radar None
Original Reporter qyang (JIRA User)
Type Bug
Environment

Xcode 12.5, Swift 5.4

Additional Detail from JIRA
Votes 0
Component/s LLDB for Swift
Labels Bug
Assignee None
Priority Medium

md5: bb137304283607e12eeb6edbecd6dffa

Issue Description:

If we define a generic type and compile it with -disable-reflection-metadata, lldb isn't able to print values inside the generic type. This issue is new to Swift 5.4 (Xcode 12.5) and I couldn't reproduce it with previous versions.

Here is the sample code,

class FooDependency {}

class FooProvider<D> {
  init(dependencies: D) {
    self.dependencies = dependencies
    print("Breakpoint Here")
  }
  private let dependencies: D
}

let d = FooDependency()
let p = FooProvider(dependencies: d)
print(p)

Then compile and debug it with this:

$ xcrun swiftc -g -Xfrontend -disable-reflection-metadata main.swift

$ xcrun lldb ./main
(lldb) target create "main"
Current executable set to '/path/to/main' (x86_64).
(lldb) breakpoint set -f main.swift -l 6
Breakpoint 1: where = main`main.FooProvider.init(dependencies: D) -> main.FooProvider<D> + 171 at main.swift:6:11, address = 0x0000000100003a2b
(lldb) r
...
Target 0: (main) stopped.
(lldb) p self
error: warning: <EXPR>:11:7: warning: initialization of variable '$__lldb_error_result' was never used; consider replacing with assignment to '_' or removing it
  var $__lldb_error_result = __lldb_tmp_error
  ~~~~^~~~~~~~~~~~~~~~~~~~
  _

error: <EXPR>:19:5: error: cannot find '$__lldb_injected_self' in scope
    $__lldb_injected_self.$__lldb_wrapped_expr_0(
    ^~~~~~~~~~~~~~~~~~~~~

(lldb) frame info
frame #&#8203;0: 0x0000000100003a2b main`FooProvider.init(dependencies=<unavailable>, self=<unavailable>) at main.swift:6:11
@adrian-prantl
Copy link
Member

This basically behaves as expected — LLDB needs reflection metadata to do pretty much anything useful — but the error message lacks greatness.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 5, 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

2 participants