github.com/arnodel/golua@v0.0.0-20230215163904-e0b5347eaaa1/lib/debuglib/lua/traceback.lua (about) 1 print(debug.traceback()) 2 --> =in function <main chunk> (file luatest:1) 3 4 5 print(debug.traceback("foo")) 6 --> =foo 7 --> =in function <main chunk> (file luatest:5) 8 9 function foo() 10 print(debug.traceback("in a function")) 11 end 12 foo() 13 --> =in a function 14 --> =in function foo (file luatest:10) 15 --> =in function <main chunk> (file luatest:12) 16 17 function bar() 18 pcall(foo) 19 end 20 bar() 21 --> =in a function 22 --> =in function foo (file luatest:10) 23 --> =in function pcall (file [Go]) 24 --> =in function bar (file luatest:18) 25 --> =in function <main chunk> (file luatest:20) 26 27 print(xpcall(error, debug.traceback, "bar")) 28 --> ~false\t.*: bar 29 --> =in function error (file [Go]) 30 --> =in function xpcall (file [Go]) 31 --> =in function <main chunk> (file luatest:27) 32 33 function foo(x) bar(x) end 34 function bar(x) baz(x) end 35 function baz(x) print(debug.traceback(nil, x)) end 36 37 foo(1) 38 --> =in function baz (file luatest:35) 39 --> =in function bar (file luatest:34) 40 --> =in function foo (file luatest:33) 41 --> =in function <main chunk> (file luatest:37) 42 43 foo(2) 44 --> =in function bar (file luatest:34) 45 --> =in function foo (file luatest:33) 46 --> =in function <main chunk> (file luatest:43) 47 48 foo(3) 49 --> =in function foo (file luatest:33) 50 --> =in function <main chunk> (file luatest:48) 51 52 -- We run out of stack here: 53 foo(10) 54 --> = 55 56 function cofoo() 57 cobar() 58 end 59 60 function cobar() 61 coroutine.yield(1) 62 end 63 64 co = coroutine.create(cofoo) 65 print(coroutine.resume(co)) 66 --> =true 1 67 68 print(debug.traceback(co)) 69 --> =in function cobar (file luatest:61) 70 --> =in function cofoo (file luatest:57) 71 72 print(debug.traceback({})) 73 --> ~table:.* 74 75 print(pcall(debug.traceback, "foo", "bar")) 76 --> ~false\t.*#2 must be an integer