about summary refs log tree commit diff stats
path: root/src/os
diff options
context:
space:
mode:
Diffstat (limited to 'src/os')
-rw-r--r--src/os/os_linux.c44
-rw-r--r--src/os/os_wine.c25
2 files changed, 67 insertions, 2 deletions
diff --git a/src/os/os_linux.c b/src/os/os_linux.c
index 556d4d9b..a8258db6 100644
--- a/src/os/os_linux.c
+++ b/src/os/os_linux.c
@@ -6,6 +6,7 @@
 #include <sys/personality.h>
 #include <dlfcn.h>
 #include <string.h>
+#include <stdarg.h>
 
 #include "os.h"
 #include "signals.h"
@@ -89,11 +90,16 @@ void* GetSegmentBase(uint32_t desc)
     return ptr;
 }
 
+const char* GetBridgeName(void* p)
+{
+    return getBridgeName(p);
+}
+
 const char* GetNativeName(void* p)
 {
     static char buff[500] = { 0 };
     {
-        const char* n = getBridgeName(p);
+        const char* n = GetBridgeName(p);
         if (n)
             return n;
     }
@@ -161,4 +167,38 @@ int InternalMunmap(void* addr, unsigned long length)
     int ret = libc_munmap(addr, length);
 #endif
     return ret;
-}
\ No newline at end of file
+}
+
+extern FILE* ftrace;
+extern char* ftrace_name;
+
+static void checkFtrace()
+{
+    int fd = fileno(ftrace);
+    if (fd < 0 || lseek(fd, 0, SEEK_CUR) == (off_t)-1) {
+        ftrace = fopen(ftrace_name, "a");
+        printf_log(LOG_INFO, "%04d|Recreated trace because fd was invalid\n", GetTID());
+    }
+}
+
+void PrintfFtrace(int prefix, const char* fmt, ...)
+{
+    if (ftrace_name) {
+        checkFtrace();
+    }
+
+    static const char* names[2] = { "BOX64", "BOX32" };
+
+    if (prefix && ftrace == stdout) {
+        if (prefix > 1) {
+            fprintf(ftrace, "[\033[31m%s\033[0m] ", names[box64_is32bits]);
+        } else {
+            fprintf(ftrace, "[%s] ", names[box64_is32bits]);
+        }
+    }
+    va_list args;
+    va_start(args, fmt);
+    vfprintf(ftrace, fmt, args);
+    fflush(ftrace);
+    va_end(args);
+}
diff --git a/src/os/os_wine.c b/src/os/os_wine.c
index e7f34a99..1e61772a 100644
--- a/src/os/os_wine.c
+++ b/src/os/os_wine.c
@@ -1,8 +1,11 @@
+#include <stdio.h>
+#include <string.h>
 #include <windows.h>
 #include <ntstatus.h>
 #include <winternl.h>
 
 #include "os.h"
+#include "wine/debug.h"
 
 #define HandleToULong(h) ((ULONG)(ULONG_PTR)(h))
 
@@ -54,11 +57,20 @@ void EmuX86Syscall(void* emu)
     // FIXME
 }
 
+const char* GetBridgeName(void* p)
+{
+    return NULL;
+}
+
 const char* GetNativeName(void* p)
 {
     return NULL;
 }
 
+void* GetNativeFnc(uintptr_t fnc)
+{
+    return NULL;
+}
 
 void PersonalityAddrLimit32Bit(void)
 {
@@ -193,3 +205,16 @@ int VolatileRangesContains(uintptr_t addr)
 {
     return 0;
 }
+
+void PrintfFtrace(int prefix, const char* fmt, ...)
+{
+    static char buf[1024] = { 0 };
+
+    char* p = buf;
+    strcpy(p, prefix > 1 ? "[\033[31mBOX64\033[0m] " : "[BOX64] ");
+    va_list args;
+    va_start(args, fmt);
+    vsprintf(p + strlen(p), fmt, args);
+    va_end(args);
+    __wine_dbg_output(p);
+}