diff --git a/src/debuginfo.cpp b/src/debuginfo.cpp index b54d9eaeb46901..ea94e440961ae4 100644 --- a/src/debuginfo.cpp +++ b/src/debuginfo.cpp @@ -1695,3 +1695,21 @@ uint64_t jl_getUnwindInfo(uint64_t dwAddr) uv_rwlock_rdunlock(&threadsafe); return ipstart; } + +extern "C" +uint64_t jl_trygetUnwindInfo(uint64_t dwAddr) +{ + // Might be called from unmanaged thread + Optional*> maybeobjmap = jl_jit_events->trygetObjectMap(); + if (maybeobjmap) { + std::map &objmap = **maybeobjmap; + std::map::iterator it = objmap.lower_bound(dwAddr); + uint64_t ipstart = 0; // ip of the start of the section (if found) + if (it != objmap.end() && dwAddr < it->first + it->second.SectionSize) { + ipstart = (uint64_t)(uintptr_t)(*it).first; + } + uv_rwlock_rdunlock(&threadsafe); + return ipstart; + } + return 0; +} diff --git a/src/julia_internal.h b/src/julia_internal.h index f75eccbd1eac5b..67df97e4c82127 100644 --- a/src/julia_internal.h +++ b/src/julia_internal.h @@ -758,6 +758,7 @@ typedef struct { // Might be called from unmanaged thread uint64_t jl_getUnwindInfo(uint64_t dwBase); +uint64_t jl_trygetUnwindInfo(uint64_t dwBase); #ifdef _OS_WINDOWS_ #include JL_DLLEXPORT EXCEPTION_DISPOSITION __julia_personality(