summaryrefslogtreecommitdiffstats
path: root/contrib/libs/libunwind/src/libunwind.cpp
diff options
context:
space:
mode:
authororivej <[email protected]>2022-02-10 16:44:49 +0300
committerDaniil Cherednik <[email protected]>2022-02-10 16:44:49 +0300
commit718c552901d703c502ccbefdfc3c9028d608b947 (patch)
tree46534a98bbefcd7b1f3faa5b52c138ab27db75b7 /contrib/libs/libunwind/src/libunwind.cpp
parente9656aae26e0358d5378e5b63dcac5c8dbe0e4d0 (diff)
Restoring authorship annotation for <[email protected]>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/libunwind/src/libunwind.cpp')
-rw-r--r--contrib/libs/libunwind/src/libunwind.cpp250
1 files changed, 125 insertions, 125 deletions
diff --git a/contrib/libs/libunwind/src/libunwind.cpp b/contrib/libs/libunwind/src/libunwind.cpp
index 03f8b75b5bb..ee2f4232890 100644
--- a/contrib/libs/libunwind/src/libunwind.cpp
+++ b/contrib/libs/libunwind/src/libunwind.cpp
@@ -1,8 +1,8 @@
//===----------------------------------------------------------------------===//
//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//
// Implements unw_* functions from <libunwind.h>
@@ -21,13 +21,13 @@
#if !defined(__has_feature)
#define __has_feature(feature) 0
#endif
-
+
#if __has_feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__)
#include <sanitizer/asan_interface.h>
#endif
-#if !defined(__USING_SJLJ_EXCEPTIONS__)
-#include "AddressSpace.hpp"
+#if !defined(__USING_SJLJ_EXCEPTIONS__)
+#include "AddressSpace.hpp"
#include "UnwindCursor.hpp"
using namespace libunwind;
@@ -39,61 +39,61 @@ _LIBUNWIND_EXPORT unw_addr_space_t unw_local_addr_space =
(unw_addr_space_t)&LocalAddressSpace::sThisAddressSpace;
/// Create a cursor of a thread in this process given 'context' recorded by
-/// __unw_getcontext().
-_LIBUNWIND_HIDDEN int __unw_init_local(unw_cursor_t *cursor,
- unw_context_t *context) {
- _LIBUNWIND_TRACE_API("__unw_init_local(cursor=%p, context=%p)",
+/// __unw_getcontext().
+_LIBUNWIND_HIDDEN int __unw_init_local(unw_cursor_t *cursor,
+ unw_context_t *context) {
+ _LIBUNWIND_TRACE_API("__unw_init_local(cursor=%p, context=%p)",
static_cast<void *>(cursor),
static_cast<void *>(context));
#if defined(__i386__)
-# define REGISTER_KIND Registers_x86
+# define REGISTER_KIND Registers_x86
#elif defined(__x86_64__)
-# define REGISTER_KIND Registers_x86_64
-#elif defined(__powerpc64__)
-# define REGISTER_KIND Registers_ppc64
+# define REGISTER_KIND Registers_x86_64
+#elif defined(__powerpc64__)
+# define REGISTER_KIND Registers_ppc64
#elif defined(__powerpc__)
-# define REGISTER_KIND Registers_ppc
-#elif defined(__aarch64__)
-# define REGISTER_KIND Registers_arm64
-#elif defined(__arm__)
-# define REGISTER_KIND Registers_arm
+# define REGISTER_KIND Registers_ppc
+#elif defined(__aarch64__)
+# define REGISTER_KIND Registers_arm64
+#elif defined(__arm__)
+# define REGISTER_KIND Registers_arm
#elif defined(__or1k__)
-# define REGISTER_KIND Registers_or1k
-#elif defined(__hexagon__)
-# define REGISTER_KIND Registers_hexagon
-#elif defined(__mips__) && defined(_ABIO32) && _MIPS_SIM == _ABIO32
-# define REGISTER_KIND Registers_mips_o32
-#elif defined(__mips64)
-# define REGISTER_KIND Registers_mips_newabi
+# define REGISTER_KIND Registers_or1k
+#elif defined(__hexagon__)
+# define REGISTER_KIND Registers_hexagon
+#elif defined(__mips__) && defined(_ABIO32) && _MIPS_SIM == _ABIO32
+# define REGISTER_KIND Registers_mips_o32
+#elif defined(__mips64)
+# define REGISTER_KIND Registers_mips_newabi
#elif defined(__mips__)
-# warning The MIPS architecture is not supported with this ABI and environment!
+# warning The MIPS architecture is not supported with this ABI and environment!
#elif defined(__sparc__) && defined(__arch64__)
#define REGISTER_KIND Registers_sparc64
-#elif defined(__sparc__)
-# define REGISTER_KIND Registers_sparc
+#elif defined(__sparc__)
+# define REGISTER_KIND Registers_sparc
#elif defined(__riscv)
-# define REGISTER_KIND Registers_riscv
+# define REGISTER_KIND Registers_riscv
#elif defined(__ve__)
# define REGISTER_KIND Registers_ve
#else
-# error Architecture not supported
+# error Architecture not supported
#endif
- // Use "placement new" to allocate UnwindCursor in the cursor buffer.
- new (reinterpret_cast<UnwindCursor<LocalAddressSpace, REGISTER_KIND> *>(cursor))
- UnwindCursor<LocalAddressSpace, REGISTER_KIND>(
- context, LocalAddressSpace::sThisAddressSpace);
-#undef REGISTER_KIND
+ // Use "placement new" to allocate UnwindCursor in the cursor buffer.
+ new (reinterpret_cast<UnwindCursor<LocalAddressSpace, REGISTER_KIND> *>(cursor))
+ UnwindCursor<LocalAddressSpace, REGISTER_KIND>(
+ context, LocalAddressSpace::sThisAddressSpace);
+#undef REGISTER_KIND
AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor;
co->setInfoBasedOnIPRegister();
return UNW_ESUCCESS;
}
-_LIBUNWIND_WEAK_ALIAS(__unw_init_local, unw_init_local)
+_LIBUNWIND_WEAK_ALIAS(__unw_init_local, unw_init_local)
/// Get value of specified register at cursor position in stack frame.
-_LIBUNWIND_HIDDEN int __unw_get_reg(unw_cursor_t *cursor, unw_regnum_t regNum,
- unw_word_t *value) {
- _LIBUNWIND_TRACE_API("__unw_get_reg(cursor=%p, regNum=%d, &value=%p)",
+_LIBUNWIND_HIDDEN int __unw_get_reg(unw_cursor_t *cursor, unw_regnum_t regNum,
+ unw_word_t *value) {
+ _LIBUNWIND_TRACE_API("__unw_get_reg(cursor=%p, regNum=%d, &value=%p)",
static_cast<void *>(cursor), regNum,
static_cast<void *>(value));
AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor;
@@ -103,44 +103,44 @@ _LIBUNWIND_HIDDEN int __unw_get_reg(unw_cursor_t *cursor, unw_regnum_t regNum,
}
return UNW_EBADREG;
}
-_LIBUNWIND_WEAK_ALIAS(__unw_get_reg, unw_get_reg)
+_LIBUNWIND_WEAK_ALIAS(__unw_get_reg, unw_get_reg)
/// Set value of specified register at cursor position in stack frame.
-_LIBUNWIND_HIDDEN int __unw_set_reg(unw_cursor_t *cursor, unw_regnum_t regNum,
- unw_word_t value) {
- _LIBUNWIND_TRACE_API("__unw_set_reg(cursor=%p, regNum=%d, value=0x%" PRIxPTR
- ")",
- static_cast<void *>(cursor), regNum, value);
+_LIBUNWIND_HIDDEN int __unw_set_reg(unw_cursor_t *cursor, unw_regnum_t regNum,
+ unw_word_t value) {
+ _LIBUNWIND_TRACE_API("__unw_set_reg(cursor=%p, regNum=%d, value=0x%" PRIxPTR
+ ")",
+ static_cast<void *>(cursor), regNum, value);
typedef LocalAddressSpace::pint_t pint_t;
AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor;
if (co->validReg(regNum)) {
co->setReg(regNum, (pint_t)value);
// specical case altering IP to re-find info (being called by personality
// function)
- if (regNum == UNW_REG_IP) {
- unw_proc_info_t info;
- // First, get the FDE for the old location and then update it.
- co->getInfo(&info);
+ if (regNum == UNW_REG_IP) {
+ unw_proc_info_t info;
+ // First, get the FDE for the old location and then update it.
+ co->getInfo(&info);
co->setInfoBasedOnIPRegister(false);
- // If the original call expects stack adjustment, perform this now.
- // Normal frame unwinding would have included the offset already in the
- // CFA computation.
- // Note: for PA-RISC and other platforms where the stack grows up,
- // this should actually be - info.gp. LLVM doesn't currently support
- // any such platforms and Clang doesn't export a macro for them.
- if (info.gp)
- co->setReg(UNW_REG_SP, co->getReg(UNW_REG_SP) + info.gp);
- }
+ // If the original call expects stack adjustment, perform this now.
+ // Normal frame unwinding would have included the offset already in the
+ // CFA computation.
+ // Note: for PA-RISC and other platforms where the stack grows up,
+ // this should actually be - info.gp. LLVM doesn't currently support
+ // any such platforms and Clang doesn't export a macro for them.
+ if (info.gp)
+ co->setReg(UNW_REG_SP, co->getReg(UNW_REG_SP) + info.gp);
+ }
return UNW_ESUCCESS;
}
return UNW_EBADREG;
}
-_LIBUNWIND_WEAK_ALIAS(__unw_set_reg, unw_set_reg)
+_LIBUNWIND_WEAK_ALIAS(__unw_set_reg, unw_set_reg)
/// Get value of specified float register at cursor position in stack frame.
-_LIBUNWIND_HIDDEN int __unw_get_fpreg(unw_cursor_t *cursor, unw_regnum_t regNum,
- unw_fpreg_t *value) {
- _LIBUNWIND_TRACE_API("__unw_get_fpreg(cursor=%p, regNum=%d, &value=%p)",
+_LIBUNWIND_HIDDEN int __unw_get_fpreg(unw_cursor_t *cursor, unw_regnum_t regNum,
+ unw_fpreg_t *value) {
+ _LIBUNWIND_TRACE_API("__unw_get_fpreg(cursor=%p, regNum=%d, &value=%p)",
static_cast<void *>(cursor), regNum,
static_cast<void *>(value));
AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor;
@@ -150,16 +150,16 @@ _LIBUNWIND_HIDDEN int __unw_get_fpreg(unw_cursor_t *cursor, unw_regnum_t regNum,
}
return UNW_EBADREG;
}
-_LIBUNWIND_WEAK_ALIAS(__unw_get_fpreg, unw_get_fpreg)
+_LIBUNWIND_WEAK_ALIAS(__unw_get_fpreg, unw_get_fpreg)
/// Set value of specified float register at cursor position in stack frame.
-_LIBUNWIND_HIDDEN int __unw_set_fpreg(unw_cursor_t *cursor, unw_regnum_t regNum,
- unw_fpreg_t value) {
-#if defined(_LIBUNWIND_ARM_EHABI)
- _LIBUNWIND_TRACE_API("__unw_set_fpreg(cursor=%p, regNum=%d, value=%llX)",
+_LIBUNWIND_HIDDEN int __unw_set_fpreg(unw_cursor_t *cursor, unw_regnum_t regNum,
+ unw_fpreg_t value) {
+#if defined(_LIBUNWIND_ARM_EHABI)
+ _LIBUNWIND_TRACE_API("__unw_set_fpreg(cursor=%p, regNum=%d, value=%llX)",
static_cast<void *>(cursor), regNum, value);
#else
- _LIBUNWIND_TRACE_API("__unw_set_fpreg(cursor=%p, regNum=%d, value=%g)",
+ _LIBUNWIND_TRACE_API("__unw_set_fpreg(cursor=%p, regNum=%d, value=%g)",
static_cast<void *>(cursor), regNum, value);
#endif
AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor;
@@ -169,32 +169,32 @@ _LIBUNWIND_HIDDEN int __unw_set_fpreg(unw_cursor_t *cursor, unw_regnum_t regNum,
}
return UNW_EBADREG;
}
-_LIBUNWIND_WEAK_ALIAS(__unw_set_fpreg, unw_set_fpreg)
+_LIBUNWIND_WEAK_ALIAS(__unw_set_fpreg, unw_set_fpreg)
/// Move cursor to next frame.
-_LIBUNWIND_HIDDEN int __unw_step(unw_cursor_t *cursor) {
- _LIBUNWIND_TRACE_API("__unw_step(cursor=%p)", static_cast<void *>(cursor));
+_LIBUNWIND_HIDDEN int __unw_step(unw_cursor_t *cursor) {
+ _LIBUNWIND_TRACE_API("__unw_step(cursor=%p)", static_cast<void *>(cursor));
AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor;
return co->step();
}
-_LIBUNWIND_WEAK_ALIAS(__unw_step, unw_step)
+_LIBUNWIND_WEAK_ALIAS(__unw_step, unw_step)
/// Get unwind info at cursor position in stack frame.
-_LIBUNWIND_HIDDEN int __unw_get_proc_info(unw_cursor_t *cursor,
- unw_proc_info_t *info) {
- _LIBUNWIND_TRACE_API("__unw_get_proc_info(cursor=%p, &info=%p)",
+_LIBUNWIND_HIDDEN int __unw_get_proc_info(unw_cursor_t *cursor,
+ unw_proc_info_t *info) {
+ _LIBUNWIND_TRACE_API("__unw_get_proc_info(cursor=%p, &info=%p)",
static_cast<void *>(cursor), static_cast<void *>(info));
AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor;
co->getInfo(info);
if (info->end_ip == 0)
return UNW_ENOINFO;
- return UNW_ESUCCESS;
+ return UNW_ESUCCESS;
}
-_LIBUNWIND_WEAK_ALIAS(__unw_get_proc_info, unw_get_proc_info)
+_LIBUNWIND_WEAK_ALIAS(__unw_get_proc_info, unw_get_proc_info)
/// Resume execution at cursor position (aka longjump).
-_LIBUNWIND_HIDDEN int __unw_resume(unw_cursor_t *cursor) {
- _LIBUNWIND_TRACE_API("__unw_resume(cursor=%p)", static_cast<void *>(cursor));
+_LIBUNWIND_HIDDEN int __unw_resume(unw_cursor_t *cursor) {
+ _LIBUNWIND_TRACE_API("__unw_resume(cursor=%p)", static_cast<void *>(cursor));
#if __has_feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__)
// Inform the ASan runtime that now might be a good time to clean stuff up.
__asan_handle_no_return();
@@ -203,75 +203,75 @@ _LIBUNWIND_HIDDEN int __unw_resume(unw_cursor_t *cursor) {
co->jumpto();
return UNW_EUNSPEC;
}
-_LIBUNWIND_WEAK_ALIAS(__unw_resume, unw_resume)
+_LIBUNWIND_WEAK_ALIAS(__unw_resume, unw_resume)
/// Get name of function at cursor position in stack frame.
-_LIBUNWIND_HIDDEN int __unw_get_proc_name(unw_cursor_t *cursor, char *buf,
- size_t bufLen, unw_word_t *offset) {
- _LIBUNWIND_TRACE_API("__unw_get_proc_name(cursor=%p, &buf=%p, bufLen=%lu)",
+_LIBUNWIND_HIDDEN int __unw_get_proc_name(unw_cursor_t *cursor, char *buf,
+ size_t bufLen, unw_word_t *offset) {
+ _LIBUNWIND_TRACE_API("__unw_get_proc_name(cursor=%p, &buf=%p, bufLen=%lu)",
static_cast<void *>(cursor), static_cast<void *>(buf),
static_cast<unsigned long>(bufLen));
AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor;
if (co->getFunctionName(buf, bufLen, offset))
return UNW_ESUCCESS;
- return UNW_EUNSPEC;
+ return UNW_EUNSPEC;
}
-_LIBUNWIND_WEAK_ALIAS(__unw_get_proc_name, unw_get_proc_name)
+_LIBUNWIND_WEAK_ALIAS(__unw_get_proc_name, unw_get_proc_name)
/// Checks if a register is a floating-point register.
-_LIBUNWIND_HIDDEN int __unw_is_fpreg(unw_cursor_t *cursor,
- unw_regnum_t regNum) {
- _LIBUNWIND_TRACE_API("__unw_is_fpreg(cursor=%p, regNum=%d)",
+_LIBUNWIND_HIDDEN int __unw_is_fpreg(unw_cursor_t *cursor,
+ unw_regnum_t regNum) {
+ _LIBUNWIND_TRACE_API("__unw_is_fpreg(cursor=%p, regNum=%d)",
static_cast<void *>(cursor), regNum);
AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor;
return co->validFloatReg(regNum);
}
-_LIBUNWIND_WEAK_ALIAS(__unw_is_fpreg, unw_is_fpreg)
+_LIBUNWIND_WEAK_ALIAS(__unw_is_fpreg, unw_is_fpreg)
/// Checks if a register is a floating-point register.
-_LIBUNWIND_HIDDEN const char *__unw_regname(unw_cursor_t *cursor,
- unw_regnum_t regNum) {
- _LIBUNWIND_TRACE_API("__unw_regname(cursor=%p, regNum=%d)",
+_LIBUNWIND_HIDDEN const char *__unw_regname(unw_cursor_t *cursor,
+ unw_regnum_t regNum) {
+ _LIBUNWIND_TRACE_API("__unw_regname(cursor=%p, regNum=%d)",
static_cast<void *>(cursor), regNum);
AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor;
return co->getRegisterName(regNum);
}
-_LIBUNWIND_WEAK_ALIAS(__unw_regname, unw_regname)
+_LIBUNWIND_WEAK_ALIAS(__unw_regname, unw_regname)
/// Checks if current frame is signal trampoline.
-_LIBUNWIND_HIDDEN int __unw_is_signal_frame(unw_cursor_t *cursor) {
- _LIBUNWIND_TRACE_API("__unw_is_signal_frame(cursor=%p)",
+_LIBUNWIND_HIDDEN int __unw_is_signal_frame(unw_cursor_t *cursor) {
+ _LIBUNWIND_TRACE_API("__unw_is_signal_frame(cursor=%p)",
static_cast<void *>(cursor));
AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor;
return co->isSignalFrame();
}
-_LIBUNWIND_WEAK_ALIAS(__unw_is_signal_frame, unw_is_signal_frame)
+_LIBUNWIND_WEAK_ALIAS(__unw_is_signal_frame, unw_is_signal_frame)
#ifdef __arm__
// Save VFP registers d0-d15 using FSTMIADX instead of FSTMIADD
-_LIBUNWIND_HIDDEN void __unw_save_vfp_as_X(unw_cursor_t *cursor) {
- _LIBUNWIND_TRACE_API("__unw_get_fpreg_save_vfp_as_X(cursor=%p)",
+_LIBUNWIND_HIDDEN void __unw_save_vfp_as_X(unw_cursor_t *cursor) {
+ _LIBUNWIND_TRACE_API("__unw_get_fpreg_save_vfp_as_X(cursor=%p)",
static_cast<void *>(cursor));
AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor;
return co->saveVFPAsX();
}
-_LIBUNWIND_WEAK_ALIAS(__unw_save_vfp_as_X, unw_save_vfp_as_X)
+_LIBUNWIND_WEAK_ALIAS(__unw_save_vfp_as_X, unw_save_vfp_as_X)
#endif
-#if defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND)
-/// SPI: walks cached DWARF entries
-_LIBUNWIND_HIDDEN void __unw_iterate_dwarf_unwind_cache(void (*func)(
+#if defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND)
+/// SPI: walks cached DWARF entries
+_LIBUNWIND_HIDDEN void __unw_iterate_dwarf_unwind_cache(void (*func)(
unw_word_t ip_start, unw_word_t ip_end, unw_word_t fde, unw_word_t mh)) {
- _LIBUNWIND_TRACE_API("__unw_iterate_dwarf_unwind_cache(func=%p)",
+ _LIBUNWIND_TRACE_API("__unw_iterate_dwarf_unwind_cache(func=%p)",
reinterpret_cast<void *>(func));
DwarfFDECache<LocalAddressSpace>::iterateCacheEntries(func);
}
-_LIBUNWIND_WEAK_ALIAS(__unw_iterate_dwarf_unwind_cache,
- unw_iterate_dwarf_unwind_cache)
+_LIBUNWIND_WEAK_ALIAS(__unw_iterate_dwarf_unwind_cache,
+ unw_iterate_dwarf_unwind_cache)
/// IPI: for __register_frame()
-void __unw_add_dynamic_fde(unw_word_t fde) {
+void __unw_add_dynamic_fde(unw_word_t fde) {
CFI_Parser<LocalAddressSpace>::FDE_Info fdeInfo;
CFI_Parser<LocalAddressSpace>::CIE_Info cieInfo;
const char *message = CFI_Parser<LocalAddressSpace>::decodeFDE(
@@ -285,14 +285,14 @@ void __unw_add_dynamic_fde(unw_word_t fde) {
fdeInfo.pcStart, fdeInfo.pcEnd,
fdeInfo.fdeStart);
} else {
- _LIBUNWIND_DEBUG_LOG("__unw_add_dynamic_fde: bad fde: %s", message);
+ _LIBUNWIND_DEBUG_LOG("__unw_add_dynamic_fde: bad fde: %s", message);
}
}
/// IPI: for __deregister_frame()
-void __unw_remove_dynamic_fde(unw_word_t fde) {
+void __unw_remove_dynamic_fde(unw_word_t fde) {
// fde is own mh_group
- DwarfFDECache<LocalAddressSpace>::removeAllIn((LocalAddressSpace::pint_t)fde);
+ DwarfFDECache<LocalAddressSpace>::removeAllIn((LocalAddressSpace::pint_t)fde);
}
void __unw_add_dynamic_eh_frame_section(unw_word_t eh_frame_start) {
@@ -323,8 +323,8 @@ void __unw_remove_dynamic_eh_frame_section(unw_word_t eh_frame_start) {
(LocalAddressSpace::pint_t)eh_frame_start);
}
-#endif // defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND)
-#endif // !defined(__USING_SJLJ_EXCEPTIONS__)
+#endif // defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND)
+#endif // !defined(__USING_SJLJ_EXCEPTIONS__)
@@ -356,17 +356,17 @@ bool logUnwinding() {
return log;
}
-_LIBUNWIND_HIDDEN
-bool logDWARF() {
- // do manual lock to avoid use of _cxa_guard_acquire or initializers
- static bool checked = false;
- static bool log = false;
- if (!checked) {
- log = (getenv("LIBUNWIND_PRINT_DWARF") != NULL);
- checked = true;
- }
- return log;
-}
-
+_LIBUNWIND_HIDDEN
+bool logDWARF() {
+ // do manual lock to avoid use of _cxa_guard_acquire or initializers
+ static bool checked = false;
+ static bool log = false;
+ if (!checked) {
+ log = (getenv("LIBUNWIND_PRINT_DWARF") != NULL);
+ checked = true;
+ }
+ return log;
+}
+
#endif // NDEBUG
-
+