diff --git a/src/coreclr/pal/src/config.h.in b/src/coreclr/pal/src/config.h.in index 52405d4c91286a..2a554a20e1841d 100644 --- a/src/coreclr/pal/src/config.h.in +++ b/src/coreclr/pal/src/config.h.in @@ -83,6 +83,7 @@ #cmakedefine01 HAVE_BROKEN_FIFO_SELECT #cmakedefine01 HAVE_BROKEN_FIFO_KEVENT #cmakedefine01 UNWIND_CONTEXT_IS_UCONTEXT_T +#cmakedefine01 HAVE_GET_PROC_INFO_IN_RANGE #cmakedefine01 HAVE_SCHED_GET_PRIORITY #cmakedefine01 HAVE_WORKING_GETTIMEOFDAY #cmakedefine01 HAVE_WORKING_CLOCK_GETTIME diff --git a/src/coreclr/pal/src/configure.cmake b/src/coreclr/pal/src/configure.cmake index 0cc20e3e427b6f..6b7ec85cac40a7 100644 --- a/src/coreclr/pal/src/configure.cmake +++ b/src/coreclr/pal/src/configure.cmake @@ -624,6 +624,7 @@ int main(int argc, char **argv) check_symbol_exists(unw_get_save_loc libunwind.h HAVE_UNW_GET_SAVE_LOC) check_symbol_exists(unw_get_accessors libunwind.h HAVE_UNW_GET_ACCESSORS) +check_symbol_exists(unw_get_proc_info_in_range libunwind.h HAVE_GET_PROC_INFO_IN_RANGE) check_cxx_source_compiles(" #include diff --git a/src/coreclr/pal/src/exception/remote-unwind.cpp b/src/coreclr/pal/src/exception/remote-unwind.cpp index 05cba618a10222..aec8822ceb45f2 100644 --- a/src/coreclr/pal/src/exception/remote-unwind.cpp +++ b/src/coreclr/pal/src/exception/remote-unwind.cpp @@ -1684,7 +1684,7 @@ StepWithCompactEncodingArm64(const libunwindInfo* info, compact_unwind_encoding_ if (!ReadCompactEncodingRegisterPair(info, &addr, &context->Lr, &context->Fp)) { return false; } - // Strip pointer authentication bits + // Strip pointer authentication bits context->Lr &= MACOS_ARM64_POINTER_AUTH_MASK; } else @@ -2328,7 +2328,13 @@ find_proc_info(unw_addr_space_t as, unw_word_t ip, unw_proc_info_t *pip, int nee } } -#ifdef FEATURE_USE_SYSTEM_LIBUNWIND +#if HAVE_GET_PROC_INFO_IN_RANGE || !defined(HOST_UNIX) + return unw_get_proc_info_in_range(start_ip, end_ip, ehFrameHdrAddr, ehFrameHdrLen, exidxFrameHdrAddr, exidxFrameHdrLen, as, ip, pip, need_unwind_info, arg); +#else // HAVE_GET_PROC_INFO_IN_RANGE || !defined(HOST_UNIX) + + // This branch is executed when using llvm-libunwind (macOS and similar platforms) + // or HP-libunwind version 1.6 and earlier. + if (ehFrameHdrAddr == 0) { ASSERT("ELF: No PT_GNU_EH_FRAME program header\n"); return -UNW_EINVAL; @@ -2400,9 +2406,7 @@ find_proc_info(unw_addr_space_t as, unw_word_t ip, unw_proc_info_t *pip, int nee } info->FunctionStart = pip->start_ip; return UNW_ESUCCESS; -#else - return unw_get_proc_info_in_range(start_ip, end_ip, ehFrameHdrAddr, ehFrameHdrLen, exidxFrameHdrAddr, exidxFrameHdrLen, as, ip, pip, need_unwind_info, arg); -#endif // FEATURE_USE_SYSTEM_LIBUNWIND +#endif // HAVE_GET_PROC_INFO_IN_RANGE || !defined(HOST_UNIX) #endif // __APPLE__ }