Skip to content

Commit

Permalink
Pallene Tracer adoption and CI script update
Browse files Browse the repository at this point in the history
  • Loading branch information
singul4ri7y committed Aug 3, 2024
1 parent 8d99ce3 commit bdfd1eb
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 30 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
3 changes: 1 addition & 2 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 SHLIBLOC = os.getenv("SHLIBLOC") or "/usr/local/lib"

local function get_uname()
local ok, err, uname = util.outputs_of_execute("uname -s")
Expand Down Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions src/pallene/coder.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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, "/* ------------------------ */")
Expand Down
46 changes: 18 additions & 28 deletions src/pallene/pallenelib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -47,45 +47,35 @@ return [==[
#include <stdlib.h>
/* 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 <ptracer.h>
#define PALLENE_UNREACHABLE __builtin_unreachable()
/* 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);
Expand Down

0 comments on commit bdfd1eb

Please sign in to comment.