aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/internal/obj/dwarf.go
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2023-08-28 05:43:51 -0700
committerGopher Robot <gobot@golang.org>2023-08-29 20:19:46 +0000
commitad74bc4a92d0c903308b2e40fa07446a735dbbd2 (patch)
tree825ed2c9102317bd1f32e4d5cab791b63cd9dc1d /src/cmd/internal/obj/dwarf.go
parent98c26afa8c9c1016d205408e2afaba5824f4d930 (diff)
downloadgo-ad74bc4a92d0c903308b2e40fa07446a735dbbd2.tar.xz
cmd/internal/obj: add Func type to replace "curfn any"
This adds a modicum of type safety to these APIs, which are otherwise quite confusing to follow. Change-Id: I268a9a1a99a47dcfef6dc1e9e5be13673af3fb85 Reviewed-on: https://go-review.googlesource.com/c/go/+/523396 Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Diffstat (limited to 'src/cmd/internal/obj/dwarf.go')
-rw-r--r--src/cmd/internal/obj/dwarf.go20
1 files changed, 9 insertions, 11 deletions
diff --git a/src/cmd/internal/obj/dwarf.go b/src/cmd/internal/obj/dwarf.go
index 482222bb74..825f0133f1 100644
--- a/src/cmd/internal/obj/dwarf.go
+++ b/src/cmd/internal/obj/dwarf.go
@@ -345,7 +345,7 @@ func (ctxt *Link) fileSymbol(fn *LSym) *LSym {
// populateDWARF fills in the DWARF Debugging Information Entries for
// TEXT symbol 's'. The various DWARF symbols must already have been
// initialized in InitTextSym.
-func (ctxt *Link) populateDWARF(curfn interface{}, s *LSym) {
+func (ctxt *Link) populateDWARF(curfn Func, s *LSym) {
myimportpath := ctxt.Pkgpath
if myimportpath == "" {
return
@@ -358,9 +358,7 @@ func (ctxt *Link) populateDWARF(curfn interface{}, s *LSym) {
var scopes []dwarf.Scope
var inlcalls dwarf.InlCalls
if ctxt.DebugInfo != nil {
- // Don't need startPos because s.Func().StartLine is populated,
- // as s is in this package.
- scopes, inlcalls, _ = ctxt.DebugInfo(s, info, curfn)
+ scopes, inlcalls = ctxt.DebugInfo(s, info, curfn)
}
var err error
dwctxt := dwCtxt{ctxt}
@@ -427,7 +425,7 @@ func (ctxt *Link) DwarfGlobal(typename string, varSym *LSym) {
dwarf.PutGlobal(dwCtxt{ctxt}, dieSym, typeSym, varSym, varname)
}
-func (ctxt *Link) DwarfAbstractFunc(curfn interface{}, s *LSym) {
+func (ctxt *Link) DwarfAbstractFunc(curfn Func, s *LSym) {
absfn := ctxt.DwFixups.AbsFuncDwarfSym(s)
if absfn.Size != 0 {
ctxt.Diag("internal error: DwarfAbstractFunc double process %v", s)
@@ -435,8 +433,8 @@ func (ctxt *Link) DwarfAbstractFunc(curfn interface{}, s *LSym) {
if s.Func() == nil {
s.NewFuncInfo()
}
- scopes, _, startPos := ctxt.DebugInfo(s, absfn, curfn)
- _, startLine := ctxt.getFileSymbolAndLine(startPos)
+ scopes, _ := ctxt.DebugInfo(s, absfn, curfn)
+ _, startLine := ctxt.getFileSymbolAndLine(curfn.Pos())
dwctxt := dwCtxt{ctxt}
fnstate := dwarf.FnState{
Name: s.Name,
@@ -515,8 +513,8 @@ type relFixup struct {
}
type fnState struct {
- // precursor function (really *gc.Node)
- precursor interface{}
+ // precursor function
+ precursor Func
// abstract function symbol
absfn *LSym
}
@@ -529,14 +527,14 @@ func NewDwarfFixupTable(ctxt *Link) *DwarfFixupTable {
}
}
-func (ft *DwarfFixupTable) GetPrecursorFunc(s *LSym) interface{} {
+func (ft *DwarfFixupTable) GetPrecursorFunc(s *LSym) Func {
if fnstate, found := ft.precursor[s]; found {
return fnstate.precursor
}
return nil
}
-func (ft *DwarfFixupTable) SetPrecursorFunc(s *LSym, fn interface{}) {
+func (ft *DwarfFixupTable) SetPrecursorFunc(s *LSym, fn Func) {
if _, found := ft.precursor[s]; found {
ft.ctxt.Diag("internal error: DwarfFixupTable.SetPrecursorFunc double call on %v", s)
}