lldb中的Swift泛型 - 错误:无法找到与完整类型的原始类型匹配的任何类型

时间:2016-08-15 22:04:28

标签: ios swift generics lldb

我有这段代码:

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)")
        }
    }
}

我在for循环中有一个断点。我想在 lldb 中显示stuffs的值。我明白了:

(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.>
}

所以我尝试了这个:

(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>>'

如何通知 lldb 完整类型?

要检查我的语法,我发现我可以准确显示useless的值。

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

注意:我正在使用Xcode 7.3.1和Swift 2.2。

更新

吉姆英厄姆是对的。这只是来自Xcode 7和Swift 2.2的错误。

使用Xcode 8.2我现在可以po stuffs看看调试输出。

(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>

0 个答案:

没有答案