NAME=mach0 swift demangle methods
FILE=bins/mach0/swift-main
CMDS=isq~&FooClass,method
EXPECT=<<EOF
0x1000047a0 0 FooClass.bar.method__String..init.witnesstable
0x100004788 0 FooClass.foo.method__Swift.Int..init.witnesstable
0x1000017a0 0 main.FooClass.foo.method__Swift.Int
0x100001860 0 main.FooClass.bar.method__String
EOF
RUN

NAME=mach0 swift-x86-64 aav
FILE=bins/mach0/swift-main
CMDS=<<EOF
C*~^?Cd
aav
C*~^?Cd
Cd~?
EOF
EXPECT=<<EOF
114
134
134
EOF
RUN

NAME=swift-x86-64 calling convention
FILE=bins/mach0/swift5.1-throwError
CMDS=<<EOF
s sym.__s10throwError7ThrowerC0a2MyB0yyKF
af
afc swift
afva
afcr
afv
EOF
EXPECT=<<EOF
cc.swift.ret: rax
cc.swift.arg0: rdi
cc.swift.arg1: rsi
cc.swift.arg2: rdx
cc.swift.arg3: rcx
cc.swift.arg4: r8
cc.swift.arg5: r9
cc.swift.arg6: xmm0
cc.swift.arg7: xmm1
cc.swift.arg8: xmm2
cc.swift.arg9: xmm3
cc.swift.arg10: xmm4
cc.swift.self: r13
cc.swift.error: r12
var int64_t var_28h @ rbp-0x28
var int64_t var_20h @ rbp-0x20
var int64_t var_18h @ rbp-0x18
var int64_t var_10h @ rbp-0x10
arg int64_t self @ r13
arg int64_t error @ r12
EOF
RUN

NAME=swift-x86-64 calling convention json
FILE=bins/mach0/swift5.1-throwError
CMDS=<<EOF
s sym.__s10throwError7ThrowerC0a2MyB0yyKF
af
afc swift
afva
afcrj
afvj
EOF
EXPECT=<<EOF
{"ret":"rax","args":["rdi","rsi","rdx","rcx","r8","r9","xmm0","xmm1","xmm2","xmm3","xmm4"],"self":"r13","error":"r12"}
{"sp":[],"bp":[{"name":"var_28h","kind":"var","type":"int64_t","ref":{"base":"rbp","offset":-40}},{"name":"var_20h","kind":"var","type":"int64_t","ref":{"base":"rbp","offset":-32}},{"name":"var_18h","kind":"var","type":"int64_t","ref":{"base":"rbp","offset":-24}},{"name":"var_10h","kind":"var","type":"int64_t","ref":{"base":"rbp","offset":-16}}],"reg":[{"name":"self","kind":"reg","type":"int64_t","ref":"r13"},{"name":"error","kind":"reg","type":"int64_t","ref":"r12"}]}
EOF
RUN
