Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

track the exact lambda associated with a fptr #14815

Merged
merged 3 commits into from
Jan 31, 2016
Merged

track the exact lambda associated with a fptr #14815

merged 3 commits into from
Jan 31, 2016

Conversation

vtjnash
Copy link
Sponsor Member

@vtjnash vtjnash commented Jan 27, 2016

this allows printing the actual method signature of the function in the call stack

both profiling and backtrace printing have been extended to show this
full linfo signature (when available)

for example:

julia> error(1,'2',"3")
ERROR: 123
 in error(Int64, Char, Vararg{Any}) at error.jl:22
 in eval(Module, Any) at ./boot.jl:265

@yuyichao
Copy link
Contributor

Does this work for sysimg frames?

@vtjnash
Copy link
Sponsor Member Author

vtjnash commented Jan 27, 2016

yes, that is covered too

@yuyichao
Copy link
Contributor

Awesome! Can't wait for the combination of this and #14799 or #12380.

Is this stored in the debug info and can it be loaded by gdb too?

@vtjnash
Copy link
Sponsor Member Author

vtjnash commented Jan 27, 2016

right now it's still just stored in the sysimg -- i'll eventually add a gdb accessor (and get jl_gdblookup to print this extra info too)


# Some tests don't currently work for Appveyor 32-bit Windows
const APPVEYOR_WIN32 = (
OS_NAME == :Windows && WORD_SIZE == 32 && get(ENV, "APPVEYOR", "False") == "True"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this still the case after your fixes @vtjnash?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Passes locally on win32. Try deleting?

edit: I take that back, partially. make testall passes but make testall1 fails...

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that sounds odd. i may need to power on my windows machine to see what's up with backtraces now

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you can't figure this out, please do not merge this with the appveyor special-casing. If it fails on win32 and we don't know how to fix it yet, skip it all the time on win32, not just on appveyor. Tests that fail locally but not on CI is no good.

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think it should be fixed now by 9ce59c8#diff-d4b80bf89e46982070f234dd7cc344a9L1107

the wrong return value there (from a post-v0.4 code reorganization) sometimes causes backtraces to become truncated / corrupted

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like it. Nice work!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

d'oh... it may have fixed win32, but locally win64 still had a failure in make testall1

     * stacktraces          Test Failed
  Expression: catch_backtrace() == StackFrame[]
   Evaluated: [Ptr{Void} @0x000000006d0b869e,Ptr{Void} @0x000000006d0b9680,Ptr{Void} @0x00000002a30eec45,Ptr{Void} @0x00000002a30eed24,Ptr{Void} @0x000000006d0c7eec,Ptr{Void} @0x000000006d09f34a,Ptr{Void} @0x000000006d0c885d,Ptr{Void} @0x000000001b43b00f,Ptr{Void} @0x000000001b43b037,Ptr{Void} @0x000000006d093697,Ptr{Void} @0x000000001b41f749,Ptr{Void} @0x000000001b41f9c7,Ptr{Void} @0x000000006d093697,Ptr{Void} @0x0000000020298f88,Ptr{Void} @0x0000000020299972,Ptr{Void} @0x0000000020299a2e,Ptr{Void} @0x000000006d093697,Ptr{Void} @0x00000000202720b9,Ptr{Void} @0x000000006d093697,Ptr{Void} @0x000000006d0a6d1a,Ptr{Void} @0x000000002026f0be,Ptr{Void} @0x000000006d093697,Ptr{Void} @0x0000000020270cdc,Ptr{Void} @0x0000000020271944,Ptr{Void} @0x000000006d09374f,Ptr{Void} @0x000000006d0b9891] == StackFrame[]
ERROR: LoadError: LoadError: There was an error during testing
 in record(Base.Test.#record, Base.Test.FallbackTestSet, Base.Test.Fail) at .\test.jl:317
 in do_test(Base.Test.#do_test, Base.Test.Returned, Expr) at .\test.jl:215
 in include(Core.#include, UTF8String) at .\boot.jl:264
 in include_from_node1(Base.#include_from_node1, ASCIIString) at .\loading.jl:417
 [inlined code] from .\util.jl:179
 in runtests(#runtests, ASCIIString) at C:\cygwin64\home\Tony\julia\test\testdefs.jl:7
 in run_work_thunk(Base.#run_work_thunk, Base.##247#248{##16#24,Tuple{ASCIIString}}, Bool) at .\multi.jl:714
 in remotecall_fetch(Base.#remotecall_fetch, Any, LocalProcess, ASCIIString, Vararg{ASCIIString}) at .\multi.jl:787
 in remotecall_fetch(Base.#remotecall_fetch, Any, Int64, ASCIIString, Vararg{ASCIIString}) at .\multi.jl:803
 [inlined code] from C:\cygwin64\home\Tony\julia\test\runtests.jl:36
 in #15(##15#23{Array{ASCIIString,1}}) at .\task.jl:431
while loading C:\cygwin64\home\Tony\julia\test\stacktraces.jl, in expression starting on line 45
 in remotecall_fetch(Base.#remotecall_fetch, Any, LocalProcess, ASCIIString, Vararg{ASCIIString}) at .\multi.jl:788
 in remotecall_fetch(Base.#remotecall_fetch, Any, Int64, ASCIIString, Vararg{ASCIIString}) at .\multi.jl:803
 [inlined code] from C:\cygwin64\home\Tony\julia\test\runtests.jl:36
 in #15(##15#23{Array{ASCIIString,1}}) at .\task.jl:431
 in sync_end(Base.#sync_end) at .\task.jl:397
 [inlined code] from .\task.jl:406
 in #11(##11#19) at C:\cygwin64\home\Tony\julia\test\runtests.jl:31
 in cd(Base.Filesystem.#cd, ##11#19, ASCIIString) at .\file.jl:57
 in include(Core.#include, ASCIIString) at .\boot.jl:264
 in include_from_node1(Base.#include_from_node1, UTF8String) at .\loading.jl:417
 in process_options(Base.#process_options, Base.JLOptions) at .\client.jl:244
 in _start(Base.#_start) at .\client.jl:300
while loading C:\cygwin64\home\Tony\julia\test\runtests.jl, in expression starting on line 13

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, right. that test needs to be fixed to work with make testall1. i'll work on submitting a patch

edit: 8702da3

@vtjnash vtjnash force-pushed the jn/debug branch 5 times, most recently from 346c230 to 0d7d141 Compare January 30, 2016 06:48
vtjnash and others added 2 commits January 30, 2016 15:25
this allows printing the actual method signature of the function in the call stack

both profiling and backtrace printing have been extended to show this
full linfo signature (when available)
Tests and documentation for stacktraces.
Updated NEWS.md with stacktraces functionality.
Refactored, doctests, show_stacktrace is now show.
Added doctests to the manual.
Removed show_stacktrace in favour of show(x::StackFrame).
Removed format_stacktrace and format_stackframe.
Additional test cases (which currently fail due to difficult to track down line number issues)
Test for invalid frame. Removed failing Win32 test.
Reintroduced UNKNOWN constant stack frame from profile.jl.
Added test case for looking up an invalid stack frame.
Selectively removed some tests that consistently fail in Appveyor's 32-bit Windows LVM.
@vtjnash vtjnash force-pushed the jn/debug branch 2 times, most recently from 6864bc3 to d10854a Compare January 30, 2016 21:01
@Keno
Copy link
Member

Keno commented Jan 30, 2016

Great! I had a hacky version of this locally. I'll update my code to use this version instead.

vtjnash added a commit that referenced this pull request Jan 31, 2016
track the exact lambda associated with a fptr
@vtjnash vtjnash merged commit 278d128 into master Jan 31, 2016
@vtjnash vtjnash deleted the jn/debug branch January 31, 2016 15:06
@Keno
Copy link
Member

Keno commented Jan 31, 2016

While you're on this track, I think one thing that would be super useful to do is to fix the way we handle inlined functions. The DWARF we generate right now is highly incorrect, and the AST representation is probably not much better. It would also be good to have a map of which functions a given function was inlined into, such that setting a breakpoint actually works (that's the one major case that won't work on my new iteration of Gallium - correctly breaking if a function was inlined).

@vtjnash
Copy link
Sponsor Member Author

vtjnash commented Jan 31, 2016

Does the map need IR range coverage, or will it be sufficient (at least for now) if I just add a link to the right lambda static data?

@Keno
Copy link
Member

Keno commented Jan 31, 2016

For now, as long as I can ask, "get me all the lambda infos into which this function was inlined" (and can go to an fptr from there), that would be most amazing!

print(io,"\n$(code[1]) will only return a complex result if called with a complex argument. Try $(code[1])(complex(x)).")
elseif (code[1] == :^ && code[2] == symbol("intfuncs.jl")) || code[1] == :power_by_squaring #3024
code = StackTraces.lookup(b)
if code !== lookup && code.from_c
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be StackTraces.lookup? the error message from sqrt(-1) is currently broken by this, evidently needs a test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants