A subsequent change will alter the semantics of _func.entry.
To make that change obvious and clear, change _func.entry to a method,
and rename the field to _func.entryPC.
Change-Id: I05d66b54d06c5956d4537b0729ddf4290c3e2635
Reviewed-on: https://go-review.googlesource.com/c/go/+/351460
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
"(*bmap).keys",
"(*bmap).overflow",
"(*waitq).enqueue",
+ "(*_func).entry",
// GC-related ones
"cgoInRange",
}
// Check that this isn't an unsafe-point.
- if pc != f.entry {
+ if pc != f.entry() {
pc--
}
up := pcdatavalue(f, _PCDATA_UnsafePoint, pc, nil)
// pc is a return PC that must first be converted to a call PC.
func printDebugLogPC(pc uintptr, returnPC bool) {
fn := findfunc(pc)
- if returnPC && (!fn.valid() || pc > fn.entry) {
+ if returnPC && (!fn.valid() || pc > fn.entry()) {
// TODO(austin): Don't back up if the previous frame
// was a sigpanic.
pc--
} else {
name := funcname(fn)
file, line := funcline(fn, pc)
- print(" [", name, "+", hex(pc-fn.entry),
+ print(" [", name, "+", hex(pc-fn.entry()),
" ", file, ":", line, "]")
}
}
// Figure out what we can about our stack map
pc := s.pc
pcdata := int32(-1) // Use the entry map at function entry
- if pc != f.entry {
+ if pc != f.entry() {
pc--
pcdata = pcdatavalue(f, _PCDATA_StackMapIndex, pc, nil)
}
dumpint(uint64(child.depth)) // # of frames deep on the stack
dumpint(uint64(uintptr(unsafe.Pointer(child.sp)))) // sp of child, or 0 if bottom of stack
dumpmemrange(unsafe.Pointer(s.sp), s.fp-s.sp) // frame contents
- dumpint(uint64(f.entry))
+ dumpint(uint64(f.entry()))
dumpint(uint64(s.pc))
dumpint(uint64(s.continpc))
name := funcname(f)
dumpint(0)
} else {
dumpstr(funcname(f))
- if i > 0 && pc > f.entry {
+ if i > 0 && pc > f.entry() {
pc--
}
file, line := funcline(f, pc)
// deferreturn that runs any remaining
// defers and then returns from the
// function.
- d1.pc = frame.fn.entry + uintptr(frame.fn.deferreturn)
+ d1.pc = frame.fn.entry() + uintptr(frame.fn.deferreturn)
d1.varp = frame.varp
d1.fd = fd
// Save the SP/PC associated with current frame,
f2 := findfunc(entry)
if f2.valid() {
name2 = funcname(f2)
- entry2 = f2.entry
+ entry2 = f2.entry()
}
badtable = true
println("ftab entry", hex(entry), "/", hex(entry2), ": ",
return true, startpc
case _PCDATA_RestartAtEntry:
// Restart from the function entry at resumption.
- return true, f.entry
+ return true, f.entry()
}
return true, pc
}
// Can we symbolize val?
fn := findfunc(val)
if fn.valid() {
- print("<", funcname(fn), "+", hex(val-fn.entry), "> ")
+ print("<", funcname(fn), "+", hex(val-fn.entry()), "> ")
}
}
minhexdigits = 0
// Keep in sync with linker (../cmd/link/internal/ld/pcln.go:/pclntab)
// and with package debug/gosym and with symtab.go in package runtime.
type _func struct {
- entry uintptr // start pc
+ entryPC uintptr // start pc
nameoff int32 // function name
args int32 // in/out args size
f := findfunc(gp.sched.pc)
if f.valid() {
pcname = funcname(f)
- pcoff = gp.sched.pc - f.entry
+ pcoff = gp.sched.pc - f.entry()
}
print("runtime: newstack at ", pcname, "+", hex(pcoff),
" sp=", hex(gp.sched.sp), " stack=[", hex(gp.stack.lo), ", ", hex(gp.stack.hi), "]\n",
f := frame.fn
pcdata := int32(-1)
- if targetpc != f.entry {
+ if targetpc != f.entry() {
// Back up to the CALL. If we're at the function entry
// point, we want to use the entry map (-1), even if
// the first instruction of the function changes the
}
lastFuncID = inltree[ix].funcID
// Back up to an instruction in the "caller".
- tracepc = f.entry + uintptr(inltree[ix].parentPc)
+ tracepc = f.entry() + uintptr(inltree[ix].parentPc)
pc = tracepc + 1
}
file, line := funcline(f, pc)
fi := &funcinl{
ones: ^uintptr(0),
- entry: f.entry, // entry of the real (the outermost) function.
+ entry: f.entry(), // entry of the real (the outermost) function.
name: name,
file: file,
line: int(line),
fi := (*funcinl)(unsafe.Pointer(fn))
return fi.entry
}
- return fn.entry
+ return fn.entry()
}
// FileLine returns the file name and line number of the
// isInlined reports whether f should be re-interpreted as a *funcinl.
func (f *_func) isInlined() bool {
- return f.entry == ^uintptr(0) // see comment for funcinl.ones
+ return f.entryPC == ^uintptr(0) // see comment for funcinl.ones
+}
+
+// entry returns the entry PC for f.
+func (f *_func) entry() uintptr {
+ return f.entryPC
}
// findfunc looks up function metadata for a PC.
if !f.valid() {
if strict && panicking == 0 {
- print("runtime: no module data for ", hex(f.entry), "\n")
+ print("runtime: no module data for ", hex(f.entry()), "\n")
throw("no module data")
}
return -1, 0
}
datap := f.datap
p := datap.pctab[off:]
- pc := f.entry
+ pc := f.entry()
prevpc := pc
val := int32(-1)
for {
var ok bool
- p, ok = step(p, &pc, &val, pc == f.entry)
+ p, ok = step(p, &pc, &val, pc == f.entry())
if !ok {
break
}
print("runtime: invalid pc-encoded table f=", funcname(f), " pc=", hex(pc), " targetpc=", hex(targetpc), " tab=", p, "\n")
p = datap.pctab[off:]
- pc = f.entry
+ pc = f.entry()
val = -1
for {
var ok bool
- p, ok = step(p, &pc, &val, pc == f.entry)
+ p, ok = step(p, &pc, &val, pc == f.entry())
if !ok {
break
}
func funcspdelta(f funcInfo, targetpc uintptr, cache *pcvalueCache) int32 {
x, _ := pcvalue(f, f.pcsp, targetpc, cache, true)
if x&(goarch.PtrSize-1) != 0 {
- print("invalid spdelta ", funcname(f), " ", hex(f.entry), " ", hex(targetpc), " ", hex(f.pcsp), " ", x, "\n")
+ print("invalid spdelta ", funcname(f), " ", hex(f.entry()), " ", hex(targetpc), " ", hex(f.pcsp), " ", x, "\n")
}
return x
}
func funcMaxSPDelta(f funcInfo) int32 {
datap := f.datap
p := datap.pctab[f.pcsp:]
- pc := f.entry
+ pc := f.entry()
val := int32(-1)
max := int32(0)
for {
var ok bool
- p, ok = step(p, &pc, &val, pc == f.entry)
+ p, ok = step(p, &pc, &val, pc == f.entry())
if !ok {
return max
}
frame.continpc = frame.pc
if waspanic {
if frame.fn.deferreturn != 0 {
- frame.continpc = frame.fn.entry + uintptr(frame.fn.deferreturn) + 1
+ frame.continpc = frame.fn.entry() + uintptr(frame.fn.deferreturn) + 1
// Note: this may perhaps keep return variables alive longer than
// strictly necessary, as we are using "function has a defer statement"
// as a proxy for "function actually deferred something". It seems
// See issue 34123.
// The pc can be at function entry when the frame is initialized without
// actually running code, like runtime.mstart.
- if (n == 0 && flags&_TraceTrap != 0) || waspanic || pc == f.entry {
+ if (n == 0 && flags&_TraceTrap != 0) || waspanic || pc == f.entry() {
pc++
} else {
tracepc--
}
lastFuncID = inltree[ix].funcID
// Back up to an instruction in the "caller".
- tracepc = frame.fn.entry + uintptr(inltree[ix].parentPc)
+ tracepc = frame.fn.entry() + uintptr(inltree[ix].parentPc)
pc = tracepc + 1
}
}
// backup to CALL instruction to read inlining info (same logic as below)
tracepc := frame.pc
- if (n > 0 || flags&_TraceTrap == 0) && frame.pc > f.entry && !waspanic {
+ if (n > 0 || flags&_TraceTrap == 0) && frame.pc > f.entry() && !waspanic {
tracepc--
}
// If there is inlining info, print the inner frames.
}
lastFuncID = inltree[ix].funcID
// Back up to an instruction in the "caller".
- tracepc = frame.fn.entry + uintptr(inltree[ix].parentPc)
+ tracepc = frame.fn.entry() + uintptr(inltree[ix].parentPc)
}
}
if (flags&_TraceRuntimeFrames) != 0 || showframe(f, gp, nprint == 0, f.funcID, lastFuncID) {
printArgs(f, argp)
print(")\n")
print("\t", file, ":", line)
- if frame.pc > f.entry {
- print(" +", hex(frame.pc-f.entry))
+ if frame.pc > f.entry() {
+ print(" +", hex(frame.pc-f.entry()))
}
if gp.m != nil && gp.m.throwing > 0 && gp == gp.m.curg || level >= 2 {
print(" fp=", hex(frame.fp), " sp=", hex(frame.sp), " pc=", hex(frame.pc))
// in the return values.
retValid = *(*bool)(unsafe.Pointer(arg0 + 4*goarch.PtrSize))
}
- if mv.fn != f.entry {
+ if mv.fn != f.entry() {
print("runtime: confused by ", funcname(f), "\n")
throw("reflect mismatch")
}
func printcreatedby1(f funcInfo, pc uintptr) {
print("created by ", funcname(f), "\n")
tracepc := pc // back up to CALL instruction for funcline.
- if pc > f.entry {
+ if pc > f.entry() {
tracepc -= sys.PCQuantum
}
file, line := funcline(f, tracepc)
print("\t", file, ":", line)
- if pc > f.entry {
- print(" +", hex(pc-f.entry))
+ if pc > f.entry() {
+ print(" +", hex(pc-f.entry()))
}
print("\n")
}
}
print(name, "(...)\n")
print("\t", file, ":", line)
- if pc > f.entry {
- print(" +", hex(pc-f.entry))
+ if pc > f.entry() {
+ print(" +", hex(pc-f.entry()))
}
print("\n")
}