diff options
Diffstat (limited to 'src/AddressSpace.hpp')
-rw-r--r-- | src/AddressSpace.hpp | 155 |
1 files changed, 16 insertions, 139 deletions
diff --git a/src/AddressSpace.hpp b/src/AddressSpace.hpp index 30ad35995aec..fb07c807db9e 100644 --- a/src/AddressSpace.hpp +++ b/src/AddressSpace.hpp @@ -1,9 +1,8 @@ //===------------------------- AddressSpace.hpp ---------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. +// 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 // // // Abstracts accessing local vs remote address spaces. @@ -28,6 +27,9 @@ #if _LIBUNWIND_USE_DLADDR #include <dlfcn.h> +#if defined(__unix__) && defined(__ELF__) && defined(_LIBUNWIND_HAS_COMMENT_LIB_PRAGMA) +#pragma comment(lib, "dl") +#endif #endif #ifdef __APPLE__ @@ -457,6 +459,8 @@ inline bool LocalAddressSpace::findUnwindSections(pint_t targetAddr, #elif defined(_LIBUNWIND_SUPPORT_SEH_UNWIND) && defined(_WIN32) // Don't even bother, since Windows has functions that do all this stuff // for us. + (void)targetAddr; + (void)info; return true; #elif defined(_LIBUNWIND_ARM_EHABI) && defined(__BIONIC__) && \ (__ANDROID_API__ < 21) @@ -534,11 +538,11 @@ inline bool LocalAddressSpace::findUnwindSections(pint_t targetAddr, #endif cbdata->sects->dwarf_index_section = eh_frame_hdr_start; cbdata->sects->dwarf_index_section_length = phdr->p_memsz; - EHHeaderParser<LocalAddressSpace>::decodeEHHdr( + found_hdr = EHHeaderParser<LocalAddressSpace>::decodeEHHdr( *cbdata->addressSpace, eh_frame_hdr_start, phdr->p_memsz, hdrInfo); - cbdata->sects->dwarf_section = hdrInfo.eh_frame_ptr; - found_hdr = true; + if (found_hdr) + cbdata->sects->dwarf_section = hdrInfo.eh_frame_ptr; } } @@ -597,142 +601,15 @@ inline bool LocalAddressSpace::findFunctionName(pint_t addr, char *buf, return true; } } +#else + (void)addr; + (void)buf; + (void)bufLen; + (void)offset; #endif return false; } - - -#ifdef UNW_REMOTE - -/// RemoteAddressSpace is used as a template parameter to UnwindCursor when -/// unwinding a thread in the another process. The other process can be a -/// different endianness and a different pointer size which is handled by -/// the P template parameter. -template <typename P> -class RemoteAddressSpace { -public: - RemoteAddressSpace(task_t task) : fTask(task) {} - - typedef typename P::uint_t pint_t; - - uint8_t get8(pint_t addr); - uint16_t get16(pint_t addr); - uint32_t get32(pint_t addr); - uint64_t get64(pint_t addr); - pint_t getP(pint_t addr); - uint64_t getRegister(pint_t addr); - uint64_t getULEB128(pint_t &addr, pint_t end); - int64_t getSLEB128(pint_t &addr, pint_t end); - pint_t getEncodedP(pint_t &addr, pint_t end, uint8_t encoding, - pint_t datarelBase = 0); - bool findFunctionName(pint_t addr, char *buf, size_t bufLen, - unw_word_t *offset); - bool findUnwindSections(pint_t targetAddr, UnwindInfoSections &info); - bool findOtherFDE(pint_t targetAddr, pint_t &fde); -private: - void *localCopy(pint_t addr); - - task_t fTask; -}; - -template <typename P> uint8_t RemoteAddressSpace<P>::get8(pint_t addr) { - return *((uint8_t *)localCopy(addr)); -} - -template <typename P> uint16_t RemoteAddressSpace<P>::get16(pint_t addr) { - return P::E::get16(*(uint16_t *)localCopy(addr)); -} - -template <typename P> uint32_t RemoteAddressSpace<P>::get32(pint_t addr) { - return P::E::get32(*(uint32_t *)localCopy(addr)); -} - -template <typename P> uint64_t RemoteAddressSpace<P>::get64(pint_t addr) { - return P::E::get64(*(uint64_t *)localCopy(addr)); -} - -template <typename P> -typename P::uint_t RemoteAddressSpace<P>::getP(pint_t addr) { - return P::getP(*(uint64_t *)localCopy(addr)); -} - -template <typename P> -typename P::uint_t OtherAddressSpace<P>::getRegister(pint_t addr) { - return P::getRegister(*(uint64_t *)localCopy(addr)); -} - -template <typename P> -uint64_t OtherAddressSpace<P>::getULEB128(pint_t &addr, pint_t end) { - uintptr_t size = (end - addr); - LocalAddressSpace::pint_t laddr = (LocalAddressSpace::pint_t) localCopy(addr); - LocalAddressSpace::pint_t sladdr = laddr; - uint64_t result = LocalAddressSpace::getULEB128(laddr, laddr + size); - addr += (laddr - sladdr); - return result; -} - -template <typename P> -int64_t RemoteAddressSpace<P>::getSLEB128(pint_t &addr, pint_t end) { - uintptr_t size = (end - addr); - LocalAddressSpace::pint_t laddr = (LocalAddressSpace::pint_t) localCopy(addr); - LocalAddressSpace::pint_t sladdr = laddr; - uint64_t result = LocalAddressSpace::getSLEB128(laddr, laddr + size); - addr += (laddr - sladdr); - return result; -} - -template <typename P> void *RemoteAddressSpace<P>::localCopy(pint_t addr) { - // FIX ME -} - -template <typename P> -bool RemoteAddressSpace<P>::findFunctionName(pint_t addr, char *buf, - size_t bufLen, - unw_word_t *offset) { - // FIX ME -} - -/// unw_addr_space is the base class that abstract unw_addr_space_t type in -/// libunwind.h points to. -struct unw_addr_space { - cpu_type_t cpuType; - task_t taskPort; -}; - -/// unw_addr_space_i386 is the concrete instance that a unw_addr_space_t points -/// to when examining -/// a 32-bit intel process. -struct unw_addr_space_i386 : public unw_addr_space { - unw_addr_space_i386(task_t task) : oas(task) {} - RemoteAddressSpace<Pointer32<LittleEndian>> oas; -}; - -/// unw_addr_space_x86_64 is the concrete instance that a unw_addr_space_t -/// points to when examining -/// a 64-bit intel process. -struct unw_addr_space_x86_64 : public unw_addr_space { - unw_addr_space_x86_64(task_t task) : oas(task) {} - RemoteAddressSpace<Pointer64<LittleEndian>> oas; -}; - -/// unw_addr_space_ppc is the concrete instance that a unw_addr_space_t points -/// to when examining -/// a 32-bit PowerPC process. -struct unw_addr_space_ppc : public unw_addr_space { - unw_addr_space_ppc(task_t task) : oas(task) {} - RemoteAddressSpace<Pointer32<BigEndian>> oas; -}; - -/// unw_addr_space_ppc is the concrete instance that a unw_addr_space_t points -/// to when examining a 64-bit PowerPC process. -struct unw_addr_space_ppc64 : public unw_addr_space { - unw_addr_space_ppc64(task_t task) : oas(task) {} - RemoteAddressSpace<Pointer64<LittleEndian>> oas; -}; - -#endif // UNW_REMOTE - } // namespace libunwind #endif // __ADDRESSSPACE_HPP__ |