Created
November 4, 2025 04:32
-
-
Save mnixry/33df8fea2350fd5aeb1fe86ad4b58bc7 to your computer and use it in GitHub Desktop.
Expose Wemeet Linux version internal logs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Usage: | |
| // gcc ./printlog.c -shared -o libwemeet_log_override.so -fPIC -Wall -Wextra | |
| // export LD_PRELOAD=$(realpath ./libwemeet_log_override.so) | |
| #include <execinfo.h> | |
| #include <stddef.h> | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| typedef struct { | |
| const char *ptr; | |
| size_t size; | |
| size_t capacity; | |
| } fake_std_string; | |
| static int g_printlog_enabled = -1; | |
| static int g_backtrace_depth = -1; | |
| // hijack the base::log::PrintLog() function | |
| void PrintLog(fake_std_string *tag, fake_std_string *file, int line, | |
| fake_std_string *func, int level, | |
| fake_std_string | |
| *msg) __asm__("_ZN4base3log8PrintLogEONSt7__cxx1112basic_" | |
| "stringIcSt11char_traitsIcESaIcEEES7_iS7_iS7_"); | |
| void PrintLog(fake_std_string *tag, fake_std_string *file, int line, | |
| fake_std_string *func, int level, fake_std_string *msg) { | |
| if (g_printlog_enabled < 0) { | |
| g_printlog_enabled = getenv("WEMEET_PRINTLOG") ? 1 : 0; | |
| } | |
| if (g_printlog_enabled == 0) { | |
| return; | |
| } | |
| printf("PrintLog: " | |
| "level=`%d`, file=`%.*s:%d`, tag=`%.*s`, func=`%.*s`, " | |
| "msg=`%.*s`\n", | |
| level, (int)file->size, file->ptr, line, (int)tag->size, tag->ptr, | |
| (int)func->size, func->ptr, (int)msg->size, msg->ptr); | |
| void *frames[32]; | |
| if (g_backtrace_depth < 0) { | |
| g_backtrace_depth = getenv("WEMEET_PRINTLOG_BACKTRACE_DEPTH") | |
| ? atoi(getenv("WEMEET_PRINTLOG_BACKTRACE_DEPTH")) | |
| : 0; | |
| if (g_backtrace_depth > (int)sizeof(frames)) { | |
| g_backtrace_depth = (int)sizeof(frames); | |
| } | |
| } | |
| if (g_backtrace_depth == 0) { | |
| return; | |
| } | |
| int frame_count = backtrace(frames, g_backtrace_depth); | |
| char **symbols = backtrace_symbols(frames, frame_count); | |
| if (symbols != NULL) { | |
| for (int i = 0; i < frame_count; ++i) { | |
| printf("\tbt[%d] %s\n", i, symbols[i]); | |
| } | |
| free(symbols); | |
| } else { | |
| for (int i = 0; i < frame_count; ++i) { | |
| printf("\tbt[%d] %p\n", i, frames[i]); | |
| } | |
| } | |
| puts("---\n"); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct std_string { | |
| uint64_t ptr; // char* | |
| uint64_t size; // length | |
| uint64_t cap; // capacity (top bit = SSO flag) | |
| } | |
| BEGIN | |
| { | |
| printf("Tracing owl backend selection via symbols (no ucontext)…\n"); | |
| } | |
| /* zlog flush (you already confirmed this address is valid in both builds) */ | |
| uprobe:/usr/lib/wemeet/libwemeet_base.so:0x8D0870 | |
| { | |
| $p = arg1; if ($p == 0) { exit(); } | |
| $head = *(uint64)($p + 32); | |
| $event_id = *(int32)($p + 44); | |
| $ctx_dp = *(uint64)($p + 56); | |
| $name_dp = *(uint64)($p + 88); | |
| $src_dp = *(uint64)($p + 120); | |
| $pay_dp = *(uint64)($p + 152); | |
| $rc = *(int32)($p + 184); | |
| $tls = *(uint64)($p + 208); | |
| printf("--- zlog --- \nid=%d rc=%d tls=%p head='%s' name='%s' src='%s' payload='%s' ctx='%s'\n stack=%s\n", | |
| $event_id, $rc, $tls, str($head), str($name_dp), str($src_dp), str($pay_dp), str($ctx_dp), ustack(perf)); | |
| } | |
| /* Coroutine trampoline (present as a symbol across builds). If this never fires, coroutines aren’t used. */ | |
| uprobe:/usr/lib/wemeet/libwemeet_base.so:co_jump_to_link | |
| { | |
| printf("co_jump_to_link(link=%p)\n", arg1); | |
| } | |
| /* Coroutine trampoline (present as a symbol across builds). If this never fires, coroutines aren’t used. */ | |
| uprobe:/usr/lib/wemeet/libwemeet_base.so:"*PrintLog*" | |
| { | |
| $tag = *(struct std_string *)arg0; | |
| $file = *(struct std_string *)arg1; | |
| $func = *(struct std_string *)arg3; | |
| $msg = *(struct std_string *)arg5; | |
| printf("PrintLog: tag=\"%s\" file=\"%s\" line=%d func=\"%s\" level=%d\n msg=\"%s\"", | |
| str($tag.ptr, $tag.size), | |
| str($file.ptr, $file.size), | |
| arg2, | |
| str($func.ptr, $func.size), | |
| arg4, | |
| str($msg.ptr, $msg.size)); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment