diff options
author | thegeorg <thegeorg@yandex-team.ru> | 2022-02-10 16:45:08 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:08 +0300 |
commit | 4e839db24a3bbc9f1c610c43d6faaaa99824dcca (patch) | |
tree | 506dac10f5df94fab310584ee51b24fc5a081c22 /contrib/libs/libunwind/src | |
parent | 2d37894b1b037cf24231090eda8589bbb44fb6fc (diff) | |
download | ydb-4e839db24a3bbc9f1c610c43d6faaaa99824dcca.tar.gz |
Restoring authorship annotation for <thegeorg@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/libunwind/src')
23 files changed, 1078 insertions, 1078 deletions
diff --git a/contrib/libs/libunwind/src/AddressSpace.hpp b/contrib/libs/libunwind/src/AddressSpace.hpp index 0c4dfeb4e6..9243f6e67f 100644 --- a/contrib/libs/libunwind/src/AddressSpace.hpp +++ b/contrib/libs/libunwind/src/AddressSpace.hpp @@ -1,4 +1,4 @@ -//===----------------------------------------------------------------------===// +//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -121,23 +121,23 @@ struct UnwindInfoSections { uintptr_t dso_base; #endif #if defined(_LIBUNWIND_USE_DL_ITERATE_PHDR) - size_t text_segment_length; + size_t text_segment_length; #endif #if defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND) uintptr_t dwarf_section; - size_t dwarf_section_length; + size_t dwarf_section_length; #endif #if defined(_LIBUNWIND_SUPPORT_DWARF_INDEX) uintptr_t dwarf_index_section; - size_t dwarf_index_section_length; + size_t dwarf_index_section_length; #endif #if defined(_LIBUNWIND_SUPPORT_COMPACT_UNWIND) uintptr_t compact_unwind_section; - size_t compact_unwind_section_length; + size_t compact_unwind_section_length; #endif #if defined(_LIBUNWIND_ARM_EHABI) uintptr_t arm_section; - size_t arm_section_length; + size_t arm_section_length; #endif }; @@ -430,7 +430,7 @@ static bool checkForUnwindInfoSegment(const Elf_Phdr *phdr, size_t image_base, // .eh_frame_hdr records the start of .eh_frame, but not its size. // Rely on a zero terminator to find the end of the section. cbdata->sects->dwarf_section = hdrInfo.eh_frame_ptr; - cbdata->sects->dwarf_section_length = SIZE_MAX; + cbdata->sects->dwarf_section_length = SIZE_MAX; return true; } } @@ -506,22 +506,22 @@ inline bool LocalAddressSpace::findUnwindSections(pint_t targetAddr, info.dso_base = (uintptr_t)dyldInfo.mh; #if defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND) info.dwarf_section = (uintptr_t)dyldInfo.dwarf_section; - info.dwarf_section_length = (size_t)dyldInfo.dwarf_section_length; + info.dwarf_section_length = (size_t)dyldInfo.dwarf_section_length; #endif info.compact_unwind_section = (uintptr_t)dyldInfo.compact_unwind_section; - info.compact_unwind_section_length = (size_t)dyldInfo.compact_unwind_section_length; + info.compact_unwind_section_length = (size_t)dyldInfo.compact_unwind_section_length; return true; } #elif defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND) && defined(_LIBUNWIND_IS_BAREMETAL) info.dso_base = 0; // Bare metal is statically linked, so no need to ask the dynamic loader - info.dwarf_section_length = (size_t)(&__eh_frame_end - &__eh_frame_start); + info.dwarf_section_length = (size_t)(&__eh_frame_end - &__eh_frame_start); info.dwarf_section = (uintptr_t)(&__eh_frame_start); _LIBUNWIND_TRACE_UNWINDING("findUnwindSections: section %p length %p", (void *)info.dwarf_section, (void *)info.dwarf_section_length); #if defined(_LIBUNWIND_SUPPORT_DWARF_INDEX) info.dwarf_index_section = (uintptr_t)(&__eh_frame_hdr_start); - info.dwarf_index_section_length = (size_t)(&__eh_frame_hdr_end - &__eh_frame_hdr_start); + info.dwarf_index_section_length = (size_t)(&__eh_frame_hdr_end - &__eh_frame_hdr_start); _LIBUNWIND_TRACE_UNWINDING("findUnwindSections: index section %p length %p", (void *)info.dwarf_index_section, (void *)info.dwarf_index_section_length); #endif @@ -530,7 +530,7 @@ inline bool LocalAddressSpace::findUnwindSections(pint_t targetAddr, #elif defined(_LIBUNWIND_ARM_EHABI) && defined(_LIBUNWIND_IS_BAREMETAL) // Bare metal is statically linked, so no need to ask the dynamic loader info.arm_section = (uintptr_t)(&__exidx_start); - info.arm_section_length = (size_t)(&__exidx_end - &__exidx_start); + info.arm_section_length = (size_t)(&__exidx_end - &__exidx_start); _LIBUNWIND_TRACE_UNWINDING("findUnwindSections: section %p length %p", (void *)info.arm_section, (void *)info.arm_section_length); if (info.arm_section && info.arm_section_length) @@ -584,7 +584,7 @@ inline bool LocalAddressSpace::findUnwindSections(pint_t targetAddr, int length = 0; info.arm_section = (uintptr_t)dl_unwind_find_exidx((_Unwind_Ptr)targetAddr, &length); - info.arm_section_length = (size_t)length * sizeof(EHABIIndexEntry); + info.arm_section_length = (size_t)length * sizeof(EHABIIndexEntry); if (info.arm_section && info.arm_section_length) return true; #elif defined(_LIBUNWIND_USE_DL_ITERATE_PHDR) diff --git a/contrib/libs/libunwind/src/CompactUnwinder.hpp b/contrib/libs/libunwind/src/CompactUnwinder.hpp index 0b2b5e111b..6b3316d0e1 100644 --- a/contrib/libs/libunwind/src/CompactUnwinder.hpp +++ b/contrib/libs/libunwind/src/CompactUnwinder.hpp @@ -1,4 +1,4 @@ -//===----------------------------------------------------------------------===// +//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -537,65 +537,65 @@ int CompactUnwinder_arm64<A>::stepWithCompactEncodingFrameless( uint64_t savedRegisterLoc = registers.getSP() + stackSize; if (encoding & UNWIND_ARM64_FRAME_X19_X20_PAIR) { - registers.setRegister(UNW_AARCH64_X19, addressSpace.get64(savedRegisterLoc)); + registers.setRegister(UNW_AARCH64_X19, addressSpace.get64(savedRegisterLoc)); savedRegisterLoc -= 8; - registers.setRegister(UNW_AARCH64_X20, addressSpace.get64(savedRegisterLoc)); + registers.setRegister(UNW_AARCH64_X20, addressSpace.get64(savedRegisterLoc)); savedRegisterLoc -= 8; } if (encoding & UNWIND_ARM64_FRAME_X21_X22_PAIR) { - registers.setRegister(UNW_AARCH64_X21, addressSpace.get64(savedRegisterLoc)); + registers.setRegister(UNW_AARCH64_X21, addressSpace.get64(savedRegisterLoc)); savedRegisterLoc -= 8; - registers.setRegister(UNW_AARCH64_X22, addressSpace.get64(savedRegisterLoc)); + registers.setRegister(UNW_AARCH64_X22, addressSpace.get64(savedRegisterLoc)); savedRegisterLoc -= 8; } if (encoding & UNWIND_ARM64_FRAME_X23_X24_PAIR) { - registers.setRegister(UNW_AARCH64_X23, addressSpace.get64(savedRegisterLoc)); + registers.setRegister(UNW_AARCH64_X23, addressSpace.get64(savedRegisterLoc)); savedRegisterLoc -= 8; - registers.setRegister(UNW_AARCH64_X24, addressSpace.get64(savedRegisterLoc)); + registers.setRegister(UNW_AARCH64_X24, addressSpace.get64(savedRegisterLoc)); savedRegisterLoc -= 8; } if (encoding & UNWIND_ARM64_FRAME_X25_X26_PAIR) { - registers.setRegister(UNW_AARCH64_X25, addressSpace.get64(savedRegisterLoc)); + registers.setRegister(UNW_AARCH64_X25, addressSpace.get64(savedRegisterLoc)); savedRegisterLoc -= 8; - registers.setRegister(UNW_AARCH64_X26, addressSpace.get64(savedRegisterLoc)); + registers.setRegister(UNW_AARCH64_X26, addressSpace.get64(savedRegisterLoc)); savedRegisterLoc -= 8; } if (encoding & UNWIND_ARM64_FRAME_X27_X28_PAIR) { - registers.setRegister(UNW_AARCH64_X27, addressSpace.get64(savedRegisterLoc)); + registers.setRegister(UNW_AARCH64_X27, addressSpace.get64(savedRegisterLoc)); savedRegisterLoc -= 8; - registers.setRegister(UNW_AARCH64_X28, addressSpace.get64(savedRegisterLoc)); + registers.setRegister(UNW_AARCH64_X28, addressSpace.get64(savedRegisterLoc)); savedRegisterLoc -= 8; } if (encoding & UNWIND_ARM64_FRAME_D8_D9_PAIR) { - registers.setFloatRegister(UNW_AARCH64_V8, + registers.setFloatRegister(UNW_AARCH64_V8, addressSpace.getDouble(savedRegisterLoc)); savedRegisterLoc -= 8; - registers.setFloatRegister(UNW_AARCH64_V9, + registers.setFloatRegister(UNW_AARCH64_V9, addressSpace.getDouble(savedRegisterLoc)); savedRegisterLoc -= 8; } if (encoding & UNWIND_ARM64_FRAME_D10_D11_PAIR) { - registers.setFloatRegister(UNW_AARCH64_V10, + registers.setFloatRegister(UNW_AARCH64_V10, addressSpace.getDouble(savedRegisterLoc)); savedRegisterLoc -= 8; - registers.setFloatRegister(UNW_AARCH64_V11, + registers.setFloatRegister(UNW_AARCH64_V11, addressSpace.getDouble(savedRegisterLoc)); savedRegisterLoc -= 8; } if (encoding & UNWIND_ARM64_FRAME_D12_D13_PAIR) { - registers.setFloatRegister(UNW_AARCH64_V12, + registers.setFloatRegister(UNW_AARCH64_V12, addressSpace.getDouble(savedRegisterLoc)); savedRegisterLoc -= 8; - registers.setFloatRegister(UNW_AARCH64_V13, + registers.setFloatRegister(UNW_AARCH64_V13, addressSpace.getDouble(savedRegisterLoc)); savedRegisterLoc -= 8; } if (encoding & UNWIND_ARM64_FRAME_D14_D15_PAIR) { - registers.setFloatRegister(UNW_AARCH64_V14, + registers.setFloatRegister(UNW_AARCH64_V14, addressSpace.getDouble(savedRegisterLoc)); savedRegisterLoc -= 8; - registers.setFloatRegister(UNW_AARCH64_V15, + registers.setFloatRegister(UNW_AARCH64_V15, addressSpace.getDouble(savedRegisterLoc)); savedRegisterLoc -= 8; } @@ -604,7 +604,7 @@ int CompactUnwinder_arm64<A>::stepWithCompactEncodingFrameless( registers.setSP(savedRegisterLoc); // set pc to be value in lr - registers.setIP(registers.getRegister(UNW_AARCH64_LR)); + registers.setIP(registers.getRegister(UNW_AARCH64_LR)); return UNW_STEP_SUCCESS; } @@ -616,65 +616,65 @@ int CompactUnwinder_arm64<A>::stepWithCompactEncodingFrame( uint64_t savedRegisterLoc = registers.getFP() - 8; if (encoding & UNWIND_ARM64_FRAME_X19_X20_PAIR) { - registers.setRegister(UNW_AARCH64_X19, addressSpace.get64(savedRegisterLoc)); + registers.setRegister(UNW_AARCH64_X19, addressSpace.get64(savedRegisterLoc)); savedRegisterLoc -= 8; - registers.setRegister(UNW_AARCH64_X20, addressSpace.get64(savedRegisterLoc)); + registers.setRegister(UNW_AARCH64_X20, addressSpace.get64(savedRegisterLoc)); savedRegisterLoc -= 8; } if (encoding & UNWIND_ARM64_FRAME_X21_X22_PAIR) { - registers.setRegister(UNW_AARCH64_X21, addressSpace.get64(savedRegisterLoc)); + registers.setRegister(UNW_AARCH64_X21, addressSpace.get64(savedRegisterLoc)); savedRegisterLoc -= 8; - registers.setRegister(UNW_AARCH64_X22, addressSpace.get64(savedRegisterLoc)); + registers.setRegister(UNW_AARCH64_X22, addressSpace.get64(savedRegisterLoc)); savedRegisterLoc -= 8; } if (encoding & UNWIND_ARM64_FRAME_X23_X24_PAIR) { - registers.setRegister(UNW_AARCH64_X23, addressSpace.get64(savedRegisterLoc)); + registers.setRegister(UNW_AARCH64_X23, addressSpace.get64(savedRegisterLoc)); savedRegisterLoc -= 8; - registers.setRegister(UNW_AARCH64_X24, addressSpace.get64(savedRegisterLoc)); + registers.setRegister(UNW_AARCH64_X24, addressSpace.get64(savedRegisterLoc)); savedRegisterLoc -= 8; } if (encoding & UNWIND_ARM64_FRAME_X25_X26_PAIR) { - registers.setRegister(UNW_AARCH64_X25, addressSpace.get64(savedRegisterLoc)); + registers.setRegister(UNW_AARCH64_X25, addressSpace.get64(savedRegisterLoc)); savedRegisterLoc -= 8; - registers.setRegister(UNW_AARCH64_X26, addressSpace.get64(savedRegisterLoc)); + registers.setRegister(UNW_AARCH64_X26, addressSpace.get64(savedRegisterLoc)); savedRegisterLoc -= 8; } if (encoding & UNWIND_ARM64_FRAME_X27_X28_PAIR) { - registers.setRegister(UNW_AARCH64_X27, addressSpace.get64(savedRegisterLoc)); + registers.setRegister(UNW_AARCH64_X27, addressSpace.get64(savedRegisterLoc)); savedRegisterLoc -= 8; - registers.setRegister(UNW_AARCH64_X28, addressSpace.get64(savedRegisterLoc)); + registers.setRegister(UNW_AARCH64_X28, addressSpace.get64(savedRegisterLoc)); savedRegisterLoc -= 8; } if (encoding & UNWIND_ARM64_FRAME_D8_D9_PAIR) { - registers.setFloatRegister(UNW_AARCH64_V8, + registers.setFloatRegister(UNW_AARCH64_V8, addressSpace.getDouble(savedRegisterLoc)); savedRegisterLoc -= 8; - registers.setFloatRegister(UNW_AARCH64_V9, + registers.setFloatRegister(UNW_AARCH64_V9, addressSpace.getDouble(savedRegisterLoc)); savedRegisterLoc -= 8; } if (encoding & UNWIND_ARM64_FRAME_D10_D11_PAIR) { - registers.setFloatRegister(UNW_AARCH64_V10, + registers.setFloatRegister(UNW_AARCH64_V10, addressSpace.getDouble(savedRegisterLoc)); savedRegisterLoc -= 8; - registers.setFloatRegister(UNW_AARCH64_V11, + registers.setFloatRegister(UNW_AARCH64_V11, addressSpace.getDouble(savedRegisterLoc)); savedRegisterLoc -= 8; } if (encoding & UNWIND_ARM64_FRAME_D12_D13_PAIR) { - registers.setFloatRegister(UNW_AARCH64_V12, + registers.setFloatRegister(UNW_AARCH64_V12, addressSpace.getDouble(savedRegisterLoc)); savedRegisterLoc -= 8; - registers.setFloatRegister(UNW_AARCH64_V13, + registers.setFloatRegister(UNW_AARCH64_V13, addressSpace.getDouble(savedRegisterLoc)); savedRegisterLoc -= 8; } if (encoding & UNWIND_ARM64_FRAME_D14_D15_PAIR) { - registers.setFloatRegister(UNW_AARCH64_V14, + registers.setFloatRegister(UNW_AARCH64_V14, addressSpace.getDouble(savedRegisterLoc)); savedRegisterLoc -= 8; - registers.setFloatRegister(UNW_AARCH64_V15, + registers.setFloatRegister(UNW_AARCH64_V15, addressSpace.getDouble(savedRegisterLoc)); savedRegisterLoc -= 8; } diff --git a/contrib/libs/libunwind/src/DwarfInstructions.hpp b/contrib/libs/libunwind/src/DwarfInstructions.hpp index c1a241c55c..cf00869d30 100644 --- a/contrib/libs/libunwind/src/DwarfInstructions.hpp +++ b/contrib/libs/libunwind/src/DwarfInstructions.hpp @@ -1,4 +1,4 @@ -//===----------------------------------------------------------------------===// +//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -74,13 +74,13 @@ private: } }; -template <typename R> -auto getSparcWCookie(const R &r, int) -> decltype(r.getWCookie()) { - return r.getWCookie(); -} -template <typename R> uint64_t getSparcWCookie(const R &, long) { - return 0; -} +template <typename R> +auto getSparcWCookie(const R &r, int) -> decltype(r.getWCookie()) { + return r.getWCookie(); +} +template <typename R> uint64_t getSparcWCookie(const R &, long) { + return 0; +} template <typename A, typename R> typename A::pint_t DwarfInstructions<A, R>::getSavedRegister( @@ -90,10 +90,10 @@ typename A::pint_t DwarfInstructions<A, R>::getSavedRegister( case CFI_Parser<A>::kRegisterInCFA: return (pint_t)addressSpace.getRegister(cfa + (pint_t)savedReg.value); - case CFI_Parser<A>::kRegisterInCFADecrypt: // sparc64 specific - return addressSpace.getP(cfa + (pint_t)savedReg.value) ^ - getSparcWCookie(registers, 0); - + case CFI_Parser<A>::kRegisterInCFADecrypt: // sparc64 specific + return addressSpace.getP(cfa + (pint_t)savedReg.value) ^ + getSparcWCookie(registers, 0); + case CFI_Parser<A>::kRegisterAtExpression: return (pint_t)addressSpace.getRegister(evaluateExpression( (pint_t)savedReg.value, addressSpace, registers, cfa)); @@ -126,16 +126,16 @@ double DwarfInstructions<A, R>::getSavedFloatRegister( return addressSpace.getDouble( evaluateExpression((pint_t)savedReg.value, addressSpace, registers, cfa)); - case CFI_Parser<A>::kRegisterUndefined: - return 0.0; - case CFI_Parser<A>::kRegisterInRegister: -#ifndef _LIBUNWIND_TARGET_ARM - return registers.getFloatRegister((int)savedReg.value); -#endif + case CFI_Parser<A>::kRegisterUndefined: + return 0.0; + case CFI_Parser<A>::kRegisterInRegister: +#ifndef _LIBUNWIND_TARGET_ARM + return registers.getFloatRegister((int)savedReg.value); +#endif case CFI_Parser<A>::kRegisterIsExpression: case CFI_Parser<A>::kRegisterUnused: case CFI_Parser<A>::kRegisterOffsetFromCFA: - case CFI_Parser<A>::kRegisterInCFADecrypt: + case CFI_Parser<A>::kRegisterInCFADecrypt: // FIX ME break; } @@ -160,7 +160,7 @@ v128 DwarfInstructions<A, R>::getSavedVectorRegister( case CFI_Parser<A>::kRegisterUndefined: case CFI_Parser<A>::kRegisterOffsetFromCFA: case CFI_Parser<A>::kRegisterInRegister: - case CFI_Parser<A>::kRegisterInCFADecrypt: + case CFI_Parser<A>::kRegisterInCFADecrypt: // FIX ME break; } @@ -183,16 +183,16 @@ int DwarfInstructions<A, R>::stepWithDwarf(A &addressSpace, pint_t pc, // restore registers that DWARF says were saved R newRegisters = registers; - - // Typically, the CFA is the stack pointer at the call site in - // the previous frame. However, there are scenarios in which this is not - // true. For example, if we switched to a new stack. In that case, the - // value of the previous SP might be indicated by a CFI directive. - // - // We set the SP here to the CFA, allowing for it to be overridden - // by a CFI directive later on. - newRegisters.setSP(cfa); - + + // Typically, the CFA is the stack pointer at the call site in + // the previous frame. However, there are scenarios in which this is not + // true. For example, if we switched to a new stack. In that case, the + // value of the previous SP might be indicated by a CFI directive. + // + // We set the SP here to the CFA, allowing for it to be overridden + // by a CFI directive later on. + newRegisters.setSP(cfa); + pint_t returnAddress = 0; const int lastReg = R::lastDwarfRegNum(); assert(static_cast<int>(CFI_Parser<A>::kMaxRegisterNumber) >= lastReg && @@ -235,7 +235,7 @@ int DwarfInstructions<A, R>::stepWithDwarf(A &addressSpace, pint_t pc, // restored. autia1716 is used instead of autia as autia1716 assembles // to a NOP on pre-v8.3a architectures. if ((R::getArch() == REGISTERS_ARM64) && - prolog.savedRegisters[UNW_AARCH64_RA_SIGN_STATE].value && + prolog.savedRegisters[UNW_AARCH64_RA_SIGN_STATE].value && returnAddress != 0) { #if !defined(_LIBUNWIND_IS_NATIVE_ONLY) return UNW_ECROSSRASIGNING; @@ -255,20 +255,20 @@ int DwarfInstructions<A, R>::stepWithDwarf(A &addressSpace, pint_t pc, } #endif -#if defined(_LIBUNWIND_IS_NATIVE_ONLY) && defined(_LIBUNWIND_TARGET_ARM) && \ - defined(__ARM_FEATURE_PAUTH) - if ((R::getArch() == REGISTERS_ARM) && - prolog.savedRegisters[UNW_ARM_RA_AUTH_CODE].value) { - pint_t pac = - getSavedRegister(addressSpace, registers, cfa, - prolog.savedRegisters[UNW_ARM_RA_AUTH_CODE]); - __asm__ __volatile__("autg %0, %1, %2" - : - : "r"(pac), "r"(returnAddress), "r"(cfa) - :); - } -#endif - +#if defined(_LIBUNWIND_IS_NATIVE_ONLY) && defined(_LIBUNWIND_TARGET_ARM) && \ + defined(__ARM_FEATURE_PAUTH) + if ((R::getArch() == REGISTERS_ARM) && + prolog.savedRegisters[UNW_ARM_RA_AUTH_CODE].value) { + pint_t pac = + getSavedRegister(addressSpace, registers, cfa, + prolog.savedRegisters[UNW_ARM_RA_AUTH_CODE]); + __asm__ __volatile__("autg %0, %1, %2" + : + : "r"(pac), "r"(returnAddress), "r"(cfa) + :); + } +#endif + #if defined(_LIBUNWIND_TARGET_SPARC) if (R::getArch() == REGISTERS_SPARC) { // Skip call site instruction and delay slot @@ -279,12 +279,12 @@ int DwarfInstructions<A, R>::stepWithDwarf(A &addressSpace, pint_t pc, } #endif -#if defined(_LIBUNWIND_TARGET_SPARC64) - // Skip call site instruction and delay slot. - if (R::getArch() == REGISTERS_SPARC64) - returnAddress += 8; -#endif - +#if defined(_LIBUNWIND_TARGET_SPARC64) + // Skip call site instruction and delay slot. + if (R::getArch() == REGISTERS_SPARC64) + returnAddress += 8; +#endif + #if defined(_LIBUNWIND_TARGET_PPC64) #define PPC64_ELFV1_R2_LOAD_INST_ENCODING 0xe8410028u // ld r2,40(r1) #define PPC64_ELFV1_R2_OFFSET 40 diff --git a/contrib/libs/libunwind/src/DwarfParser.hpp b/contrib/libs/libunwind/src/DwarfParser.hpp index b5a53166fc..23e5cc42d3 100644 --- a/contrib/libs/libunwind/src/DwarfParser.hpp +++ b/contrib/libs/libunwind/src/DwarfParser.hpp @@ -1,4 +1,4 @@ -//===----------------------------------------------------------------------===// +//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -71,7 +71,7 @@ public: kRegisterUnused, kRegisterUndefined, kRegisterInCFA, - kRegisterInCFADecrypt, // sparc64 specific + kRegisterInCFADecrypt, // sparc64 specific kRegisterOffsetFromCFA, kRegisterInRegister, kRegisterAtExpression, @@ -152,11 +152,11 @@ public: }; static bool findFDE(A &addressSpace, pint_t pc, pint_t ehSectionStart, - size_t sectionLength, pint_t fdeHint, FDE_Info *fdeInfo, + size_t sectionLength, pint_t fdeHint, FDE_Info *fdeInfo, CIE_Info *cieInfo); static const char *decodeFDE(A &addressSpace, pint_t fdeStart, - FDE_Info *fdeInfo, CIE_Info *cieInfo, - bool useCIEInfo = false); + FDE_Info *fdeInfo, CIE_Info *cieInfo, + bool useCIEInfo = false); static bool parseFDEInstructions(A &addressSpace, const FDE_Info &fdeInfo, const CIE_Info &cieInfo, pint_t upToPC, int arch, PrologInfo *results); @@ -164,14 +164,14 @@ public: static const char *parseCIE(A &addressSpace, pint_t cie, CIE_Info *cieInfo); }; -/// Parse a FDE into a CIE_Info and an FDE_Info. If useCIEInfo is -/// true, treat cieInfo as already-parsed CIE_Info (whose start offset -/// must match the one specified by the FDE) rather than parsing the -/// one indicated within the FDE. +/// Parse a FDE into a CIE_Info and an FDE_Info. If useCIEInfo is +/// true, treat cieInfo as already-parsed CIE_Info (whose start offset +/// must match the one specified by the FDE) rather than parsing the +/// one indicated within the FDE. template <typename A> const char *CFI_Parser<A>::decodeFDE(A &addressSpace, pint_t fdeStart, - FDE_Info *fdeInfo, CIE_Info *cieInfo, - bool useCIEInfo) { + FDE_Info *fdeInfo, CIE_Info *cieInfo, + bool useCIEInfo) { pint_t p = fdeStart; pint_t cfiLength = (pint_t)addressSpace.get32(p); p += 4; @@ -187,14 +187,14 @@ const char *CFI_Parser<A>::decodeFDE(A &addressSpace, pint_t fdeStart, return "FDE is really a CIE"; // this is a CIE not an FDE pint_t nextCFI = p + cfiLength; pint_t cieStart = p - ciePointer; - if (useCIEInfo) { - if (cieInfo->cieStart != cieStart) - return "CIE start does not match"; - } else { - const char *err = parseCIE(addressSpace, cieStart, cieInfo); - if (err != NULL) - return err; - } + if (useCIEInfo) { + if (cieInfo->cieStart != cieStart) + return "CIE start does not match"; + } else { + const char *err = parseCIE(addressSpace, cieStart, cieInfo); + if (err != NULL) + return err; + } p += 4; // Parse pc begin and range. pint_t pcStart = @@ -231,11 +231,11 @@ const char *CFI_Parser<A>::decodeFDE(A &addressSpace, pint_t fdeStart, /// Scan an eh_frame section to find an FDE for a pc template <typename A> bool CFI_Parser<A>::findFDE(A &addressSpace, pint_t pc, pint_t ehSectionStart, - size_t sectionLength, pint_t fdeHint, + size_t sectionLength, pint_t fdeHint, FDE_Info *fdeInfo, CIE_Info *cieInfo) { //fprintf(stderr, "findFDE(0x%llX)\n", (long long)pc); pint_t p = (fdeHint != 0) ? fdeHint : ehSectionStart; - const pint_t ehSectionEnd = (sectionLength == SIZE_MAX) + const pint_t ehSectionEnd = (sectionLength == SIZE_MAX) ? static_cast<pint_t>(-1) : (ehSectionStart + sectionLength); while (p < ehSectionEnd) { @@ -734,8 +734,8 @@ bool CFI_Parser<A>::parseFDEInstructions(A &addressSpace, "DW_CFA_GNU_negative_offset_extended(%" PRId64 ")\n", offset); break; -#if defined(_LIBUNWIND_TARGET_AARCH64) || defined(_LIBUNWIND_TARGET_SPARC) || \ - defined(_LIBUNWIND_TARGET_SPARC64) +#if defined(_LIBUNWIND_TARGET_AARCH64) || defined(_LIBUNWIND_TARGET_SPARC) || \ + defined(_LIBUNWIND_TARGET_SPARC64) // The same constant is used to represent different instructions on // AArch64 (negate_ra_state) and SPARC (window_save). static_assert(DW_CFA_AARCH64_negate_ra_state == DW_CFA_GNU_window_save, @@ -745,8 +745,8 @@ bool CFI_Parser<A>::parseFDEInstructions(A &addressSpace, #if defined(_LIBUNWIND_TARGET_AARCH64) case REGISTERS_ARM64: { int64_t value = - results->savedRegisters[UNW_AARCH64_RA_SIGN_STATE].value ^ 0x1; - results->setRegisterValue(UNW_AARCH64_RA_SIGN_STATE, value, + results->savedRegisters[UNW_AARCH64_RA_SIGN_STATE].value ^ 0x1; + results->setRegisterValue(UNW_AARCH64_RA_SIGN_STATE, value, initialState); _LIBUNWIND_TRACE_DWARF("DW_CFA_AARCH64_negate_ra_state\n"); } break; @@ -769,31 +769,31 @@ bool CFI_Parser<A>::parseFDEInstructions(A &addressSpace, } break; #endif - -#if defined(_LIBUNWIND_TARGET_SPARC64) - // case DW_CFA_GNU_window_save: - case REGISTERS_SPARC64: - // Don't save %o0-%o7 on sparc64. - // https://reviews.llvm.org/D32450#736405 - - for (reg = UNW_SPARC_L0; reg <= UNW_SPARC_I7; reg++) { - if (reg == UNW_SPARC_I7) - results->setRegister( - reg, kRegisterInCFADecrypt, - static_cast<int64_t>((reg - UNW_SPARC_L0) * sizeof(pint_t)), - initialState); - else - results->setRegister( - reg, kRegisterInCFA, - static_cast<int64_t>((reg - UNW_SPARC_L0) * sizeof(pint_t)), - initialState); - } - _LIBUNWIND_TRACE_DWARF("DW_CFA_GNU_window_save\n"); - break; -#endif + +#if defined(_LIBUNWIND_TARGET_SPARC64) + // case DW_CFA_GNU_window_save: + case REGISTERS_SPARC64: + // Don't save %o0-%o7 on sparc64. + // https://reviews.llvm.org/D32450#736405 + + for (reg = UNW_SPARC_L0; reg <= UNW_SPARC_I7; reg++) { + if (reg == UNW_SPARC_I7) + results->setRegister( + reg, kRegisterInCFADecrypt, + static_cast<int64_t>((reg - UNW_SPARC_L0) * sizeof(pint_t)), + initialState); + else + results->setRegister( + reg, kRegisterInCFA, + static_cast<int64_t>((reg - UNW_SPARC_L0) * sizeof(pint_t)), + initialState); + } + _LIBUNWIND_TRACE_DWARF("DW_CFA_GNU_window_save\n"); + break; +#endif } break; - + #else (void)arch; #endif diff --git a/contrib/libs/libunwind/src/EHHeaderParser.hpp b/contrib/libs/libunwind/src/EHHeaderParser.hpp index 9a38070fab..03b8086517 100644 --- a/contrib/libs/libunwind/src/EHHeaderParser.hpp +++ b/contrib/libs/libunwind/src/EHHeaderParser.hpp @@ -1,4 +1,4 @@ -//===----------------------------------------------------------------------===// +//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. diff --git a/contrib/libs/libunwind/src/RWMutex.hpp b/contrib/libs/libunwind/src/RWMutex.hpp index 344d35641f..52c087c906 100644 --- a/contrib/libs/libunwind/src/RWMutex.hpp +++ b/contrib/libs/libunwind/src/RWMutex.hpp @@ -1,4 +1,4 @@ -//===----------------------------------------------------------------------===// +//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. diff --git a/contrib/libs/libunwind/src/Registers.hpp b/contrib/libs/libunwind/src/Registers.hpp index cbc3876d67..f5f8dad0b5 100644 --- a/contrib/libs/libunwind/src/Registers.hpp +++ b/contrib/libs/libunwind/src/Registers.hpp @@ -1,4 +1,4 @@ -//===----------------------------------------------------------------------===// +//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -15,8 +15,8 @@ #include <stdint.h> #include <string.h> -#include "cet_unwind.h" -#include "config.h" +#include "cet_unwind.h" +#include "config.h" #include "libunwind.h" namespace libunwind { @@ -35,7 +35,7 @@ enum { REGISTERS_MIPS_O32, REGISTERS_MIPS_NEWABI, REGISTERS_SPARC, - REGISTERS_SPARC64, + REGISTERS_SPARC64, REGISTERS_HEXAGON, REGISTERS_RISCV, REGISTERS_VE, @@ -44,13 +44,13 @@ enum { #if defined(_LIBUNWIND_TARGET_I386) class _LIBUNWIND_HIDDEN Registers_x86; extern "C" void __libunwind_Registers_x86_jumpto(Registers_x86 *); - -#if defined(_LIBUNWIND_USE_CET) -extern "C" void *__libunwind_cet_get_jump_target() { - return reinterpret_cast<void *>(&__libunwind_Registers_x86_jumpto); -} -#endif - + +#if defined(_LIBUNWIND_USE_CET) +extern "C" void *__libunwind_cet_get_jump_target() { + return reinterpret_cast<void *>(&__libunwind_Registers_x86_jumpto); +} +#endif + /// Registers_x86 holds the register state of a thread in a 32-bit intel /// process. class _LIBUNWIND_HIDDEN Registers_x86 { @@ -262,13 +262,13 @@ inline void Registers_x86::setVectorRegister(int, v128) { /// process. class _LIBUNWIND_HIDDEN Registers_x86_64; extern "C" void __libunwind_Registers_x86_64_jumpto(Registers_x86_64 *); - -#if defined(_LIBUNWIND_USE_CET) -extern "C" void *__libunwind_cet_get_jump_target() { - return reinterpret_cast<void *>(&__libunwind_Registers_x86_64_jumpto); -} -#endif - + +#if defined(_LIBUNWIND_USE_CET) +extern "C" void *__libunwind_cet_get_jump_target() { + return reinterpret_cast<void *>(&__libunwind_Registers_x86_64_jumpto); +} +#endif + class _LIBUNWIND_HIDDEN Registers_x86_64 { public: Registers_x86_64(); @@ -355,7 +355,7 @@ inline bool Registers_x86_64::validRegister(int regNum) const { return true; if (regNum < 0) return false; - if (regNum > 16) + if (regNum > 16) return false; return true; } @@ -363,7 +363,7 @@ inline bool Registers_x86_64::validRegister(int regNum) const { inline uint64_t Registers_x86_64::getRegister(int regNum) const { switch (regNum) { case UNW_REG_IP: - case UNW_X86_64_RIP: + case UNW_X86_64_RIP: return _registers.__rip; case UNW_REG_SP: return _registers.__rsp; @@ -406,7 +406,7 @@ inline uint64_t Registers_x86_64::getRegister(int regNum) const { inline void Registers_x86_64::setRegister(int regNum, uint64_t value) { switch (regNum) { case UNW_REG_IP: - case UNW_X86_64_RIP: + case UNW_X86_64_RIP: _registers.__rip = value; return; case UNW_REG_SP: @@ -467,7 +467,7 @@ inline void Registers_x86_64::setRegister(int regNum, uint64_t value) { inline const char *Registers_x86_64::getRegisterName(int regNum) { switch (regNum) { case UNW_REG_IP: - case UNW_X86_64_RIP: + case UNW_X86_64_RIP: return "rip"; case UNW_REG_SP: return "rsp"; @@ -1866,7 +1866,7 @@ inline bool Registers_arm64::validRegister(int regNum) const { return false; if (regNum > 95) return false; - if (regNum == UNW_AARCH64_RA_SIGN_STATE) + if (regNum == UNW_AARCH64_RA_SIGN_STATE) return true; if ((regNum > 32) && (regNum < 64)) return false; @@ -1874,15 +1874,15 @@ inline bool Registers_arm64::validRegister(int regNum) const { } inline uint64_t Registers_arm64::getRegister(int regNum) const { - if (regNum == UNW_REG_IP || regNum == UNW_AARCH64_PC) + if (regNum == UNW_REG_IP || regNum == UNW_AARCH64_PC) return _registers.__pc; - if (regNum == UNW_REG_SP || regNum == UNW_AARCH64_SP) + if (regNum == UNW_REG_SP || regNum == UNW_AARCH64_SP) return _registers.__sp; - if (regNum == UNW_AARCH64_RA_SIGN_STATE) + if (regNum == UNW_AARCH64_RA_SIGN_STATE) return _registers.__ra_sign_state; - if (regNum == UNW_AARCH64_FP) + if (regNum == UNW_AARCH64_FP) return _registers.__fp; - if (regNum == UNW_AARCH64_LR) + if (regNum == UNW_AARCH64_LR) return _registers.__lr; if ((regNum >= 0) && (regNum < 29)) return _registers.__x[regNum]; @@ -1890,15 +1890,15 @@ inline uint64_t Registers_arm64::getRegister(int regNum) const { } inline void Registers_arm64::setRegister(int regNum, uint64_t value) { - if (regNum == UNW_REG_IP || regNum == UNW_AARCH64_PC) + if (regNum == UNW_REG_IP || regNum == UNW_AARCH64_PC) _registers.__pc = value; - else if (regNum == UNW_REG_SP || regNum == UNW_AARCH64_SP) + else if (regNum == UNW_REG_SP || regNum == UNW_AARCH64_SP) _registers.__sp = value; - else if (regNum == UNW_AARCH64_RA_SIGN_STATE) + else if (regNum == UNW_AARCH64_RA_SIGN_STATE) _registers.__ra_sign_state = value; - else if (regNum == UNW_AARCH64_FP) + else if (regNum == UNW_AARCH64_FP) _registers.__fp = value; - else if (regNum == UNW_AARCH64_LR) + else if (regNum == UNW_AARCH64_LR) _registers.__lr = value; else if ((regNum >= 0) && (regNum < 29)) _registers.__x[regNum] = value; @@ -1912,135 +1912,135 @@ inline const char *Registers_arm64::getRegisterName(int regNum) { return "pc"; case UNW_REG_SP: return "sp"; - case UNW_AARCH64_X0: + case UNW_AARCH64_X0: return "x0"; - case UNW_AARCH64_X1: + case UNW_AARCH64_X1: return "x1"; - case UNW_AARCH64_X2: + case UNW_AARCH64_X2: return "x2"; - case UNW_AARCH64_X3: + case UNW_AARCH64_X3: return "x3"; - case UNW_AARCH64_X4: + case UNW_AARCH64_X4: return "x4"; - case UNW_AARCH64_X5: + case UNW_AARCH64_X5: return "x5"; - case UNW_AARCH64_X6: + case UNW_AARCH64_X6: return "x6"; - case UNW_AARCH64_X7: + case UNW_AARCH64_X7: return "x7"; - case UNW_AARCH64_X8: + case UNW_AARCH64_X8: return "x8"; - case UNW_AARCH64_X9: + case UNW_AARCH64_X9: return "x9"; - case UNW_AARCH64_X10: + case UNW_AARCH64_X10: return "x10"; - case UNW_AARCH64_X11: + case UNW_AARCH64_X11: return "x11"; - case UNW_AARCH64_X12: + case UNW_AARCH64_X12: return "x12"; - case UNW_AARCH64_X13: + case UNW_AARCH64_X13: return "x13"; - case UNW_AARCH64_X14: + case UNW_AARCH64_X14: return "x14"; - case UNW_AARCH64_X15: + case UNW_AARCH64_X15: return "x15"; - case UNW_AARCH64_X16: + case UNW_AARCH64_X16: return "x16"; - case UNW_AARCH64_X17: + case UNW_AARCH64_X17: return "x17"; - case UNW_AARCH64_X18: + case UNW_AARCH64_X18: return "x18"; - case UNW_AARCH64_X19: + case UNW_AARCH64_X19: return "x19"; - case UNW_AARCH64_X20: + case UNW_AARCH64_X20: return "x20"; - case UNW_AARCH64_X21: + case UNW_AARCH64_X21: return "x21"; - case UNW_AARCH64_X22: + case UNW_AARCH64_X22: return "x22"; - case UNW_AARCH64_X23: + case UNW_AARCH64_X23: return "x23"; - case UNW_AARCH64_X24: + case UNW_AARCH64_X24: return "x24"; - case UNW_AARCH64_X25: + case UNW_AARCH64_X25: return "x25"; - case UNW_AARCH64_X26: + case UNW_AARCH64_X26: return "x26"; - case UNW_AARCH64_X27: + case UNW_AARCH64_X27: return "x27"; - case UNW_AARCH64_X28: + case UNW_AARCH64_X28: return "x28"; - case UNW_AARCH64_FP: + case UNW_AARCH64_FP: return "fp"; - case UNW_AARCH64_LR: + case UNW_AARCH64_LR: return "lr"; - case UNW_AARCH64_SP: + case UNW_AARCH64_SP: return "sp"; - case UNW_AARCH64_PC: + case UNW_AARCH64_PC: return "pc"; - case UNW_AARCH64_V0: + case UNW_AARCH64_V0: return "d0"; - case UNW_AARCH64_V1: + case UNW_AARCH64_V1: return "d1"; - case UNW_AARCH64_V2: + case UNW_AARCH64_V2: return "d2"; - case UNW_AARCH64_V3: + case UNW_AARCH64_V3: return "d3"; - case UNW_AARCH64_V4: + case UNW_AARCH64_V4: return "d4"; - case UNW_AARCH64_V5: + case UNW_AARCH64_V5: return "d5"; - case UNW_AARCH64_V6: + case UNW_AARCH64_V6: return "d6"; - case UNW_AARCH64_V7: + case UNW_AARCH64_V7: return "d7"; - case UNW_AARCH64_V8: + case UNW_AARCH64_V8: return "d8"; - case UNW_AARCH64_V9: + case UNW_AARCH64_V9: return "d9"; - case UNW_AARCH64_V10: + case UNW_AARCH64_V10: return "d10"; - case UNW_AARCH64_V11: + case UNW_AARCH64_V11: return "d11"; - case UNW_AARCH64_V12: + case UNW_AARCH64_V12: return "d12"; - case UNW_AARCH64_V13: + case UNW_AARCH64_V13: return "d13"; - case UNW_AARCH64_V14: + case UNW_AARCH64_V14: return "d14"; - case UNW_AARCH64_V15: + case UNW_AARCH64_V15: return "d15"; - case UNW_AARCH64_V16: + case UNW_AARCH64_V16: return "d16"; - case UNW_AARCH64_V17: + case UNW_AARCH64_V17: return "d17"; - case UNW_AARCH64_V18: + case UNW_AARCH64_V18: return "d18"; - case UNW_AARCH64_V19: + case UNW_AARCH64_V19: return "d19"; - case UNW_AARCH64_V20: + case UNW_AARCH64_V20: return "d20"; - case UNW_AARCH64_V21: + case UNW_AARCH64_V21: return "d21"; - case UNW_AARCH64_V22: + case UNW_AARCH64_V22: return "d22"; - case UNW_AARCH64_V23: + case UNW_AARCH64_V23: return "d23"; - case UNW_AARCH64_V24: + case UNW_AARCH64_V24: return "d24"; - case UNW_AARCH64_V25: + case UNW_AARCH64_V25: return "d25"; - case UNW_AARCH64_V26: + case UNW_AARCH64_V26: return "d26"; - case UNW_AARCH64_V27: + case UNW_AARCH64_V27: return "d27"; - case UNW_AARCH64_V28: + case UNW_AARCH64_V28: return "d28"; - case UNW_AARCH64_V29: + case UNW_AARCH64_V29: return "d29"; - case UNW_AARCH64_V30: + case UNW_AARCH64_V30: return "d30"; - case UNW_AARCH64_V31: + case UNW_AARCH64_V31: return "d31"; default: return "unknown register"; @@ -2048,21 +2048,21 @@ inline const char *Registers_arm64::getRegisterName(int regNum) { } inline bool Registers_arm64::validFloatRegister(int regNum) const { - if (regNum < UNW_AARCH64_V0) + if (regNum < UNW_AARCH64_V0) return false; - if (regNum > UNW_AARCH64_V31) + if (regNum > UNW_AARCH64_V31) return false; return true; } inline double Registers_arm64::getFloatRegister(int regNum) const { assert(validFloatRegister(regNum)); - return _vectorHalfRegisters[regNum - UNW_AARCH64_V0]; + return _vectorHalfRegisters[regNum - UNW_AARCH64_V0]; } inline void Registers_arm64::setFloatRegister(int regNum, double value) { assert(validFloatRegister(regNum)); - _vectorHalfRegisters[regNum - UNW_AARCH64_V0] = value; + _vectorHalfRegisters[regNum - UNW_AARCH64_V0] = value; } inline bool Registers_arm64::validVectorRegister(int) const { @@ -2141,10 +2141,10 @@ private: uint32_t __pc; // Program counter r15 }; - struct PseudoRegisters { - uint32_t __pac; // Return Authentication Code (PAC) - }; - + struct PseudoRegisters { + uint32_t __pac; // Return Authentication Code (PAC) + }; + static void saveVFPWithFSTMD(void*); static void saveVFPWithFSTMX(void*); static void saveVFPv3(void*); @@ -2161,7 +2161,7 @@ private: // ARM registers GPRs _registers; - PseudoRegisters _pseudo_registers; + PseudoRegisters _pseudo_registers; // We save floating point registers lazily because we can't know ahead of // time which ones are used. See EHABI #4.7. @@ -2199,7 +2199,7 @@ inline Registers_arm::Registers_arm(const void *registers) "arm registers do not fit into unw_context_t"); // See __unw_getcontext() note about data. memcpy(&_registers, registers, sizeof(_registers)); - memset(&_pseudo_registers, 0, sizeof(_pseudo_registers)); + memset(&_pseudo_registers, 0, sizeof(_pseudo_registers)); memset(&_vfp_d0_d15_pad, 0, sizeof(_vfp_d0_d15_pad)); memset(&_vfp_d16_d31, 0, sizeof(_vfp_d16_d31)); #if defined(__ARM_WMMX) @@ -2215,7 +2215,7 @@ inline Registers_arm::Registers_arm() _saved_vfp_d0_d15(false), _saved_vfp_d16_d31(false) { memset(&_registers, 0, sizeof(_registers)); - memset(&_pseudo_registers, 0, sizeof(_pseudo_registers)); + memset(&_pseudo_registers, 0, sizeof(_pseudo_registers)); memset(&_vfp_d0_d15_pad, 0, sizeof(_vfp_d0_d15_pad)); memset(&_vfp_d16_d31, 0, sizeof(_vfp_d16_d31)); #if defined(__ARM_WMMX) @@ -2243,11 +2243,11 @@ inline bool Registers_arm::validRegister(int regNum) const { return true; #endif -#ifdef __ARM_FEATURE_PAUTH - if (regNum == UNW_ARM_RA_AUTH_CODE) - return true; -#endif - +#ifdef __ARM_FEATURE_PAUTH + if (regNum == UNW_ARM_RA_AUTH_CODE) + return true; +#endif + return false; } @@ -2274,11 +2274,11 @@ inline uint32_t Registers_arm::getRegister(int regNum) const { } #endif -#ifdef __ARM_FEATURE_PAUTH - if (regNum == UNW_ARM_RA_AUTH_CODE) - return _pseudo_registers.__pac; -#endif - +#ifdef __ARM_FEATURE_PAUTH + if (regNum == UNW_ARM_RA_AUTH_CODE) + return _pseudo_registers.__pac; +#endif + _LIBUNWIND_ABORT("unsupported arm register"); } @@ -2314,11 +2314,11 @@ inline void Registers_arm::setRegister(int regNum, uint32_t value) { } #endif - if (regNum == UNW_ARM_RA_AUTH_CODE) { - _pseudo_registers.__pac = value; - return; - } - + if (regNum == UNW_ARM_RA_AUTH_CODE) { + _pseudo_registers.__pac = value; + return; + } + _LIBUNWIND_ABORT("unsupported arm register"); } @@ -3587,191 +3587,191 @@ inline const char *Registers_sparc::getRegisterName(int regNum) { } #endif // _LIBUNWIND_TARGET_SPARC -#if defined(_LIBUNWIND_TARGET_SPARC64) -/// Registers_sparc64 holds the register state of a thread in a 64-bit -/// sparc process. -class _LIBUNWIND_HIDDEN Registers_sparc64 { -public: - Registers_sparc64() = default; - Registers_sparc64(const void *registers); - - bool validRegister(int num) const; - uint64_t getRegister(int num) const; - void setRegister(int num, uint64_t value); - bool validFloatRegister(int num) const; - double getFloatRegister(int num) const; - void setFloatRegister(int num, double value); - bool validVectorRegister(int num) const; - v128 getVectorRegister(int num) const; - void setVectorRegister(int num, v128 value); - const char *getRegisterName(int num); - void jumpto(); - static int lastDwarfRegNum() { - return _LIBUNWIND_HIGHEST_DWARF_REGISTER_SPARC64; - } - static int getArch() { return REGISTERS_SPARC64; } - - uint64_t getSP() const { return _registers.__regs[UNW_SPARC_O6] + 2047; } - void setSP(uint64_t value) { _registers.__regs[UNW_SPARC_O6] = value - 2047; } - uint64_t getIP() const { return _registers.__regs[UNW_SPARC_O7]; } - void setIP(uint64_t value) { _registers.__regs[UNW_SPARC_O7] = value; } - uint64_t getWCookie() const { return _wcookie; } - -private: - struct sparc64_thread_state_t { - uint64_t __regs[32]; - }; - - sparc64_thread_state_t _registers{}; - uint64_t _wcookie = 0; -}; - -inline Registers_sparc64::Registers_sparc64(const void *registers) { - static_assert((check_fit<Registers_sparc64, unw_context_t>::does_fit), - "sparc64 registers do not fit into unw_context_t"); - memcpy(&_registers, registers, sizeof(_registers)); - memcpy(&_wcookie, - static_cast<const uint8_t *>(registers) + sizeof(_registers), - sizeof(_wcookie)); -} - -inline bool Registers_sparc64::validRegister(int regNum) const { - if (regNum == UNW_REG_IP) - return true; - if (regNum == UNW_REG_SP) - return true; - if (regNum < 0) - return false; - if (regNum <= UNW_SPARC_I7) - return true; - return false; -} - -inline uint64_t Registers_sparc64::getRegister(int regNum) const { - if (regNum >= UNW_SPARC_G0 && regNum <= UNW_SPARC_I7) - return _registers.__regs[regNum]; - - switch (regNum) { - case UNW_REG_IP: - return _registers.__regs[UNW_SPARC_O7]; - case UNW_REG_SP: - return _registers.__regs[UNW_SPARC_O6] + 2047; - } - _LIBUNWIND_ABORT("unsupported sparc64 register"); -} - -inline void Registers_sparc64::setRegister(int regNum, uint64_t value) { - if (regNum >= UNW_SPARC_G0 && regNum <= UNW_SPARC_I7) { - _registers.__regs[regNum] = value; - return; - } - - switch (regNum) { - case UNW_REG_IP: - _registers.__regs[UNW_SPARC_O7] = value; - return; - case UNW_REG_SP: - _registers.__regs[UNW_SPARC_O6] = value - 2047; - return; - } - _LIBUNWIND_ABORT("unsupported sparc64 register"); -} - -inline bool Registers_sparc64::validFloatRegister(int) const { return false; } - -inline double Registers_sparc64::getFloatRegister(int) const { - _LIBUNWIND_ABORT("no sparc64 float registers"); -} - -inline void Registers_sparc64::setFloatRegister(int, double) { - _LIBUNWIND_ABORT("no sparc64 float registers"); -} - -inline bool Registers_sparc64::validVectorRegister(int) const { return false; } - -inline v128 Registers_sparc64::getVectorRegister(int) const { - _LIBUNWIND_ABORT("no sparc64 vector registers"); -} - -inline void Registers_sparc64::setVectorRegister(int, v128) { - _LIBUNWIND_ABORT("no sparc64 vector registers"); -} - -inline const char *Registers_sparc64::getRegisterName(int regNum) { - switch (regNum) { - case UNW_REG_IP: - return "pc"; - case UNW_SPARC_G0: - return "g0"; - case UNW_SPARC_G1: - return "g1"; - case UNW_SPARC_G2: - return "g2"; - case UNW_SPARC_G3: - return "g3"; - case UNW_SPARC_G4: - return "g4"; - case UNW_SPARC_G5: - return "g5"; - case UNW_SPARC_G6: - return "g6"; - case UNW_SPARC_G7: - return "g7"; - case UNW_SPARC_O0: - return "o0"; - case UNW_SPARC_O1: - return "o1"; - case UNW_SPARC_O2: - return "o2"; - case UNW_SPARC_O3: - return "o3"; - case UNW_SPARC_O4: - return "o4"; - case UNW_SPARC_O5: - return "o5"; - case UNW_REG_SP: - case UNW_SPARC_O6: - return "o6"; - case UNW_SPARC_O7: - return "o7"; - case UNW_SPARC_L0: - return "l0"; - case UNW_SPARC_L1: - return "l1"; - case UNW_SPARC_L2: - return "l2"; - case UNW_SPARC_L3: - return "l3"; - case UNW_SPARC_L4: - return "l4"; - case UNW_SPARC_L5: - return "l5"; - case UNW_SPARC_L6: - return "l6"; - case UNW_SPARC_L7: - return "l7"; - case UNW_SPARC_I0: - return "i0"; - case UNW_SPARC_I1: - return "i1"; - case UNW_SPARC_I2: - return "i2"; - case UNW_SPARC_I3: - return "i3"; - case UNW_SPARC_I4: - return "i4"; - case UNW_SPARC_I5: - return "i5"; - case UNW_SPARC_I6: - return "i6"; - case UNW_SPARC_I7: - return "i7"; - default: - return "unknown register"; - } -} -#endif // _LIBUNWIND_TARGET_SPARC64 - +#if defined(_LIBUNWIND_TARGET_SPARC64) +/// Registers_sparc64 holds the register state of a thread in a 64-bit +/// sparc process. +class _LIBUNWIND_HIDDEN Registers_sparc64 { +public: + Registers_sparc64() = default; + Registers_sparc64(const void *registers); + + bool validRegister(int num) const; + uint64_t getRegister(int num) const; + void setRegister(int num, uint64_t value); + bool validFloatRegister(int num) const; + double getFloatRegister(int num) const; + void setFloatRegister(int num, double value); + bool validVectorRegister(int num) const; + v128 getVectorRegister(int num) const; + void setVectorRegister(int num, v128 value); + const char *getRegisterName(int num); + void jumpto(); + static int lastDwarfRegNum() { + return _LIBUNWIND_HIGHEST_DWARF_REGISTER_SPARC64; + } + static int getArch() { return REGISTERS_SPARC64; } + + uint64_t getSP() const { return _registers.__regs[UNW_SPARC_O6] + 2047; } + void setSP(uint64_t value) { _registers.__regs[UNW_SPARC_O6] = value - 2047; } + uint64_t getIP() const { return _registers.__regs[UNW_SPARC_O7]; } + void setIP(uint64_t value) { _registers.__regs[UNW_SPARC_O7] = value; } + uint64_t getWCookie() const { return _wcookie; } + +private: + struct sparc64_thread_state_t { + uint64_t __regs[32]; + }; + + sparc64_thread_state_t _registers{}; + uint64_t _wcookie = 0; +}; + +inline Registers_sparc64::Registers_sparc64(const void *registers) { + static_assert((check_fit<Registers_sparc64, unw_context_t>::does_fit), + "sparc64 registers do not fit into unw_context_t"); + memcpy(&_registers, registers, sizeof(_registers)); + memcpy(&_wcookie, + static_cast<const uint8_t *>(registers) + sizeof(_registers), + sizeof(_wcookie)); +} + +inline bool Registers_sparc64::validRegister(int regNum) const { + if (regNum == UNW_REG_IP) + return true; + if (regNum == UNW_REG_SP) + return true; + if (regNum < 0) + return false; + if (regNum <= UNW_SPARC_I7) + return true; + return false; +} + +inline uint64_t Registers_sparc64::getRegister(int regNum) const { + if (regNum >= UNW_SPARC_G0 && regNum <= UNW_SPARC_I7) + return _registers.__regs[regNum]; + + switch (regNum) { + case UNW_REG_IP: + return _registers.__regs[UNW_SPARC_O7]; + case UNW_REG_SP: + return _registers.__regs[UNW_SPARC_O6] + 2047; + } + _LIBUNWIND_ABORT("unsupported sparc64 register"); +} + +inline void Registers_sparc64::setRegister(int regNum, uint64_t value) { + if (regNum >= UNW_SPARC_G0 && regNum <= UNW_SPARC_I7) { + _registers.__regs[regNum] = value; + return; + } + + switch (regNum) { + case UNW_REG_IP: + _registers.__regs[UNW_SPARC_O7] = value; + return; + case UNW_REG_SP: + _registers.__regs[UNW_SPARC_O6] = value - 2047; + return; + } + _LIBUNWIND_ABORT("unsupported sparc64 register"); +} + +inline bool Registers_sparc64::validFloatRegister(int) const { return false; } + +inline double Registers_sparc64::getFloatRegister(int) const { + _LIBUNWIND_ABORT("no sparc64 float registers"); +} + +inline void Registers_sparc64::setFloatRegister(int, double) { + _LIBUNWIND_ABORT("no sparc64 float registers"); +} + +inline bool Registers_sparc64::validVectorRegister(int) const { return false; } + +inline v128 Registers_sparc64::getVectorRegister(int) const { + _LIBUNWIND_ABORT("no sparc64 vector registers"); +} + +inline void Registers_sparc64::setVectorRegister(int, v128) { + _LIBUNWIND_ABORT("no sparc64 vector registers"); +} + +inline const char *Registers_sparc64::getRegisterName(int regNum) { + switch (regNum) { + case UNW_REG_IP: + return "pc"; + case UNW_SPARC_G0: + return "g0"; + case UNW_SPARC_G1: + return "g1"; + case UNW_SPARC_G2: + return "g2"; + case UNW_SPARC_G3: + return "g3"; + case UNW_SPARC_G4: + return "g4"; + case UNW_SPARC_G5: + return "g5"; + case UNW_SPARC_G6: + return "g6"; + case UNW_SPARC_G7: + return "g7"; + case UNW_SPARC_O0: + return "o0"; + case UNW_SPARC_O1: + return "o1"; + case UNW_SPARC_O2: + return "o2"; + case UNW_SPARC_O3: + return "o3"; + case UNW_SPARC_O4: + return "o4"; + case UNW_SPARC_O5: + return "o5"; + case UNW_REG_SP: + case UNW_SPARC_O6: + return "o6"; + case UNW_SPARC_O7: + return "o7"; + case UNW_SPARC_L0: + return "l0"; + case UNW_SPARC_L1: + return "l1"; + case UNW_SPARC_L2: + return "l2"; + case UNW_SPARC_L3: + return "l3"; + case UNW_SPARC_L4: + return "l4"; + case UNW_SPARC_L5: + return "l5"; + case UNW_SPARC_L6: + return "l6"; + case UNW_SPARC_L7: + return "l7"; + case UNW_SPARC_I0: + return "i0"; + case UNW_SPARC_I1: + return "i1"; + case UNW_SPARC_I2: + return "i2"; + case UNW_SPARC_I3: + return "i3"; + case UNW_SPARC_I4: + return "i4"; + case UNW_SPARC_I5: + return "i5"; + case UNW_SPARC_I6: + return "i6"; + case UNW_SPARC_I7: + return "i7"; + default: + return "unknown register"; + } +} +#endif // _LIBUNWIND_TARGET_SPARC64 + #if defined(_LIBUNWIND_TARGET_HEXAGON) /// Registers_hexagon holds the register state of a thread in a Hexagon QDSP6 /// process. diff --git a/contrib/libs/libunwind/src/Unwind-EHABI.cpp b/contrib/libs/libunwind/src/Unwind-EHABI.cpp index 21c8b2777b..7787d1ed34 100644 --- a/contrib/libs/libunwind/src/Unwind-EHABI.cpp +++ b/contrib/libs/libunwind/src/Unwind-EHABI.cpp @@ -1,4 +1,4 @@ -//===----------------------------------------------------------------------===// +//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -97,11 +97,11 @@ _Unwind_Reason_Code ProcessDescriptors( case Descriptor::LU32: descriptor = getNextWord(descriptor, &length); descriptor = getNextWord(descriptor, &offset); - break; + break; case Descriptor::LU16: descriptor = getNextNibble(descriptor, &length); descriptor = getNextNibble(descriptor, &offset); - break; + break; default: assert(false); return _URC_FAILURE; @@ -187,14 +187,14 @@ static _Unwind_Reason_Code unwindOneFrame(_Unwind_State state, if (result != _URC_CONTINUE_UNWIND) return result; - switch (__unw_step(reinterpret_cast<unw_cursor_t *>(context))) { - case UNW_STEP_SUCCESS: - return _URC_CONTINUE_UNWIND; - case UNW_STEP_END: - return _URC_END_OF_STACK; - default: + switch (__unw_step(reinterpret_cast<unw_cursor_t *>(context))) { + case UNW_STEP_SUCCESS: + return _URC_CONTINUE_UNWIND; + case UNW_STEP_END: + return _URC_END_OF_STACK; + default: return _URC_FAILURE; - } + } } // Generates mask discriminator for _Unwind_VRS_Pop, e.g. for _UVRSC_CORE / @@ -261,7 +261,7 @@ _Unwind_VRS_Interpret(_Unwind_Context *context, const uint32_t *data, size_t offset, size_t len) { bool wrotePC = false; bool finish = false; - bool hasReturnAddrAuthCode = false; + bool hasReturnAddrAuthCode = false; while (offset < len && !finish) { uint8_t byte = getByte(data, offset++); if ((byte & 0x80) == 0) { @@ -348,10 +348,10 @@ _Unwind_VRS_Interpret(_Unwind_Context *context, const uint32_t *data, break; } case 0xb4: - hasReturnAddrAuthCode = true; - _Unwind_VRS_Pop(context, _UVRSC_PSEUDO, - 0 /* Return Address Auth Code */, _UVRSD_UINT32); - break; + hasReturnAddrAuthCode = true; + _Unwind_VRS_Pop(context, _UVRSC_PSEUDO, + 0 /* Return Address Auth Code */, _UVRSD_UINT32); + break; case 0xb5: case 0xb6: case 0xb7: @@ -427,16 +427,16 @@ _Unwind_VRS_Interpret(_Unwind_Context *context, const uint32_t *data, if (!wrotePC) { uint32_t lr; _Unwind_VRS_Get(context, _UVRSC_CORE, UNW_ARM_LR, _UVRSD_UINT32, &lr); -#ifdef __ARM_FEATURE_PAUTH - if (hasReturnAddrAuthCode) { - uint32_t sp; - uint32_t pac; - _Unwind_VRS_Get(context, _UVRSC_CORE, UNW_ARM_SP, _UVRSD_UINT32, &sp); - _Unwind_VRS_Get(context, _UVRSC_PSEUDO, UNW_ARM_RA_AUTH_CODE, - _UVRSD_UINT32, &pac); - __asm__ __volatile__("autg %0, %1, %2" : : "r"(pac), "r"(lr), "r"(sp) :); - } -#endif +#ifdef __ARM_FEATURE_PAUTH + if (hasReturnAddrAuthCode) { + uint32_t sp; + uint32_t pac; + _Unwind_VRS_Get(context, _UVRSC_CORE, UNW_ARM_SP, _UVRSD_UINT32, &sp); + _Unwind_VRS_Get(context, _UVRSC_PSEUDO, UNW_ARM_RA_AUTH_CODE, + _UVRSD_UINT32, &pac); + __asm__ __volatile__("autg %0, %1, %2" : : "r"(pac), "r"(lr), "r"(sp) :); + } +#endif _Unwind_VRS_Set(context, _UVRSC_CORE, UNW_ARM_IP, _UVRSD_UINT32, &lr); } return _URC_CONTINUE_UNWIND; @@ -483,7 +483,7 @@ unwind_phase1(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *except return _URC_FATAL_PHASE1_ERROR; } -#ifndef NDEBUG +#ifndef NDEBUG // When tracing, print state information. if (_LIBUNWIND_TRACING_UNWINDING) { char functionBuf[512]; @@ -502,7 +502,7 @@ unwind_phase1(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *except frameInfo.start_ip, functionName, frameInfo.lsda, frameInfo.handler); } -#endif +#endif // If there is a personality routine, ask it if it will want to stop at // this frame. @@ -604,7 +604,7 @@ static _Unwind_Reason_Code unwind_phase2(unw_context_t *uc, unw_cursor_t *cursor return _URC_FATAL_PHASE2_ERROR; } -#ifndef NDEBUG +#ifndef NDEBUG // When tracing, print state information. if (_LIBUNWIND_TRACING_UNWINDING) { char functionBuf[512]; @@ -621,12 +621,12 @@ static _Unwind_Reason_Code unwind_phase2(unw_context_t *uc, unw_cursor_t *cursor functionName, sp, frameInfo.lsda, frameInfo.handler); } -#endif +#endif // If there is a personality routine, tell it we are unwinding. if (frameInfo.handler != 0) { _Unwind_Personality_Fn p = - (_Unwind_Personality_Fn)(intptr_t)(frameInfo.handler); + (_Unwind_Personality_Fn)(intptr_t)(frameInfo.handler); struct _Unwind_Context *context = (struct _Unwind_Context *)(cursor); // EHABI #7.2 exception_object->pr_cache.fnstart = frameInfo.start_ip; @@ -694,123 +694,123 @@ static _Unwind_Reason_Code unwind_phase2(unw_context_t *uc, unw_cursor_t *cursor return _URC_FATAL_PHASE2_ERROR; } -static _Unwind_Reason_Code -unwind_phase2_forced(unw_context_t *uc, unw_cursor_t *cursor, - _Unwind_Exception *exception_object, _Unwind_Stop_Fn stop, - void *stop_parameter) { - bool endOfStack = false; - // See comment at the start of unwind_phase1 regarding VRS integrity. - __unw_init_local(cursor, uc); - _LIBUNWIND_TRACE_UNWINDING("unwind_phase2_force(ex_ojb=%p)", - static_cast<void *>(exception_object)); - // Walk each frame until we reach where search phase said to stop - while (!endOfStack) { - // Update info about this frame. - unw_proc_info_t frameInfo; - if (__unw_get_proc_info(cursor, &frameInfo) != UNW_ESUCCESS) { - _LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): __unw_step " - "failed => _URC_END_OF_STACK", - (void *)exception_object); - return _URC_FATAL_PHASE2_ERROR; - } - -#ifndef NDEBUG - // When tracing, print state information. - if (_LIBUNWIND_TRACING_UNWINDING) { - char functionBuf[512]; - const char *functionName = functionBuf; - unw_word_t offset; - if ((__unw_get_proc_name(cursor, functionBuf, sizeof(functionBuf), - &offset) != UNW_ESUCCESS) || - (frameInfo.start_ip + offset > frameInfo.end_ip)) - functionName = ".anonymous."; - _LIBUNWIND_TRACE_UNWINDING( - "unwind_phase2_forced(ex_ojb=%p): start_ip=0x%" PRIxPTR - ", func=%s, lsda=0x%" PRIxPTR ", personality=0x%" PRIxPTR, - (void *)exception_object, frameInfo.start_ip, functionName, - frameInfo.lsda, frameInfo.handler); - } -#endif - - // Call stop function at each frame. - _Unwind_Action action = - (_Unwind_Action)(_UA_FORCE_UNWIND | _UA_CLEANUP_PHASE); - _Unwind_Reason_Code stopResult = - (*stop)(1, action, exception_object->exception_class, exception_object, - (_Unwind_Context *)(cursor), stop_parameter); - _LIBUNWIND_TRACE_UNWINDING( - "unwind_phase2_forced(ex_ojb=%p): stop function returned %d", - (void *)exception_object, stopResult); - if (stopResult != _URC_NO_REASON) { - _LIBUNWIND_TRACE_UNWINDING( - "unwind_phase2_forced(ex_ojb=%p): stopped by stop function", - (void *)exception_object); - return _URC_FATAL_PHASE2_ERROR; - } - - // If there is a personality routine, tell it we are unwinding. - if (frameInfo.handler != 0) { - _Unwind_Personality_Fn p = - (_Unwind_Personality_Fn)(uintptr_t)(frameInfo.handler); - struct _Unwind_Context *context = (struct _Unwind_Context *)(cursor); - // EHABI #7.2 - exception_object->pr_cache.fnstart = frameInfo.start_ip; - exception_object->pr_cache.ehtp = - (_Unwind_EHT_Header *)frameInfo.unwind_info; - exception_object->pr_cache.additional = frameInfo.flags; - _Unwind_Reason_Code personalityResult = - (*p)(_US_FORCE_UNWIND | _US_UNWIND_FRAME_STARTING, exception_object, - context); - switch (personalityResult) { - case _URC_CONTINUE_UNWIND: - _LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): " - "personality returned " - "_URC_CONTINUE_UNWIND", - (void *)exception_object); - // Destructors called, continue unwinding - break; - case _URC_INSTALL_CONTEXT: - _LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): " - "personality returned " - "_URC_INSTALL_CONTEXT", - (void *)exception_object); - // We may get control back if landing pad calls _Unwind_Resume(). - __unw_resume(cursor); - break; - case _URC_END_OF_STACK: - _LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): " - "personality returned " - "_URC_END_OF_STACK", - (void *)exception_object); - // Personalty routine did the step and it can't step forward. - endOfStack = true; - break; - default: - // Personality routine returned an unknown result code. - _LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): " - "personality returned %d, " - "_URC_FATAL_PHASE2_ERROR", - (void *)exception_object, personalityResult); - return _URC_FATAL_PHASE2_ERROR; - } - } - } - - // Call stop function one last time and tell it we've reached the end - // of the stack. - _LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): calling stop " - "function with _UA_END_OF_STACK", - (void *)exception_object); - _Unwind_Action lastAction = - (_Unwind_Action)(_UA_FORCE_UNWIND | _UA_CLEANUP_PHASE | _UA_END_OF_STACK); - (*stop)(1, lastAction, exception_object->exception_class, exception_object, - (struct _Unwind_Context *)(cursor), stop_parameter); - - // Clean up phase did not resume at the frame that the search phase said it - // would. - return _URC_FATAL_PHASE2_ERROR; -} - +static _Unwind_Reason_Code +unwind_phase2_forced(unw_context_t *uc, unw_cursor_t *cursor, + _Unwind_Exception *exception_object, _Unwind_Stop_Fn stop, + void *stop_parameter) { + bool endOfStack = false; + // See comment at the start of unwind_phase1 regarding VRS integrity. + __unw_init_local(cursor, uc); + _LIBUNWIND_TRACE_UNWINDING("unwind_phase2_force(ex_ojb=%p)", + static_cast<void *>(exception_object)); + // Walk each frame until we reach where search phase said to stop + while (!endOfStack) { + // Update info about this frame. + unw_proc_info_t frameInfo; + if (__unw_get_proc_info(cursor, &frameInfo) != UNW_ESUCCESS) { + _LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): __unw_step " + "failed => _URC_END_OF_STACK", + (void *)exception_object); + return _URC_FATAL_PHASE2_ERROR; + } + +#ifndef NDEBUG + // When tracing, print state information. + if (_LIBUNWIND_TRACING_UNWINDING) { + char functionBuf[512]; + const char *functionName = functionBuf; + unw_word_t offset; + if ((__unw_get_proc_name(cursor, functionBuf, sizeof(functionBuf), + &offset) != UNW_ESUCCESS) || + (frameInfo.start_ip + offset > frameInfo.end_ip)) + functionName = ".anonymous."; + _LIBUNWIND_TRACE_UNWINDING( + "unwind_phase2_forced(ex_ojb=%p): start_ip=0x%" PRIxPTR + ", func=%s, lsda=0x%" PRIxPTR ", personality=0x%" PRIxPTR, + (void *)exception_object, frameInfo.start_ip, functionName, + frameInfo.lsda, frameInfo.handler); + } +#endif + + // Call stop function at each frame. + _Unwind_Action action = + (_Unwind_Action)(_UA_FORCE_UNWIND | _UA_CLEANUP_PHASE); + _Unwind_Reason_Code stopResult = + (*stop)(1, action, exception_object->exception_class, exception_object, + (_Unwind_Context *)(cursor), stop_parameter); + _LIBUNWIND_TRACE_UNWINDING( + "unwind_phase2_forced(ex_ojb=%p): stop function returned %d", + (void *)exception_object, stopResult); + if (stopResult != _URC_NO_REASON) { + _LIBUNWIND_TRACE_UNWINDING( + "unwind_phase2_forced(ex_ojb=%p): stopped by stop function", + (void *)exception_object); + return _URC_FATAL_PHASE2_ERROR; + } + + // If there is a personality routine, tell it we are unwinding. + if (frameInfo.handler != 0) { + _Unwind_Personality_Fn p = + (_Unwind_Personality_Fn)(uintptr_t)(frameInfo.handler); + struct _Unwind_Context *context = (struct _Unwind_Context *)(cursor); + // EHABI #7.2 + exception_object->pr_cache.fnstart = frameInfo.start_ip; + exception_object->pr_cache.ehtp = + (_Unwind_EHT_Header *)frameInfo.unwind_info; + exception_object->pr_cache.additional = frameInfo.flags; + _Unwind_Reason_Code personalityResult = + (*p)(_US_FORCE_UNWIND | _US_UNWIND_FRAME_STARTING, exception_object, + context); + switch (personalityResult) { + case _URC_CONTINUE_UNWIND: + _LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): " + "personality returned " + "_URC_CONTINUE_UNWIND", + (void *)exception_object); + // Destructors called, continue unwinding + break; + case _URC_INSTALL_CONTEXT: + _LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): " + "personality returned " + "_URC_INSTALL_CONTEXT", + (void *)exception_object); + // We may get control back if landing pad calls _Unwind_Resume(). + __unw_resume(cursor); + break; + case _URC_END_OF_STACK: + _LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): " + "personality returned " + "_URC_END_OF_STACK", + (void *)exception_object); + // Personalty routine did the step and it can't step forward. + endOfStack = true; + break; + default: + // Personality routine returned an unknown result code. + _LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): " + "personality returned %d, " + "_URC_FATAL_PHASE2_ERROR", + (void *)exception_object, personalityResult); + return _URC_FATAL_PHASE2_ERROR; + } + } + } + + // Call stop function one last time and tell it we've reached the end + // of the stack. + _LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): calling stop " + "function with _UA_END_OF_STACK", + (void *)exception_object); + _Unwind_Action lastAction = + (_Unwind_Action)(_UA_FORCE_UNWIND | _UA_CLEANUP_PHASE | _UA_END_OF_STACK); + (*stop)(1, lastAction, exception_object->exception_class, exception_object, + (struct _Unwind_Context *)(cursor), stop_parameter); + + // Clean up phase did not resume at the frame that the search phase said it + // would. + return _URC_FATAL_PHASE2_ERROR; +} + /// Called by __cxa_throw. Only returns if there is a fatal error. _LIBUNWIND_EXPORT _Unwind_Reason_Code _Unwind_RaiseException(_Unwind_Exception *exception_object) { @@ -858,13 +858,13 @@ _Unwind_Resume(_Unwind_Exception *exception_object) { unw_cursor_t cursor; __unw_getcontext(&uc); - if (exception_object->unwinder_cache.reserved1) - unwind_phase2_forced( - &uc, &cursor, exception_object, - (_Unwind_Stop_Fn)exception_object->unwinder_cache.reserved1, - (void *)exception_object->unwinder_cache.reserved3); - else - unwind_phase2(&uc, &cursor, exception_object, true); + if (exception_object->unwinder_cache.reserved1) + unwind_phase2_forced( + &uc, &cursor, exception_object, + (_Unwind_Stop_Fn)exception_object->unwinder_cache.reserved1, + (void *)exception_object->unwinder_cache.reserved3); + else + unwind_phase2(&uc, &cursor, exception_object, true); // Clients assume _Unwind_Resume() does not return, so all we can do is abort. _LIBUNWIND_ABORT("_Unwind_Resume() can't return"); @@ -956,15 +956,15 @@ _Unwind_VRS_Set(_Unwind_Context *context, _Unwind_VRS_RegClass regclass, case _UVRSC_WMMXD: break; #endif - case _UVRSC_PSEUDO: - // There's only one pseudo-register, PAC, with regno == 0. - if (representation != _UVRSD_UINT32 || regno != 0) - return _UVRSR_FAILED; - return __unw_set_reg(cursor, (unw_regnum_t)(UNW_ARM_RA_AUTH_CODE), - *(unw_word_t *)valuep) == UNW_ESUCCESS - ? _UVRSR_OK - : _UVRSR_FAILED; - break; + case _UVRSC_PSEUDO: + // There's only one pseudo-register, PAC, with regno == 0. + if (representation != _UVRSD_UINT32 || regno != 0) + return _UVRSR_FAILED; + return __unw_set_reg(cursor, (unw_regnum_t)(UNW_ARM_RA_AUTH_CODE), + *(unw_word_t *)valuep) == UNW_ESUCCESS + ? _UVRSR_OK + : _UVRSR_FAILED; + break; } _LIBUNWIND_ABORT("unsupported register class"); } @@ -1019,15 +1019,15 @@ _Unwind_VRS_Get_Internal(_Unwind_Context *context, case _UVRSC_WMMXD: break; #endif - case _UVRSC_PSEUDO: - // There's only one pseudo-register, PAC, with regno == 0. - if (representation != _UVRSD_UINT32 || regno != 0) - return _UVRSR_FAILED; - return __unw_get_reg(cursor, (unw_regnum_t)(UNW_ARM_RA_AUTH_CODE), - (unw_word_t *)valuep) == UNW_ESUCCESS - ? _UVRSR_OK - : _UVRSR_FAILED; - break; + case _UVRSC_PSEUDO: + // There's only one pseudo-register, PAC, with regno == 0. + if (representation != _UVRSD_UINT32 || regno != 0) + return _UVRSR_FAILED; + return __unw_get_reg(cursor, (unw_regnum_t)(UNW_ARM_RA_AUTH_CODE), + (unw_word_t *)valuep) == UNW_ESUCCESS + ? _UVRSR_OK + : _UVRSR_FAILED; + break; } _LIBUNWIND_ABORT("unsupported register class"); } @@ -1125,45 +1125,45 @@ _Unwind_VRS_Pop(_Unwind_Context *context, _Unwind_VRS_RegClass regclass, return _Unwind_VRS_Set(context, _UVRSC_CORE, UNW_ARM_SP, _UVRSD_UINT32, &sp); } - case _UVRSC_PSEUDO: { - if (representation != _UVRSD_UINT32 || discriminator != 0) - return _UVRSR_FAILED; - // Return Address Authentication code (PAC) - discriminator 0 - uint32_t *sp; - if (_Unwind_VRS_Get(context, _UVRSC_CORE, UNW_ARM_SP, _UVRSD_UINT32, - &sp) != _UVRSR_OK) { - return _UVRSR_FAILED; - } - uint32_t pac = *sp++; - _Unwind_VRS_Set(context, _UVRSC_CORE, UNW_ARM_SP, _UVRSD_UINT32, &sp); - return _Unwind_VRS_Set(context, _UVRSC_CORE, UNW_ARM_RA_AUTH_CODE, - _UVRSD_UINT32, &pac); - } + case _UVRSC_PSEUDO: { + if (representation != _UVRSD_UINT32 || discriminator != 0) + return _UVRSR_FAILED; + // Return Address Authentication code (PAC) - discriminator 0 + uint32_t *sp; + if (_Unwind_VRS_Get(context, _UVRSC_CORE, UNW_ARM_SP, _UVRSD_UINT32, + &sp) != _UVRSR_OK) { + return _UVRSR_FAILED; + } + uint32_t pac = *sp++; + _Unwind_VRS_Set(context, _UVRSC_CORE, UNW_ARM_SP, _UVRSD_UINT32, &sp); + return _Unwind_VRS_Set(context, _UVRSC_CORE, UNW_ARM_RA_AUTH_CODE, + _UVRSD_UINT32, &pac); + } } _LIBUNWIND_ABORT("unsupported register class"); } -/// Not used by C++. -/// Unwinds stack, calling "stop" function at each frame. -/// Could be used to implement longjmp(). -_LIBUNWIND_EXPORT _Unwind_Reason_Code -_Unwind_ForcedUnwind(_Unwind_Exception *exception_object, _Unwind_Stop_Fn stop, - void *stop_parameter) { - _LIBUNWIND_TRACE_API("_Unwind_ForcedUnwind(ex_obj=%p, stop=%p)", - (void *)exception_object, (void *)(uintptr_t)stop); - unw_context_t uc; - unw_cursor_t cursor; - __unw_getcontext(&uc); - - // Mark that this is a forced unwind, so _Unwind_Resume() can do - // the right thing. - exception_object->unwinder_cache.reserved1 = (uintptr_t)stop; - exception_object->unwinder_cache.reserved3 = (uintptr_t)stop_parameter; - - return unwind_phase2_forced(&uc, &cursor, exception_object, stop, - stop_parameter); -} - +/// Not used by C++. +/// Unwinds stack, calling "stop" function at each frame. +/// Could be used to implement longjmp(). +_LIBUNWIND_EXPORT _Unwind_Reason_Code +_Unwind_ForcedUnwind(_Unwind_Exception *exception_object, _Unwind_Stop_Fn stop, + void *stop_parameter) { + _LIBUNWIND_TRACE_API("_Unwind_ForcedUnwind(ex_obj=%p, stop=%p)", + (void *)exception_object, (void *)(uintptr_t)stop); + unw_context_t uc; + unw_cursor_t cursor; + __unw_getcontext(&uc); + + // Mark that this is a forced unwind, so _Unwind_Resume() can do + // the right thing. + exception_object->unwinder_cache.reserved1 = (uintptr_t)stop; + exception_object->unwinder_cache.reserved3 = (uintptr_t)stop_parameter; + + return unwind_phase2_forced(&uc, &cursor, exception_object, stop, + stop_parameter); +} + /// Called by personality handler during phase 2 to find the start of the /// function. _LIBUNWIND_EXPORT uintptr_t @@ -1191,17 +1191,17 @@ _Unwind_DeleteException(_Unwind_Exception *exception_object) { } extern "C" _LIBUNWIND_EXPORT _Unwind_Reason_Code -__gnu_unwind_frame(_Unwind_Exception * /* exception_object */, +__gnu_unwind_frame(_Unwind_Exception * /* exception_object */, struct _Unwind_Context *context) { unw_cursor_t *cursor = (unw_cursor_t *)context; - switch (__unw_step(cursor)) { - case UNW_STEP_SUCCESS: - return _URC_OK; - case UNW_STEP_END: - return _URC_END_OF_STACK; - default: + switch (__unw_step(cursor)) { + case UNW_STEP_SUCCESS: + return _URC_OK; + case UNW_STEP_END: + return _URC_END_OF_STACK; + default: return _URC_FAILURE; - } + } } #endif // defined(_LIBUNWIND_ARM_EHABI) diff --git a/contrib/libs/libunwind/src/Unwind-EHABI.h b/contrib/libs/libunwind/src/Unwind-EHABI.h index ff3b5fc6fe..7b3aa95114 100644 --- a/contrib/libs/libunwind/src/Unwind-EHABI.h +++ b/contrib/libs/libunwind/src/Unwind-EHABI.h @@ -1,4 +1,4 @@ -//===----------------------------------------------------------------------===// +//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. diff --git a/contrib/libs/libunwind/src/Unwind-seh.cpp b/contrib/libs/libunwind/src/Unwind-seh.cpp index f00bc4721b..10a58e72f9 100644 --- a/contrib/libs/libunwind/src/Unwind-seh.cpp +++ b/contrib/libs/libunwind/src/Unwind-seh.cpp @@ -1,4 +1,4 @@ -//===----------------------------------------------------------------------===// +//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -169,8 +169,8 @@ _GCC_specific_handler(PEXCEPTION_RECORD ms_exc, PVOID frame, PCONTEXT ms_ctx, __unw_get_reg(&cursor, UNW_ARM_R1, &exc->private_[3]); #elif defined(__aarch64__) exc->private_[2] = disp->TargetPc; - __unw_get_reg(&cursor, UNW_AARCH64_X0, &retval); - __unw_get_reg(&cursor, UNW_AARCH64_X1, &exc->private_[3]); + __unw_get_reg(&cursor, UNW_AARCH64_X0, &retval); + __unw_get_reg(&cursor, UNW_AARCH64_X1, &exc->private_[3]); #endif __unw_get_reg(&cursor, UNW_REG_IP, &target); ms_exc->ExceptionCode = STATUS_GCC_UNWIND; @@ -244,7 +244,7 @@ unwind_phase2_forced(unw_context_t *uc, return _URC_FATAL_PHASE2_ERROR; } -#ifndef NDEBUG +#ifndef NDEBUG // When tracing, print state information. if (_LIBUNWIND_TRACING_UNWINDING) { char functionBuf[512]; @@ -260,7 +260,7 @@ unwind_phase2_forced(unw_context_t *uc, (void *)exception_object, frameInfo.start_ip, functionName, frameInfo.lsda, frameInfo.handler); } -#endif +#endif // Call stop function at each frame. _Unwind_Action action = diff --git a/contrib/libs/libunwind/src/Unwind-sjlj.c b/contrib/libs/libunwind/src/Unwind-sjlj.c index d487995bb7..df764a020e 100644 --- a/contrib/libs/libunwind/src/Unwind-sjlj.c +++ b/contrib/libs/libunwind/src/Unwind-sjlj.c @@ -1,4 +1,4 @@ -//===----------------------------------------------------------------------===// +//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. diff --git a/contrib/libs/libunwind/src/UnwindCursor.hpp b/contrib/libs/libunwind/src/UnwindCursor.hpp index 1ca842f33a..f45f07ad2b 100644 --- a/contrib/libs/libunwind/src/UnwindCursor.hpp +++ b/contrib/libs/libunwind/src/UnwindCursor.hpp @@ -1,4 +1,4 @@ -//===----------------------------------------------------------------------===// +//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -11,7 +11,7 @@ #ifndef __UNWINDCURSOR_HPP__ #define __UNWINDCURSOR_HPP__ -#include "cet_unwind.h" +#include "cet_unwind.h" #include <stdint.h> #include <stdio.h> #include <stdlib.h> @@ -450,12 +450,12 @@ public: #ifdef __arm__ virtual void saveVFPAsX() { _LIBUNWIND_ABORT("saveVFPAsX not implemented"); } #endif - -#if defined(_LIBUNWIND_USE_CET) - virtual void *get_registers() { - _LIBUNWIND_ABORT("get_registers not implemented"); - } -#endif + +#if defined(_LIBUNWIND_USE_CET) + virtual void *get_registers() { + _LIBUNWIND_ABORT("get_registers not implemented"); + } +#endif }; #if defined(_LIBUNWIND_SUPPORT_SEH_UNWIND) && defined(_WIN32) @@ -627,12 +627,12 @@ UnwindCursor<A, R>::UnwindCursor(unw_context_t *context, A &as) _msContext.D[i - UNW_ARM_D0] = d.w; } #elif defined(_LIBUNWIND_TARGET_AARCH64) - for (int i = UNW_AARCH64_X0; i <= UNW_ARM64_X30; ++i) - _msContext.X[i - UNW_AARCH64_X0] = r.getRegister(i); + for (int i = UNW_AARCH64_X0; i <= UNW_ARM64_X30; ++i) + _msContext.X[i - UNW_AARCH64_X0] = r.getRegister(i); _msContext.Sp = r.getRegister(UNW_REG_SP); _msContext.Pc = r.getRegister(UNW_REG_IP); - for (int i = UNW_AARCH64_V0; i <= UNW_ARM64_D31; ++i) - _msContext.V[i - UNW_AARCH64_V0].D[0] = r.getFloatRegister(i); + for (int i = UNW_AARCH64_V0; i <= UNW_ARM64_D31; ++i) + _msContext.V[i - UNW_AARCH64_V0].D[0] = r.getFloatRegister(i); #endif } @@ -655,11 +655,11 @@ bool UnwindCursor<A, R>::validReg(int regNum) { #if defined(_LIBUNWIND_TARGET_X86_64) if (regNum >= UNW_X86_64_RAX && regNum <= UNW_X86_64_R15) return true; #elif defined(_LIBUNWIND_TARGET_ARM) - if ((regNum >= UNW_ARM_R0 && regNum <= UNW_ARM_R15) || - regNum == UNW_ARM_RA_AUTH_CODE) - return true; + if ((regNum >= UNW_ARM_R0 && regNum <= UNW_ARM_R15) || + regNum == UNW_ARM_RA_AUTH_CODE) + return true; #elif defined(_LIBUNWIND_TARGET_AARCH64) - if (regNum >= UNW_AARCH64_X0 && regNum <= UNW_ARM64_X30) return true; + if (regNum >= UNW_AARCH64_X0 && regNum <= UNW_ARM64_X30) return true; #endif return false; } @@ -708,7 +708,7 @@ unw_word_t UnwindCursor<A, R>::getReg(int regNum) { #elif defined(_LIBUNWIND_TARGET_AARCH64) case UNW_REG_SP: return _msContext.Sp; case UNW_REG_IP: return _msContext.Pc; - default: return _msContext.X[regNum - UNW_AARCH64_X0]; + default: return _msContext.X[regNum - UNW_AARCH64_X0]; #endif } _LIBUNWIND_ABORT("unsupported register"); @@ -758,37 +758,37 @@ void UnwindCursor<A, R>::setReg(int regNum, unw_word_t value) { #elif defined(_LIBUNWIND_TARGET_AARCH64) case UNW_REG_SP: _msContext.Sp = value; break; case UNW_REG_IP: _msContext.Pc = value; break; - case UNW_AARCH64_X0: - case UNW_AARCH64_X1: - case UNW_AARCH64_X2: - case UNW_AARCH64_X3: - case UNW_AARCH64_X4: - case UNW_AARCH64_X5: - case UNW_AARCH64_X6: - case UNW_AARCH64_X7: - case UNW_AARCH64_X8: - case UNW_AARCH64_X9: - case UNW_AARCH64_X10: - case UNW_AARCH64_X11: - case UNW_AARCH64_X12: - case UNW_AARCH64_X13: - case UNW_AARCH64_X14: - case UNW_AARCH64_X15: - case UNW_AARCH64_X16: - case UNW_AARCH64_X17: - case UNW_AARCH64_X18: - case UNW_AARCH64_X19: - case UNW_AARCH64_X20: - case UNW_AARCH64_X21: - case UNW_AARCH64_X22: - case UNW_AARCH64_X23: - case UNW_AARCH64_X24: - case UNW_AARCH64_X25: - case UNW_AARCH64_X26: - case UNW_AARCH64_X27: - case UNW_AARCH64_X28: - case UNW_AARCH64_FP: - case UNW_AARCH64_LR: _msContext.X[regNum - UNW_ARM64_X0] = value; break; + case UNW_AARCH64_X0: + case UNW_AARCH64_X1: + case UNW_AARCH64_X2: + case UNW_AARCH64_X3: + case UNW_AARCH64_X4: + case UNW_AARCH64_X5: + case UNW_AARCH64_X6: + case UNW_AARCH64_X7: + case UNW_AARCH64_X8: + case UNW_AARCH64_X9: + case UNW_AARCH64_X10: + case UNW_AARCH64_X11: + case UNW_AARCH64_X12: + case UNW_AARCH64_X13: + case UNW_AARCH64_X14: + case UNW_AARCH64_X15: + case UNW_AARCH64_X16: + case UNW_AARCH64_X17: + case UNW_AARCH64_X18: + case UNW_AARCH64_X19: + case UNW_AARCH64_X20: + case UNW_AARCH64_X21: + case UNW_AARCH64_X22: + case UNW_AARCH64_X23: + case UNW_AARCH64_X24: + case UNW_AARCH64_X25: + case UNW_AARCH64_X26: + case UNW_AARCH64_X27: + case UNW_AARCH64_X28: + case UNW_AARCH64_FP: + case UNW_AARCH64_LR: _msContext.X[regNum - UNW_ARM64_X0] = value; break; #endif default: _LIBUNWIND_ABORT("unsupported register"); @@ -801,7 +801,7 @@ bool UnwindCursor<A, R>::validFloatReg(int regNum) { if (regNum >= UNW_ARM_S0 && regNum <= UNW_ARM_S31) return true; if (regNum >= UNW_ARM_D0 && regNum <= UNW_ARM_D31) return true; #elif defined(_LIBUNWIND_TARGET_AARCH64) - if (regNum >= UNW_AARCH64_V0 && regNum <= UNW_ARM64_D31) return true; + if (regNum >= UNW_AARCH64_V0 && regNum <= UNW_ARM64_D31) return true; #else (void)regNum; #endif @@ -829,7 +829,7 @@ unw_fpreg_t UnwindCursor<A, R>::getFloatReg(int regNum) { } _LIBUNWIND_ABORT("unsupported float register"); #elif defined(_LIBUNWIND_TARGET_AARCH64) - return _msContext.V[regNum - UNW_AARCH64_V0].D[0]; + return _msContext.V[regNum - UNW_AARCH64_V0].D[0]; #else (void)regNum; _LIBUNWIND_ABORT("float registers unimplemented"); @@ -857,7 +857,7 @@ void UnwindCursor<A, R>::setFloatReg(int regNum, unw_fpreg_t value) { } _LIBUNWIND_ABORT("unsupported float register"); #elif defined(_LIBUNWIND_TARGET_AARCH64) - _msContext.V[regNum - UNW_AARCH64_V0].D[0] = value; + _msContext.V[regNum - UNW_AARCH64_V0].D[0] = value; #else (void)regNum; (void)value; @@ -910,9 +910,9 @@ public: virtual void saveVFPAsX(); #endif -#if defined(_LIBUNWIND_USE_CET) - virtual void *get_registers() { return &_registers; } -#endif +#if defined(_LIBUNWIND_USE_CET) + virtual void *get_registers() { return &_registers; } +#endif // libunwind does not and should not depend on C++ library which means that we // need our own defition of inline placement new. static void *operator new(size_t, UnwindCursor<A, R> *p) { return p; } @@ -1032,10 +1032,10 @@ private: int stepWithCompactEncoding(Registers_sparc &) { return UNW_EINVAL; } #endif -#if defined(_LIBUNWIND_TARGET_SPARC64) - int stepWithCompactEncoding(Registers_sparc64 &) { return UNW_EINVAL; } -#endif - +#if defined(_LIBUNWIND_TARGET_SPARC64) + int stepWithCompactEncoding(Registers_sparc64 &) { return UNW_EINVAL; } +#endif + #if defined (_LIBUNWIND_TARGET_RISCV) int stepWithCompactEncoding(Registers_riscv &) { return UNW_EINVAL; @@ -1108,12 +1108,12 @@ private: bool compactSaysUseDwarf(Registers_sparc &, uint32_t *) const { return true; } #endif -#if defined(_LIBUNWIND_TARGET_SPARC64) - bool compactSaysUseDwarf(Registers_sparc64 &, uint32_t *) const { - return true; - } -#endif - +#if defined(_LIBUNWIND_TARGET_SPARC64) + bool compactSaysUseDwarf(Registers_sparc64 &, uint32_t *) const { + return true; + } +#endif + #if defined (_LIBUNWIND_TARGET_RISCV) bool compactSaysUseDwarf(Registers_riscv &, uint32_t *) const { return true; @@ -1192,12 +1192,12 @@ private: compact_unwind_encoding_t dwarfEncoding(Registers_sparc &) const { return 0; } #endif -#if defined(_LIBUNWIND_TARGET_SPARC64) - compact_unwind_encoding_t dwarfEncoding(Registers_sparc64 &) const { - return 0; - } -#endif - +#if defined(_LIBUNWIND_TARGET_SPARC64) + compact_unwind_encoding_t dwarfEncoding(Registers_sparc64 &) const { + return 0; + } +#endif + #if defined (_LIBUNWIND_TARGET_RISCV) compact_unwind_encoding_t dwarfEncoding(Registers_riscv &) const { return 0; @@ -1765,16 +1765,16 @@ bool UnwindCursor<A, R>::getInfoFromCompactEncodingSection(pint_t pc, else funcEnd = firstLevelNextPageFunctionOffset + sects.dso_base; if (pc < funcStart) { - _LIBUNWIND_DEBUG_LOG("malformed __unwind_info, pc=0x%llX " - "not in second level compressed unwind table. " - "funcStart=0x%llX", + _LIBUNWIND_DEBUG_LOG("malformed __unwind_info, pc=0x%llX " + "not in second level compressed unwind table. " + "funcStart=0x%llX", (uint64_t) pc, (uint64_t) funcStart); return false; } if (pc > funcEnd) { - _LIBUNWIND_DEBUG_LOG("malformed __unwind_info, pc=0x%llX " - "not in second level compressed unwind table. " - "funcEnd=0x%llX", + _LIBUNWIND_DEBUG_LOG("malformed __unwind_info, pc=0x%llX " + "not in second level compressed unwind table. " + "funcEnd=0x%llX", (uint64_t) pc, (uint64_t) funcEnd); return false; } @@ -1794,9 +1794,9 @@ bool UnwindCursor<A, R>::getInfoFromCompactEncodingSection(pint_t pc, pageEncodingIndex * sizeof(uint32_t)); } } else { - _LIBUNWIND_DEBUG_LOG( - "malformed __unwind_info at 0x%0llX bad second level page", - (uint64_t)sects.compact_unwind_section); + _LIBUNWIND_DEBUG_LOG( + "malformed __unwind_info at 0x%0llX bad second level page", + (uint64_t)sects.compact_unwind_section); return false; } @@ -2089,7 +2089,7 @@ int UnwindCursor<A, R>::stepThroughSigReturn(Registers_arm64 &) { for (int i = 0; i <= 30; ++i) { uint64_t value = _addressSpace.get64(sigctx + kOffsetGprs + static_cast<pint_t>(i * 8)); - _registers.setRegister(UNW_AARCH64_X0 + i, value); + _registers.setRegister(UNW_AARCH64_X0 + i, value); } _registers.setSP(_addressSpace.get64(sigctx + kOffsetSp)); _registers.setIP(_addressSpace.get64(sigctx + kOffsetPc)); @@ -2153,12 +2153,12 @@ bool UnwindCursor<A, R>::getFunctionName(char *buf, size_t bufLen, buf, bufLen, offset); } -#if defined(_LIBUNWIND_USE_CET) -extern "C" void *__libunwind_cet_get_registers(unw_cursor_t *cursor) { - AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor; - return co->get_registers(); -} -#endif +#if defined(_LIBUNWIND_USE_CET) +extern "C" void *__libunwind_cet_get_registers(unw_cursor_t *cursor) { + AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor; + return co->get_registers(); +} +#endif } // namespace libunwind #endif // __UNWINDCURSOR_HPP__ diff --git a/contrib/libs/libunwind/src/UnwindLevel1-gcc-ext.c b/contrib/libs/libunwind/src/UnwindLevel1-gcc-ext.c index 951d5d219a..3154dee5e2 100644 --- a/contrib/libs/libunwind/src/UnwindLevel1-gcc-ext.c +++ b/contrib/libs/libunwind/src/UnwindLevel1-gcc-ext.c @@ -1,4 +1,4 @@ -//===----------------------------------------------------------------------===// +//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -25,24 +25,24 @@ #if defined(_LIBUNWIND_BUILD_ZERO_COST_APIS) #if defined(_LIBUNWIND_SUPPORT_SEH_UNWIND) -#define PRIVATE_1 private_[0] -#elif defined(_LIBUNWIND_ARM_EHABI) -#define PRIVATE_1 unwinder_cache.reserved1 -#else -#define PRIVATE_1 private_1 +#define PRIVATE_1 private_[0] +#elif defined(_LIBUNWIND_ARM_EHABI) +#define PRIVATE_1 unwinder_cache.reserved1 +#else +#define PRIVATE_1 private_1 #endif /// Called by __cxa_rethrow(). _LIBUNWIND_EXPORT _Unwind_Reason_Code _Unwind_Resume_or_Rethrow(_Unwind_Exception *exception_object) { - _LIBUNWIND_TRACE_API( - "_Unwind_Resume_or_Rethrow(ex_obj=%p), private_1=%" PRIdPTR, - (void *)exception_object, (intptr_t)exception_object->PRIVATE_1); + _LIBUNWIND_TRACE_API( + "_Unwind_Resume_or_Rethrow(ex_obj=%p), private_1=%" PRIdPTR, + (void *)exception_object, (intptr_t)exception_object->PRIVATE_1); // If this is non-forced and a stopping place was found, then this is a // re-throw. // Call _Unwind_RaiseException() as if this was a new exception - if (exception_object->PRIVATE_1 == 0) { + if (exception_object->PRIVATE_1 == 0) { return _Unwind_RaiseException(exception_object); // Will return if there is no catch clause, so that __cxa_rethrow can call // std::terminate(). @@ -109,7 +109,7 @@ _Unwind_Backtrace(_Unwind_Trace_Fn callback, void *ref) { // Create a mock exception object for force unwinding. _Unwind_Exception ex; memset(&ex, '\0', sizeof(ex)); - strcpy((char *)&ex.exception_class, "CLNGUNW"); + strcpy((char *)&ex.exception_class, "CLNGUNW"); #endif // walk each frame diff --git a/contrib/libs/libunwind/src/UnwindLevel1.c b/contrib/libs/libunwind/src/UnwindLevel1.c index 13ca17cc6a..331bf6f297 100644 --- a/contrib/libs/libunwind/src/UnwindLevel1.c +++ b/contrib/libs/libunwind/src/UnwindLevel1.c @@ -1,4 +1,4 @@ -//===----------------------------------------------------------------------===// +//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -25,7 +25,7 @@ #include <stdio.h> #include <string.h> -#include "cet_unwind.h" +#include "cet_unwind.h" #include "config.h" #include "libunwind.h" #include "libunwind_ext.h" @@ -35,38 +35,38 @@ #ifndef _LIBUNWIND_SUPPORT_SEH_UNWIND -// When CET is enabled, each "call" instruction will push return address to -// CET shadow stack, each "ret" instruction will pop current CET shadow stack -// top and compare it with target address which program will return. -// In exception handing, some stack frames will be skipped before jumping to -// landing pad and we must adjust CET shadow stack accordingly. -// _LIBUNWIND_POP_CET_SSP is used to adjust CET shadow stack pointer and we -// directly jump to __libunwind_Registerts_x86/x86_64_jumpto instead of using -// a regular function call to avoid pushing to CET shadow stack again. -#if !defined(_LIBUNWIND_USE_CET) -#define __unw_phase2_resume(cursor, fn) __unw_resume((cursor)) -#elif defined(_LIBUNWIND_TARGET_I386) -#define __unw_phase2_resume(cursor, fn) \ - do { \ - _LIBUNWIND_POP_CET_SSP((fn)); \ - void *cetRegContext = __libunwind_cet_get_registers((cursor)); \ - void *cetJumpAddress = __libunwind_cet_get_jump_target(); \ - __asm__ volatile("push %%edi\n\t" \ - "sub $4, %%esp\n\t" \ - "jmp *%%edx\n\t" :: "D"(cetRegContext), \ - "d"(cetJumpAddress)); \ - } while (0) -#elif defined(_LIBUNWIND_TARGET_X86_64) -#define __unw_phase2_resume(cursor, fn) \ - do { \ - _LIBUNWIND_POP_CET_SSP((fn)); \ - void *cetRegContext = __libunwind_cet_get_registers((cursor)); \ - void *cetJumpAddress = __libunwind_cet_get_jump_target(); \ - __asm__ volatile("jmpq *%%rdx\n\t" :: "D"(cetRegContext), \ - "d"(cetJumpAddress)); \ - } while (0) -#endif - +// When CET is enabled, each "call" instruction will push return address to +// CET shadow stack, each "ret" instruction will pop current CET shadow stack +// top and compare it with target address which program will return. +// In exception handing, some stack frames will be skipped before jumping to +// landing pad and we must adjust CET shadow stack accordingly. +// _LIBUNWIND_POP_CET_SSP is used to adjust CET shadow stack pointer and we +// directly jump to __libunwind_Registerts_x86/x86_64_jumpto instead of using +// a regular function call to avoid pushing to CET shadow stack again. +#if !defined(_LIBUNWIND_USE_CET) +#define __unw_phase2_resume(cursor, fn) __unw_resume((cursor)) +#elif defined(_LIBUNWIND_TARGET_I386) +#define __unw_phase2_resume(cursor, fn) \ + do { \ + _LIBUNWIND_POP_CET_SSP((fn)); \ + void *cetRegContext = __libunwind_cet_get_registers((cursor)); \ + void *cetJumpAddress = __libunwind_cet_get_jump_target(); \ + __asm__ volatile("push %%edi\n\t" \ + "sub $4, %%esp\n\t" \ + "jmp *%%edx\n\t" :: "D"(cetRegContext), \ + "d"(cetJumpAddress)); \ + } while (0) +#elif defined(_LIBUNWIND_TARGET_X86_64) +#define __unw_phase2_resume(cursor, fn) \ + do { \ + _LIBUNWIND_POP_CET_SSP((fn)); \ + void *cetRegContext = __libunwind_cet_get_registers((cursor)); \ + void *cetJumpAddress = __libunwind_cet_get_jump_target(); \ + __asm__ volatile("jmpq *%%rdx\n\t" :: "D"(cetRegContext), \ + "d"(cetJumpAddress)); \ + } while (0) +#endif + static _Unwind_Reason_Code unwind_phase1(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *exception_object) { __unw_init_local(cursor, uc); @@ -118,7 +118,7 @@ unwind_phase1(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *except return _URC_FATAL_PHASE1_ERROR; } -#ifndef NDEBUG +#ifndef NDEBUG // When tracing, print state information. if (_LIBUNWIND_TRACING_UNWINDING) { char functionBuf[512]; @@ -136,7 +136,7 @@ unwind_phase1(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *except (void *)exception_object, pc, frameInfo.start_ip, functionName, frameInfo.lsda, frameInfo.handler); } -#endif +#endif // If there is a personality routine, ask it if it will want to stop at // this frame. @@ -187,9 +187,9 @@ unwind_phase2(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *except _LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p)", (void *)exception_object); - // uc is initialized by __unw_getcontext in the parent frame. The first stack - // frame walked is unwind_phase2. - unsigned framesWalked = 1; + // uc is initialized by __unw_getcontext in the parent frame. The first stack + // frame walked is unwind_phase2. + unsigned framesWalked = 1; // Walk each frame until we reach where search phase said to stop. while (true) { @@ -222,7 +222,7 @@ unwind_phase2(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *except return _URC_FATAL_PHASE2_ERROR; } -#ifndef NDEBUG +#ifndef NDEBUG // When tracing, print state information. if (_LIBUNWIND_TRACING_UNWINDING) { char functionBuf[512]; @@ -239,9 +239,9 @@ unwind_phase2(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *except functionName, sp, frameInfo.lsda, frameInfo.handler); } -#endif +#endif - ++framesWalked; + ++framesWalked; // If there is a personality routine, tell it we are unwinding. if (frameInfo.handler != 0) { _Unwind_Personality_Fn p = @@ -281,9 +281,9 @@ unwind_phase2(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *except ", sp=0x%" PRIxPTR, (void *)exception_object, pc, sp); } - - __unw_phase2_resume(cursor, framesWalked); - // __unw_phase2_resume() only returns if there was an error. + + __unw_phase2_resume(cursor, framesWalked); + // __unw_phase2_resume() only returns if there was an error. return _URC_FATAL_PHASE2_ERROR; default: // Personality routine returned an unknown result code. @@ -305,9 +305,9 @@ unwind_phase2_forced(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Stop_Fn stop, void *stop_parameter) { __unw_init_local(cursor, uc); - // uc is initialized by __unw_getcontext in the parent frame. The first stack - // frame walked is unwind_phase2_forced. - unsigned framesWalked = 1; + // uc is initialized by __unw_getcontext in the parent frame. The first stack + // frame walked is unwind_phase2_forced. + unsigned framesWalked = 1; // Walk each frame until we reach where search phase said to stop while (__unw_step(cursor) > 0) { @@ -320,7 +320,7 @@ unwind_phase2_forced(unw_context_t *uc, unw_cursor_t *cursor, return _URC_FATAL_PHASE2_ERROR; } -#ifndef NDEBUG +#ifndef NDEBUG // When tracing, print state information. if (_LIBUNWIND_TRACING_UNWINDING) { char functionBuf[512]; @@ -336,7 +336,7 @@ unwind_phase2_forced(unw_context_t *uc, unw_cursor_t *cursor, (void *)exception_object, frameInfo.start_ip, functionName, frameInfo.lsda, frameInfo.handler); } -#endif +#endif // Call stop function at each frame. _Unwind_Action action = @@ -354,7 +354,7 @@ unwind_phase2_forced(unw_context_t *uc, unw_cursor_t *cursor, return _URC_FATAL_PHASE2_ERROR; } - ++framesWalked; + ++framesWalked; // If there is a personality routine, tell it we are unwinding. if (frameInfo.handler != 0) { _Unwind_Personality_Fn p = @@ -379,7 +379,7 @@ unwind_phase2_forced(unw_context_t *uc, unw_cursor_t *cursor, "_URC_INSTALL_CONTEXT", (void *)exception_object); // We may get control back if landing pad calls _Unwind_Resume(). - __unw_phase2_resume(cursor, framesWalked); + __unw_phase2_resume(cursor, framesWalked); break; default: // Personality routine returned an unknown result code. diff --git a/contrib/libs/libunwind/src/UnwindRegistersRestore.S b/contrib/libs/libunwind/src/UnwindRegistersRestore.S index 1df97f5fc4..91ea68aa50 100644 --- a/contrib/libs/libunwind/src/UnwindRegistersRestore.S +++ b/contrib/libs/libunwind/src/UnwindRegistersRestore.S @@ -1,4 +1,4 @@ -//===----------------------------------------------------------------------===// +//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -25,8 +25,8 @@ DEFINE_LIBUNWIND_FUNCTION(__libunwind_Registers_x86_jumpto) # + return address + # +-----------------------+ <-- SP # + + - - _LIBUNWIND_CET_ENDBR + + _LIBUNWIND_CET_ENDBR movl 4(%esp), %eax # set up eax and ret on new stack location movl 28(%eax), %edx # edx holds new stack pointer @@ -48,8 +48,8 @@ DEFINE_LIBUNWIND_FUNCTION(__libunwind_Registers_x86_jumpto) # skip ss # skip eflags pop %eax # eax was already pushed on new stack - pop %ecx - jmp *%ecx + pop %ecx + jmp *%ecx # skip cs # skip ds # skip es @@ -73,7 +73,7 @@ DEFINE_LIBUNWIND_FUNCTION(__libunwind_Registers_x86_64_jumpto) # On entry, thread_state pointer is in rdi #endif - _LIBUNWIND_CET_ENDBR + _LIBUNWIND_CET_ENDBR movq 56(%rdi), %rax # rax holds new stack pointer subq $16, %rax movq %rax, 56(%rdi) @@ -123,8 +123,8 @@ DEFINE_LIBUNWIND_FUNCTION(__libunwind_Registers_x86_64_jumpto) #endif movq 56(%rdi), %rsp # cut back rsp to new location pop %rdi # rdi was saved here earlier - pop %rcx - jmpq *%rcx + pop %rcx + jmpq *%rcx #elif defined(__powerpc64__) @@ -394,7 +394,7 @@ Lnovec: PPC64_LR(3) bctr -#elif defined(__powerpc__) +#elif defined(__powerpc__) DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_ppc6jumptoEv) // @@ -660,13 +660,13 @@ DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_arm20restoreCoreAndJumpToEv) ldr sp, [lr, #52] ldr lr, [lr, #60] @ restore pc into lr #endif -#if defined(__ARM_FEATURE_BTI_DEFAULT) && !defined(__ARM_ARCH_ISA_ARM) - // 'bx' is not BTI setting when used with lr, therefore r12 is used instead - mov r12, lr - JMP(r12) -#else +#if defined(__ARM_FEATURE_BTI_DEFAULT) && !defined(__ARM_ARCH_ISA_ARM) + // 'bx' is not BTI setting when used with lr, therefore r12 is used instead + mov r12, lr + JMP(r12) +#else JMP(lr) -#endif +#endif @ @ static void libunwind::Registers_arm::restoreVFPWithFLDMD(unw_fpreg_t* values) @@ -811,9 +811,9 @@ DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind14Registers_or1k6jumptoEv) l.lwz r30,120(r3) l.lwz r31,124(r3) - # load new pc into ra - l.lwz r9, 128(r3) - + # load new pc into ra + l.lwz r9, 128(r3) + # at last, restore r3 l.lwz r3, 12(r3) @@ -1062,53 +1062,53 @@ DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind21Registers_mips_newabi6jumptoEv) ld $4, (8 * 4)($4) .set pop -#elif defined(__sparc__) && defined(__arch64__) - -DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind17Registers_sparc646jumptoEv) -// -// void libunwind::Registers_sparc64::jumpto() -// -// On entry: -// thread_state pointer is in %o0 -// - .register %g2, #scratch - .register %g3, #scratch - .register %g6, #scratch - .register %g7, #scratch - flushw - ldx [%o0 + 0x08], %g1 - ldx [%o0 + 0x10], %g2 - ldx [%o0 + 0x18], %g3 - ldx [%o0 + 0x20], %g4 - ldx [%o0 + 0x28], %g5 - ldx [%o0 + 0x30], %g6 - ldx [%o0 + 0x38], %g7 - ldx [%o0 + 0x48], %o1 - ldx [%o0 + 0x50], %o2 - ldx [%o0 + 0x58], %o3 - ldx [%o0 + 0x60], %o4 - ldx [%o0 + 0x68], %o5 - ldx [%o0 + 0x70], %o6 - ldx [%o0 + 0x78], %o7 - ldx [%o0 + 0x80], %l0 - ldx [%o0 + 0x88], %l1 - ldx [%o0 + 0x90], %l2 - ldx [%o0 + 0x98], %l3 - ldx [%o0 + 0xa0], %l4 - ldx [%o0 + 0xa8], %l5 - ldx [%o0 + 0xb0], %l6 - ldx [%o0 + 0xb8], %l7 - ldx [%o0 + 0xc0], %i0 - ldx [%o0 + 0xc8], %i1 - ldx [%o0 + 0xd0], %i2 - ldx [%o0 + 0xd8], %i3 - ldx [%o0 + 0xe0], %i4 - ldx [%o0 + 0xe8], %i5 - ldx [%o0 + 0xf0], %i6 - ldx [%o0 + 0xf8], %i7 - jmp %o7 - ldx [%o0 + 0x40], %o0 - +#elif defined(__sparc__) && defined(__arch64__) + +DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind17Registers_sparc646jumptoEv) +// +// void libunwind::Registers_sparc64::jumpto() +// +// On entry: +// thread_state pointer is in %o0 +// + .register %g2, #scratch + .register %g3, #scratch + .register %g6, #scratch + .register %g7, #scratch + flushw + ldx [%o0 + 0x08], %g1 + ldx [%o0 + 0x10], %g2 + ldx [%o0 + 0x18], %g3 + ldx [%o0 + 0x20], %g4 + ldx [%o0 + 0x28], %g5 + ldx [%o0 + 0x30], %g6 + ldx [%o0 + 0x38], %g7 + ldx [%o0 + 0x48], %o1 + ldx [%o0 + 0x50], %o2 + ldx [%o0 + 0x58], %o3 + ldx [%o0 + 0x60], %o4 + ldx [%o0 + 0x68], %o5 + ldx [%o0 + 0x70], %o6 + ldx [%o0 + 0x78], %o7 + ldx [%o0 + 0x80], %l0 + ldx [%o0 + 0x88], %l1 + ldx [%o0 + 0x90], %l2 + ldx [%o0 + 0x98], %l3 + ldx [%o0 + 0xa0], %l4 + ldx [%o0 + 0xa8], %l5 + ldx [%o0 + 0xb0], %l6 + ldx [%o0 + 0xb8], %l7 + ldx [%o0 + 0xc0], %i0 + ldx [%o0 + 0xc8], %i1 + ldx [%o0 + 0xd0], %i2 + ldx [%o0 + 0xd8], %i3 + ldx [%o0 + 0xe0], %i4 + ldx [%o0 + 0xe8], %i5 + ldx [%o0 + 0xf0], %i6 + ldx [%o0 + 0xf8], %i7 + jmp %o7 + ldx [%o0 + 0x40], %o0 + #elif defined(__sparc__) // diff --git a/contrib/libs/libunwind/src/UnwindRegistersSave.S b/contrib/libs/libunwind/src/UnwindRegistersSave.S index 9566bb0335..3b1e844168 100644 --- a/contrib/libs/libunwind/src/UnwindRegistersSave.S +++ b/contrib/libs/libunwind/src/UnwindRegistersSave.S @@ -1,4 +1,4 @@ -//===----------------------------------------------------------------------===// +//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -27,8 +27,8 @@ # + + # DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext) - - _LIBUNWIND_CET_ENDBR + + _LIBUNWIND_CET_ENDBR push %eax movl 8(%esp), %eax movl %ebx, 4(%eax) @@ -72,7 +72,7 @@ DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext) #define TMP %rsi #endif - _LIBUNWIND_CET_ENDBR + _LIBUNWIND_CET_ENDBR movq %rax, (PTR) movq %rbx, 8(PTR) movq %rcx, 16(PTR) @@ -559,7 +559,7 @@ DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext) blr -#elif defined(__powerpc__) +#elif defined(__powerpc__) // // extern int unw_getcontext(unw_context_t* thread_state) @@ -999,64 +999,64 @@ DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext) jumpr r31 -#elif defined(__sparc__) && defined(__arch64__) - -# -# extern int __unw_getcontext(unw_context_t* thread_state) -# -# On entry: -# thread_state pointer is in %o0 -# -DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext) - .register %g2, #scratch - .register %g3, #scratch - .register %g6, #scratch - .register %g7, #scratch - stx %g1, [%o0 + 0x08] - stx %g2, [%o0 + 0x10] - stx %g3, [%o0 + 0x18] - stx %g4, [%o0 + 0x20] - stx %g5, [%o0 + 0x28] - stx %g6, [%o0 + 0x30] - stx %g7, [%o0 + 0x38] - stx %o0, [%o0 + 0x40] - stx %o1, [%o0 + 0x48] - stx %o2, [%o0 + 0x50] - stx %o3, [%o0 + 0x58] - stx %o4, [%o0 + 0x60] - stx %o5, [%o0 + 0x68] - stx %o6, [%o0 + 0x70] - stx %o7, [%o0 + 0x78] - stx %l0, [%o0 + 0x80] - stx %l1, [%o0 + 0x88] - stx %l2, [%o0 + 0x90] - stx %l3, [%o0 + 0x98] - stx %l4, [%o0 + 0xa0] - stx %l5, [%o0 + 0xa8] - stx %l6, [%o0 + 0xb0] - stx %l7, [%o0 + 0xb8] - stx %i0, [%o0 + 0xc0] - stx %i1, [%o0 + 0xc8] - stx %i2, [%o0 + 0xd0] - stx %i3, [%o0 + 0xd8] - stx %i4, [%o0 + 0xe0] - stx %i5, [%o0 + 0xe8] - stx %i6, [%o0 + 0xf0] - stx %i7, [%o0 + 0xf8] - - # save StackGhost cookie - mov %i7, %g4 - save %sp, -176, %sp - # register window flush necessary even without StackGhost - flushw - restore - ldx [%sp + 2047 + 0x78], %g5 - xor %g4, %g5, %g4 - stx %g4, [%o0 + 0x100] - retl - # return UNW_ESUCCESS - clr %o0 - +#elif defined(__sparc__) && defined(__arch64__) + +# +# extern int __unw_getcontext(unw_context_t* thread_state) +# +# On entry: +# thread_state pointer is in %o0 +# +DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext) + .register %g2, #scratch + .register %g3, #scratch + .register %g6, #scratch + .register %g7, #scratch + stx %g1, [%o0 + 0x08] + stx %g2, [%o0 + 0x10] + stx %g3, [%o0 + 0x18] + stx %g4, [%o0 + 0x20] + stx %g5, [%o0 + 0x28] + stx %g6, [%o0 + 0x30] + stx %g7, [%o0 + 0x38] + stx %o0, [%o0 + 0x40] + stx %o1, [%o0 + 0x48] + stx %o2, [%o0 + 0x50] + stx %o3, [%o0 + 0x58] + stx %o4, [%o0 + 0x60] + stx %o5, [%o0 + 0x68] + stx %o6, [%o0 + 0x70] + stx %o7, [%o0 + 0x78] + stx %l0, [%o0 + 0x80] + stx %l1, [%o0 + 0x88] + stx %l2, [%o0 + 0x90] + stx %l3, [%o0 + 0x98] + stx %l4, [%o0 + 0xa0] + stx %l5, [%o0 + 0xa8] + stx %l6, [%o0 + 0xb0] + stx %l7, [%o0 + 0xb8] + stx %i0, [%o0 + 0xc0] + stx %i1, [%o0 + 0xc8] + stx %i2, [%o0 + 0xd0] + stx %i3, [%o0 + 0xd8] + stx %i4, [%o0 + 0xe0] + stx %i5, [%o0 + 0xe8] + stx %i6, [%o0 + 0xf0] + stx %i7, [%o0 + 0xf8] + + # save StackGhost cookie + mov %i7, %g4 + save %sp, -176, %sp + # register window flush necessary even without StackGhost + flushw + restore + ldx [%sp + 2047 + 0x78], %g5 + xor %g4, %g5, %g4 + stx %g4, [%o0 + 0x100] + retl + # return UNW_ESUCCESS + clr %o0 + #elif defined(__sparc__) # diff --git a/contrib/libs/libunwind/src/Unwind_AppleExtras.cpp b/contrib/libs/libunwind/src/Unwind_AppleExtras.cpp index ffb49a89e5..ed6813f817 100644 --- a/contrib/libs/libunwind/src/Unwind_AppleExtras.cpp +++ b/contrib/libs/libunwind/src/Unwind_AppleExtras.cpp @@ -1,4 +1,4 @@ -//===----------------------------------------------------------------------===// +//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. diff --git a/contrib/libs/libunwind/src/assembly.h b/contrib/libs/libunwind/src/assembly.h index 978f6bd619..a2a2ddca7d 100644 --- a/contrib/libs/libunwind/src/assembly.h +++ b/contrib/libs/libunwind/src/assembly.h @@ -15,13 +15,13 @@ #ifndef UNWIND_ASSEMBLY_H #define UNWIND_ASSEMBLY_H -#if (defined(__i386__) || defined(__x86_64__)) && defined(__linux__) -#include <cet.h> -#define _LIBUNWIND_CET_ENDBR _CET_ENDBR -#else -#define _LIBUNWIND_CET_ENDBR -#endif - +#if (defined(__i386__) || defined(__x86_64__)) && defined(__linux__) +#include <cet.h> +#define _LIBUNWIND_CET_ENDBR _CET_ENDBR +#else +#define _LIBUNWIND_CET_ENDBR +#endif + #if defined(__powerpc64__) #define SEPARATOR ; #define PPC64_OFFS_SRR0 0 @@ -81,7 +81,7 @@ #define PPC64_OPD2 #endif -#if defined(__aarch64__) && defined(__ARM_FEATURE_BTI_DEFAULT) +#if defined(__aarch64__) && defined(__ARM_FEATURE_BTI_DEFAULT) .pushsection ".note.gnu.property", "a" SEPARATOR \ .balign 8 SEPARATOR \ .long 4 SEPARATOR \ @@ -99,17 +99,17 @@ #define AARCH64_BTI #endif -#if !defined(__aarch64__) -#ifdef __ARM_FEATURE_PAC_DEFAULT - .eabi_attribute Tag_PAC_extension, 2 - .eabi_attribute Tag_PACRET_use, 1 -#endif -#ifdef __ARM_FEATURE_BTI_DEFAULT - .eabi_attribute Tag_BTI_extension, 1 - .eabi_attribute Tag_BTI_use, 1 -#endif -#endif - +#if !defined(__aarch64__) +#ifdef __ARM_FEATURE_PAC_DEFAULT + .eabi_attribute Tag_PAC_extension, 2 + .eabi_attribute Tag_PACRET_use, 1 +#endif +#ifdef __ARM_FEATURE_BTI_DEFAULT + .eabi_attribute Tag_BTI_extension, 1 + .eabi_attribute Tag_BTI_use, 1 +#endif +#endif + #define GLUE2(a, b) a ## b #define GLUE(a, b) GLUE2(a, b) #define SYMBOL_NAME(name) GLUE(__USER_LABEL_PREFIX__, name) @@ -234,7 +234,7 @@ #endif #endif /* __arm__ */ -#if defined(__powerpc__) +#if defined(__powerpc__) #define PPC_LEFT_SHIFT(index) << (index) #endif diff --git a/contrib/libs/libunwind/src/cet_unwind.h b/contrib/libs/libunwind/src/cet_unwind.h index e371be20c4..9a548151b3 100644 --- a/contrib/libs/libunwind/src/cet_unwind.h +++ b/contrib/libs/libunwind/src/cet_unwind.h @@ -1,41 +1,41 @@ -//===----------------------------------------------------------------------===// -// -// 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 -// -// -//===----------------------------------------------------------------------===// - -#ifndef LIBUNWIND_CET_UNWIND_H -#define LIBUNWIND_CET_UNWIND_H - -#include "libunwind.h" - -// Currently, CET is implemented on Linux x86 platforms. -#if defined(_LIBUNWIND_TARGET_LINUX) && defined(__CET__) && defined(__SHSTK__) -#define _LIBUNWIND_USE_CET 1 -#endif - -#if defined(_LIBUNWIND_USE_CET) -#include <cet.h> -#include <immintrin.h> - -#define _LIBUNWIND_POP_CET_SSP(x) \ - do { \ - unsigned long ssp = _get_ssp(); \ - if (ssp != 0) { \ - unsigned int tmp = (x); \ - while (tmp > 255) { \ - _inc_ssp(255); \ - tmp -= 255; \ - } \ - _inc_ssp(tmp); \ - } \ - } while (0) -#endif - -extern void *__libunwind_cet_get_registers(unw_cursor_t *); -extern void *__libunwind_cet_get_jump_target(); - -#endif +//===----------------------------------------------------------------------===// +// +// 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 +// +// +//===----------------------------------------------------------------------===// + +#ifndef LIBUNWIND_CET_UNWIND_H +#define LIBUNWIND_CET_UNWIND_H + +#include "libunwind.h" + +// Currently, CET is implemented on Linux x86 platforms. +#if defined(_LIBUNWIND_TARGET_LINUX) && defined(__CET__) && defined(__SHSTK__) +#define _LIBUNWIND_USE_CET 1 +#endif + +#if defined(_LIBUNWIND_USE_CET) +#include <cet.h> +#include <immintrin.h> + +#define _LIBUNWIND_POP_CET_SSP(x) \ + do { \ + unsigned long ssp = _get_ssp(); \ + if (ssp != 0) { \ + unsigned int tmp = (x); \ + while (tmp > 255) { \ + _inc_ssp(255); \ + tmp -= 255; \ + } \ + _inc_ssp(tmp); \ + } \ + } while (0) +#endif + +extern void *__libunwind_cet_get_registers(unw_cursor_t *); +extern void *__libunwind_cet_get_jump_target(); + +#endif diff --git a/contrib/libs/libunwind/src/config.h b/contrib/libs/libunwind/src/config.h index 560edda04e..5a4e5008d7 100644 --- a/contrib/libs/libunwind/src/config.h +++ b/contrib/libs/libunwind/src/config.h @@ -1,4 +1,4 @@ -//===----------------------------------------------------------------------===// +//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -72,14 +72,14 @@ #if defined(__APPLE__) #if defined(_LIBUNWIND_HIDE_SYMBOLS) -#define _LIBUNWIND_ALIAS_VISIBILITY(name) __asm__(".private_extern " name); +#define _LIBUNWIND_ALIAS_VISIBILITY(name) __asm__(".private_extern " name); #else #define _LIBUNWIND_ALIAS_VISIBILITY(name) #endif #define _LIBUNWIND_WEAK_ALIAS(name, aliasname) \ __asm__(".globl " SYMBOL_NAME(aliasname)); \ __asm__(SYMBOL_NAME(aliasname) " = " SYMBOL_NAME(name)); \ - _LIBUNWIND_ALIAS_VISIBILITY(SYMBOL_NAME(aliasname)) + _LIBUNWIND_ALIAS_VISIBILITY(SYMBOL_NAME(aliasname)) #elif defined(__ELF__) #define _LIBUNWIND_WEAK_ALIAS(name, aliasname) \ extern "C" _LIBUNWIND_EXPORT __typeof(name) aliasname \ @@ -105,7 +105,7 @@ #define _LIBUNWIND_BUILD_SJLJ_APIS #endif -#if defined(__i386__) || defined(__x86_64__) || defined(__powerpc__) +#if defined(__i386__) || defined(__x86_64__) || defined(__powerpc__) #define _LIBUNWIND_SUPPORT_FRAME_APIS #endif diff --git a/contrib/libs/libunwind/src/dwarf2.h b/contrib/libs/libunwind/src/dwarf2.h index 174277d5a7..26ab3af726 100644 --- a/contrib/libs/libunwind/src/dwarf2.h +++ b/contrib/libs/libunwind/src/dwarf2.h @@ -1,4 +1,4 @@ -//===----------------------------------------------------------------------===// +//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. diff --git a/contrib/libs/libunwind/src/libunwind.cpp b/contrib/libs/libunwind/src/libunwind.cpp index 03f8b75b5b..3fc67fe7b7 100644 --- a/contrib/libs/libunwind/src/libunwind.cpp +++ b/contrib/libs/libunwind/src/libunwind.cpp @@ -1,4 +1,4 @@ -//===----------------------------------------------------------------------===// +//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -11,21 +11,21 @@ #include <libunwind.h> -#include "config.h" +#include "config.h" #include "libunwind_ext.h" #include <stdlib.h> -// Define the __has_feature extension for compilers that do not support it so -// that we can later check for the presence of ASan in a compiler-neutral way. -#if !defined(__has_feature) -#define __has_feature(feature) 0 -#endif - -#if __has_feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__) -#include <sanitizer/asan_interface.h> -#endif +// Define the __has_feature extension for compilers that do not support it so +// that we can later check for the presence of ASan in a compiler-neutral way. +#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" #include "UnwindCursor.hpp" @@ -51,7 +51,7 @@ _LIBUNWIND_HIDDEN int __unw_init_local(unw_cursor_t *cursor, # define REGISTER_KIND Registers_x86_64 #elif defined(__powerpc64__) # define REGISTER_KIND Registers_ppc64 -#elif defined(__powerpc__) +#elif defined(__powerpc__) # define REGISTER_KIND Registers_ppc #elif defined(__aarch64__) # define REGISTER_KIND Registers_arm64 @@ -67,8 +67,8 @@ _LIBUNWIND_HIDDEN int __unw_init_local(unw_cursor_t *cursor, # define REGISTER_KIND Registers_mips_newabi #elif defined(__mips__) # 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__) && defined(__arch64__) +#define REGISTER_KIND Registers_sparc64 #elif defined(__sparc__) # define REGISTER_KIND Registers_sparc #elif defined(__riscv) @@ -195,10 +195,10 @@ _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)); -#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(); -#endif +#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(); +#endif AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor; co->jumpto(); return UNW_EUNSPEC; @@ -294,35 +294,35 @@ void __unw_remove_dynamic_fde(unw_word_t fde) { // fde is own mh_group DwarfFDECache<LocalAddressSpace>::removeAllIn((LocalAddressSpace::pint_t)fde); } - -void __unw_add_dynamic_eh_frame_section(unw_word_t eh_frame_start) { - // The eh_frame section start serves as the mh_group - unw_word_t mh_group = eh_frame_start; - CFI_Parser<LocalAddressSpace>::CIE_Info cieInfo; - CFI_Parser<LocalAddressSpace>::FDE_Info fdeInfo; - auto p = (LocalAddressSpace::pint_t)eh_frame_start; - while (true) { - if (CFI_Parser<LocalAddressSpace>::decodeFDE( - LocalAddressSpace::sThisAddressSpace, p, &fdeInfo, &cieInfo, - true) == NULL) { - DwarfFDECache<LocalAddressSpace>::add((LocalAddressSpace::pint_t)mh_group, - fdeInfo.pcStart, fdeInfo.pcEnd, - fdeInfo.fdeStart); - p += fdeInfo.fdeLength; - } else if (CFI_Parser<LocalAddressSpace>::parseCIE( - LocalAddressSpace::sThisAddressSpace, p, &cieInfo) == NULL) { - p += cieInfo.cieLength; - } else - return; - } -} - -void __unw_remove_dynamic_eh_frame_section(unw_word_t eh_frame_start) { - // The eh_frame section start serves as the mh_group - DwarfFDECache<LocalAddressSpace>::removeAllIn( - (LocalAddressSpace::pint_t)eh_frame_start); -} - + +void __unw_add_dynamic_eh_frame_section(unw_word_t eh_frame_start) { + // The eh_frame section start serves as the mh_group + unw_word_t mh_group = eh_frame_start; + CFI_Parser<LocalAddressSpace>::CIE_Info cieInfo; + CFI_Parser<LocalAddressSpace>::FDE_Info fdeInfo; + auto p = (LocalAddressSpace::pint_t)eh_frame_start; + while (true) { + if (CFI_Parser<LocalAddressSpace>::decodeFDE( + LocalAddressSpace::sThisAddressSpace, p, &fdeInfo, &cieInfo, + true) == NULL) { + DwarfFDECache<LocalAddressSpace>::add((LocalAddressSpace::pint_t)mh_group, + fdeInfo.pcStart, fdeInfo.pcEnd, + fdeInfo.fdeStart); + p += fdeInfo.fdeLength; + } else if (CFI_Parser<LocalAddressSpace>::parseCIE( + LocalAddressSpace::sThisAddressSpace, p, &cieInfo) == NULL) { + p += cieInfo.cieLength; + } else + return; + } +} + +void __unw_remove_dynamic_eh_frame_section(unw_word_t eh_frame_start) { + // The eh_frame section start serves as the mh_group + DwarfFDECache<LocalAddressSpace>::removeAllIn( + (LocalAddressSpace::pint_t)eh_frame_start); +} + #endif // defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND) #endif // !defined(__USING_SJLJ_EXCEPTIONS__) diff --git a/contrib/libs/libunwind/src/libunwind_ext.h b/contrib/libs/libunwind/src/libunwind_ext.h index 7065ffcdae..62365c8c1b 100644 --- a/contrib/libs/libunwind/src/libunwind_ext.h +++ b/contrib/libs/libunwind/src/libunwind_ext.h @@ -1,4 +1,4 @@ -//===----------------------------------------------------------------------===// +//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -51,9 +51,9 @@ extern void __unw_iterate_dwarf_unwind_cache(void (*func)( extern void __unw_add_dynamic_fde(unw_word_t fde); extern void __unw_remove_dynamic_fde(unw_word_t fde); -extern void __unw_add_dynamic_eh_frame_section(unw_word_t eh_frame_start); -extern void __unw_remove_dynamic_eh_frame_section(unw_word_t eh_frame_start); - +extern void __unw_add_dynamic_eh_frame_section(unw_word_t eh_frame_start); +extern void __unw_remove_dynamic_eh_frame_section(unw_word_t eh_frame_start); + #if defined(_LIBUNWIND_ARM_EHABI) extern const uint32_t* decode_eht_entry(const uint32_t*, size_t*, size_t*); extern _Unwind_Reason_Code _Unwind_VRS_Interpret(_Unwind_Context *context, |