ssa: debug info of interface
This commit is contained in:
@@ -33,10 +33,10 @@ type StructWithAllTypeFields struct {
|
||||
e E
|
||||
pf *StructWithAllTypeFields // resursive
|
||||
pi *int
|
||||
// intr Interface
|
||||
intr Interface
|
||||
// m map[string]uint64
|
||||
// c chan int
|
||||
// err error
|
||||
err error
|
||||
// fn func(string) (int, error)
|
||||
}
|
||||
|
||||
@@ -80,10 +80,10 @@ func FuncWithAllTypeParams(
|
||||
f StructWithAllTypeFields,
|
||||
pf *StructWithAllTypeFields,
|
||||
pi *int,
|
||||
// intr Interface,
|
||||
intr Interface,
|
||||
// m map[string]uint64,
|
||||
// c chan int,
|
||||
// err error,
|
||||
err error,
|
||||
// fn func(string) (int, error),
|
||||
) (int, error) {
|
||||
println(
|
||||
@@ -92,7 +92,9 @@ func FuncWithAllTypeParams(
|
||||
c64, c128,
|
||||
slice, arr[0:],
|
||||
s,
|
||||
// &e, &f, pf, pi, intr, m, c, err,
|
||||
&e,
|
||||
// &f, pf, pi, intr, m, c,
|
||||
err,
|
||||
// fn,
|
||||
)
|
||||
return 1, errors.New("Some error")
|
||||
@@ -123,10 +125,10 @@ func main() {
|
||||
e: E{i: 30},
|
||||
pf: &StructWithAllTypeFields{},
|
||||
pi: &i,
|
||||
// intr: &Struct{},
|
||||
intr: &Struct{},
|
||||
// m: make(map[string]uint64),
|
||||
// c: make(chan int),
|
||||
// err: errors.New("Test error"),
|
||||
err: errors.New("Test error"),
|
||||
// fn: func(s string) (int, error) {
|
||||
// println("fn:", s)
|
||||
// return 1, errors.New("fn error")
|
||||
@@ -143,7 +145,9 @@ func main() {
|
||||
s.s,
|
||||
s.e, s,
|
||||
s.pf, s.pi,
|
||||
// s.intr, s.m, s.c, s.err,
|
||||
s.intr,
|
||||
//s.m, s.c,
|
||||
s.err,
|
||||
// s.fn,
|
||||
)
|
||||
println(i, err)
|
||||
|
||||
43
ssa/di.go
43
ssa/di.go
@@ -149,7 +149,8 @@ func (b diBuilder) createType(ty Type, pos token.Position) DIType {
|
||||
case *types.Named:
|
||||
return b.diType(b.prog.rawType(t.Underlying()), pos)
|
||||
case *types.Interface:
|
||||
return b.createBasicType(ty)
|
||||
ty := b.prog.rawType(b.prog.rtType("Iface").RawType().Underlying())
|
||||
return b.createInterfaceType(ty)
|
||||
case *types.Slice:
|
||||
ty := b.prog.rawType(b.prog.rtType("Slice").RawType().Underlying())
|
||||
tyElem := b.prog.rawType(t.Elem())
|
||||
@@ -361,6 +362,44 @@ func (b diBuilder) createSliceType(ty, tyElem Type) DIType {
|
||||
}
|
||||
}
|
||||
|
||||
func (b diBuilder) createInterfaceType(ty Type) DIType {
|
||||
tyRaw := ty.RawType().Underlying()
|
||||
tyIntr := b.prog.rawType(tyRaw)
|
||||
tyType := b.prog.VoidPtr()
|
||||
tyData := b.prog.VoidPtr()
|
||||
|
||||
return &aDIType{ll: b.di.CreateStructType(
|
||||
llvm.Metadata{},
|
||||
llvm.DIStructType{
|
||||
Name: ty.RawType().String(),
|
||||
SizeInBits: b.prog.SizeOf(tyIntr) * 8,
|
||||
AlignInBits: uint32(b.prog.sizes.Alignof(ty.RawType()) * 8),
|
||||
Elements: []llvm.Metadata{
|
||||
b.di.CreateMemberType(
|
||||
llvm.Metadata{},
|
||||
llvm.DIMemberType{
|
||||
Name: "type",
|
||||
SizeInBits: b.prog.SizeOf(tyType) * 8,
|
||||
AlignInBits: uint32(b.prog.sizes.Alignof(tyType.RawType()) * 8),
|
||||
OffsetInBits: b.prog.OffsetOf(ty, 0) * 8,
|
||||
Type: b.diType(tyType, token.Position{}).ll,
|
||||
},
|
||||
),
|
||||
b.di.CreateMemberType(
|
||||
llvm.Metadata{},
|
||||
llvm.DIMemberType{
|
||||
Name: "data",
|
||||
SizeInBits: b.prog.SizeOf(tyData) * 8,
|
||||
AlignInBits: uint32(b.prog.sizes.Alignof(tyData.RawType()) * 8),
|
||||
OffsetInBits: b.prog.OffsetOf(ty, 1) * 8,
|
||||
Type: b.diType(tyData, token.Position{}).ll,
|
||||
},
|
||||
),
|
||||
},
|
||||
},
|
||||
)}
|
||||
}
|
||||
|
||||
func (b diBuilder) createComplexType(t Type) DIType {
|
||||
var tfield Type
|
||||
if t.RawType().(*types.Basic).Kind() == types.Complex128 {
|
||||
@@ -617,8 +656,6 @@ const (
|
||||
|
||||
func skipType(t types.Type) bool {
|
||||
switch t.(type) {
|
||||
case *types.Interface:
|
||||
return true
|
||||
case *types.Signature:
|
||||
return true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user