Skip to content

Commit

Permalink
ssa: debug info of chan
Browse files Browse the repository at this point in the history
  • Loading branch information
cpunion committed Sep 18, 2024
1 parent 9109158 commit 68a2d86
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
14 changes: 7 additions & 7 deletions cl/_testdata/debug/in.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ type StructWithAllTypeFields struct {
pi *int
intr Interface
m map[string]uint64
// c chan int
err error
c chan int
err error
// fn func(string) (int, error)
}

Expand Down Expand Up @@ -82,7 +82,7 @@ func FuncWithAllTypeParams(
pi *int,
intr Interface,
m map[string]uint64,
// c chan int,
c chan int,
err error,
// fn func(string) (int, error),
) (int, error) {
Expand All @@ -94,7 +94,7 @@ func FuncWithAllTypeParams(
s,
&e,
&f, pf, pi, intr, m,
// c,
c,
err,
// fn,
)
Expand Down Expand Up @@ -128,8 +128,8 @@ func main() {
pi: &i,
intr: &Struct{},
m: map[string]uint64{"a": 31, "b": 32},
// c: make(chan int),
err: errors.New("Test error"),
c: make(chan int),
err: errors.New("Test error"),
// fn: func(s string) (int, error) {
// println("fn:", s)
// return 1, errors.New("fn error")
Expand All @@ -148,7 +148,7 @@ func main() {
s.pf, s.pi,
s.intr,
s.m,
// s.c,
s.c,
s.err,
// s.fn,
)
Expand Down
16 changes: 15 additions & 1 deletion ssa/di.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func (b diBuilder) createType(ty Type, pos token.Position) DIType {
case *types.Array:
return b.createArrayType(ty, t.Len())
case *types.Chan:
return b.createBasicType(ty)
return b.createChanType(ty)
case *types.Map:
ty := b.prog.rtType("Map")
tk := b.prog.rawType(t.Key())
Expand Down Expand Up @@ -365,6 +365,20 @@ func (b diBuilder) createMapType(tyMap, tk, tv Type) DIType {
}
}

func (b diBuilder) createChanType(t Type) DIType {
tyElem := b.prog.rawType(t.RawType().(*types.Chan).Elem())
fmt.Printf("tyElem: %v, %T\n", tyElem, tyElem)
return &aDIType{ll: b.di.CreateStructType(
llvm.Metadata{},
llvm.DIStructType{
Name: t.RawType().String(),
SizeInBits: b.prog.SizeOf(t) * 8,
AlignInBits: uint32(b.prog.sizes.Alignof(t.RawType()) * 8),
Elements: []llvm.Metadata{},
},
)}
}

func (b diBuilder) createComplexType(t Type) DIType {
var tfield Type
if t.RawType().(*types.Basic).Kind() == types.Complex128 {
Expand Down

0 comments on commit 68a2d86

Please sign in to comment.