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

Pallene Tracer new API adaption #621

Merged
merged 3 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ jobs:
run: |
git clone https://github.com/pallene-lang/pallene-tracer
cd pallene-tracer
sudo make install
luarocks --local make
sudo make install LUA_DIR=/usr/local

- name: Build
run: luarocks --local make
Expand Down
1 change: 0 additions & 1 deletion pallene-dev-1.rockspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ dependencies = {
"lua == 5.4",
"lpeg >= 1.0",
"argparse >= 0.7.0",
"pallene-tracer >= 0.5.0a"
}
external_dependencies = {
PTRACER = {
Expand Down
11 changes: 3 additions & 8 deletions spec/traceback/anon_lua/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@

local anon = require "spec.traceback.anon_lua.anon_lua"

local function wrapper()
anon.call_anon_lua_fn(function()
error "Error from an anonymous Lua fn!"
end)
end

-- luacheck: globals pallene_tracer_debug_traceback
xpcall(wrapper, pallene_tracer_debug_traceback)
anon.call_anon_lua_fn(function()
error "Error from an anonymous Lua fn!"
end)
10 changes: 1 addition & 9 deletions spec/traceback/depth_recursion/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,4 @@ function lua_fn(depth)
pallene.pallene_fn(lua_fn, depth - 1)
end

-- Should be local.
-- Making it global so that it is visible in the traceback.
-- luacheck: globals wrapper
function wrapper()
lua_fn(10)
end

-- luacheck: globals pallene_tracer_debug_traceback
xpcall(wrapper, pallene_tracer_debug_traceback)
lua_fn(10)
10 changes: 1 addition & 9 deletions spec/traceback/module_lua/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,4 @@ function lua_3(sum)
error "Any normal error from Lua!"
end

-- Should be local.
-- Making it global so that it is visible in the traceback.
-- luacheck: globals wrapper
function wrapper()
another_module.call_lua_callback(lua_1)
end

-- luacheck: globals pallene_tracer_debug_traceback
xpcall(wrapper, pallene_tracer_debug_traceback)
another_module.call_lua_callback(lua_1)
10 changes: 1 addition & 9 deletions spec/traceback/module_pallene/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,4 @@ function lua_1()
pallene_alt.alternate_everyday_fn(lua_2)
end

-- Should be local.
-- Making it global so that it is visible in the traceback.
-- luacheck: globals wrapper
function wrapper()
pallene.normal_everyday_fn(lua_1)
end

-- luacheck: globals pallene_tracer_debug_traceback
xpcall(wrapper, pallene_tracer_debug_traceback)
pallene.normal_everyday_fn(lua_1)
10 changes: 1 addition & 9 deletions spec/traceback/rect/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,4 @@

local rect = require "spec.traceback.rect.rect"

-- Should be local.
-- Making it global so that it is visible in the traceback.
-- luacheck: globals wrapper
function wrapper()
print(rect.area { width = "Huh, gotcha!", height = 16.0 })
end

-- luacheck: globals pallene_tracer_debug_traceback
xpcall(wrapper, pallene_tracer_debug_traceback)
print(rect.area { width = "Huh, gotcha!", height = 16.0 })
8 changes: 1 addition & 7 deletions spec/traceback/stack_overflow/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,4 @@ function please_dont_overflow()
so.no_overflow(please_dont_overflow)
end

-- luacheck: globals wrapper
function wrapper()
please_dont_overflow()
end

-- luacheck: globals pallene_tracer_debug_traceback
xpcall(wrapper, pallene_tracer_debug_traceback)
please_dont_overflow()
45 changes: 15 additions & 30 deletions spec/traceback_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,18 @@ local function assert_test(test, expected_traceback)
end

local luafile = util.shell_quote("spec/traceback/"..test.."/main.lua")
local ok, err, _, err_content = util.outputs_of_execute("lua "..luafile)
assert(ok, err)
local ok, _, output_content, err_content = util.outputs_of_execute("pt-run "..luafile)
assert(not ok, output_content)
assert.are.same(expected_traceback, err_content)
end

it("Rectangle", function()
assert_test("rect", [[
Runtime error: spec/traceback/rect/main.lua:12: file spec/traceback/rect/rect.pln: line 10: wrong type for downcasted value, expected float but found string
Runtime error: spec/traceback/rect/main.lua:8: file spec/traceback/rect/rect.pln: line 10: wrong type for downcasted value, expected float but found string
Stack traceback:
spec/traceback/rect/rect.pln:10: in function 'universal_calc_area'
spec/traceback/rect/rect.pln:13: in function 'area'
spec/traceback/rect/main.lua:12: in function 'wrapper'
C: in function 'xpcall'
spec/traceback/rect/main.lua:16: in <main>
C: in function '<?>'
spec/traceback/rect/main.lua:8: in <main>
]])
end)

Expand All @@ -48,10 +45,7 @@ Stack traceback:
spec/traceback/module_lua/module_lua.pln:8: in function 'pallene_1'
spec/traceback/module_lua/main.lua:12: in function 'callback'
./spec/traceback/module_lua/another_module.lua:7: in function 'call_lua_callback'
spec/traceback/module_lua/main.lua:32: in function 'wrapper'
C: in function 'xpcall'
spec/traceback/module_lua/main.lua:36: in <main>
C: in function '<?>'
spec/traceback/module_lua/main.lua:28: in <main>
Copy link
Member

Choose a reason for hiding this comment

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

These test cases are breaking too often (#617). We should look at this later.

]])
end)

