Commit 516c6b40 authored by Shahar Kohanim's avatar Shahar Kohanim Committed by David Crawshaw

cmd/link: Clean up Pcln struct

Removes unnecessary fields from Pcln.

Change-Id: I175049ca749b510eedaf65162355bc4d7a93315e
Reviewed-on: https://go-review.googlesource.com/21041Reviewed-by: 's avatarDavid Crawshaw <crawshaw@golang.org>
parent 53efe1e1
......@@ -344,7 +344,7 @@ func (d *deadcodepass) flood() {
}
if s.Pcln != nil {
for i := 0; i < s.Pcln.Nfuncdata; i++ {
for i := range s.Pcln.Funcdata {
d.mark(s.Pcln.Funcdata[i], s)
}
}
......
......@@ -1367,7 +1367,7 @@ func finddebugruntimepath(s *LSym) {
return
}
for i := 0; i < s.Pcln.Nfile; i++ {
for i := range s.Pcln.File {
f := s.Pcln.File[i]
if i := strings.Index(f.Name, "runtime/runtime.go"); i >= 0 {
gdbscript = f.Name[:i] + "runtime/runtime-gdb.py"
......
......@@ -235,13 +235,9 @@ type Pcln struct {
Pcfile Pcdata
Pcline Pcdata
Pcdata []Pcdata
Npcdata int
Funcdata []*LSym
Funcdataoff []int64
Nfuncdata int
File []*LSym
Nfile int
Mfile int
Lastfile *LSym
Lastindex int
}
......
......@@ -282,14 +282,12 @@ overwrite:
pc.Pcline.P = rddata(f, buf)
n = rdint(f)
pc.Pcdata = make([]Pcdata, n)
pc.Npcdata = n
for i := 0; i < n; i++ {
pc.Pcdata[i].P = rddata(f, buf)
}
n = rdint(f)
pc.Funcdata = make([]*LSym, n)
pc.Funcdataoff = make([]int64, n)
pc.Nfuncdata = n
for i := 0; i < n; i++ {
pc.Funcdata[i] = rdsym(ctxt, f, pkg)
}
......@@ -298,7 +296,6 @@ overwrite:
}
n = rdint(f)
pc.File = make([]*LSym, n)
pc.Nfile = n
for i := 0; i < n; i++ {
pc.File[i] = rdsym(ctxt, f, pkg)
}
......
......@@ -280,8 +280,8 @@ func pclntab() {
// fixed size of struct, checked below
off = funcstart
end = funcstart + int32(Thearch.Ptrsize) + 3*4 + 5*4 + int32(pcln.Npcdata)*4 + int32(pcln.Nfuncdata)*int32(Thearch.Ptrsize)
if pcln.Nfuncdata > 0 && (end&int32(Thearch.Ptrsize-1) != 0) {
end = funcstart + int32(Thearch.Ptrsize) + 3*4 + 5*4 + int32(len(pcln.Pcdata))*4 + int32(len(pcln.Funcdata))*int32(Thearch.Ptrsize)
if len(pcln.Funcdata) > 0 && (end&int32(Thearch.Ptrsize-1) != 0) {
end += 4
}
Symgrow(Ctxt, ftab, int64(end))
......@@ -321,19 +321,19 @@ func pclntab() {
off = addpctab(ftab, off, &pcln.Pcfile)
off = addpctab(ftab, off, &pcln.Pcline)
off = int32(setuint32(Ctxt, ftab, int64(off), uint32(pcln.Npcdata)))
off = int32(setuint32(Ctxt, ftab, int64(off), uint32(pcln.Nfuncdata)))
for i = 0; i < int32(pcln.Npcdata); i++ {
off = int32(setuint32(Ctxt, ftab, int64(off), uint32(len(pcln.Pcdata))))
off = int32(setuint32(Ctxt, ftab, int64(off), uint32(len(pcln.Funcdata))))
for i = 0; i < int32(len(pcln.Pcdata)); i++ {
off = addpctab(ftab, off, &pcln.Pcdata[i])
}
// funcdata, must be pointer-aligned and we're only int32-aligned.
// Missing funcdata will be 0 (nil pointer).
if pcln.Nfuncdata > 0 {
if len(pcln.Funcdata) > 0 {
if off&int32(Thearch.Ptrsize-1) != 0 {
off += 4
}
for i = 0; i < int32(pcln.Nfuncdata); i++ {
for i = 0; i < int32(len(pcln.Funcdata)); i++ {
if pcln.Funcdata[i] == nil {
setuintxx(Ctxt, ftab, int64(off)+int64(Thearch.Ptrsize)*int64(i), uint64(pcln.Funcdataoff[i]), int64(Thearch.Ptrsize))
} else {
......@@ -344,11 +344,11 @@ func pclntab() {
}
}
off += int32(pcln.Nfuncdata) * int32(Thearch.Ptrsize)
off += int32(len(pcln.Funcdata)) * int32(Thearch.Ptrsize)
}
if off != end {
Diag("bad math in functab: funcstart=%d off=%d but end=%d (npcdata=%d nfuncdata=%d ptrsize=%d)", funcstart, off, end, pcln.Npcdata, pcln.Nfuncdata, Thearch.Ptrsize)
Diag("bad math in functab: funcstart=%d off=%d but end=%d (npcdata=%d nfuncdata=%d ptrsize=%d)", funcstart, off, end, len(pcln.Pcdata), len(pcln.Funcdata), Thearch.Ptrsize)
errorexit()
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment