forked from snabbco/snabb
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
60 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
** Audit log. Records JIT/runtime events for offline analysis. | ||
*/ | ||
|
||
#define lj_auditlog_c | ||
|
||
#include <stdio.h> | ||
|
||
#include "lj_auditlog.h" | ||
|
||
FILE *fp; | ||
|
||
/* Ensure that the log file is open. */ | ||
static void ensure_log_open() | ||
{ | ||
if (!fp) { | ||
fp = fopen("audit.log", "w"); | ||
lua_assert(fp != NULL); | ||
} | ||
} | ||
|
||
/* Log a snapshot of an object in memory. */ | ||
static void log(const char *type, void *ptr, unsigned int size) | ||
{ | ||
ensure_log_open(); | ||
fprintf(fp, "type=%s address=%p size=%d data:\n", type, ptr, size); | ||
fwrite(ptr, size, 1, fp); | ||
} | ||
|
||
/* Log a trace that has just been compiled. */ | ||
void lj_auditlog_trace_stop(jit_State *J, GCtrace *T) | ||
{ | ||
/* Log the memory containing the GCtrace object and other important | ||
memory that it references. */ | ||
log("GCtrace", T, sizeof(*T)); | ||
log("MCode[]", T->mcode, T->szmcode); | ||
log("SnapShot[]", T->snap, T->nsnap * sizeof(*T->snap)); | ||
log("SnapEntry[]", T->snapmap, T->nsnapmap * sizeof(*T->snapmap)); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
** Audit log. Records JIT/runtime events for offline analysis. | ||
*/ | ||
|
||
#ifndef _LJ_AUDITLOG_H | ||
#define _LJ_AUDITLOG_H | ||
|
||
#include "lj_jit.h" | ||
|
||
void lj_auditlog_trace_flush(jit_State *J); | ||
void lj_auditlog_trace_start(jit_State *J); | ||
void lj_auditlog_trace_stop(jit_State *J, GCtrace *T); | ||
void lj_auditlog_trace_abort(jit_State *J); | ||
void lj_auditlog_trace_record_bytecode(jit_State *J); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters