1//===------------------------- AddressSpace.hpp ---------------------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is dual licensed under the MIT and the University of Illinois Open 6// Source Licenses. See LICENSE.TXT for details. 7// 8// 9// Abstracts accessing local vs remote address spaces. 10// 11//===----------------------------------------------------------------------===// 12 13extern "C" { 14#include <unwind.h> 15} 16#include "config.h" 17#include "AddressSpace.hpp" 18 19#include "DwarfParser.hpp" 20 21using namespace libunwind; 22 23bool LocalAddressSpace::findUnwindSections(pint_t targetAddr, 24 UnwindInfoSections &info) 25{ 26#ifdef BARRELFISH 27 bool result = 0; 28 29 uint64_t eh_frame = 0; 30 uint64_t eh_frame_size = 0; 31 bf_unwind_get_eh(&eh_frame, &eh_frame_size); 32 33 if (eh_frame != 0 && eh_frame_size != 0) { 34#if _LIBUNWIND_SUPPORT_DWARF_UNWIND 35 info.dwarf_section = eh_frame; 36 info.dwarf_section_length = eh_frame_size; 37 result = 1; 38#endif 39#if _LIBUNWIND_SUPPORT_COMPACT_UNWIND 40 info.compact_unwind_section = eh_frame_ptr; 41 info.compact_unwind_section_length = eh_frame_size; 42#endif 43 } 44 45 uint64_t eh_frame_hdr; 46 uint64_t eh_frame_hdr_size; 47 bf_unwind_get_eh_hdr(&eh_frame_hdr, &eh_frame_hdr_size); 48 if (eh_frame_hdr != 0 && eh_frame_hdr_size != 0) { 49#if _LIBUNWIND_SUPPORT_DWARF_INDEX 50 info.dwarf_index_section = eh_frame_hdr; 51 info.dwarf_index_section_length = eh_frame_hdr_size; 52#endif 53#if _LIBUNWIND_SUPPORT_DWARF_UNWIND 54 if (eh_frame == 0 || eh_frame_size == 0) { 55 uint8_t *hdr = (uint8_t *) eh_frame; 56 pint_t addr = (pint_t) (hdr + 4); 57 pint_t eh_frame_ptr = LocalAddressSpace::getEncodedP(addr, addr + 16, hdr[1]); 58 info.dwarf_section = eh_frame_ptr; 59 info.dwarf_section_length = 0xffffffff; 60 result = 1; 61 } 62#endif 63 } 64 65 return result; 66#endif 67 return false; 68} 69