diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 816b2e5b..234256ea 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -48,6 +48,13 @@ jobs: make sudo make install + - name: Install Pallene Tracer + run: | + git clone - https://github.com/pallene-lang/pallene-tracer + cd pallene-tracer + sudo make install + sudo luarocks make pallene-tracer-0.5.0a-1.rockspec + - name: Install Luacheck run: luarocks install --local luacheck @@ -77,6 +84,13 @@ jobs: make sudo make install + - name: Install Pallene Tracer + run: | + git clone - https://github.com/pallene-lang/pallene-tracer + cd pallene-tracer + sudo make install + sudo luarocks make pallene-tracer-0.5.0a-1.rockspec + - name: Build run: luarocks --local make diff --git a/src/pallene/c_compiler.lua b/src/pallene/c_compiler.lua index e884fdb6..3c8d0fd0 100644 --- a/src/pallene/c_compiler.lua +++ b/src/pallene/c_compiler.lua @@ -18,7 +18,6 @@ local c_compiler = {} local CC = os.getenv("CC") or "cc" local CFLAGS = os.getenv("CFLAGS") or "-O2" -local SHLIBLOC = os.getenv("SHLIBLOC") or "/usr/local/lib" local function get_uname() local ok, err, uname = util.outputs_of_execute("uname -s") @@ -63,7 +62,7 @@ function c_compiler.compile_o_to_so(in_filename, out_filename) "-o", util.shell_quote(out_filename), util.shell_quote(in_filename), "-lptracer", - "-Wl,-rpath="..SHLIBLOC, + "-Wl,-rpath=/usr/local/lib", }) end diff --git a/src/pallene/coder.lua b/src/pallene/coder.lua index 19ae5c75..860357e0 100644 --- a/src/pallene/coder.lua +++ b/src/pallene/coder.lua @@ -1802,6 +1802,10 @@ function Coder:generate_module_header() table.insert(out, "/* This file was generated by the Pallene compiler. Do not edit by hand */") table.insert(out, "") table.insert(out, string.format("#define PALLENE_SOURCE_FILE %s", C.string(self.filename))) + if self.flags.use_traceback then + table.insert(out, "/* Enable Pallene Tracer debugging. */") + table.insert(out, "#define PT_DEBUG") + end table.insert(out, "") table.insert(out, "/* ------------------------ */") diff --git a/src/pallene/pallenelib.lua b/src/pallene/pallenelib.lua index bb2129da..09199567 100644 --- a/src/pallene/pallenelib.lua +++ b/src/pallene/pallenelib.lua @@ -47,7 +47,7 @@ return [==[ #include /* Pallene Tracer for tracebacks (dynamically linked). */ -/* Look at https://github.com/pallene-lang/pallene-tracer for more info. */ +/* Look at `https://github.com/pallene-lang/pallene-tracer` for more info. */ #include #define PALLENE_UNREACHABLE __builtin_unreachable() @@ -55,37 +55,27 @@ return [==[ /* PALLENE TRACER MACROS */ /* Prepares finalizer function for Lua interface calls. */ -#define PALLENE_PREPARE_FINALIZER() \ - setobj(L, s2v(L->top.p++), &K->uv[1].uv); \ +#define PALLENE_PREPARE_FINALIZER() \ + setobj(L, s2v(L->top.p++), &K->uv[1].uv); \ lua_toclose(L, -1) -#define PALLENE_C_FRAMEENTER(L, name) \ - pt_cont_t *cont = pvalue(&K->uv[0].uv); \ - static pt_fn_details_t _details = { \ - .fn_name = name, \ - .filename = PALLENE_SOURCE_FILE \ - }; \ - pt_frame_t _frame = { \ - .type = PALLENE_TRACER_FRAME_TYPE_C, \ - .shared = { \ - .details = &_details \ - } \ - }; \ - pallene_tracer_frameenter(L, cont, &_frame) - -#define PALLENE_LUA_FRAMEENTER(L, sig) \ - pt_cont_t *cont = pvalue(&K->uv[0].uv); \ - pt_frame_t _frame = { \ - .type = PALLENE_TRACER_FRAME_TYPE_LUA, \ - .shared = { \ - .frame_sig = sig \ - } \ - }; \ - pallene_tracer_frameenter(L, cont, &_frame); \ +#define PALLENE_C_FRAMEENTER(L, name) \ + pt_fnstack_t *fnstack = pvalue(&K->uv[0].uv); \ + static pt_fn_details_t _details = \ + PALLENE_TRACER_FN_DETAILS(name, PALLENE_SOURCE_FILE); \ + pt_frame_t _frame = \ + PALLENE_TRACER_C_FRAME(_details); \ + PALLENE_TRACER_FRAMEENTER(L, fnstack, &_frame); + +#define PALLENE_LUA_FRAMEENTER(L, fnptr) \ + pt_fnstack_t *fnstack = pvalue(&K->uv[0].uv); \ + pt_frame_t _frame = \ + PALLENE_TRACER_LUA_FRAME(fnptr); \ + PALLENE_TRACER_FRAMEENTER(L, fnstack, &_frame); \ PALLENE_PREPARE_FINALIZER() -#define PALLENE_SETLINE(line) pallene_tracer_setline(cont, line) -#define PALLENE_FRAMEEXIT() pallene_tracer_frameexit(cont) +#define PALLENE_SETLINE(line) PALLENE_TRACER_SETLINE(fnstack, line) +#define PALLENE_FRAMEEXIT() PALLENE_TRACER_FRAMEEXIT(fnstack) /* Type tags */ static const char *pallene_type_name(lua_State *L, const TValue *v);