From: Twaik Yont <9674930+twaik@users.noreply.github.com> Mirror Wine debug output to Android logcat on Android builds. Android is effectively an embedded platform and does not provide a convenient standard stdout/stderr workflow. Capturing debug output by redirecting it to a file is also awkward in practice, while logcat provides a straightforward way to inspect live logs on-device. Load __android_log_print from liblog in dbg_init() and emit debug output through the WineOut tag while preserving the existing stderr path. For cases where file logging is preferred, Wine already provides a separate mechanism to set WINEDEBUG and redirect the output to a file. Signed-off-by: Twaik Yont <9674930+twaik@users.noreply.github.com> --- dlls/ntdll/unix/debug.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/dlls/ntdll/unix/debug.c b/dlls/ntdll/unix/debug.c index d4aad491edc..504409e18dc 100644 --- a/dlls/ntdll/unix/debug.c +++ b/dlls/ntdll/unix/debug.c @@ -41,6 +41,12 @@ #include "unix_private.h" #include "wine/debug.h" +#ifdef __ANDROID__ +#include <dlfcn.h> +#include <android/log.h> +static __typeof__(__android_log_print) *android_log_print; +#endif + WINE_DECLARE_DEBUG_CHANNEL(pid); WINE_DECLARE_DEBUG_CHANNEL(timestamp); WINE_DEFAULT_DEBUG_CHANNEL(ntdll); @@ -277,6 +283,9 @@ const char * __cdecl __wine_dbg_strdup( const char *str ) NTSTATUS unixcall_wine_dbg_write( void *args ) { struct wine_dbg_write_params *params = args; +#ifdef __ANDROID__ + if (android_log_print) android_log_print( ANDROID_LOG_VERBOSE, "WineOut", "%.*s", params->len, params->str); +#endif return write( 2, params->str, params->len ); } @@ -293,6 +302,9 @@ NTSTATUS wow64_wine_dbg_write( void *args ) unsigned int len; } const *params32 = args; +#ifdef __ANDROID__ + if (android_log_print) android_log_print( ANDROID_LOG_VERBOSE, "WineOut", "%.*s", params32->len, ULongToPtr(params32->str)); +#endif return write( 2, ULongToPtr(params32->str), params32->len ); } #endif @@ -309,6 +321,9 @@ int __cdecl __wine_dbg_output( const char *str ) if (end) { ret += append_output( info, str, end + 1 - str ); +#ifdef __ANDROID__ + if (android_log_print) android_log_print( ANDROID_LOG_VERBOSE, "WineOut", "%.*s", info->out_pos, info->output); +#endif write( 2, info->output, info->out_pos ); info->out_pos = 0; str = end + 1; @@ -355,6 +370,12 @@ int __cdecl __wine_dbg_header( enum __wine_debug_class cls, struct __wine_debug_ void dbg_init(void) { struct __wine_debug_channel *options, default_option = { default_flags }; +#ifdef __ANDROID__ + void *liblog = NULL; + liblog = dlopen("liblog.so", RTLD_NOW | RTLD_LOCAL); + if (liblog) + android_log_print = (__typeof__(__android_log_print) *) dlsym(liblog, "__android_log_print"); +#endif setbuf( stdout, NULL ); setbuf( stderr, NULL ); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10574