aboutsummaryrefslogtreecommitdiff
path: root/src/debug
diff options
context:
space:
mode:
authorJosh Bleecher Snyder <josharian@gmail.com>2021-09-22 11:13:20 -0700
committerJosh Bleecher Snyder <josharian@gmail.com>2021-09-27 22:19:43 +0000
commit45134acbe645665e93cf1d399027d56b44f23299 (patch)
treee95d35f2508f439ed64ba08e1e2ee4e1f1c5d0f5 /src/debug
parent788731387932e70d4dd951770c046c7eec9f9d96 (diff)
downloadgo-45134acbe645665e93cf1d399027d56b44f23299.tar.gz
go-45134acbe645665e93cf1d399027d56b44f23299.zip
debug/gosym: add pcHeader parsing helpers
A subsequent change will duplicate most of case ver116. Make it easier to read. Change-Id: I3a93181c7f094b12715b8a618e9efef7a1438a27 Reviewed-on: https://go-review.googlesource.com/c/go/+/351909 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>
Diffstat (limited to 'src/debug')
-rw-r--r--src/debug/gosym/pclntab.go28
1 files changed, 15 insertions, 13 deletions
diff --git a/src/debug/gosym/pclntab.go b/src/debug/gosym/pclntab.go
index a72f9847d7..555add67e3 100644
--- a/src/debug/gosym/pclntab.go
+++ b/src/debug/gosym/pclntab.go
@@ -225,21 +225,23 @@ func (t *LineTable) parsePclnTab() {
t.quantum = uint32(t.Data[6])
t.ptrsize = uint32(t.Data[7])
+ offset := func(word uint32) uint64 {
+ return t.uintptr(t.Data[8+word*t.ptrsize:])
+ }
+ data := func(word uint32) []byte {
+ return t.Data[offset(word):]
+ }
+
switch possibleVersion {
case ver116:
- t.nfunctab = uint32(t.uintptr(t.Data[8:]))
- t.nfiletab = uint32(t.uintptr(t.Data[8+t.ptrsize:]))
- offset := t.uintptr(t.Data[8+2*t.ptrsize:])
- t.funcnametab = t.Data[offset:]
- offset = t.uintptr(t.Data[8+3*t.ptrsize:])
- t.cutab = t.Data[offset:]
- offset = t.uintptr(t.Data[8+4*t.ptrsize:])
- t.filetab = t.Data[offset:]
- offset = t.uintptr(t.Data[8+5*t.ptrsize:])
- t.pctab = t.Data[offset:]
- offset = t.uintptr(t.Data[8+6*t.ptrsize:])
- t.funcdata = t.Data[offset:]
- t.functab = t.Data[offset:]
+ t.nfunctab = uint32(offset(0))
+ t.nfiletab = uint32(offset(1))
+ t.funcnametab = data(2)
+ t.cutab = data(3)
+ t.filetab = data(4)
+ t.pctab = data(5)
+ t.funcdata = data(6)
+ t.functab = data(6)
functabsize := t.nfunctab*2*t.ptrsize + t.ptrsize
t.functab = t.functab[:functabsize]
case ver12: