Skip to content

Commit

Permalink
lib_jit.c: Add 'jit.auditlog(filename)' Lua API function
Browse files Browse the repository at this point in the history
Supports opening the auditlog from Lua. Note that the log always
includes every entry since the process started (even if opened late.)
  • Loading branch information
lukego committed Dec 11, 2017
1 parent 857073c commit 671d770
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/lib_jit.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "lj_dispatch.h"
#include "lj_vm.h"
#include "lj_lib.h"
#include "lj_auditlog.h"

#include "luajit.h"

Expand Down Expand Up @@ -80,6 +81,19 @@ LJLIB_CF(jit_flush)
return setjitmode(L, LUAJIT_MODE_FLUSH);
}

LJLIB_CF(jit_auditlog)
{
if (L->base < L->top && tvisstr(L->base)) {
if (lj_auditlog_open(strdata(lj_lib_checkstr(L, 1)))) {
return 0;
} else {
lj_err_caller(L, LJ_ERR_AUDITLOG);
}
} else {
lj_err_argtype(L, 1, "string filename");
}
}

/* Push a string for every flag bit that is set. */
static void flagbits_to_strings(lua_State *L, uint32_t flags, uint32_t base,
const char *str)
Expand Down
1 change: 1 addition & 0 deletions src/lj_errmsg.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ ERRDEF(BADMODN, "name conflict for module " LUA_QS)
ERRDEF(JITPROT, "runtime code generation failed, restricted kernel?")
ERRDEF(NOJIT, "JIT compiler disabled, CPU does not support SSE2")
ERRDEF(JITOPT, "unknown or malformed optimization flag " LUA_QS)
ERRDEF(AUDITLOG,"auditlog could not be opened")

/* Lexer/parser errors. */
ERRDEF(XMODE, "attempt to load chunk with wrong mode")
Expand Down

0 comments on commit 671d770

Please sign in to comment.