Base

parent 8433ea6d
...@@ -31,6 +31,8 @@ ...@@ -31,6 +31,8 @@
static LIST_HEAD(allocations); static LIST_HEAD(allocations);
static LIST_HEAD(mmaps); static LIST_HEAD(mmaps);
extern char *log_base;
void replay_memory() void replay_memory()
{ {
struct panwrap_mapped_memory *pos; struct panwrap_mapped_memory *pos;
...@@ -42,7 +44,7 @@ void replay_memory() ...@@ -42,7 +44,7 @@ void replay_memory()
/* Dump to file */ /* Dump to file */
char filename[128]; char filename[128];
snprintf(filename, 128, "/dev/shm/%s.bin", pos->name); snprintf(filename, 128, "%s/%s.bin", log_base, pos->name);
FILE *fp = fopen(filename, "wb"); FILE *fp = fopen(filename, "wb");
fwrite(pos->addr, 1, pos->length, fp); fwrite(pos->addr, 1, pos->length, fp);
fclose(fp); fclose(fp);
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "panwrap.h" #include "panwrap.h"
FILE *log_output; FILE *log_output;
char *log_base;
/** /**
* Grab the location of a symbol from the system's libc instead of our * Grab the location of a symbol from the system's libc instead of our
...@@ -55,22 +56,19 @@ __rd_dlsym_helper(const char *name) ...@@ -55,22 +56,19 @@ __rd_dlsym_helper(const char *name)
static void __attribute__((constructor)) constructor_util(void) { static void __attribute__((constructor)) constructor_util(void) {
const char *env; const char *env;
env = getenv("PANWRAP_OUTPUT"); log_base = getenv("PANWRAP_OUTPUT");
if (env) {
/* Don't try to reopen stderr or stdout, that won't work */ if (!log_base) {
if (strcmp(env, "/dev/stderr") == 0) { log_base = "/dev/shm";
log_output = stderr; }
} else if (strcmp(env, "/dev/stdout") == 0) {
log_output = stdout; char control_name[256];
} else { snprintf(control_name, sizeof(control_name), "%s/control.log", log_base);
log_output = fopen(env, "w+"); log_output = fopen(control_name, "w+");
if (!log_output) {
fprintf(stderr, "Failed to open %s: %s\n", if (!log_output) {
env, strerror(errno)); fprintf(stderr, "Failed to open %s: %s\n",
exit(1); env, strerror(errno));
} exit(1);
}
} else {
log_output = stdout;
} }
} }
...@@ -21,11 +21,6 @@ ...@@ -21,11 +21,6 @@
#include <time.h> #include <time.h>
#include "panwrap-mmap.h" #include "panwrap-mmap.h"
struct panwrap_flag_info {
u64 flag;
const char *name;
};
#define PROLOG(func) \ #define PROLOG(func) \
static typeof(func) *orig_##func = NULL; \ static typeof(func) *orig_##func = NULL; \
if (!orig_##func) \ if (!orig_##func) \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment