Commit b07a214d authored by Josh Bleecher Snyder's avatar Josh Bleecher Snyder

cmd/internal/obj: change linkgetline from C to Go func style

Passes toolstash -cmp.

Change-Id: I8725dee490778be9c1fd31990a6b27df9713c3c9
Reviewed-on: https://go-review.googlesource.com/20957Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
parent 075d6664
...@@ -40,9 +40,7 @@ func TestLineHist(t *testing.T) { ...@@ -40,9 +40,7 @@ func TestLineHist(t *testing.T) {
} }
for i, want := range expect { for i, want := range expect {
var f *LSym f, l := linkgetline(ctxt, int32(i))
var l int32
linkgetline(ctxt, int32(i), &f, &l)
have := fmt.Sprintf("%s:%d", f.Name, l) have := fmt.Sprintf("%s:%d", f.Name, l)
if have != want { if have != want {
t.Errorf("linkgetline(%d) = %q, want %q", i, have, want) t.Errorf("linkgetline(%d) = %q, want %q", i, have, want)
......
...@@ -273,18 +273,15 @@ func (h *LineHist) AbsFileLine(lineno int) (file string, line int) { ...@@ -273,18 +273,15 @@ func (h *LineHist) AbsFileLine(lineno int) (file string, line int) {
// This is a simplified copy of linklinefmt above. // This is a simplified copy of linklinefmt above.
// It doesn't allow printing the full stack, and it returns the file name and line number separately. // It doesn't allow printing the full stack, and it returns the file name and line number separately.
// TODO: Unify with linklinefmt somehow. // TODO: Unify with linklinefmt somehow.
func linkgetline(ctxt *Link, lineno int32, f **LSym, l *int32) { func linkgetline(ctxt *Link, lineno int32) (f *LSym, l int32) {
stk := ctxt.LineHist.At(int(lineno)) stk := ctxt.LineHist.At(int(lineno))
if stk == nil || stk.AbsFile == "" { if stk == nil || stk.AbsFile == "" {
*f = Linklookup(ctxt, "??", HistVersion) return Linklookup(ctxt, "??", HistVersion), 0
*l = 0
return
} }
if stk.Sym == nil { if stk.Sym == nil {
stk.Sym = Linklookup(ctxt, stk.AbsFile, HistVersion) stk.Sym = Linklookup(ctxt, stk.AbsFile, HistVersion)
} }
*f = stk.Sym return stk.Sym, int32(stk.fileLineAt(int(lineno)))
*l = int32(stk.fileLineAt(int(lineno)))
} }
func Linkprfile(ctxt *Link, line int) { func Linkprfile(ctxt *Link, line int) {
......
...@@ -143,9 +143,7 @@ func pctofileline(ctxt *Link, sym *LSym, oldval int32, p *Prog, phase int32, arg ...@@ -143,9 +143,7 @@ func pctofileline(ctxt *Link, sym *LSym, oldval int32, p *Prog, phase int32, arg
if p.As == ATEXT || p.As == ANOP || p.As == AUSEFIELD || p.Lineno == 0 || phase == 1 { if p.As == ATEXT || p.As == ANOP || p.As == AUSEFIELD || p.Lineno == 0 || phase == 1 {
return oldval return oldval
} }
var l int32 f, l := linkgetline(ctxt, p.Lineno)
var f *LSym
linkgetline(ctxt, p.Lineno, &f, &l)
if f == nil { if f == nil {
// print("getline failed for %s %v\n", ctxt->cursym->name, p); // print("getline failed for %s %v\n", ctxt->cursym->name, p);
return oldval return oldval
......
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