Skip to content

[libunwind] Add unw_strerror function #129084

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libunwind/include/libunwind.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ extern int unw_get_fpreg(unw_cursor_t *, unw_regnum_t, unw_fpreg_t *) LIBUNWIND_
extern int unw_set_reg(unw_cursor_t *, unw_regnum_t, unw_word_t) LIBUNWIND_AVAIL;
extern int unw_set_fpreg(unw_cursor_t *, unw_regnum_t, unw_fpreg_t) LIBUNWIND_AVAIL;
extern int unw_resume(unw_cursor_t *) LIBUNWIND_AVAIL;
extern const char *unw_strerror(int) LIBUNWIND_AVAIL;

#ifdef __arm__
/* Save VFP registers in FSTMX format (instead of FSTMD). */
Expand Down
34 changes: 34 additions & 0 deletions libunwind/src/libunwind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,40 @@ _LIBUNWIND_HIDDEN int __unw_is_signal_frame(unw_cursor_t *cursor) {
}
_LIBUNWIND_WEAK_ALIAS(__unw_is_signal_frame, unw_is_signal_frame)

_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 "cross unwind with return address signing";
#endif
default:
return "unknown error occurred";
}
}
_LIBUNWIND_WEAK_ALIAS(__unw_strerror, unw_strerror)

#ifdef _AIX
_LIBUNWIND_EXPORT uintptr_t __unw_get_data_rel_base(unw_cursor_t *cursor) {
_LIBUNWIND_TRACE_API("unw_get_data_rel_base(cursor=%p)",
Expand Down
1 change: 1 addition & 0 deletions libunwind/src/libunwind_ext.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ extern int __unw_get_fpreg(unw_cursor_t *, unw_regnum_t, unw_fpreg_t *);
extern int __unw_set_reg(unw_cursor_t *, unw_regnum_t, unw_word_t);
extern int __unw_set_fpreg(unw_cursor_t *, unw_regnum_t, unw_fpreg_t);
extern int __unw_resume(unw_cursor_t *);
extern const char *__unw_strerror(int);

#ifdef __arm__
/* Save VFP registers in FSTMX format (instead of FSTMD). */
Expand Down
Loading