[libunwind] libunwind: Implement the unw_strerror function for better nongnu libunwind compatibility (PR #160887)

Gleb Popov via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 7 03:13:11 PDT 2025


================
@@ -347,6 +347,41 @@ void __unw_remove_dynamic_eh_frame_section(unw_word_t eh_frame_start) {
 }
 
 #endif // defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND)
+
+/// Maps the UNW_* error code to a textual representation
+_LIBUNWIND_HIDDEN const char *__unw_strerror(int error_code) {
+  switch (error_code) {
+  case UNW_ESUCCESS:
+    return "no error";
+  case UNW_EUNSPEC:
+    return "unspecified (general) error";
+  case UNW_ENOMEM:
+    return "out of memory";
+  case UNW_EBADREG:
+    return "bad register number";
+  case UNW_EREADONLYREG:
+    return "attempt to write read-only register";
+  case UNW_ESTOPUNWIND:
+    return "stop unwinding";
+  case UNW_EINVALIDIP:
+    return "invalid IP";
+  case UNW_EBADFRAME:
+    return "bad frame";
+  case UNW_EINVAL:
+    return "unsupported operation or bad value";
+  case UNW_EBADVERSION:
+    return "unwind info has unsupported version";
+  case UNW_ENOINFO:
+    return "no unwind info found";
+#if defined(_LIBUNWIND_TARGET_AARCH64) && !defined(_LIBUNWIND_IS_NATIVE_ONLY)
+  case UNW_ECROSSRASIGNING:
+    return "return address require authentication";
----------------
arrowd wrote:

Sorry, English isn't my native. I took message strings from nongnu libunwind: https://github.com/libunwind/libunwind/blob/bfc0d618f72ba4b725c3735188e0a6d8c710411c/src/mi/strerror.c#L31

https://github.com/llvm/llvm-project/pull/160887


More information about the cfe-commits mailing list