Expand All @@ -64,10 +58,7 @@ Stack traceback:
spec/traceback/module_pallene/module_pallene_alt.pln:8: in function 'alternate_everyday_fn'
spec/traceback/module_pallene/main.lua:16: in function 'lua_1'
spec/traceback/module_pallene/module_pallene.pln:8: in function 'normal_everyday_fn'
spec/traceback/module_pallene/main.lua:23: in function 'wrapper'
C: in function 'xpcall'
spec/traceback/module_pallene/main.lua:27: in <main>
C: in function '<?>'
spec/traceback/module_pallene/main.lua:19: in <main>
]])
end)

Expand All @@ -87,10 +78,7 @@ Stack traceback:
spec/traceback/depth_recursion/main.lua:14: in function 'lua_fn'
spec/traceback/depth_recursion/depth_recursion.pln:8: in function 'pallene_fn'
spec/traceback/depth_recursion/main.lua:14: in function 'lua_fn'
spec/traceback/depth_recursion/main.lua:21: in function 'wrapper'
C: in function 'xpcall'
spec/traceback/depth_recursion/main.lua:25: in <main>
C: in function '<?>'
spec/traceback/depth_recursion/main.lua:17: in <main>
]])
end)

Expand All @@ -109,31 +97,28 @@ Stack traceback:
spec/traceback/stack_overflow/stack_overflow.pln:8: in function 'no_overflow'
spec/traceback/stack_overflow/main.lua:10: in function 'please_dont_overflow'

... (Skipped 379 frames) ...
... (Skipped 380 frames) ...

spec/traceback/stack_overflow/main.lua:10: in function 'please_dont_overflow'
spec/traceback/stack_overflow/stack_overflow.pln:8: in function 'no_overflow'
spec/traceback/stack_overflow/main.lua:10: in function 'please_dont_overflow'
spec/traceback/stack_overflow/stack_overflow.pln:8: in function 'no_overflow'
spec/traceback/stack_overflow/main.lua:10: in function 'please_dont_overflow'
spec/traceback/stack_overflow/stack_overflow.pln:8: in function 'no_overflow'
spec/traceback/stack_overflow/main.lua:10: in function 'please_dont_overflow'
spec/traceback/stack_overflow/stack_overflow.pln:8: in function 'no_overflow'
spec/traceback/stack_overflow/main.lua:10: in function 'please_dont_overflow'
spec/traceback/stack_overflow/main.lua:15: in function 'wrapper'
C: in function 'xpcall'
spec/traceback/stack_overflow/main.lua:19: in <main>
C: in function '<?>'
spec/traceback/stack_overflow/main.lua:13: in <main>
]])
end)

it("Anonymous lua functions", function()
assert_test("anon_lua", [[
Runtime error: spec/traceback/anon_lua/main.lua:10: Error from an anonymous Lua fn!
Runtime error: spec/traceback/anon_lua/main.lua:9: Error from an anonymous Lua fn!
Stack traceback:
C: in function 'error'
spec/traceback/anon_lua/main.lua:10: in function '<?>'
spec/traceback/anon_lua/anon_lua.pln:8: in function 'call_anon_lua_fn'
spec/traceback/anon_lua/main.lua:9: in function '<?>'
C: in function 'xpcall'
spec/traceback/anon_lua/main.lua:15: in <main>
C: in function '<?>'
spec/traceback/anon_lua/anon_lua.pln:8: in function 'call_anon_lua_fn'
spec/traceback/anon_lua/main.lua:8: in <main>
]])
end)
3 changes: 0 additions & 3 deletions src/pallene/c_compiler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ local c_compiler = {}

local CC = os.getenv("CC") or "cc"
local CFLAGS = os.getenv("CFLAGS") or "-O2"
local PTLIBDIR = os.getenv("PTLIBDIR") or "/usr/local/lib"

local function get_uname()
local ok, err, uname = util.outputs_of_execute("uname -s")
Expand Down Expand Up @@ -62,8 +61,6 @@ function c_compiler.compile_o_to_so(in_filename, out_filename)
CFLAGS_SHARED,
"-o", util.shell_quote(out_filename),
util.shell_quote(in_filename),
"-lptracer",
"-Wl,-rpath="..PTLIBDIR,
})
end

Expand Down
1 change: 1 addition & 0 deletions src/pallene/pallenelib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ return [==[

/* Pallene Tracer for function call tracebacks. */
/* Look at `https://github.com/pallene-lang/pallene-tracer` for more info. */
#define PT_IMPLEMENTATION
#include <ptracer.h>

#define PALLENE_UNREACHABLE __builtin_unreachable()
Expand Down
Loading