-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Description
Having the parent Module and other method metadata available for each frame in a backtrace is quite useful for pretty printing, but we're currently missing it for inlined frames. For example:
julia> bar() = backtrace()
julia> foo() = bar()
julia> st = stacktrace(foo())
15-element Vector{Base.StackTraces.StackFrame}:
bar at REPL[10]:1 [inlined]
foo() at REPL[11]:1
top-level scope at REPL[13]:1
...
For the foo
frame, the linfo
field contains the MethodInstance
which in turn can be traced back to the Method
using st[2].linfo.def
to get the Module
or other desired metadata. However, for the bar
frame we just get nothing
here.
julia> dump(st[1])
Base.StackTraces.StackFrame
func: Symbol bar
file: Symbol ./REPL[10]
line: Int64 1
linfo: Nothing nothing
from_c: Bool false
inlined: Bool true
pointer: UInt64 0x00007f832223b37c
julia> dump(st[2])
Base.StackTraces.StackFrame
func: Symbol foo
file: Symbol ./REPL[11]
line: Int64 1
linfo: Core.MethodInstance
def: Method
name: Symbol foo
module: Module Main
file: Symbol REPL[11]
line: Int32 1
[.....]
from_c: Bool false
inlined: Bool false
pointer: UInt64 0x00007f832223b37c
A place to start looking is inside the lookup code at
Line 542 in 1a2285b
frame->linfo = NULL; // TODO: if (new_frames[n_frames - 1].linfo) frame->linfo = lookup(func_name in linfo)? |
As suggested there, we should have the MethodInstance (or a CodeInfo thunk for toplevel code... IIRC) for the parent non-inlined frame in new_frames[n_frames-1]
. So if we made sure that contained sufficient information about inlined methods we could fill in linfo
in some way from there.
See also #33065 (comment)