Skip to content

Commit c24ed2c

Browse files
committed
Debugging an issue on linux/arm64 (IX)
1 parent c233084 commit c24ed2c

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

src/miniexpr.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5823,6 +5823,35 @@ static bool dsl_jit_compile_libtcc_in_memory(me_dsl_compiled_program *program) {
58235823
}
58245824
#endif
58255825

5826+
#if !ME_USE_LIBTCC_FALLBACK
5827+
static bool dsl_jit_module_path_from_symbol(const void *symbol, char *out, size_t out_size) {
5828+
if (!symbol || !out || out_size == 0) {
5829+
return false;
5830+
}
5831+
#if defined(_WIN32) || defined(_WIN64)
5832+
HMODULE module = NULL;
5833+
if (!GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
5834+
GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
5835+
(LPCSTR)symbol, &module)) {
5836+
return false;
5837+
}
5838+
DWORD n = GetModuleFileNameA(module, out, (DWORD)out_size);
5839+
if (n == 0 || n >= (DWORD)out_size) {
5840+
return false;
5841+
}
5842+
out[n] = '\0';
5843+
return true;
5844+
#else
5845+
Dl_info info;
5846+
if (dladdr(symbol, &info) == 0 || !info.dli_fname || info.dli_fname[0] == '\0') {
5847+
return false;
5848+
}
5849+
int n = snprintf(out, out_size, "%s", info.dli_fname);
5850+
return n > 0 && (size_t)n < out_size;
5851+
#endif
5852+
}
5853+
#endif
5854+
58265855
#if !defined(_WIN32) && !defined(_WIN64) && !defined(__EMSCRIPTEN__)
58275856
static bool dsl_jit_cc_math_bridge_available(void) {
58285857
for (size_t i = 0; i < sizeof(dsl_jit_bridge_symbol_names) / sizeof(dsl_jit_bridge_symbol_names[0]); i++) {

0 commit comments

Comments
 (0)