Skip to content

Commit

Permalink
lj_auditlog.c: Log raptorjit VM DWARF debug information to audit.log
Browse files Browse the repository at this point in the history
  • Loading branch information
lukego committed Apr 25, 2018
1 parent 02062e9 commit 229fc15
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/lj_auditlog.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "lj_trace.h"
#include "lj_ctype.h"
#include "lj_auditlog.h"
#include "lj_debuginfo.h"

/* Maximum data to buffer in memory before file is opened. */
#define MAX_MEM_BUFFER 1024*1024
Expand Down Expand Up @@ -61,7 +62,7 @@ static void uint_64(uint64_t n) {
cfwrite(&big, sizeof(big), 1, fp); /* value */
}

static void bin_32(void *ptr, int n) {
static void bin_32(const void *ptr, int n) {
uint32_t biglen = __builtin_bswap32(n);
cfputc(0xc6, fp); /* array 32 header */
cfwrite(&biglen, sizeof(biglen), 1, fp); /* length */
Expand Down Expand Up @@ -90,10 +91,18 @@ static void log_event(const char *type, int nattributes) {
/* Caller fills in the further nattributes... */
}

static void log_blob(const char *name, const char *ptr, int size) {
fixmap(3);
str_16("type"); /* = */ str_16("blob");
str_16("name"); /* = */ str_16(name);
str_16("data"); /* = */ bin_32(ptr, size);
}

/* Log objects that define the virtual machine. */
static void lj_auditlog_vm_definitions()
{
log_mem("lj_ir_mode", (void*)&lj_ir_mode, sizeof(lj_ir_mode));
log_blob("lj_dwarf.dwo", &_binary_lj_dwarf_dwo_start, &_binary_lj_dwarf_dwo_end - &_binary_lj_dwarf_dwo_start);
}

/* Check that the log is open before logging a message. */
Expand Down

0 comments on commit 229fc15

Please sign in to comment.