cherry
unread,Sep 29, 2015, 6:50:24 PM9/29/15Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golan...@googlegroups.com, Ian Lance Taylor, minux
Hi Gophers,
The doc of runtime.Callers says
> Callers fills the slice pc with the return program counters
and also
> To look up the file and line number of the call itself, use pc[i]-1
The two points become conflict when the return pc is not right
following the CALL instruction, for example, with branch delay slot
between them on architectures like MIPS. CL 14990 brings up the
question.
In order to work with this circumstance, we could either return the
"return pc" (which breaks "pc-1" idiom), or return the pc right after
the CALL instruction, i.e. the delay slot, so "pc-1" still work (but
breaks "return pc" spec). Either way, it needs some adjustment of the
doc. Any suggestions?
Is the main purpose of this function to look up the file/line
information of the CALL instructions? If so, I would go with Ian's
suggestion, keeping the "pc-1" idiom.
BTW, runtime.Caller is fine, as it returns the pc of CALL instruction directly.
Thanks,
Cherry