From 044dec0bfa0f3f8f62f7703d6b0a8600c1354dc5 Mon Sep 17 00:00:00 2001 From: Yang Liu Date: Tue, 21 Jan 2025 23:13:51 +0800 Subject: [ENV] Initial refactor of env variables infrastructure (#2274) * [ENV] Initial refactor of env variables infrastructure * Ported BOX64_DYNAREC_LOG * Ported more options * Ported BOX64_MALLOC_HACK * Ported BOX64_DYNAREC_TEST * Ported more options * Ported more options * Ported more options * Ported all options * Removed old rcfile parser * Fix * review * fix * fix * more fixes --- src/include/debug.h | 99 +++++++++-------------------------------------------- 1 file changed, 16 insertions(+), 83 deletions(-) (limited to 'src/include/debug.h') diff --git a/src/include/debug.h b/src/include/debug.h index 48843392..36a2e14a 100644 --- a/src/include/debug.h +++ b/src/include/debug.h @@ -1,52 +1,16 @@ #ifndef __DEBUG_H_ #define __DEBUG_H_ #include +#include typedef struct box64context_s box64context_t; -extern int box64_log; // log level -extern int box64_dump; // dump elf or not -extern int box64_dynarec_log; -extern int box64_dynarec; +extern box64env_t box64env; + extern uintptr_t box64_pagesize; -extern uintptr_t box64_load_addr; -extern int box64_dynarec_test; -extern int box64_maxcpu; -extern int box64_mmap32; -extern int box64_ignoreint3; extern int box64_rdtsc; -extern int box64_rdtsc_1ghz; extern uint8_t box64_rdtsc_shift; extern int box64_is32bits; -extern int box64_x11sync; -extern int box64_dynarec_gdbjit; -extern int box64_cputype; #ifdef DYNAREC -extern int box64_dynarec_dump; -extern int box64_dynarec_trace; -extern int box64_dynarec_forced; -extern uintptr_t box64_nodynarec_start, box64_nodynarec_end; -extern uintptr_t box64_dynarec_test_start, box64_dynarec_test_end; -extern int box64_dynarec_bigblock; -extern int box64_dynarec_forward; -extern int box64_dynarec_strongmem; -extern int box64_dynarec_weakbarrier; -extern int box64_dynarec_pause; -extern int box64_dynarec_fastnan; -extern int box64_dynarec_fastround; -extern int box64_dynarec_x87double; -extern int box64_dynarec_div0; -extern int box64_dynarec_safeflags; -extern int box64_dynarec_callret; -extern int box64_dynarec_bleeding_edge; -extern int box64_dynarec_tbb; -extern int box64_dynarec_wait; -extern int box64_dynarec_missing; -extern int box64_dynarec_aligned_atomics; -extern int box64_dynarec_nativeflags; -extern int box64_dynarec_df; -extern int box64_dynarec_perf_map; -extern int box64_dynarec_perf_map_fd; -extern int box64_dynarec_dirty; #ifdef ARM64 extern int arm64_asimd; extern int arm64_aes; @@ -84,58 +48,18 @@ extern int la64_lamcas; extern int la64_scq; #endif #endif -extern int box64_libcef; -extern int box64_jvm; -extern int box64_unityplayer; -extern int box64_sdl2_jguid; -extern int dlsym_error; // log dlsym error -extern int cycle_log; // if using rolling logs #ifdef HAVE_TRACE -extern int trace_xmm; // include XMM reg in trace? -extern int trace_emm; // include EMM reg in trace? -extern int trace_regsdiff; // colorize standard registers on changes extern uintptr_t trace_start, trace_end; extern char* trace_func; -extern char* trace_init; -extern char* box64_trace; -extern uint64_t start_cnt; #endif -extern int box64_nosandbox; -extern int box64_inprocessgpu; -extern int box64_cefdisablegpu; -extern int box64_cefdisablegpucompositor; -extern int box64_maxcpu_immutable; -extern int box64_malloc_hack; -extern int box64_dummy_crashhandler; -extern int box64_sse_flushto0; -extern int box64_x87_no80bits; -extern int box64_sync_rounding; -extern int box64_shaext; -extern int box64_sse42; -extern int box64_avx; -extern int box64_avx2; -extern int allow_missing_libs; extern int box64_mapclean; -extern int box64_prefer_wrapped; -extern int box64_prefer_emulated; -extern int box64_wrap_egl; extern int box64_steam; extern int box64_steamcmd; extern int box64_wine; extern int box64_musl; -extern int box64_nopulse; // disabling the use of wrapped pulseaudio -extern int box64_nogtk; // disabling the use of wrapped gtk -extern int box64_novulkan; // disabling the use of wrapped vulkan -extern int box64_showsegv; // show sigv, even if a signal handler is present -extern int box64_showbt; // show a backtrace if a signal is caught extern int box64_isglibc234; // is the program linked with glibc 2.34+ -extern int box64_futex_waitv; -extern int box64_x11threads; -extern int box64_x11glx; -extern char* box64_libGL; extern uintptr_t fmod_smc_start, fmod_smc_end; // to handle libfmod (from Unreal) SMC (self modifying code) extern uint32_t default_gs, default_fs; -extern int jit_gdb; // launch gdb when a segfault is trapped extern int box64_tcmalloc_minimal; // when using tcmalloc_minimal #define LOG_NONE 0 #define LOG_INFO 1 @@ -145,13 +69,22 @@ extern int box64_tcmalloc_minimal; // when using tcmalloc_minimal void printf_ftrace(const char* fmt, ...); -#define printf_log(L, ...) do {if((L)<=box64_log) {printf_ftrace(__VA_ARGS__);}} while(0) +#define printf_log(L, ...) \ + do { \ + if ((L) <= BOX64ENV(log)) { printf_ftrace(__VA_ARGS__); } \ + } while (0) -#define printf_dump(L, ...) do {if(box64_dump || ((L)<=box64_log)) {printf_ftrace(__VA_ARGS__);}} while(0) +#define printf_dump(L, ...) \ + do { \ + if (BOX64ENV(dump) || ((L) <= BOX64ENV(log))) { printf_ftrace(__VA_ARGS__); } \ + } while (0) -#define printf_dlsym(L, ...) do {if(dlsym_error || ((L)<=box64_log)) {printf_ftrace(__VA_ARGS__);}} while(0) +#define printf_dlsym(L, ...) \ + do { \ + if (BOX64ENV(dlsym_error) || ((L) <= BOX64ENV(log))) { printf_ftrace(__VA_ARGS__); } \ + } while (0) -#define dynarec_log(L, ...) do {if((L)<=box64_dynarec_log) {printf_ftrace(__VA_ARGS__);}} while(0) +#define dynarec_log(L, ...) do {if((L)<=BOX64ENV(dynarec_log)) {printf_ftrace(__VA_ARGS__);}} while(0) #define EXPORT __attribute__((visibility("default"))) #ifdef BUILD_DYNAMIC -- cgit 1.4.1