]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/cgo: run recordTypes for each of the debugs at the end of Translate
authormatloob <matloob@golang.org>
Mon, 25 Aug 2025 21:16:05 +0000 (17:16 -0400)
committerGopher Robot <gobot@golang.org>
Mon, 8 Sep 2025 20:14:03 +0000 (13:14 -0700)
Save the debug information in a slice and then process all of them at
the end of the loop.

For #75167

Change-Id: I6a6a6964dffa784b0aa776334562333ecf247023
Reviewed-on: https://go-review.googlesource.com/c/go/+/699019
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@google.com>
Auto-Submit: Michael Matloob <matloob@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
src/cmd/cgo/gcc.go

index c1530b9f15489874e037e29bce36d3f6a32daefa..aa418af93b8b3c246ad1bf7db4584aec5711eef9 100644 (file)
@@ -192,9 +192,7 @@ func (p *Package) Translate(f *File) {
                cref.Name.C = cname(cref.Name.Go)
        }
 
-       var conv typeConv
-       conv.Init(p.PtrSize, p.IntSize)
-
+       var debugs []*debug // debug data from iterations of gccDebug
        ft := fileTypedefs{typedefs: make(map[string]bool)}
        numTypedefs := -1
        for len(ft.typedefs) > numTypedefs {
@@ -213,8 +211,7 @@ func (p *Package) Translate(f *File) {
                }
                needType := p.guessKinds(f)
                if len(needType) > 0 {
-                       d := p.loadDWARF(f, &ft, needType)
-                       p.recordTypes(f, d, &conv)
+                       debugs = append(debugs, p.loadDWARF(f, &ft, needType))
                }
 
                // In godefs mode we're OK with the typedefs, which
@@ -224,6 +221,12 @@ func (p *Package) Translate(f *File) {
                        break
                }
        }
+
+       var conv typeConv
+       conv.Init(p.PtrSize, p.IntSize)
+       for _, d := range debugs {
+               p.recordTypes(f, d, &conv)
+       }
        p.prepareNames(f)
        if p.rewriteCalls(f) {
                // Add `import _cgo_unsafe "unsafe"` after the package statement.