diff options
| author | ptitSeb <sebastien.chev@gmail.com> | 2022-11-15 12:58:40 +0100 |
|---|---|---|
| committer | ptitSeb <sebastien.chev@gmail.com> | 2022-11-15 12:58:40 +0100 |
| commit | 277f54230425f976ad169bcf0ccc7e434b1a680b (patch) | |
| tree | 160ab860dfe284dd000b79ccda6c27b9acd8527c /src | |
| parent | 517a5b68440cac900255736b1f4c2d85548f587c (diff) | |
| download | box64-277f54230425f976ad169bcf0ccc7e434b1a680b.tar.gz box64-277f54230425f976ad169bcf0ccc7e434b1a680b.zip | |
Better handling of rolling logs
Diffstat (limited to 'src')
| -rwxr-xr-x | src/box64context.c | 43 | ||||
| -rwxr-xr-x | src/include/box64context.h | 5 | ||||
| -rwxr-xr-x | src/include/x64run.h | 1 |
3 files changed, 32 insertions, 17 deletions
diff --git a/src/box64context.c b/src/box64context.c index d5e1700f..aa130f46 100755 --- a/src/box64context.c +++ b/src/box64context.c @@ -136,6 +136,31 @@ static void atfork_child_box64context(void) init_mutexes(my_context); } +void freeCycleLog(box64context_t* ctx) +{ + if(cycle_log) { + for(int i=0; i<cycle_log; ++i) { + box_free(ctx->log_call[i]); + box_free(ctx->log_ret[i]); + } + box_free(ctx->log_call); + box_free(ctx->log_ret); + ctx->log_call = NULL; + ctx->log_ret = NULL; + } +} +void initCycleLog(box64context_t* context) +{ + if(cycle_log) { + context->log_call = (char**)box_calloc(cycle_log, sizeof(char*)); + context->log_ret = (char**)box_calloc(cycle_log, sizeof(char*)); + for(int i=0; i<cycle_log; ++i) { + context->log_call[i] = (char*)box_calloc(256, 1); + context->log_ret[i] = (char*)box_calloc(128, 1); + } + } +} + EXPORTDYN box64context_t *NewBox64Context(int argc) { @@ -148,14 +173,7 @@ box64context_t *NewBox64Context(int argc) // init and put default values box64context_t *context = my_context = (box64context_t*)box_calloc(1, sizeof(box64context_t)); - if(cycle_log) { - context->log_call = (char**)box_calloc(cycle_log, sizeof(char*)); - context->log_ret = (char**)box_calloc(cycle_log, sizeof(char*)); - for(int i=0; i<cycle_log; ++i) { - context->log_call[i] = (char*)box_calloc(256, 1); - context->log_ret[i] = (char*)box_calloc(128, 1); - } - } + initCycleLog(context); context->deferedInit = 1; context->sel_serial = 1; @@ -299,14 +317,7 @@ void FreeBox64Context(box64context_t** context) pthread_mutex_destroy(&ctx->mutex_thread); pthread_mutex_destroy(&ctx->mutex_bridge); - if(cycle_log) { - for(int i=0; i<cycle_log; ++i) { - box_free(ctx->log_call[i]); - box_free(ctx->log_ret[i]); - } - box_free(ctx->log_call); - box_free(ctx->log_ret); - } + freeCycleLog(ctx); box_free(ctx); } diff --git a/src/include/box64context.h b/src/include/box64context.h index 1d7d8b58..682cdae8 100755 --- a/src/include/box64context.h +++ b/src/include/box64context.h @@ -189,6 +189,11 @@ extern box64context_t *my_context; // global context box64context_t *NewBox64Context(int argc); void FreeBox64Context(box64context_t** context); +// Cycle log handling +void freeCycleLog(box64context_t* ctx); +void initCycleLog(box64context_t* context); +void print_cycle_log(int loglevel); + // return the index of the added header int AddElfHeader(box64context_t* ctx, elfheader_t* head); diff --git a/src/include/x64run.h b/src/include/x64run.h index c69290fd..78903bbc 100755 --- a/src/include/x64run.h +++ b/src/include/x64run.h @@ -10,6 +10,5 @@ uint32_t LibSyscall(x64emu_t *emu); void PltResolver(x64emu_t* emu); extern uintptr_t pltResolver; int GetTID(); -void print_cycle_log(int loglevel); #endif //__X64RUN_H_ \ No newline at end of file |