You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In #183 the definition of errors.Frame was altered to type Frame runtime.Frame. This was necessary because of the changes to mid stack inlining in Go 1.12 and the deprecation of runtime.FuncForPC.
I agree.. Since we can obtain runtime.Frame from PC's we could have just let good ol' Frame stay there. But I don't know whether it's too late to revert this breaking change or not. Other libraries might have adopted this change :(
we could alter implementation of format like this:
// format allows stack trace printing calls to be made with a bytes.Buffer.func (ptrFrameFrame) format(w io.Writer, s fmt.State, verbrune) {
frames:=runtime.CallersFrames([]uintptr{uintptr(ptrFrame)})
ifframes==nil {
return
}
f, _:=frames.Next()
....
The goal is to return to the original type Frame uintptr declaration. This would only work of the runtime.CallersFrames conversion is accurate when passed a single pc, and that still leaves the problem of converting from a uintptr Frame to a runtime.Func to retrieve the name, file, and line.
On 6 Jan 2019, at 21:04, Mohamad mehdi Kharatizadeh ***@***.***> wrote:
we could alter implementation of format like this:
// format allows stack trace printing calls to be made with a bytes.Buffer.
func (ptrFrame MyFrame) format(w io.Writer, s fmt.State, verb rune) {
frames := runtime.CallersFrames([]uintptr{uintptr(ptrFrame)})
if frames == nil {
return
}
f, _ := frames.Next()
....
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
I understand. I was merely pointing out that we could obtain an instance of runtime.Frame this way instead of #183 . And we could use runtime.Frame.Function, runtime.Frame.Line.. etc. And I've confirmed that we can accurately convert a single PC to runtime.Frame.
Complete listing is as follows:
Basically it's #183 without changing type of errors.Frame. Instead a we convert a single PC to runtime.Frame and the rest is still #183
On 6 Jan 2019, at 21:56, Mohamad mehdi Kharatizadeh ***@***.***> wrote:
I understand. I was merely pointing out that we could obtain an instance of runtime.Frame this way instead of #183 . And we could use runtime.Frame.Function, runtime.Frame.Line.. etc. And I've confirmed that we can accurately convert a single PC to runtime.Frame.
Complete listing is as follows:
Basically it's #183 without changing type of errors.Frame. Instead a we convert a single PC to runtime.Frame and the rest is still #183
// format allows stack trace printing calls to be made with a bytes.Buffer.
func (ptrFrame Frame) format(w io.Writer, s fmt.State, verb rune) {
frames := runtime.CallersFrames([]uintptr{uintptr(ptrFrame)})
if frames == nil {
return
}
f, _ := frames.Next()
switch verb {
case 's':
switch {
case s.Flag('+'):
fn := runtime.Frame(f).Func
if fn == nil {
io.WriteString(w, "unknown")
} else {
file := runtime.Frame(f).File
io.WriteString(w, fn.Name())
io.WriteString(w, "\n\t")
io.WriteString(w, file)
}
default:
file := runtime.Frame(f).File
if file == "" {
file = "unknown"
}
io.WriteString(w, path.Base(file))
}
case 'd':
io.WriteString(w, strconv.Itoa(runtime.Frame(f).Line))
case 'n':
name := runtime.Frame(f).Function
io.WriteString(s, funcname(name))
case 'v':
ptrFrame.format(w, s, 's')
io.WriteString(w, ":")
ptrFrame.format(w, s, 'd')
}
}
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
Thanks for letting me know. I’m watching the changes to runtime.FuncForPC and will revert the change in pkg/errors if Go 1.12 reverts their changes to func for pc.
At the moment the workaround is to use v0.8.1 which was tagged before the change to errors.Frame.
On 7 Jan 2019, at 23:08, Bo Sunesen ***@***.***> wrote:
Is there any reason for using runtime.Frame(f).Func.Name() instead of runtime.Frame(f).Function?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
Activity
arcana261 commentedon Jan 6, 2019
I agree.. Since we can obtain
runtime.Framefrom PC's we could have just let good ol'Framestay there. But I don't know whether it's too late to revert this breaking change or not. Other libraries might have adopted this change :(davecheney commentedon Jan 6, 2019
How would you do that?
As to breaking change on master, I tagged v0.8.1 before I made this change.
arcana261 commentedon Jan 6, 2019
using
runtime.CallersFrames? maybe?Thank you for tagging.. much appreciated ^_^
arcana261 commentedon Jan 6, 2019
we could alter implementation of
formatlike this:davecheney commentedon Jan 6, 2019
arcana261 commentedon Jan 6, 2019
I understand. I was merely pointing out that we could obtain an instance of
runtime.Framethis way instead of #183 . And we could useruntime.Frame.Function,runtime.Frame.Line.. etc. And I've confirmed that we can accurately convert a single PC toruntime.Frame.Complete listing is as follows:
Basically it's #183 without changing type of
errors.Frame. Instead a we convert a single PC toruntime.Frameand the rest is still #183davecheney commentedon Jan 6, 2019
uberbo commentedon Jan 7, 2019
Is there any reason for using
runtime.Frame(f).Func.Name()instead ofruntime.Frame(f).Function?dcu commentedon Jan 8, 2019
aws/aws-xray-sdk-go#77 is related to this
davecheney commentedon Jan 8, 2019
davecheney commentedon Jan 9, 2019
Closed in #193