Skip to content

Commit 9357008

Browse files
[libunwind] Add unw_strerror function
Co-authored-by: Randy Eckenrode <[email protected]>
1 parent d91e5c3 commit 9357008

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

libunwind/include/libunwind.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ extern int unw_is_signal_frame(unw_cursor_t *) LIBUNWIND_AVAIL;
131131
extern int unw_get_proc_name(unw_cursor_t *, char *, size_t, unw_word_t *) LIBUNWIND_AVAIL;
132132
//extern int unw_get_save_loc(unw_cursor_t*, int, unw_save_loc_t*);
133133

134+
extern const char *unw_strerror(int) LIBUNWIND_AVAIL;
135+
134136
extern unw_addr_space_t unw_local_addr_space;
135137

136138
#ifdef __cplusplus

libunwind/src/libunwind.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,41 @@ _LIBUNWIND_HIDDEN int __unw_is_signal_frame(unw_cursor_t *cursor) {
260260
}
261261
_LIBUNWIND_WEAK_ALIAS(__unw_is_signal_frame, unw_is_signal_frame)
262262

263+
_LIBUNWIND_HIDDEN const char *__unw_strerror(int error_code) {
264+
switch (error_code) {
265+
case UNW_ESUCCESS:
266+
return "no error";
267+
case UNW_EUNSPEC:
268+
return "unspecified (general) error";
269+
case UNW_ENOMEM:
270+
return "out of memory";
271+
case UNW_EBADREG:
272+
return "bad register number";
273+
case UNW_EREADONLYREG:
274+
return "attempt to write read-only register";
275+
case UNW_ESTOPUNWIND:
276+
return "stop unwinding";
277+
case UNW_EINVALIDIP:
278+
return "invalid IP";
279+
case UNW_EBADFRAME:
280+
return "bad frame";
281+
case UNW_EINVAL:
282+
return "unsupported operation or bad value";
283+
case UNW_EBADVERSION:
284+
return "unwind info has unsupported version";
285+
case UNW_ENOINFO:
286+
return "no unwind info found";
287+
#if defined(_LIBUNWIND_TARGET_AARCH64) && !defined(_LIBUNWIND_IS_NATIVE_ONLY)
288+
case UNW_ECROSSRASIGNING:
289+
return "cross unwind with return address signing";
290+
#endif
291+
default:
292+
return "unknown error occurred";
293+
}
294+
}
295+
}
296+
_LIBUNWIND_WEAK_ALIAS(__unw_strerror, unw_strerror)
297+
263298
#ifdef _AIX
264299
_LIBUNWIND_EXPORT uintptr_t __unw_get_data_rel_base(unw_cursor_t *cursor) {
265300
_LIBUNWIND_TRACE_API("unw_get_data_rel_base(cursor=%p)",

0 commit comments

Comments
 (0)