Skip to content

Commit

Permalink
lj_auditlog.c: Log prototype names (GCstr)
Browse files Browse the repository at this point in the history
Add the initial version of a generic GCobj dumper.
  • Loading branch information
lukego committed Dec 1, 2017
1 parent 4d8b3eb commit 5843c53
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/lj_auditlog.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ static void ensure_log_open() {

/* -- high-level LuaJIT object logging ------------------------------------ */

static void log_GCobj(GCobj *o);

static void log_jit_State(jit_State *J)
{
log_mem("BCRecLog[]", J->bclog, J->nbclog * sizeof(*J->bclog));
Expand All @@ -93,9 +95,31 @@ static void log_GCtrace(GCtrace *T)

static void log_GCproto(GCproto *pt)
{
log_GCobj(gcref(pt->chunkname));
log_mem("GCproto", pt, pt->sizept); /* includes colocated arrays */
}

static void log_GCstr(GCstr *s)
{
log_mem("GCstr", s, sizeof(*s) + s->len);
}

static void log_GCobj(GCobj *o)
{
/* Log some kinds of objects (could be fancier...) */
switch (o->gch.gct) {
case ~LJ_TPROTO:
log_GCproto((GCproto *)o);
break;
case ~LJ_TTRACE:
log_GCtrace((GCtrace *)o);
break;
case ~LJ_TSTR:
log_GCstr((GCstr *)o);
break;
}
}

/* API functions */

/* Log a trace that has just been compiled. */
Expand Down

0 comments on commit 5843c53

Please sign in to comment.