Skip to content

Instantly share code, notes, and snippets.

@vtjnash
Last active August 29, 2015 14:05
Show Gist options
  • Save vtjnash/4420c11ede5eb71554fc to your computer and use it in GitHub Desktop.
Save vtjnash/4420c11ede5eb71554fc to your computer and use it in GitHub Desktop.
~/Documents/no-backup/julia/base$ lldb -- ../usr/bin/julia-debug --build x sysimg.jl
Current executable set to '../usr/bin/julia-debug' (x86_64).
(lldb) break set -n jl_throw
Breakpoint 1: no locations (pending).
WARNING: Unable to resolve breakpoint to any actual locations.
(lldb) r
Process 10078 launched: '../usr/bin/julia-debug' (x86_64)
1 location added to breakpoint 1
exports.jl
base.jl
reflection.jl
build_h.jl
version_git.jl
c.jl
promotion.jl
tuple.jl
range.jl
expr.jl
error.jl
bool.jl
number.jl
int.jl
Process 10078 stopped
* thread #1: tid = 0x20cba, 0x00000001000ed61c libjulia-debug.dylib`jl_throw(e=0x0000000101b17f50) + 12 at task.c:745, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
frame #0: 0x00000001000ed61c libjulia-debug.dylib`jl_throw(e=0x0000000101b17f50) + 12 at task.c:745
742 // record backtrace and raise an error
743 DLLEXPORT void jl_throw(jl_value_t *e)
744 {
-> 745 assert(e != NULL);
746 record_backtrace();
747 throw_internal(e);
748 }
(lldb) bt
* thread #1: tid = 0x20cba, 0x00000001000ed61c libjulia-debug.dylib`jl_throw(e=0x0000000101b17f50) + 12 at task.c:745, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
* frame #0: 0x00000001000ed61c libjulia-debug.dylib`jl_throw(e=0x0000000101b17f50) + 12 at task.c:745
frame #1: 0x0000000100020326 libjulia-debug.dylib`jl_undefined_var_error(var=0x0000000101766af8) + 134 at builtins.c:106
frame #2: 0x0000000102204f30
frame #3: 0x0000000100021985 libjulia-debug.dylib`jl_apply(f=0x0000000101b0d0e0, args=0x00007fff5fbfe130, nargs=4) + 69 at julia.h:981
frame #4: 0x0000000100023bfe libjulia-debug.dylib`jl_trampoline(F=0x0000000101b0d0e0, args=0x00007fff5fbfe130, nargs=4) + 558 at builtins.c:811
frame #5: 0x0000000100015215 libjulia-debug.dylib`jl_apply(f=0x0000000101b0d0e0, args=0x00007fff5fbfe130, nargs=4) + 69 at julia.h:981
frame #6: 0x000000010001732d libjulia-debug.dylib`jl_apply_generic(F=0x00000001019278e0, args=0x00007fff5fbfe130, nargs=4) + 749 at gf.c:1428
frame #7: 0x0000000100021985 libjulia-debug.dylib`jl_apply(f=0x00000001019278e0, args=0x00007fff5fbfe130, nargs=4) + 69 at julia.h:981
frame #8: 0x00000001000217b6 libjulia-debug.dylib`jl_f_apply(F=0x000000010186bfa0, args=0x00007fff5fbfe268, nargs=3) + 1766 at builtins.c:337
frame #9: 0x0000000102203fb7
frame #10: 0x0000000100021985 libjulia-debug.dylib`jl_apply(f=0x0000000101b0ce80, args=0x00007fff5fbfe460, nargs=3) + 69 at julia.h:981
frame #11: 0x0000000100023bfe libjulia-debug.dylib`jl_trampoline(F=0x0000000101b0ce80, args=0x00007fff5fbfe460, nargs=3) + 558 at builtins.c:811
frame #12: 0x0000000100015215 libjulia-debug.dylib`jl_apply(f=0x0000000101b0ce80, args=0x00007fff5fbfe460, nargs=3) + 69 at julia.h:981
frame #13: 0x000000010001732d libjulia-debug.dylib`jl_apply_generic(F=0x0000000101927960, args=0x00007fff5fbfe460, nargs=3) + 749 at gf.c:1428
frame #14: 0x0000000102203dac
frame #15: 0x0000000100021985 libjulia-debug.dylib`jl_apply(f=0x0000000101b0ce40, args=0x00007fff5fbfe6d0, nargs=1) + 69 at julia.h:981
frame #16: 0x0000000100023bfe libjulia-debug.dylib`jl_trampoline(F=0x0000000101b0ce40, args=0x00007fff5fbfe6d0, nargs=1) + 558 at builtins.c:811
frame #17: 0x0000000100015215 libjulia-debug.dylib`jl_apply(f=0x0000000101b0ce40, args=0x00007fff5fbfe6d0, nargs=1) + 69 at julia.h:981
frame #18: 0x000000010001732d libjulia-debug.dylib`jl_apply_generic(F=0x000000010194dec0, args=0x00007fff5fbfe6d0, nargs=1) + 749 at gf.c:1428
frame #19: 0x0000000102202ca8
frame #20: 0x0000000100021985 libjulia-debug.dylib`jl_apply(f=0x0000000101b0c7c0, args=0x0000000000000000, nargs=0) + 69 at julia.h:981
frame #21: 0x0000000100023bfe libjulia-debug.dylib`jl_trampoline(F=0x0000000101b0c7c0, args=0x0000000000000000, nargs=0) + 558 at builtins.c:811
frame #22: 0x00000001000f97e5 libjulia-debug.dylib`jl_apply(f=0x0000000101b0c7c0, args=0x0000000000000000, nargs=0) + 69 at julia.h:981
frame #23: 0x00000001000f8da6 libjulia-debug.dylib`jl_toplevel_eval_flex(e=0x0000000101b0ba80, fast=1) + 2342 at toplevel.c:505
frame #24: 0x00000001000f99a8 libjulia-debug.dylib`jl_parse_eval_all(fname=0x000000010191d0f0) + 408 at toplevel.c:541
frame #25: 0x00000001000f9ba9 libjulia-debug.dylib`jl_load(fname=0x000000010191d0f0) + 217 at toplevel.c:575
frame #26: 0x00000001000f9c2b libjulia-debug.dylib`jl_load_(str=0x0000000101941a50) + 43 at toplevel.c:583
frame #27: 0x00000001022002e8
frame #28: 0x0000000100015215 libjulia-debug.dylib`jl_apply(f=0x000000010194e180, args=0x00007fff5fbfed78, nargs=1) + 69 at julia.h:981
frame #29: 0x0000000100017201 libjulia-debug.dylib`jl_apply_generic(F=0x0000000101913bc0, args=0x00007fff5fbfed78, nargs=1) + 449 at gf.c:1409
frame #30: 0x00000001000e26a5 libjulia-debug.dylib`jl_apply(f=0x0000000101913bc0, args=0x00007fff5fbfed78, nargs=1) + 69 at julia.h:981
frame #31: 0x00000001000e2325 libjulia-debug.dylib`do_call(f=0x0000000101913bc0, args=0x00000001030d41f8, nargs=1, eval0=0x0000000000000000, locals=0x0000000000000000, nl=0) + 437 at interpreter.c:72
frame #32: 0x00000001000dfb68 libjulia-debug.dylib`eval(e=0x00000001030d0240, locals=0x0000000000000000, nl=0) + 2232 at interpreter.c:212
frame #33: 0x00000001000df283 libjulia-debug.dylib`jl_interpret_toplevel_expr(e=0x00000001030d0240) + 51 at interpreter.c:25
frame #34: 0x00000001000f8cec libjulia-debug.dylib`jl_toplevel_eval_flex(e=0x0000000101928340, fast=1) + 2156 at toplevel.c:493
frame #35: 0x00000001000f8318 libjulia-debug.dylib`jl_eval_module_expr(ex=0x0000000101927ae0) + 1016 at toplevel.c:143
frame #36: 0x00000001000f8537 libjulia-debug.dylib`jl_toplevel_eval_flex(e=0x0000000101927ae0, fast=1) + 183 at toplevel.c:386
frame #37: 0x00000001000f99a8 libjulia-debug.dylib`jl_parse_eval_all(fname=0x00007fff5fbffc79) + 408 at toplevel.c:541
frame #38: 0x00000001000f9ba9 libjulia-debug.dylib`jl_load(fname=0x00007fff5fbffc79) + 217 at toplevel.c:575
frame #39: 0x000000010000227d julia-debug`exec_program + 301 at repl.c:239
frame #40: 0x0000000100001f55 julia-debug`true_main(argc=1, argv=0x00007fff5fbffb48) + 389 at repl.c:296
frame #41: 0x00000001000ec39f libjulia-debug.dylib`julia_trampoline(argc=1, argv=0x00007fff5fbffb48, pmain=0x0000000100001dd0) + 175 at init.c:1007
frame #42: 0x00000001000024f6 julia-debug`main(argc=1, argv=0x00007fff5fbffb48) + 166 at repl.c:356
(lldb) up
frame #1: 0x0000000100020326 libjulia-debug.dylib`jl_undefined_var_error(var=0x0000000101766af8) + 134 at builtins.c:106
103 if (nxt)
104 var = jl_symbol(nxt+1);
105 }
-> 106 jl_throw(jl_new_struct(jl_undefvarerror_type, var));
107 }
108
109 JL_CALLABLE(jl_f_throw)
(lldb) up
frame #2: 0x0000000102204f30
-> 0x102204f30: movabsq $0x100029ac0, %rax
0x102204f3a: callq *%rax
0x102204f3c: int $-0x33
0x102204f3e: int $-0x33
(lldb) up
frame #3: 0x0000000100021985 libjulia-debug.dylib`jl_apply(f=0x0000000101b0d0e0, args=0x00007fff5fbfe130, nargs=4) + 69 at julia.h:981
978 STATIC_INLINE
979 jl_value_t *jl_apply(jl_function_t *f, jl_value_t **args, uint32_t nargs)
980 {
-> 981 return f->fptr((jl_value_t*)f, args, nargs);
982 }
983
984 DLLEXPORT jl_value_t *jl_call(jl_function_t *f, jl_value_t **args, int32_t nargs);
(lldb) print jl_(f->linfo_
error: no member named 'linfo_' in '_jl_function_t'
error: 1 errors parsing expression
(lldb) print jl_(f->linfo)
Core.__call#1__(Array{Any, 1}, Function, Module, Any...)
(lldb) print nargs
(uint32_t) $0 = 4
(lldb) print jl_(args[0])
Array{Any, 1}[]
(lldb) print jl_(args[1])
#<function>
(lldb) print jl_(args[2])
Base
(lldb) print jl_(args[3])
Expr(:call, :convert, Expr(:::, Expr(:curly, :Type, Int8)::Any)::Any, Expr(:::, :x, Bool)::Any)::Any = Expr(:block, Expr(:line, 288, :int.jl)::Any, Expr(:call, :box, Int8, Expr(:call, :zext_int, Int8, Expr(:call, :unbox, Bool, :x)::Any)::Any)::Any)::Any
(lldb) print jl_(((jl_function_t*)args[1])->linfo)
#<null>
(lldb) print jl_(((jl_function_t*)args[1])->ast)
error: no member named 'ast' in '_jl_function_t'
error: 1 errors parsing expression
(lldb) down
frame #2: 0x0000000102204f30
-> 0x102204f30: movabsq $0x100029ac0, %rax
0x102204f3a: callq *%rax
0x102204f3c: int $-0x33
0x102204f3e: int $-0x33
(lldb) print gdblookup(0x0000000102204f30)
call at boot.jl:247
(lldb) print jl_(*((jl_function_t*)args[1]))
error: use of undeclared identifier 'args'
error: 1 errors parsing expression
(lldb) up
frame #3: 0x0000000100021985 libjulia-debug.dylib`jl_apply(f=0x0000000101b0d0e0, args=0x00007fff5fbfe130, nargs=4) + 69 at julia.h:981
978 STATIC_INLINE
979 jl_value_t *jl_apply(jl_function_t *f, jl_value_t **args, uint32_t nargs)
980 {
-> 981 return f->fptr((jl_value_t*)f, args, nargs);
982 }
983
984 DLLEXPORT jl_value_t *jl_call(jl_function_t *f, jl_value_t **args, int32_t nargs);
(lldb) print jl_(*((jl_function_t*)args[1]))
error: no matching function for call to 'jl_'
note: candidate function not viable: no known conversion from 'jl_function_t' (aka '_jl_function_t') to 'void *' for 1st argument; remove *
error: 1 errors parsing expression
(lldb) print *((jl_function_t*)args[1])
(jl_function_t) $1 = {
type = 0x0000000101859880
fptr = 0x0000000100021da0 (libjulia-debug.dylib`jl_f_top_eval at builtins.c:402)
env = 0x0000000101765ed0
linfo = 0x0000000000000000
}
(lldb) print jl_(((jl_function_t*)args[1])->env)
:eval
(lldb)
------------- ------------- ------------- ------------- ------------- ------------- -------------
------------- I'm going to skip a lot of boring repeated steps now, where -------------
------------- I just do a bunch of stack walking to look at various jl_apply -------------
------------- calls and inspect their f->linfo object and their args -------------
------------- and just jump to a frame that shows some more interesting information -------------
------------- ------------- ------------- ------------- ------------- ------------- -------------
(lldb) frame select 15
frame #15: 0x0000000100021985 libjulia-debug.dylib`jl_apply(f=0x0000000101b0ce40, args=0x00007fff5fbfe6d0, nargs=1) + 69 at julia.h:981
978 STATIC_INLINE
979 jl_value_t *jl_apply(jl_function_t *f, jl_value_t **args, uint32_t nargs)
980 {
-> 981 return f->fptr((jl_value_t*)f, args, nargs);
982 }
983
984 DLLEXPORT jl_value_t *jl_call(jl_function_t *f, jl_value_t **args, int32_t nargs);
(lldb) print jl_(jl_uncompress_ast(f->linfo,f->linfo->ast))
Expr(:lambda, Array{Any, 1}[:x], Array{Any, 1}[Array{Any, 1}[], Array{Any, 1}[Array{Any, 1}[:x, :Any, 0]], Array{Any, 1}[]], Expr(:body,
Expr(:line, 6, :sysimg.jl)::Any,
Expr(:return, Expr(:call, Expr(:call, top(:getfield), :Core, :eval)::Any, :Base, :x)::Any)::Any)::Any)::Any
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment