mirror of https://github.com/golang/go.git
runtime: dedup function name logic into moduledata method
For #54466. Change-Id: I4d8e1953703b6c763e5bd53024da43efcc993489 Reviewed-on: https://go-review.googlesource.com/c/go/+/466095 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Pratt <mpratt@google.com> Run-TryBot: Austin Clements <austin@google.com>
This commit is contained in:
parent
6f22d42c74
commit
dcb4c1c1aa
|
|
@ -187,7 +187,8 @@ func raceSymbolizeCode(ctx *symbolizeCodeContext) {
|
|||
continue
|
||||
}
|
||||
ctx.pc = f.Entry() + uintptr(inltree[ix].parentPc) // "caller" pc
|
||||
ctx.fn = cfuncnameFromNameOff(fi, inltree[ix].nameOff)
|
||||
name := funcnameFromNameOff(fi, inltree[ix].nameOff)
|
||||
ctx.fn = &bytes(name)[0] // assume NUL-terminated
|
||||
ctx.line = uintptr(line)
|
||||
ctx.file = &bytes(file)[0] // assume NUL-terminated
|
||||
ctx.off = pc - f.Entry()
|
||||
|
|
@ -197,7 +198,8 @@ func raceSymbolizeCode(ctx *symbolizeCodeContext) {
|
|||
break
|
||||
}
|
||||
}
|
||||
ctx.fn = cfuncname(fi)
|
||||
name := funcname(fi)
|
||||
ctx.fn = &bytes(name)[0] // assume NUL-terminated
|
||||
ctx.line = uintptr(line)
|
||||
ctx.file = &bytes(file)[0] // assume NUL-terminated
|
||||
ctx.off = pc - f.Entry()
|
||||
|
|
|
|||
|
|
@ -733,6 +733,14 @@ func (md *moduledata) textOff(pc uintptr) (uint32, bool) {
|
|||
return res, true
|
||||
}
|
||||
|
||||
// funcName returns the string at nameOff in the function name table.
|
||||
func (md *moduledata) funcName(nameOff int32) string {
|
||||
if nameOff == 0 {
|
||||
return ""
|
||||
}
|
||||
return gostringnocopy(&md.funcnametab[nameOff])
|
||||
}
|
||||
|
||||
// FuncForPC returns a *Func describing the function that contains the
|
||||
// given program counter address, or else nil.
|
||||
//
|
||||
|
|
@ -1004,15 +1012,11 @@ func pcvalue(f funcInfo, off uint32, targetpc uintptr, cache *pcvalueCache, stri
|
|||
return -1, 0
|
||||
}
|
||||
|
||||
func cfuncname(f funcInfo) *byte {
|
||||
if !f.valid() || f.nameOff == 0 {
|
||||
return nil
|
||||
}
|
||||
return &f.datap.funcnametab[f.nameOff]
|
||||
}
|
||||
|
||||
func funcname(f funcInfo) string {
|
||||
return gostringnocopy(cfuncname(f))
|
||||
if !f.valid() {
|
||||
return ""
|
||||
}
|
||||
return f.datap.funcName(f.nameOff)
|
||||
}
|
||||
|
||||
func funcpkgpath(f funcInfo) string {
|
||||
|
|
@ -1031,15 +1035,11 @@ func funcpkgpath(f funcInfo) string {
|
|||
return name[:i]
|
||||
}
|
||||
|
||||
func cfuncnameFromNameOff(f funcInfo, nameOff int32) *byte {
|
||||
if !f.valid() {
|
||||
return nil
|
||||
}
|
||||
return &f.datap.funcnametab[nameOff]
|
||||
}
|
||||
|
||||
func funcnameFromNameOff(f funcInfo, nameOff int32) string {
|
||||
return gostringnocopy(cfuncnameFromNameOff(f, nameOff))
|
||||
if !f.valid() {
|
||||
return ""
|
||||
}
|
||||
return f.datap.funcName(nameOff)
|
||||
}
|
||||
|
||||
func funcfile(f funcInfo, fileno int32) string {
|
||||
|
|
|
|||
Loading…
Reference in New Issue