Commit 9f1c7878 authored by Dmitry Vyukov's avatar Dmitry Vyukov

cmd/cgo: fix line info in _cgo_gotypes.go

Don't write line info for types, we don't have it.
Otherwise types look like:

type _Ctype_struct_cb struct {
//line :1
      on_test *[0]byte
//line :1
}

Which is not useful. Moreover we never override source info,
so subsequent source code uses the same source info.
Moreover, empty file name makes compile emit no source debug info at all.

Update #17190

Change-Id: I7ae6fa4964520d7665743d340419b787df0b51e8
Reviewed-on: https://go-review.googlesource.com/29713
Run-TryBot: Dmitry Vyukov <dvyukov@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
parent c1405064
...@@ -19,7 +19,10 @@ import ( ...@@ -19,7 +19,10 @@ import (
"strings" "strings"
) )
var conf = printer.Config{Mode: printer.SourcePos, Tabwidth: 8} var (
conf = printer.Config{Mode: printer.SourcePos, Tabwidth: 8}
noSourceConf = printer.Config{Tabwidth: 8}
)
// writeDefs creates output files to be compiled by gc and gcc. // writeDefs creates output files to be compiled by gc and gcc.
func (p *Package) writeDefs() { func (p *Package) writeDefs() {
...@@ -95,7 +98,19 @@ func (p *Package) writeDefs() { ...@@ -95,7 +98,19 @@ func (p *Package) writeDefs() {
for _, name := range typedefNames { for _, name := range typedefNames {
def := typedef[name] def := typedef[name]
fmt.Fprintf(fgo2, "type %s ", name) fmt.Fprintf(fgo2, "type %s ", name)
conf.Fprint(fgo2, fset, def.Go) // We don't have source info for these types, so write them out without source info.
// Otherwise types would look like:
//
// type _Ctype_struct_cb struct {
// //line :1
// on_test *[0]byte
// //line :1
// }
//
// Which is not useful. Moreover we never override source info,
// so subsequent source code uses the same source info.
// Moreover, empty file name makes compile emit no source debug info at all.
noSourceConf.Fprint(fgo2, fset, def.Go)
fmt.Fprintf(fgo2, "\n\n") fmt.Fprintf(fgo2, "\n\n")
} }
if *gccgo { if *gccgo {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment