mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/cgo: split loadDWARF into two parts
The first part runs gcc to get the debug information, and the second part processes the debug information. The first part doesn't touch the global and package level information that's computed so we can run it earlier and concurrently in a later CL. For #75167 Change-Id: I6a6a6964769a47792892066d06c16f239f532858 Reviewed-on: https://go-review.googlesource.com/c/go/+/699018 Reviewed-by: Michael Matloob <matloob@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
This commit is contained in:
parent
a7d9d5a80a
commit
8377adafc5
1 changed files with 18 additions and 2 deletions
|
|
@ -213,7 +213,8 @@ func (p *Package) Translate(f *File) {
|
||||||
}
|
}
|
||||||
needType := p.guessKinds(f)
|
needType := p.guessKinds(f)
|
||||||
if len(needType) > 0 {
|
if len(needType) > 0 {
|
||||||
p.loadDWARF(f, &ft, &conv, needType)
|
d := p.loadDWARF(f, &ft, needType)
|
||||||
|
p.recordTypes(f, d, &conv)
|
||||||
}
|
}
|
||||||
|
|
||||||
// In godefs mode we're OK with the typedefs, which
|
// In godefs mode we're OK with the typedefs, which
|
||||||
|
|
@ -522,7 +523,7 @@ func (p *Package) guessKinds(f *File) []*Name {
|
||||||
// loadDWARF parses the DWARF debug information generated
|
// loadDWARF parses the DWARF debug information generated
|
||||||
// by gcc to learn the details of the constants, variables, and types
|
// by gcc to learn the details of the constants, variables, and types
|
||||||
// being referred to as C.xxx.
|
// being referred to as C.xxx.
|
||||||
func (p *Package) loadDWARF(f *File, ft *fileTypedefs, conv *typeConv, names []*Name) {
|
func (p *Package) loadDWARF(f *File, ft *fileTypedefs, names []*Name) *debug {
|
||||||
// Extract the types from the DWARF section of an object
|
// Extract the types from the DWARF section of an object
|
||||||
// from a well-formed C program. Gcc only generates DWARF info
|
// from a well-formed C program. Gcc only generates DWARF info
|
||||||
// for symbols in the object file, so it is not enough to print the
|
// for symbols in the object file, so it is not enough to print the
|
||||||
|
|
@ -643,6 +644,21 @@ func (p *Package) loadDWARF(f *File, ft *fileTypedefs, conv *typeConv, names []*
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return &debug{names, types, ints, floats, strs}
|
||||||
|
}
|
||||||
|
|
||||||
|
// debug is the data extracted by running an iteration of loadDWARF on a file.
|
||||||
|
type debug struct {
|
||||||
|
names []*Name
|
||||||
|
types []dwarf.Type
|
||||||
|
ints []int64
|
||||||
|
floats []float64
|
||||||
|
strs []string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Package) recordTypes(f *File, data *debug, conv *typeConv) {
|
||||||
|
names, types, ints, floats, strs := data.names, data.types, data.ints, data.floats, data.strs
|
||||||
|
|
||||||
// Record types and typedef information.
|
// Record types and typedef information.
|
||||||
for i, n := range names {
|
for i, n := range names {
|
||||||
if strings.HasSuffix(n.Go, "GetTypeID") && types[i].String() == "func() CFTypeID" {
|
if strings.HasSuffix(n.Go, "GetTypeID") && types[i].String() == "func() CFTypeID" {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue