Swift generics in lldb - error: unable to find any types that match the raw type for full type

1

I have this bit of code:

class Talker:NSObject {
    func describe<T: Showable, U:Showable>(stuffs: [Blob<T, U>]) {
        let useless:Int = 71
        print("useless = \(useless)")
        for s in stuffs {
            print("s = \(s)")
        }
    }
}

I have a breakpoint inside the for loop. I am trying to display the value of stuffs in lldb. I get this:

(lldb) po stuffs
error: <EXPR>:2:1: error: use of unresolved identifier 'stuffs'
stuffs
^~~~
(lldb) frame variable -L stuffs
0x00007fff5be1b9d8: ([Fork.Blob<T, Fork.Stem>]) stuffs = 1 value {
:   [0] = <Unable to determine byte size.>
}

So I tried this:

(lldb) register read pc
    rip = 0x000000010240209d  Fork`Fork.Talker.describe <A, B where A: Fork.Showable, B: Fork.Showable> (Swift.Array<Fork.Blob<A, B>>) -> () + 1741 at Blossom.swift:89
(lldb) image lookup -va 0x000000010240209d
      Address: Fork[0x000000010000709d] (Fork.__TEXT.__text + 25389)
      Summary: Fork`Fork.Talker.describe <A, B where A: Fork.Showable, B: Fork.Showable> (Swift.Array<Fork.Blob<A, B>>) -> () + 1741 at Blossom.swift:89
       Module: file = "/Users/abc/Library/Developer/Xcode/DerivedData/Fork-gdjlcshhkbqtnyajeeyaxbaeesyu/Build/Products/Debug-iphonesimulator/Fork.app/Fork", arch = "x86_64"
  CompileUnit: id = {0x00000000}, file = "/Users/abc/Code/Fork/Fork/Blossom.swift", language = "swift"
     Function: id = {0x300001272}, name = "@convention(method) (Fork.Talker) -> <T : Showable, U : Showable> (Swift.Array<Fork.Blob<T, U>>) -> ()", range = [0x00000001024019d0-0x0000000102402413)
     FuncType: id = {0x300001272}, byte-size = 8, decl = Blossom.swift:85, compiler_type = "@convention(method) Fork.Talker -> <T : Showable, U : Showable> [Fork.Blob<T, U>] -> ()
"
       Blocks: id = {0x300001272}, range = [0x1024019d0-0x102402413)
               id = {0x3000012cd}, range = [0x1024019fc-0x102402413)
               id = {0x3000012ed}, range = [0x102401b8d-0x1024023d4)
    LineEntry: [0x000000010240209d-0x000000010240211c): /Users/abc/Code/Fork/Fork/Blossom.swift:89:19
       Symbol: id = {0x0000022c}, range = [0x00000001024019d0-0x0000000102402420), name="Fork.Talker.describe <A, B where A: Fork.Showable, B: Fork.Showable> (Swift.Array<Fork.Blob<A, B>>) -> ()", mangled="_TFC4Fork6Talker8describeu0_RxS_8Showable_S1_rfGSaGVS_4Blobxq___T_"
     Variable: id = {0x3000012fe}, name = "s", type = "Fork.Blob<T, U>", location =  DW_OP_fbreg(-664), decl = Blossom.swift:88
     Variable: id = {0x3000012de}, name = "useless", type = "Swift.Int", location =  DW_OP_fbreg(-96), decl = Blossom.swift:86
     Variable: id = {0x300001294}, name = "stuffs", type = "Swift.Array<Fork.Blob<T, U>>", location =  DW_OP_fbreg(-80), decl = Blossom.swift:85
     Variable: id = {0x3000012a3}, name = "self", type = "Fork.Talker", location =  DW_OP_fbreg(-88), decl = Blossom.swift:85
     Variable: id = {0x3000012b3}, name = "$swift.type.T", type = "Builtin.RawPointer", location =  DW_OP_fbreg(-48), decl = 
     Variable: id = {0x3000012c0}, name = "$swift.type.U", type = "Builtin.RawPointer", location =  DW_OP_fbreg(-56), decl = 
(lldb) memory read -t "Swift.Array<Fork.Blob<T, U>>" -a $fp-80
error: unable to find any types that match the raw type 'Swift.Array<Fork.Blob<T, U>>' for full type 'Swift.Array<Fork.Blob<T, U>>'

How can I inform lldb of the full type?

To check my syntax, I see I can display the value of useless accurately.

(lldb) memory read -t "Swift.Int" -a $fp-96
(Int) 0x7fff5d801390 = 71

Note: I'm using Xcode 7.3.1 and Swift 2.2.

Update

Jim Ingham was correct. This was just a bug from Xcode 7 and Swift 2.2.

Using Xcode 8.2 I can po stuffs now and see debug output.

(lldb) po stuffs
▿ 2 elements
  ▿ 0 : Blob<Blossom, Stem>
    ▿ thing : <Fork.Blossom: 0x600000058210>
    ▿ otherThings : Optional<Array<Stem>>
      ▿ some : 2 elements
        ▿ 0 : <Fork.Stem: 0x60800005a880>
        ▿ 1 : <Fork.Stem: 0x60800005a2e0>
  ▿ 1 : Blob<Blossom, Stem>
    ▿ thing : <Fork.Blossom: 0x600000058240>
    ▿ otherThings : Optional<Array<Stem>>
      ▿ some : 2 elements
        ▿ 0 : <Fork.Stem: 0x60800005a880>
        ▿ 1 : <Fork.Stem: 0x60800005a2e0>
ios
swift
generics
lldb
asked on Stack Overflow Aug 15, 2016 by Jeff • edited Jan 9, 2017 by Jeff

1 Answer

1

You shouldn't have to tell lldb the type. OTOH, lldb has to be able to figure out what the fully resolved type of this argument is at runtime, and that can be tricky.

If this is Xcode 7 or Swift 2.x, you might try with Xcode 8/Swift 3.0. lldb got a fair bit better at this task with some help from the Swift 3.0 compiler. If it still doesn't work with Swift 3.0, please file a bug with http://bugreporter.apple.com.

answered on Stack Overflow Aug 16, 2016 by Jim Ingham

User contributions licensed under CC BY-SA 3.0